From 6bfd41eb0addf7e1d02c898696de31187320c30e 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 Signed-off-by: Kyle Hall Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize --- 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 +- installer/data/mysql/account_credit_types.sql | 3 +-- .../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/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(+), 36 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 d7d18457bc..67988f2b51 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 b5bd5ca4b4..63888cd082 100644 --- a/Koha/REST/V1/Patrons/Account.pm +++ b/Koha/REST/V1/Patrons/Account.pm @@ -92,7 +92,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 @@ -107,7 +107,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/account_credit_types.sql b/installer/data/mysql/account_credit_types.sql index a91a7a32ba..579de316cf 100644 --- a/installer/data/mysql/account_credit_types.sql +++ b/installer/data/mysql/account_credit_types.sql @@ -1,6 +1,5 @@ INSERT INTO account_debit_types ( code, description, can_be_added_manually, 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), 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 18fa309044..19b5b3bbbf 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 1269cec3b7..cbf59ee017 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 d637256b53..99cb3f32f9 100644 --- a/t/db_dependent/Accounts.t +++ b/t/db_dependent/Accounts.t @@ -433,7 +433,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" ); @@ -493,7 +493,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 07037d7de1..0f78fa5b8f 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/Koha/Account.t b/t/db_dependent/Koha/Account.t index e211ccfcd2..a4853b52df 100755 --- a/t/db_dependent/Koha/Account.t +++ b/t/db_dependent/Koha/Account.t @@ -220,7 +220,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 } ); @@ -232,7 +232,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' } @@ -241,7 +241,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 ); @@ -259,7 +259,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 8cc18fb8f2..d63de70938 100755 --- a/t/db_dependent/Koha/Account/Lines.t +++ b/t/db_dependent/Koha/Account/Lines.t @@ -587,7 +587,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 a9d236959a..6921931c1b 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.39.5