From a503abb3db48bb60a87ee0e24fc80a3aecbc71a6 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 4 May 2018 15:17:51 -0400 Subject: [PATCH] Bug 19191: (QA follow-up) Remove double fetches from database Signed-off-by: Nick Clemens --- Koha/Account.pm | 4 ++-- installer/data/mysql/atomicupdate/bug_19191.sql | 2 +- t/db_dependent/Accounts.t | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Koha/Account.pm b/Koha/Account.pm index 6b838a1c28..4926f9e2e8 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -270,14 +270,14 @@ sub pay { module => 'circulation', letter_code => uc("ACCOUNT_$type"), message_transport_type => 'email', - lang => Koha::Patrons->find( $self->{patron_id} )->lang, + lang => $patron->lang, tables => { borrowers => $self->{patron_id}, branches => $self->{library_id}, }, substitute => { credit => $payment, - offsets => scalar Koha::Account::Offsets->search( { id => { -in => [ map { $_->id } @account_offsets ] } } ), + offsets => \@account_offsets, }, ) ) diff --git a/installer/data/mysql/atomicupdate/bug_19191.sql b/installer/data/mysql/atomicupdate/bug_19191.sql index 99d9f97756..8e54bb6e18 100644 --- a/installer/data/mysql/atomicupdate/bug_19191.sql +++ b/installer/data/mysql/atomicupdate/bug_19191.sql @@ -1,7 +1,7 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES ('circulation', 'ACCOUNT_PAYMENT', '', 'Account payment', 0, 'Account payment', '[%- USE Price -%]\r\nA payment of [% credit.amount * -1 | $Price %] has been applied to your account.\r\n\r\nThis payment affected the following fees:\r\n[%- FOREACH o IN offsets %]\r\nDescription: [% o.debit.description %]\r\nAmount paid: [% o.amount * -1 | $Price %]\r\nAmount remaining: [% o.debit.amountoutstanding | $Price %]\r\n[% END %]', 'email', 'default'), - ('circulation', 'ACCOUNT_WRITEOFF', '', 'Account Writeoff', 0, 'Account Writeoff', '[%- USE Price -%]\r\nAn account writeoff of [% credit.amount * -1 | $Price %] has been applied to your account.\r\n\r\nThis writeoff affected the following fees:\r\n[%- FOREACH o IN offsets %]\r\nDescription: [% o.debit.description %]\r\nAmount paid: [% o.amount * -1 | $Price %]\r\nAmount remaining: [% o.debit.amountoutstanding | $Price %]\r\n[% END %]', 'email', 'default'); + ('circulation', 'ACCOUNT_WRITEOFF', '', 'Account writeoff', 0, 'Account writeoff', '[%- USE Price -%]\r\nAn account writeoff of [% credit.amount * -1 | $Price %] has been applied to your account.\r\n\r\nThis writeoff affected the following fees:\r\n[%- FOREACH o IN offsets %]\r\nDescription: [% o.debit.description %]\r\nAmount paid: [% o.amount * -1 | $Price %]\r\nAmount remaining: [% o.debit.amountoutstanding | $Price %]\r\n[% END %]', 'email', 'default'); $dbh->do(q{ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t index 1069877385..26a789c96a 100644 --- a/t/db_dependent/Accounts.t +++ b/t/db_dependent/Accounts.t @@ -1013,7 +1013,7 @@ subtest "Payment notice tests" => sub { $id = $account->pay( { amount => 13, type => 'writeoff' } ); $notice = Koha::Notice::Messages->search()->next(); - is( $notice->subject, 'Account Writeoff', 'Notice subject is correct for payment' ); + is( $notice->subject, 'Account writeoff', 'Notice subject is correct for payment' ); is( $notice->letter_code, 'ACCOUNT_WRITEOFF', 'Notice letter code is correct for writeoff' ); is( $notice->content, 'A writeoff of 13.00 has been applied to your account.', 'Notice content is correct for writeoff' ); }; -- 2.39.5