Bug 19191: (QA follow-up) Remove double fetches from database
authorKyle M Hall <kyle@bywatetsolutions.com>
Fri, 4 May 2018 19:17:51 +0000 (15:17 -0400)
committerNick Clemens <nick@bywatersolutions.com>
Mon, 23 Jul 2018 15:09:01 +0000 (15:09 +0000)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Koha/Account.pm
installer/data/mysql/atomicupdate/bug_19191.sql
t/db_dependent/Accounts.t

index 6b838a1..4926f9e 100644 (file)
@@ -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,
                 },
               )
           )
index 99d9f97..8e54bb6 100644 (file)
@@ -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`)
index 1069877..26a789c 100644 (file)
@@ -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' );
 };