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>
This commit is contained in:
parent
ce479d7a7d
commit
6bfd41eb0a
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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'){
|
||||
|
|
|
|||
|
|
@ -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" );
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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' );
|
||||
|
|
|
|||
|
|
@ -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…
Reference in New Issue