From 5fbf423e94b3482eb0521b53eac9ef1f3ff8d0f2 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 14 Oct 2019 17:07:11 +0100 Subject: [PATCH] Bug 23805: Update 'W' to 'WRITEOFF' 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 | 16 ++++++++-------- .../definitions/patron_account_credit.json | 2 +- installer/data/mysql/account_credit_types.sql | 3 +-- .../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 | 6 +++--- reports/cash_register_stats.pl | 4 ++-- t/db_dependent/Accounts.t | 8 ++++---- t/db_dependent/Circulation.t | 4 ++-- 11 files changed, 32 insertions(+), 29 deletions(-) diff --git a/C4/SIP/ILS/Transaction/FeePayment.pm b/C4/SIP/ILS/Transaction/FeePayment.pm index 668d90e45a..7e19cc26df 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 67988f2b51..dd233ec718 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -79,7 +79,7 @@ sub pay { 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'; + my $offset_type = $params->{offset_type} || $type eq 'WRITEOFF' ? 'Writeoff' : 'Payment'; my $cash_register = $params->{cash_register}; my $userenv = C4::Context->userenv; @@ -216,11 +216,11 @@ sub pay { } $credit_type ||= - $type eq 'writeoff' - ? 'W' + $type eq 'WRITEOFF' + ? 'WRITEOFF' : 'PAYMENT'; - $description ||= $type eq 'writeoff' ? 'Writeoff' : q{}; + $description ||= $type eq 'WRITEOFF' ? 'Writeoff' : q{}; my $payment = Koha::Account::Line->new( { @@ -326,7 +326,7 @@ $credit_type can be any of: - 'PAYMENT' - 'FORGIVEN' - 'LOST_RETURN' - - 'writeoff' + - 'WRITEOFF' =cut @@ -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( @@ -720,7 +720,7 @@ our $offset_type = { 'FORGIVEN' => 'Writeoff', 'LOST_RETURN' => 'Lost Item', 'PAYMENT' => 'Payment', - 'writeoff' => 'Writeoff', + 'WRITEOFF' => 'Writeoff', 'ACCOUNT' => 'Account Fee', 'ACCOUNT_RENEW' => 'Account Fee', 'RESERVE' => 'Reserve Fee', @@ -743,7 +743,7 @@ our $account_type_credit = { 'FORGIVEN' => 'FORGIVEN', 'LOST_RETURN' => 'LOST_RETURN', 'PAYMENT' => 'PAYMENT', - 'writeoff' => 'W' + 'WRITEOFF' => 'WRITEOFF' }; =head1 AUTHORS diff --git a/api/v1/swagger/definitions/patron_account_credit.json b/api/v1/swagger/definitions/patron_account_credit.json index 90683b4a98..a231471c21 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 579de316cf..d247427f69 100644 --- a/installer/data/mysql/account_credit_types.sql +++ b/installer/data/mysql/account_credit_types.sql @@ -1,7 +1,6 @@ INSERT INTO account_debit_types ( code, description, can_be_added_manually, is_system ) VALUES ('PAYMENT', 'Payment', 0, 1), -('W', 'Writeoff', 0, 1), -('WO', 'Writeoff', 0, 1), +('WRITEOFF', 'Writeoff', 0, 1), ('FORGIVEN', 'Forgiven', 1, 1), ('CREDIT', 'Credit', 1, 1), ('LOST_RETURN', 'Lost item fee refund', 0, 1); diff --git a/installer/data/mysql/atomicupdate/bug_23805_credit.perl b/installer/data/mysql/atomicupdate/bug_23805_credit.perl index abd55ad3ce..27896d0313 100644 --- a/installer/data/mysql/atomicupdate/bug_23805_credit.perl +++ b/installer/data/mysql/atomicupdate/bug_23805_credit.perl @@ -37,8 +37,7 @@ if ( CheckVersion($DBversion) ) { ) VALUES ('PAYMENT', 'Payment', 0, 1), - ('W', 'Writeoff', 0, 1), - ('WO', 'Writeoff', 0, 1), + ('WRITEOFF', 'Writeoff', 0, 1), ('FORGIVEN', 'Forgiven', 1, 1), ('CREDIT', 'Credit', 1, 1), ('LOST_RETURN', 'Lost item fee refund', 0, 1) @@ -95,6 +94,13 @@ if ( CheckVersion($DBversion) ) { } ); + # Update accountype 'W' to 'WRITEOFF' + $dbh->do( + qq{ + UPDATE accountlines SET accounttype = 'WRITEOFF' WHERE accounttype = 'W' OR accounttype = 'WO' + } + ); + # 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 19b5b3bbbf..8d9e836729 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc @@ -3,9 +3,8 @@ [%- IF account.credit_type_code -%] [%- SWITCH account.credit_type_code -%] [%- CASE 'PAYMENT' -%]Payment - [%- CASE 'W' -%]Writeoff + [%- CASE 'WRITEOFF' -%]Writeoff [%- CASE 'FORGIVEN' -%]Forgiven - [%- CASE 'WO' -%]Writeoff [%- CASE 'CREDIT' -%]Credit [%- CASE 'LOST_RETURN' -%]Lost item fee refund [%- CASE -%][% account.credit_type.description | html %] 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 cbf59ee017..17f1ae3264 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc @@ -174,9 +174,8 @@ [%- IF account.credit_type_code -%] [%- SWITCH account.credit_type_code -%] [%- CASE 'PAYMENT' -%]Payment - [%- CASE 'W' -%]Writeoff + [%- CASE 'WRITEOFF' -%]Writeoff [%- CASE 'FORGIVEN' -%]Forgiven - [%- CASE 'WO' -%]Writeoff [%- CASE 'CREDIT' -%]Credit [%- CASE 'LOST_RETURN' -%]Lost item fee refund [%- CASE -%][% account.credit_type.description | html %] diff --git a/members/pay.pl b/members/pay.pl index b12bd19c92..32c8c36dec 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -84,7 +84,7 @@ elsif ( $input->param('payselected') ) { payselected({ params => \@names }); } elsif ( $input->param('writeoff_selected') ) { - payselected({ params => \@names, type => 'writeoff' }); + payselected({ params => \@names, type => 'WRITEOFF' }); } elsif ( $input->param('woall') ) { writeoff_all(@names); @@ -116,7 +116,7 @@ elsif ( $input->param('confirm_writeoff') ) { { amount => $amount, lines => [ scalar Koha::Account::Lines->find($accountlines_id) ], - type => 'writeoff', + type => 'WRITEOFF', note => $payment_note, interface => C4::Context->interface, library_id => $branch, @@ -223,7 +223,7 @@ sub writeoff_all { { amount => $amount, lines => [ scalar Koha::Account::Lines->find($accountlines_id) ], - type => 'writeoff', + type => 'WRITEOFF', note => $payment_note, interface => C4::Context->interface, library_id => $branch, diff --git a/reports/cash_register_stats.pl b/reports/cash_register_stats.pl index da7b511358..84ce1949a1 100755 --- a/reports/cash_register_stats.pl +++ b/reports/cash_register_stats.pl @@ -74,7 +74,7 @@ if ($do_it) { } elsif ($transaction_type eq 'ACT') { #Active $whereTType = q{ AND credit_type_code IN ('PAYMENT','CREDIT') }; } elsif ($transaction_type eq 'FORW') { - $whereTType = q{ AND credit_type_code IN ('FORGIVEN','W') }; + $whereTType = q{ AND credit_type_code IN ('FORGIVEN','WRITEOFF') }; } else { if ( any { $transaction_type eq $_->code } @debit_types ) { $whereTType = q{ AND debit_type_code = ? }; @@ -128,7 +128,7 @@ if ($do_it) { 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'){ + }elsif($row->{credit_type_code} eq 'FORGIVEN' || $row->{credit_type_code} eq 'WRITEOFF'){ }else{ $grantotal += abs($row->{amount}); } diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t index 99cb3f32f9..c7e21ab04b 100644 --- a/t/db_dependent/Accounts.t +++ b/t/db_dependent/Accounts.t @@ -374,7 +374,7 @@ subtest "Koha::Account::pay writeoff tests" => sub { { lines => [$line], amount => 42, - type => 'writeoff', + type => 'WRITEOFF', } ); @@ -384,7 +384,7 @@ subtest "Koha::Account::pay writeoff tests" => sub { my $writeoff = Koha::Account::Lines->find( $id ); - is( $writeoff->credit_type_code, 'W', 'Type is correct for writeoff' ); + is( $writeoff->credit_type_code, 'WRITEOFF', 'Type is correct for WRITEOFF' ); is( $writeoff->description, 'Writeoff', 'Description is correct' ); is( $writeoff->amount, '-42.000000', 'Amount is correct' ); }; @@ -1180,7 +1180,7 @@ subtest "Payment notice tests" => sub { my $id = $account->pay( { amount => 1 } ); is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if UseEmailReceipts is disabled' ); - $id = $account->pay( { amount => 1, type => 'writeoff' } ); + $id = $account->pay( { amount => 1, type => 'WRITEOFF' } ); is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if UseEmailReceipts is disabled' ); t::lib::Mocks::mock_preference('UseEmailReceipts', '1'); @@ -1196,7 +1196,7 @@ subtest "Payment notice tests" => sub { $letter->content('[%- USE Price -%]A writeoff of [% credit.amount * -1 | $Price %] has been applied to your account.'); $letter->store(); - $id = $account->pay( { amount => 13, type => 'writeoff' } ); + $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->letter_code, 'ACCOUNT_WRITEOFF', 'Notice letter code is correct for writeoff' ); diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 0f78fa5b8f..dddedd9654 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -2148,7 +2148,7 @@ subtest '_FixAccountForLostAndReturned' => sub { # Write off the debt my $credit = $account->add_credit( { amount => $account->balance, - type => 'writeoff', + type => 'WRITEOFF', interface => 'test', } ); @@ -2345,7 +2345,7 @@ subtest '_FixAccountForLostAndReturned' => sub { my $write_off_amount = 25; my $write_off = $account->add_credit( { amount => $write_off_amount, - type => 'writeoff', + type => 'WRITEOFF', interface => 'test', } ); -- 2.39.5