my $is_writeoff = shift;
my $disallow_overpayment = shift;
- my $type = $is_writeoff ? 'writeoff' : 'payment';
+ my $type = $is_writeoff ? 'writeoff' : 'PAYMENT';
warn("RECORD:$borrowernumber::$amt");
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';
$credit_type ||=
$type eq 'writeoff'
? 'W'
- : 'Pay';
+ : 'PAYMENT';
$description ||= $type eq 'writeoff' ? 'Writeoff' : q{};
$credit_type can be any of:
- 'CREDIT'
- - 'payment'
+ - 'PAYMENT'
- 'FORGIVEN'
- 'LOST_RETURN'
- 'writeoff'
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 ) {
amount => $amount,
borrowernumber => $self->{patron_id},
}
- ) if grep { $type eq $_ } ('payment', 'writeoff') ;
+ ) if grep { $type eq $_ } ('PAYMENT', 'writeoff') ;
if ( C4::Context->preference("FinesLog") ) {
logaction(
'CREDIT' => 'Manual Credit',
'FORGIVEN' => 'Writeoff',
'LOST_RETURN' => 'Lost Item',
- 'payment' => 'Payment',
+ 'PAYMENT' => 'Payment',
'writeoff' => 'Writeoff',
'ACCOUNT' => 'Account Fee',
'ACCOUNT_RENEW' => 'Account Fee',
'CREDIT' => 'CREDIT',
'FORGIVEN' => 'FORGIVEN',
'LOST_RETURN' => 'LOST_RETURN',
- 'payment' => 'Pay',
+ 'PAYMENT' => 'PAYMENT',
'writeoff' => 'W'
};
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
my $credit = $account->add_credit(
{ amount => $amount,
- credit_type => $credit_type,
+ type => $credit_type,
payment_type => $payment_type,
description => $description,
note => $note,
"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",
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),
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),
}
);
+ # 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{
<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
<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
my $parameters = shift;
my @params = @{ $parameters->{params} };
- my $type = $parameters->{type} || 'payment';
+ my $type = $parameters->{type} || 'PAYMENT';
my $amt = 0;
my @lines_to_pay;
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(
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 {
$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'){
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" );
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" );
# Write off the debt
my $credit = $account->add_credit(
{ amount => $account->balance,
- type => 'payment',
+ type => 'PAYMENT',
interface => 'test',
}
);
my $payment_amount = 27;
my $payment = $account->add_credit(
{ amount => $payment_amount,
- type => 'payment',
+ type => 'PAYMENT',
interface => 'test',
}
);
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' );
my $payment_amount = 27;
my $payment = $account->add_credit(
{ amount => $payment_amount,
- type => 'payment',
+ type => 'PAYMENT',
interface => 'test',
}
);
description => 'Payment of 25',
library_id => $patron->branchcode,
note => 'not really important',
- type => 'payment',
+ type => 'PAYMENT',
user_id => $patron->id
}
);
description => 'Payment of 25',
library_id => $patron->branchcode,
note => 'not really important',
- type => 'payment',
+ type => 'PAYMENT',
user_id => $patron->id,
interface => 'commandline'
}
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 );
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;
$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' );
note => 'He paid!',
description => 'Finally!',
library_id => $patron->branchcode,
- account_type => 'Pay',
+ account_type => 'PAYMENT',
offset_type => 'Payment'
}
);