Bug 21759: Regression tests
This patch tests for a new behaviour in the _FixAccountForLostAndFound method. The method will now add the amountoutstanding value for the lost item fee to the CR credit to be generated. This means that: - If there's some remaining debt, the same amount will be added to the CR credit and used to cancel that debt. The final amountoutstanding will be the same as before, but an offset will be generated as required. - If the line was written off, the behaviour remains unchanged, so no offset. - If the line was payed and/or written off in full only the payments are refund, preserving the current behaviour. Only changes to the 'remaining debt' use cases on this tests are expected. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Circulation.t => FAIL: Tests fail because the behaviour is not correct. Note: some tests order changes are introduced to avoid calling discard_changes twice Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
9a2bd027e5
commit
1622f0f609
|
|
@ -2053,7 +2053,7 @@ subtest '_FixAccountForLostAndReturned' => sub {
|
|||
my $lost_fee_line = $lost_fee_lines->next;
|
||||
is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' );
|
||||
is( $lost_fee_line->amountoutstanding + 0,
|
||||
$replacement_amount, 'The right L amountountstanding is generated' );
|
||||
$replacement_amount, 'The right L amountoutstanding is generated' );
|
||||
|
||||
my $account = $patron->account;
|
||||
my $debts = $account->outstanding_debits;
|
||||
|
|
@ -2148,7 +2148,7 @@ subtest '_FixAccountForLostAndReturned' => sub {
|
|||
|
||||
subtest 'Test without payment or write off' => sub {
|
||||
|
||||
plan tests => 10;
|
||||
plan tests => 12;
|
||||
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
my $barcode = 'KD123456791';
|
||||
|
|
@ -2187,7 +2187,11 @@ subtest '_FixAccountForLostAndReturned' => sub {
|
|||
$replacement_amount, 'The right L amountountstanding is generated' );
|
||||
|
||||
my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item_id, $patron->id );
|
||||
is( $credit_return_id, undef, 'No CR account line added' );
|
||||
my $credit_return = Koha::Account::Lines->find($credit_return_id);
|
||||
|
||||
is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' );
|
||||
is( $credit_return->amount + 0, -99.00, 'The account line of type CR has an amount of -99' );
|
||||
is( $credit_return->amountoutstanding + 0, 0, 'The account line of type CR has an amountoutstanding of 0' );
|
||||
|
||||
$lost_fee_line->discard_changes;
|
||||
is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
|
||||
|
|
@ -2263,26 +2267,30 @@ subtest '_FixAccountForLostAndReturned' => sub {
|
|||
'Payment and write off applied'
|
||||
);
|
||||
|
||||
# Store the amountoutstanding value
|
||||
$lost_fee_line->discard_changes;
|
||||
my $outstanding = $lost_fee_line->amountoutstanding;
|
||||
|
||||
my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item_id, $patron->id );
|
||||
my $credit_return = Koha::Account::Lines->find($credit_return_id);
|
||||
|
||||
is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PF - payment (CR)' );
|
||||
|
||||
$lost_fee_line->discard_changes;
|
||||
is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
|
||||
is( $lost_fee_line->accounttype,
|
||||
'LR', 'Lost fee now has account type of LR ( Lost Returned )' );
|
||||
|
||||
is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' );
|
||||
is( $credit_return->amount + 0,
|
||||
$payment_amount * -1,
|
||||
'The account line of type CR has an amount equal to the payment'
|
||||
($payment_amount + $outstanding ) * -1,
|
||||
'The account line of type CR has an amount equal to the payment + outstanding'
|
||||
);
|
||||
is( $credit_return->amountoutstanding + 0,
|
||||
$payment_amount * -1,
|
||||
'The account line of type CR has an amountoutstanding equal to the payment'
|
||||
);
|
||||
|
||||
$lost_fee_line->discard_changes;
|
||||
is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
|
||||
is( $lost_fee_line->accounttype,
|
||||
'LR', 'Lost fee now has account type of LR ( Lost Returned )' );
|
||||
|
||||
is( $account->balance,
|
||||
$processfee_amount - $payment_amount,
|
||||
'The patron balance is the difference between the PF and the credit'
|
||||
|
|
|
|||
Loading…
Reference in New Issue