From 5a083fe9fdfff309a1df48c94373a65325455179 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 14 Oct 2019 16:54:56 +0100 Subject: [PATCH] Bug 23805: Update 'Pay' to 'PAYMENT' for consistency --- C4/SIP/ILS/Transaction/FeePayment.pm | 2 +- Koha/Account.pm | 14 +++++++------- Koha/REST/V1/Patrons/Account.pm | 4 ++-- .../swagger/definitions/patron_account_credit.json | 2 +- .../data/mysql/atomicupdate/bug_23805_credit.perl | 10 ++++++++-- .../intranet-tmpl/prog/en/includes/accounts.inc | 3 +-- .../bootstrap/en/includes/account-table.inc | 3 +-- members/pay.pl | 2 +- members/paycollect.pl | 2 +- reports/cash_register_stats.pl | 6 +++--- t/db_dependent/Accounts.t | 4 ++-- t/db_dependent/Circulation.t | 8 ++++---- t/db_dependent/ILSDI_Services.t | 2 +- t/db_dependent/Koha/Account.t | 8 ++++---- t/db_dependent/Koha/Account/Lines.t | 2 +- t/db_dependent/api/v1/patrons_accounts.t | 2 +- 16 files changed, 39 insertions(+), 35 deletions(-) diff --git a/C4/SIP/ILS/Transaction/FeePayment.pm b/C4/SIP/ILS/Transaction/FeePayment.pm index 943176456d..668d90e45a 100644 --- a/C4/SIP/ILS/Transaction/FeePayment.pm +++ b/C4/SIP/ILS/Transaction/FeePayment.pm @@ -50,7 +50,7 @@ sub pay { my $is_writeoff = shift; my $disallow_overpayment = shift; - my $type = $is_writeoff ? 'writeoff' : 'payment'; + my $type = $is_writeoff ? 'writeoff' : 'PAYMENT'; warn("RECORD:$borrowernumber::$amt"); diff --git a/Koha/Account.pm b/Koha/Account.pm index 39321ae749..4c65c50750 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -76,7 +76,7 @@ sub pay { my $note = $params->{note} || q{}; my $library_id = $params->{library_id}; my $lines = $params->{lines}; - my $type = $params->{type} || 'payment'; + my $type = $params->{type} || 'PAYMENT'; my $payment_type = $params->{payment_type} || undef; my $credit_type = $params->{credit_type}; my $offset_type = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment'; @@ -218,7 +218,7 @@ sub pay { $credit_type ||= $type eq 'writeoff' ? 'W' - : 'Pay'; + : 'PAYMENT'; $description ||= $type eq 'writeoff' ? 'Writeoff' : q{}; @@ -323,7 +323,7 @@ my $credit_line = Koha::Account->new({ patron_id => $patron_id })->add_credit( $credit_type can be any of: - 'CREDIT' - - 'payment' + - 'PAYMENT' - 'forgiven' - 'LOST_RETURN' - 'writeoff' @@ -343,7 +343,7 @@ sub add_credit { my $library_id = $params->{library_id}; my $cash_register = $params->{cash_register}; my $payment_type = $params->{payment_type}; - my $type = $params->{type} || 'payment'; + my $type = $params->{type} || 'PAYMENT'; my $item_id = $params->{item_id}; unless ( $interface ) { @@ -398,7 +398,7 @@ sub add_credit { amount => $amount, borrowernumber => $self->{patron_id}, } - ) if grep { $type eq $_ } ('payment', 'writeoff') ; + ) if grep { $type eq $_ } ('PAYMENT', 'writeoff') ; if ( C4::Context->preference("FinesLog") ) { logaction( @@ -719,7 +719,7 @@ our $offset_type = { 'CREDIT' => 'Manual Credit', 'FORGIVEN' => 'Writeoff', 'LOST_RETURN' => 'Lost Item', - 'payment' => 'Payment', + 'PAYMENT' => 'Payment', 'writeoff' => 'Writeoff', 'ACCOUNT' => 'Account Fee', 'ACCOUNT_RENEW' => 'Account Fee', @@ -742,7 +742,7 @@ our $account_type_credit = { 'CREDIT' => 'CREDIT', 'FORGIVEN' => 'FORGIVEN', 'LOST_RETURN' => 'LOST_RETURN', - 'payment' => 'Pay', + 'PAYMENT' => 'PAYMENT', 'writeoff' => 'W' }; diff --git a/Koha/REST/V1/Patrons/Account.pm b/Koha/REST/V1/Patrons/Account.pm index 933d9bcea2..19e391de66 100644 --- a/Koha/REST/V1/Patrons/Account.pm +++ b/Koha/REST/V1/Patrons/Account.pm @@ -94,7 +94,7 @@ sub add_credit { my $body = $c->validation->param('body'); return try { - my $credit_type = $body->{credit_type} || 'payment'; # default to 'payment' + my $credit_type = $body->{credit_type} || 'PAYMENT'; # default to 'PAYMENT' my $amount = $body->{amount}; # mandatory, validated by openapi unless ( $amount > 0 ) { # until we support newer JSON::Validator and thus minimumExclusive @@ -109,7 +109,7 @@ sub add_credit { my $credit = $account->add_credit( { amount => $amount, - credit_type => $credit_type, + type => $credit_type, payment_type => $payment_type, description => $description, note => $note, diff --git a/api/v1/swagger/definitions/patron_account_credit.json b/api/v1/swagger/definitions/patron_account_credit.json index 9f00f26eda..90683b4a98 100644 --- a/api/v1/swagger/definitions/patron_account_credit.json +++ b/api/v1/swagger/definitions/patron_account_credit.json @@ -3,7 +3,7 @@ "properties": { "credit_type": { "type": "string", - "description": "Type of credit ('CREDIT', 'FORGIVEN', 'LOST_RETURN', 'payment', 'writeoff' )" + "description": "Type of credit ('CREDIT', 'FORGIVEN', 'LOST_RETURN', 'PAYMENT', 'writeoff' )" }, "amount": { "type": "number", diff --git a/installer/data/mysql/atomicupdate/bug_23805_credit.perl b/installer/data/mysql/atomicupdate/bug_23805_credit.perl index d3ca751054..abd55ad3ce 100644 --- a/installer/data/mysql/atomicupdate/bug_23805_credit.perl +++ b/installer/data/mysql/atomicupdate/bug_23805_credit.perl @@ -36,8 +36,7 @@ if ( CheckVersion($DBversion) ) { is_system ) VALUES - ('Pay', 'Payment', 0, 1), - ('PAY', 'Payment', 0, 1), + ('PAYMENT', 'Payment', 0, 1), ('W', 'Writeoff', 0, 1), ('WO', 'Writeoff', 0, 1), ('FORGIVEN', 'Forgiven', 1, 1), @@ -89,6 +88,13 @@ if ( CheckVersion($DBversion) ) { } ); + # Update accountype 'Pay' to 'PAYMENT' + $dbh->do( + qq{ + UPDATE accountlines SET accounttype = 'PAYMENT' WHERE accounttype = 'Pay' OR accounttype = 'PAY' + } + ); + # Populating credit_type_code $dbh->do( qq{ diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc index 8884c0d6ed..809ffe4479 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc @@ -2,10 +2,9 @@ [%- IF account.credit_type_code -%] [%- SWITCH account.credit_type_code -%] - [%- CASE 'Pay' -%]Payment + [%- CASE 'PAYMENT' -%]Payment [%- CASE 'W' -%]Writeoff [%- CASE 'FORGIVEN' -%]Forgiven - [%- CASE 'PAY' -%]Payment [%- CASE 'WO' -%]Writeoff [%- CASE 'CREDIT' -%]Credit [%- CASE 'LOST_RETURN' -%]Lost item fee refund diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc index 43bd8d5dff..9533d6a423 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc @@ -173,10 +173,9 @@ [%- IF account.credit_type_code -%] [%- SWITCH account.credit_type_code -%] - [%- CASE 'Pay' -%]Payment + [%- CASE 'PAYMENT' -%]Payment [%- CASE 'W' -%]Writeoff [%- CASE 'FORGIVEN' -%]Forgiven - [%- CASE 'PAY' -%]Payment [%- CASE 'WO' -%]Writeoff [%- CASE 'CREDIT' -%]Credit [%- CASE 'LOST_RETURN' -%]Lost item fee refund diff --git a/members/pay.pl b/members/pay.pl index a5467b2676..b12bd19c92 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -240,7 +240,7 @@ sub payselected { my $parameters = shift; my @params = @{ $parameters->{params} }; - my $type = $parameters->{type} || 'payment'; + my $type = $parameters->{type} || 'PAYMENT'; my $amt = 0; my @lines_to_pay; diff --git a/members/paycollect.pl b/members/paycollect.pl index 33be232e67..3c1e8aa201 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -40,7 +40,7 @@ my $input = CGI->new(); my $payment_id = $input->param('payment_id'); my $writeoff_individual = $input->param('writeoff_individual'); my $change_given = $input->param('change_given'); -my $type = scalar $input->param('type') || 'payment'; +my $type = scalar $input->param('type') || 'PAYMENT'; my $updatecharges_permissions = ($writeoff_individual || $type eq 'writeoff') ? 'writeoff' : 'remaining_permissions'; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( diff --git a/reports/cash_register_stats.pl b/reports/cash_register_stats.pl index 52cf12488a..da7b511358 100755 --- a/reports/cash_register_stats.pl +++ b/reports/cash_register_stats.pl @@ -72,7 +72,7 @@ if ($do_it) { if ($transaction_type eq 'ALL') { #All Transactons $whereTType = q{}; } elsif ($transaction_type eq 'ACT') { #Active - $whereTType = q{ AND credit_type_code IN ('Pay','CREDIT') }; + $whereTType = q{ AND credit_type_code IN ('PAYMENT','CREDIT') }; } elsif ($transaction_type eq 'FORW') { $whereTType = q{ AND credit_type_code IN ('FORGIVEN','W') }; } else { @@ -121,11 +121,11 @@ if ($do_it) { $row->{date} = dt_from_string($row->{date}, 'sql'); push (@loopresult, $row); - if($transaction_type eq 'ACT' && ($row->{credit_type_code} !~ /^C$|^CR$|^Pay$/)){ + if($transaction_type eq 'ACT' && ($row->{credit_type_code} !~ /^CREDIT$|^PAYMENT$/)){ pop @loopresult; next; } - if($row->{credit_type_code} =~ /^C$|^CR$/){ + if($row->{credit_type_code} =~ /^CREDIT$/){ $grantotal -= abs($row->{amount}); $row->{amount} = '-' . $row->{amount}; }elsif($row->{credit_type_code} eq 'FORGIVEN' || $row->{credit_type_code} eq 'W'){ diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t index f0a822db2a..8e30f17cdd 100644 --- a/t/db_dependent/Accounts.t +++ b/t/db_dependent/Accounts.t @@ -417,7 +417,7 @@ subtest "More Koha::Account::pay tests" => sub { my $stat = $schema->resultset('Statistic')->search({ branch => $branch, - type => 'payment' + type => 'PAYMENT' }, { order_by => { -desc => 'datetime' } })->next(); ok( defined $stat, "There's a payment log that matches the branch" ); @@ -471,7 +471,7 @@ subtest "Even more Koha::Account::pay tests" => sub { my $stat = $schema->resultset('Statistic')->search({ branch => $branch, - type => 'payment' + type => 'PAYMENT' }, { order_by => { -desc => 'datetime' } })->next(); ok( defined $stat, "There's a payment log that matches the branch" ); diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 66b20376ef..8fb9ae2c14 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -2210,7 +2210,7 @@ subtest '_FixAccountForLostAndReturned' => sub { # Write off the debt my $credit = $account->add_credit( { amount => $account->balance, - type => 'payment', + type => 'PAYMENT', interface => 'test', } ); @@ -2334,7 +2334,7 @@ subtest '_FixAccountForLostAndReturned' => sub { my $payment_amount = 27; my $payment = $account->add_credit( { amount => $payment_amount, - type => 'payment', + type => 'PAYMENT', interface => 'test', } ); @@ -2363,7 +2363,7 @@ subtest '_FixAccountForLostAndReturned' => sub { my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id ); my $credit_return = Koha::Account::Lines->find($credit_return_id); - is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PROCESSING - payment (LOST_RETURN)' ); + is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PROCESSING - PAYMENT (LOST_RETURN)' ); $lost_fee_line->discard_changes; is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); @@ -2438,7 +2438,7 @@ subtest '_FixAccountForLostAndReturned' => sub { my $payment_amount = 27; my $payment = $account->add_credit( { amount => $payment_amount, - type => 'payment', + type => 'PAYMENT', interface => 'test', } ); diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t index acd1828f19..5ba5ec56d9 100644 --- a/t/db_dependent/ILSDI_Services.t +++ b/t/db_dependent/ILSDI_Services.t @@ -200,7 +200,7 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes source => 'Accountline', value => { borrowernumber => $brwr->{borrowernumber}, - credit_type_code => 'Pay', + credit_type_code => 'PAYMENT', amountoutstanding => 10 } } diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t index 8280bbd4c0..4c29e64016 100755 --- a/t/db_dependent/Koha/Account.t +++ b/t/db_dependent/Koha/Account.t @@ -180,7 +180,7 @@ subtest 'add_credit() tests' => sub { description => 'Payment of 25', library_id => $patron->branchcode, note => 'not really important', - type => 'payment', + type => 'PAYMENT', user_id => $patron->id } ); @@ -192,7 +192,7 @@ subtest 'add_credit() tests' => sub { description => 'Payment of 25', library_id => $patron->branchcode, note => 'not really important', - type => 'payment', + type => 'PAYMENT', user_id => $patron->id, interface => 'commandline' } @@ -201,7 +201,7 @@ subtest 'add_credit() tests' => sub { is( $account->balance, -25, 'Patron has a balance of -25' ); is( $schema->resultset('ActionLog')->count(), $action_logs + 0, 'No log was added' ); is( $schema->resultset('Statistic')->count(), $statistics + 1, 'Action added to statistics' ); - is( $line_1->credit_type_code, $Koha::Account::account_type_credit->{'payment'}, 'Account type is correctly set' ); + is( $line_1->credit_type_code, $Koha::Account::account_type_credit->{'PAYMENT'}, 'Account type is correctly set' ); # Enable logs t::lib::Mocks::mock_preference( 'FinesLog', 1 ); @@ -219,7 +219,7 @@ subtest 'add_credit() tests' => sub { is( $account->balance, -62, 'Patron has a balance of -25' ); is( $schema->resultset('ActionLog')->count(), $action_logs + 1, 'Log was added' ); is( $schema->resultset('Statistic')->count(), $statistics + 2, 'Action added to statistics' ); - is( $line_2->credit_type_code, $Koha::Account::account_type_credit->{'payment'}, 'Account type is correctly set' ); + is( $line_2->credit_type_code, $Koha::Account::account_type_credit->{'PAYMENT'}, 'Account type is correctly set' ); # offsets have the credit_id set to accountlines_id, and debit_id is undef my $offset_1 = Koha::Account::Offsets->search({ credit_id => $line_1->id })->next; diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t index dfd9dbb44c..6981eefd52 100755 --- a/t/db_dependent/Koha/Account/Lines.t +++ b/t/db_dependent/Koha/Account/Lines.t @@ -571,7 +571,7 @@ subtest "void() tests" => sub { $line1->_result->discard_changes(); $line2->_result->discard_changes(); - is( $account_payment->credit_type_code, 'Pay', 'Voided payment credit_type_code is still Pay' ); + is( $account_payment->credit_type_code, 'PAYMENT', 'Voided payment credit_type_code is still PAYMENT' ); is( $account_payment->status, 'VOID', 'Voided payment status is VOID' ); is( $account_payment->amount+0, 0, 'Voided payment amount is 0' ); is( $account_payment->amountoutstanding+0, 0, 'Voided payment amount outstanding is 0' ); diff --git a/t/db_dependent/api/v1/patrons_accounts.t b/t/db_dependent/api/v1/patrons_accounts.t index 53cebb3e25..fc797fc508 100644 --- a/t/db_dependent/api/v1/patrons_accounts.t +++ b/t/db_dependent/api/v1/patrons_accounts.t @@ -113,7 +113,7 @@ subtest 'get_balance() tests' => sub { note => 'He paid!', description => 'Finally!', library_id => $patron->branchcode, - account_type => 'Pay', + account_type => 'PAYMENT', offset_type => 'Payment' } ); -- 2.20.1