Bugzilla – Attachment 92978 Details for
Bug 22837
Koha::Account::Line->apply should not require a 'set' of debits
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22837: Update callers to use new signature
Bug-22837-Update-callers-to-use-new-signature.patch (text/plain), 10.05 KB, created by
Liz Rea
on 2019-09-19 18:54:30 UTC
(
hide
)
Description:
Bug 22837: Update callers to use new signature
Filename:
MIME Type:
Creator:
Liz Rea
Created:
2019-09-19 18:54:30 UTC
Size:
10.05 KB
patch
obsolete
>From 6cd9ac785fab0dbdb0738aa701553d9ab1ae09be Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 3 May 2019 13:13:07 +0100 >Subject: [PATCH] Bug 22837: Update callers to use new signature > >Test plan: >Run t/db_dependent/Circulation.t, t/db_dependent/Koha/Account.t, >t/db_dependent/Koha/Account/Lines.t and >t/db_dependent/api/v1/patrons_accounts.t and all should pass. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Liz Rea <wizzyrea@gmail.com> >--- > C4/Circulation.pm | 5 ++--- > Koha/Account.pm | 2 +- > Koha/REST/V1/Patrons/Account.pm | 4 ++-- > t/db_dependent/Circulation.t | 10 +++++----- > t/db_dependent/Koha/Account.t | 2 +- > t/db_dependent/Koha/Account/Lines.t | 16 ++++++++-------- > 6 files changed, 19 insertions(+), 20 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index e346e2dfd6..66993ea461 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2370,7 +2370,7 @@ sub _FixOverduesOnReturn { > } > ); > >- $credit->apply({ debits => $accountlines->reset, offset_type => 'Forgiven' }); >+ $credit->apply({ debits => [ $accountline ], offset_type => 'Forgiven' }); > > $accountline->status('FORGIVEN'); > >@@ -2459,8 +2459,7 @@ sub _FixAccountForLostAndReturned { > } > ); > >- # TODO: ->apply should just accept the accountline >- $credit->apply( { debits => $accountlines->reset } ); >+ $credit->apply( { debits => [ $accountline ] } ); > } > > # Update the account status >diff --git a/Koha/Account.pm b/Koha/Account.pm >index 35b438a0e1..49c90023f5 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -677,7 +677,7 @@ sub reconcile_balance { > and my $credit = $outstanding_credits->next ) > { > # there's both outstanding debits and credits >- $credit->apply( { debits => $outstanding_debits } ); # applying credit, no special offset >+ $credit->apply( { debits => [ $outstanding_debits->as_list ] } ); # applying credit, no special offset > > $outstanding_debits = $self->outstanding_debits; > >diff --git a/Koha/REST/V1/Patrons/Account.pm b/Koha/REST/V1/Patrons/Account.pm >index d35e896c93..eb495f924e 100644 >--- a/Koha/REST/V1/Patrons/Account.pm >+++ b/Koha/REST/V1/Patrons/Account.pm >@@ -132,12 +132,12 @@ sub add_credit { > my $outstanding_credit = $credit->amountoutstanding; > if ($debits) { > # pay them! >- $outstanding_credit = $credit->apply({ debits => $debits, offset_type => 'payment' }); >+ $outstanding_credit = $credit->apply({ debits => [ $debits->as_list ], offset_type => 'payment' }); > } > > if ($outstanding_credit) { > my $outstanding_debits = $account->outstanding_debits; >- $credit->apply({ debits => $outstanding_debits, offset_type => 'payment' }); >+ $credit->apply({ debits => [ $outstanding_debits->as_list ], offset_type => 'payment' }); > } > > return $c->render( status => 200, openapi => { account_line_id => $credit->id } ); >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index b7acf2a617..4399abe75c 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -2227,7 +2227,7 @@ subtest '_FixAccountForLostAndReturned' => sub { > interface => 'test', > } > ); >- $credit->apply( { debits => $debts, offset_type => 'Writeoff' } ); >+ $credit->apply( { debits => [ $debts->as_list ], offset_type => 'Writeoff' } ); > > my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id ); > is( $credit_return_id, undef, 'No LOST_RETURN account line added' ); >@@ -2289,7 +2289,7 @@ subtest '_FixAccountForLostAndReturned' => sub { > interface => 'test', > } > ); >- $credit->apply( { debits => $debts, offset_type => 'Payment' } ); >+ $credit->apply( { debits => [ $debts->as_list ], offset_type => 'Payment' } ); > > my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id ); > my $credit_return = Koha::Account::Lines->find($credit_return_id); >@@ -2414,7 +2414,7 @@ subtest '_FixAccountForLostAndReturned' => sub { > } > ); > >- $payment->apply( { debits => $lost_fee_lines->reset, offset_type => 'Payment' } ); >+ $payment->apply( { debits => [ $lost_fee_line ], offset_type => 'Payment' } ); > > # Partially write off fee > my $write_off_amount = 25; >@@ -2424,7 +2424,7 @@ subtest '_FixAccountForLostAndReturned' => sub { > interface => 'test', > } > ); >- $write_off->apply( { debits => $lost_fee_lines->reset, offset_type => 'Writeoff' } ); >+ $write_off->apply( { debits => [ $lost_fee_line ], offset_type => 'Writeoff' } ); > > is( $account->balance, > $processfee_amount + $replacement_amount - $payment_amount - $write_off_amount, >@@ -2517,7 +2517,7 @@ subtest '_FixAccountForLostAndReturned' => sub { > interface => 'test', > } > ); >- $payment->apply({ debits => $lost_fee_lines->reset, offset_type => 'Payment' }); >+ $payment->apply({ debits => [ $lost_fee_line ], offset_type => 'Payment' }); > > is( $account->balance, > $replacement_amount - $payment_amount, >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index e3b7472f7a..cec72ed6ca 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -391,7 +391,7 @@ subtest 'lines() tests' => sub { > > # Paid Off > $account->add_credit( { amount => 1, interface => 'commandline' } ) >- ->apply( { debits => scalar $account->outstanding_debits } ); >+ ->apply( { debits => [ $account->outstanding_debits->as_list ] } ); > > my $lines = $account->lines; > is( $lines->_resultset->count, 9, "All accountlines (debits, credits and paid off) were fetched"); >diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t >index 9b8e4fa724..7f9dcf01e2 100755 >--- a/t/db_dependent/Koha/Account/Lines.t >+++ b/t/db_dependent/Koha/Account/Lines.t >@@ -242,7 +242,7 @@ subtest 'apply() tests' => sub { > $debit_1->discard_changes; > > my $debits = Koha::Account::Lines->search({ accountlines_id => $debit_1->id }); >- my $remaining_credit = $credit->apply( { debits => $debits, offset_type => 'Manual Credit' } ); >+ my $remaining_credit = $credit->apply( { debits => [ $debits->as_list ], offset_type => 'Manual Credit' } ); > is( $remaining_credit * 1, 90, 'Remaining credit is correctly calculated' ); > $credit->discard_changes; > is( $credit->amountoutstanding * -1, $remaining_credit, 'Remaining credit correctly stored' ); >@@ -258,7 +258,7 @@ subtest 'apply() tests' => sub { > is( $THE_offset->type, 'Manual Credit', 'Passed type stored correctly' ); > > $debits = Koha::Account::Lines->search({ accountlines_id => $debit_2->id }); >- $remaining_credit = $credit->apply( { debits => $debits } ); >+ $remaining_credit = $credit->apply( { debits => [ $debits->as_list ] } ); > is( $remaining_credit, 0, 'No remaining credit left' ); > $credit->discard_changes; > is( $credit->amountoutstanding * 1, 0, 'No outstanding credit' ); >@@ -273,20 +273,20 @@ subtest 'apply() tests' => sub { > > $debits = Koha::Account::Lines->search({ accountlines_id => $debit_1->id }); > throws_ok >- { $credit->apply({ debits => $debits }); } >+ { $credit->apply({ debits => [ $debits->as_list ] }); } > 'Koha::Exceptions::Account::NoAvailableCredit', > '->apply() can only be used with outstanding credits'; > > $debits = Koha::Account::Lines->search({ accountlines_id => $credit->id }); > throws_ok >- { $debit_1->apply({ debits => $debits }); } >+ { $debit_1->apply({ debits => [ $debits->as_list ] }); } > 'Koha::Exceptions::Account::IsNotCredit', > '->apply() can only be used with credits'; > > $debits = Koha::Account::Lines->search({ accountlines_id => $credit->id }); > my $credit_3 = $account->add_credit({ amount => 1, interface => 'commandline' }); > throws_ok >- { $credit_3->apply({ debits => $debits }); } >+ { $credit_3->apply({ debits => [ $debits->as_list ] }); } > 'Koha::Exceptions::Account::IsNotDebit', > '->apply() can only be applied to credits'; > >@@ -303,7 +303,7 @@ subtest 'apply() tests' => sub { > > $debits = Koha::Account::Lines->search({ accountlines_id => { -in => [ $debit_1->id, $debit_2->id, $debit_3->id, $credit->id ] } }); > throws_ok { >- $credit_2->apply( { debits => $debits, offset_type => 'Manual Credit' } ); } >+ $credit_2->apply( { debits => [ $debits->as_list ], offset_type => 'Manual Credit' } ); } > 'Koha::Exceptions::Account::IsNotDebit', > '->apply() rolls back if any of the passed lines is not a debit'; > >@@ -313,7 +313,7 @@ subtest 'apply() tests' => sub { > is( $credit_2->discard_changes->amountoutstanding * -1, 20, 'No changes made' ); > > $debits = Koha::Account::Lines->search({ accountlines_id => { -in => [ $debit_1->id, $debit_2->id, $debit_3->id ] } }); >- $remaining_credit = $credit_2->apply( { debits => $debits, offset_type => 'Manual Credit' } ); >+ $remaining_credit = $credit_2->apply( { debits => [ $debits->as_list ], offset_type => 'Manual Credit' } ); > > is( $debit_1->discard_changes->amountoutstanding * 1, 0, 'No changes to already cancelled debit' ); > is( $debit_2->discard_changes->amountoutstanding * 1, 0, 'Debit cancelled' ); >@@ -426,7 +426,7 @@ subtest 'adjust() tests' => sub { > > # Update fine to partially paid > my $debits = Koha::Account::Lines->search({ accountlines_id => $debit_2->id }); >- $credit->apply( { debits => $debits, offset_type => 'Manual Credit' } ); >+ $credit->apply( { debits => [ $debits->as_list ], offset_type => 'Manual Credit' } ); > > $debit_2->discard_changes; > is( $debit_2->amount * 1, 150, 'Fine amount unaffected by partial payment' ); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22837
:
89314
|
89315
|
89316
|
89317
|
89468
|
89469
|
92972
|
92973
|
92977
|
92978
|
92979
|
92980
|
92981
|
92982
|
92983
|
92984