From 87465867a5aab5a068a95b5ac4b865fa30a4892d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 10 Oct 2019 16:31:17 +0100 Subject: [PATCH] Bug 23049: Capitalise type passed to add_debit for `account` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Séverine QUEUNE --- Koha/Account.pm | 12 ++++++------ Koha/Patron.pm | 2 +- t/db_dependent/Accounts.t | 16 ++++++++-------- t/db_dependent/SIP/Transaction.t | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Koha/Account.pm b/Koha/Account.pm index 8dfd3a4d4d..183928a152 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -444,8 +444,8 @@ my $debit_line = Koha::Account->new({ patron_id => $patron_id })->add_debit( ); $debit_type can be any of: - - account - - account_renew + - ACCOUNT + - ACCOUNT_RENEW - hold_expired - lost_item - sundry @@ -709,8 +709,8 @@ our $offset_type = { 'lost_item_return' => 'Lost Item', 'payment' => 'Payment', 'writeoff' => 'Writeoff', - 'account' => 'Account Fee', - 'account_renew' => 'Account Fee', + 'ACCOUNT' => 'Account Fee', + 'ACCOUNT_RENEW' => 'Account Fee', 'RESERVE' => 'Reserve Fee', 'PROCESSING' => 'Processing Fee', 'lost_item' => 'Lost Item', @@ -740,8 +740,8 @@ our $account_type_credit = { =cut our $account_type_debit = { - 'account' => 'ACCOUNT', - 'account_renew' => 'ACCOUNT_RENEW', + 'ACCOUNT' => 'ACCOUNT', + 'ACCOUNT_RENEW' => 'ACCOUNT_RENEW', 'hold_expired' => 'HE', 'lost_item' => 'LOST', 'sundry' => 'M', diff --git a/Koha/Patron.pm b/Koha/Patron.pm index fca796ff28..d4dcec986e 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -887,7 +887,7 @@ sub add_enrolment_fee_if_needed { my ($self, $renewal) = @_; my $enrolment_fee = $self->category->enrolmentfee; if ( $enrolment_fee && $enrolment_fee > 0 ) { - my $type = $renewal ? 'account_renew' : 'account'; + my $type = $renewal ? 'ACCOUNT_RENEW' : 'ACCOUNT'; $self->account->add_debit( { amount => $enrolment_fee, diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t index a34c523341..4e93b9e85b 100644 --- a/t/db_dependent/Accounts.t +++ b/t/db_dependent/Accounts.t @@ -183,8 +183,8 @@ subtest "Koha::Account::pay tests" => sub { my $account = Koha::Account->new({ patron_id => $borrower->id }); - my $line1 = $account->add_debit({ type => 'account', amount => 100, interface => 'commandline' }); - my $line2 = $account->add_debit({ type => 'account', amount => 200, interface => 'commandline' }); + my $line1 = $account->add_debit({ type => 'ACCOUNT', amount => 100, interface => 'commandline' }); + my $line2 = $account->add_debit({ type => 'ACCOUNT', amount => 200, interface => 'commandline' }); $sth = $dbh->prepare("SELECT count(*) FROM accountlines"); $sth->execute; @@ -283,7 +283,7 @@ subtest "Koha::Account::pay tests" => sub { $note = $sth->fetchrow_array; is($note,'$200.00 payment note', '$200.00 payment note is registered'); - my $line3 = $account->add_debit({ type => 'account', amount => 42, interface => 'commandline' }); + my $line3 = $account->add_debit({ type => 'ACCOUNT', amount => 42, interface => 'commandline' }); my $payment_id = $account->pay( { lines => [$line3], amount => 42 } ); my $payment = Koha::Account::Lines->find( $payment_id ); is( $payment->amount(), '-42.000000', "Payment paid the specified fine" ); @@ -311,10 +311,10 @@ subtest "Koha::Account::pay particular line tests" => sub { my $account = Koha::Account->new({ patron_id => $borrower->id }); - my $line1 = $account->add_debit({ type => 'account', amount => 1, interface => 'commandline' }); - my $line2 = $account->add_debit({ type => 'account', amount => 2, interface => 'commandline' }); - my $line3 = $account->add_debit({ type => 'account', amount => 3, interface => 'commandline' }); - my $line4 = $account->add_debit({ type => 'account', amount => 4, interface => 'commandline' }); + my $line1 = $account->add_debit({ type => 'ACCOUNT', amount => 1, interface => 'commandline' }); + my $line2 = $account->add_debit({ type => 'ACCOUNT', amount => 2, interface => 'commandline' }); + my $line3 = $account->add_debit({ type => 'ACCOUNT', amount => 3, interface => 'commandline' }); + my $line4 = $account->add_debit({ type => 'ACCOUNT', amount => 4, interface => 'commandline' }); is( $account->balance(), 10, "Account balance is 10" ); @@ -356,7 +356,7 @@ subtest "Koha::Account::pay writeoff tests" => sub { my $account = Koha::Account->new({ patron_id => $borrower->id }); - my $line = $account->add_debit({ type => 'account', amount => 42, interface => 'commandline' }); + my $line = $account->add_debit({ type => 'ACCOUNT', amount => 42, interface => 'commandline' }); is( $account->balance(), 42, "Account balance is 42" ); diff --git a/t/db_dependent/SIP/Transaction.t b/t/db_dependent/SIP/Transaction.t index c630fadfde..53d59d8011 100755 --- a/t/db_dependent/SIP/Transaction.t +++ b/t/db_dependent/SIP/Transaction.t @@ -106,9 +106,9 @@ subtest "FeePayment->pay tests" => sub { my $account = Koha::Account->new( { patron_id => $patron->{borrowernumber} } ); my $debt1 = $account->add_debit( - { type => 'account', amount => 100, interface => 'commandline' } ); + { type => 'ACCOUNT', amount => 100, interface => 'commandline' } ); my $debt2 = $account->add_debit( - { type => 'account', amount => 200, interface => 'commandline' } ); + { type => 'ACCOUNT', amount => 200, interface => 'commandline' } ); # Instantiate a new FeePayment transaction object my $trans = C4::SIP::ILS::Transaction::FeePayment->new(); -- 2.20.1