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: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2019-05-03 13:13:07 +01:00
parent 22b18cc96d
commit 5f8e09bbaa
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
6 changed files with 19 additions and 20 deletions

View File

@ -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

View File

@ -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;

View File

@ -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 } );

View File

@ -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,

View File

@ -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");

View File

@ -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' );