Browse Source

Bug 23805: Update 'W' to 'WRITEOFF' 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
5fbf423e94
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 2
      C4/SIP/ILS/Transaction/FeePayment.pm
  2. 16
      Koha/Account.pm
  3. 2
      api/v1/swagger/definitions/patron_account_credit.json
  4. 3
      installer/data/mysql/account_credit_types.sql
  5. 10
      installer/data/mysql/atomicupdate/bug_23805_credit.perl
  6. 3
      koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc
  7. 3
      koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc
  8. 6
      members/pay.pl
  9. 4
      reports/cash_register_stats.pl
  10. 8
      t/db_dependent/Accounts.t
  11. 4
      t/db_dependent/Circulation.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");

16
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

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

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

3
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 %]

3
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 %]

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

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

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

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

Loading…
Cancel
Save