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' );
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);
}
);
- $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;
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,
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,
$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' );
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' );
$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';
$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';
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' );
# 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' );