From 7293115c5615213aa1768811ccf38f316f9bd9d9 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 21 Jun 2021 17:08:33 +0100 Subject: [PATCH] Bug 22435: (QA follow-up) Fix returned offsets in moredetail This patch updates the offsets query for lost item returns displayed in the catalogue/moredetail controller. Test plan (Same as bug 19919) Test plan: 1) Pay off a LOST item 2) Check for the associated display of 'Paidfor?:' on the itemdetails page 3) Writeoff a LOST item 4) Check that a 'Paidfor?:' is not displayed on the itemdetails page. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- catalogue/moredetail.pl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index 38eab6aafa..e033a2105b 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -208,14 +208,13 @@ foreach my $item (@items){ ); if ( my $accountline = $accountlines->next ) { - my $payment_offsets = Koha::Account::Offsets->search( + my $payment_offsets = $accountline->debit_offsets( { - debit_id => $accountline->id, credit_id => { '!=' => undef }, # it is not the debit itself - type => { '!=' => [ 'Writeoff', 'Forgiven' ] }, - amount => { '<' => 0 } # credits are negative on the DB + 'credit.credit_type_code' => + { '!=' => [ 'Writeoff', 'Forgiven' ] }, }, - { order_by => { '-desc' => 'created_on' } } + { join => 'credit', order_by => { '-desc' => 'created_on' } } ); if ($payment_offsets->count) { -- 2.39.5