Browse Source

Bug 19191: (QA follow-up) Remove double fetches from database

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
18.11.x
Kyle M Hall 6 years ago
committed by Nick Clemens
parent
commit
a503abb3db
  1. 4
      Koha/Account.pm
  2. 2
      installer/data/mysql/atomicupdate/bug_19191.sql
  3. 2
      t/db_dependent/Accounts.t

4
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,
},
)
)

2
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`)

2
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' );
};

Loading…
Cancel
Save