From a19bb92203158a7e6cc541028dc4e3bc13e1c0d2 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 30 Sep 2021 10:02:20 -0300 Subject: [PATCH] [21.05.x] Bug 29139: Only pass the offsets for lines the credit was applied to On writing the regression tests, I noticed the CREATE offset was added to the template. The idea behind passing the offsets is that we can print information about the lines that got the credit applied. Having the CREATE offset is meaningless, and (worse) would require users to add logic to skip it. And all the payment information is already passed in the 'credit' variable anyway. This patch filters the credit_offsets by type, leaving the APPLY ones only. To test: 1. Apply up to the regression tests 2. Run: $ kshell k$ prove t/db_dependent/Koha/Account.t => FAIL: 3 offsets, including the CREATE one, boo! 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! Only the two APPLY offsets are returned! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Martin Renvoize --- Koha/Account.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Koha/Account.pm b/Koha/Account.pm index 2c4f8bf0a6..73bf2c3608 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -113,7 +113,12 @@ sub pay { } my $patron = Koha::Patrons->find( $self->{patron_id} ); - my @account_offsets = $payment->credit_offsets->as_list; + my @account_offsets = $payment->credit_offsets( + { + type => $Koha::Account::offset_type->{$type}, + -not => { debit_id => undef } + } + )->as_list; if ( C4::Context->preference('UseEmailReceipts') ) { if ( my $letter = C4::Letters::GetPreparedLetter( -- 2.32.0