From dfaf5834d15010cab2f76c3f9c9aca93237d6166 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 27 Oct 2022 01:13:08 +0000 Subject: [PATCH] Bug 23012: (follow-up) Fix t/db_dependent/Koha/Items.t Signed-off-by: Tomas Cohen Arazi --- Koha/Item.pm | 2 +- t/db_dependent/Koha/Items.t | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 25b4e54dc3..3ef1e04194 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1325,7 +1325,7 @@ sub _set_found_trigger { } } - my $processingreturn_policy = $lost_proc_return_policy->{lostreturn}; + my $processingreturn_policy = $lost_proc_return_policy->{processingreturn}; if ( $processingreturn_policy ) { diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t index 6c1ebc3aac..0c424f98db 100755 --- a/t/db_dependent/Koha/Items.t +++ b/t/db_dependent/Koha/Items.t @@ -368,7 +368,7 @@ subtest 'store' => sub { subtest 'Full payment tests' => sub { - plan tests => 14; + plan tests => 16; my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); @@ -455,6 +455,18 @@ subtest 'store' => sub { 'The account line of type LOST_FOUND has an amountoutstanding of -99' ); + my $processing_return = Koha::Account::Lines->search( + { + itemnumber => $item->itemnumber, + credit_type_code => 'PROCESSING_FOUND' + }, + { rows => 1 } + )->single; + ok( $processing_return, 'An account line of type PROCESSING_FOUND is added' ); + is( $processing_return->amount + 0, + -20.00, + 'The account line of type PROCESSING_FOUND has an amount of -20' ); + $lost_fee_line->discard_changes; is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); @@ -463,8 +475,8 @@ subtest 'store' => sub { is( $lost_fee_line->status, 'FOUND', "Lost fee now has account status of FOUND" ); - is( $patron->account->balance, -99, -'The patron balance is -99, a credit that equals the lost fee payment' + is( $patron->account->balance, -119, +'The patron balance is -119, a credit that equals the lost fee payment and the processing fee' ); }; @@ -523,6 +535,21 @@ subtest 'store' => sub { $replacement_amount, 'The right LOST amountountstanding is generated' ); + # Set processingreturn_policy to '0' so processing fee is retained + # these tests are just for lostreturn + my $processingreturn_rule = $builder->build( + { + source => 'CirculationRule', + value => { + branchcode => undef, + categorycode => undef, + itemtype => undef, + rule_name => 'processingreturn', + rule_value => '0' + } + } + ); + # Simulate item marked as found $item->itemlost(0)->store; is( scalar ( grep { $_->message eq 'lost_refunded' } @{$item->object_messages} ), 1, 'Refund triggered' ); -- 2.39.5