Browse Source

Bug 23805: Update 'Pay' to 'PAYMENT' for consistency

Signed-off-by: Kyle Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
remotes/origin/19.11.x
Martin Renvoize 3 years ago
parent
commit
6bfd41eb0a
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 2
      C4/SIP/ILS/Transaction/FeePayment.pm
  2. 14
      Koha/Account.pm
  3. 4
      Koha/REST/V1/Patrons/Account.pm
  4. 2
      api/v1/swagger/definitions/patron_account_credit.json
  5. 3
      installer/data/mysql/account_credit_types.sql
  6. 10
      installer/data/mysql/atomicupdate/bug_23805_credit.perl
  7. 3
      koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc
  8. 3
      koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc
  9. 2
      members/pay.pl
  10. 2
      members/paycollect.pl
  11. 6
      reports/cash_register_stats.pl
  12. 4
      t/db_dependent/Accounts.t
  13. 8
      t/db_dependent/Circulation.t
  14. 8
      t/db_dependent/Koha/Account.t
  15. 2
      t/db_dependent/Koha/Account/Lines.t
  16. 2
      t/db_dependent/api/v1/patrons_accounts.t

2
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");

14
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'
};

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

2
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",

3
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),

10
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{

3
koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc

@ -2,10 +2,9 @@
<span>
[%- 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

3
koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc

@ -173,10 +173,9 @@
<span>
[%- 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

2
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;

2
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(

6
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'){

4
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" );

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

8
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;

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

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

Loading…
Cancel
Save