From 467dd6778fcafdaaa9ad09461895f9f732082078 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 22 Mar 2019 16:28:52 +0000 Subject: [PATCH] Bug 22563: Update lost handling to use accountline.status Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall --- C4/Circulation.pm | 11 +++-- Koha/Account.pm | 2 +- .../prog/en/includes/accounts.inc | 41 +++++++++---------- .../en/modules/reports/cash_register_stats.tt | 2 +- .../bootstrap/en/includes/account-table.inc | 3 +- reports/cash_register_stats.pl | 4 +- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index da03954e4b..981ad84728 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2391,7 +2391,9 @@ sub _FixOverduesOnReturn { &_FixAccountForLostAndReturned($itemnumber, [$borrowernumber, $barcode]); -Calculates the charge for a book lost and returned. +Finds the most recent lost item charge for this item and refunds the borrower +appropriatly, taking into account any payments or writeoffs already applied +against the charge. Internal function, not exported, called only by AddReturn. @@ -2408,7 +2410,8 @@ sub _FixAccountForLostAndReturned { my $accountlines = Koha::Account::Lines->search( { itemnumber => $itemnumber, - accounttype => { -in => [ 'LOST', 'W' ] }, + accounttype => 'LOST', + status => [ undef, { '<>' => 'RETURNED' } ] }, { order_by => { -desc => [ 'date', 'accountlines_id' ] } @@ -2454,8 +2457,8 @@ sub _FixAccountForLostAndReturned { $credit->apply( { debits => $accountlines->reset } ); } - # Manually set the accounttype - $accountline->discard_changes->accounttype('LR'); + # Update the account status + $accountline->discard_changes->status('RETURNED'); $accountline->store; ModItem( { paidfor => '' }, undef, $itemnumber, { log_action => 0 } ); diff --git a/Koha/Account.pm b/Koha/Account.pm index 8a5d4362d9..0239bac73c 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -709,7 +709,7 @@ our $offset_type = { our $account_type_credit = { 'credit' => 'C', 'forgiven' => 'FOR', - 'lost_item_return' => 'CR', + 'lost_item_return' => 'LOST_RETURN', 'payment' => 'Pay', 'writeoff' => 'W' }; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc index 9b17ba0c4c..dfce02b6fe 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc @@ -1,26 +1,25 @@ [%- BLOCK account_type_description -%] [%- SWITCH account.accounttype -%] - [%- CASE 'Pay' -%]Payment - [%- CASE 'Pay00' -%]Payment (cash via SIP2) - [%- CASE 'Pay01' -%]Payment (VISA via SIP2) - [%- CASE 'Pay02' -%]Payment (credit card via SIP2) - [%- CASE 'N' -%]New card - [%- CASE 'OVERDUE' -%]Fine - [%- CASE 'A' -%]Account management fee - [%- CASE 'M' -%]Sundry - [%- CASE 'LOST' -%]Lost item - [%- CASE 'W' -%]Writeoff - [%- CASE 'HE' -%]Hold waiting too long - [%- CASE 'Rent' -%]Rental fee - [%- CASE 'FOR' -%]Forgiven - [%- CASE 'LR' -%]Lost item fee refund - [%- CASE 'PF' -%]Lost item processing fee - [%- CASE 'PAY' -%]Payment - [%- CASE 'WO' -%]Writeoff - [%- CASE 'C' -%]Credit - [%- CASE 'CR' -%]Credit - [%- CASE 'Res' -%]Hold fee - [%- CASE -%][% account.accounttype | html %] + [%- CASE 'Pay' -%]Payment + [%- CASE 'Pay00' -%]Payment (cash via SIP2) + [%- CASE 'Pay01' -%]Payment (VISA via SIP2) + [%- CASE 'Pay02' -%]Payment (credit card via SIP2) + [%- CASE 'N' -%]New card + [%- CASE 'OVERDUE' -%]Fine + [%- CASE 'A' -%]Account management fee + [%- CASE 'M' -%]Sundry + [%- CASE 'LOST' -%]Lost item + [%- CASE 'W' -%]Writeoff + [%- CASE 'HE' -%]Hold waiting too long + [%- CASE 'Rent' -%]Rental fee + [%- CASE 'FOR' -%]Forgiven + [%- CASE 'PF' -%]Lost item processing fee + [%- CASE 'PAY' -%]Payment + [%- CASE 'WO' -%]Writeoff + [%- CASE 'C' -%]Credit + [%- CASE 'LOST_RETURN' -%]Lost item fee refund + [%- CASE 'Res' -%]Hold fee + [%- CASE -%][% account.accounttype | html %] [%- END -%] [%- PROCESS account_status_description account=account -%] [%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt index 1aca2fb209..88f6a8dc73 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt @@ -211,7 +211,7 @@ Account management fee [% ELSIF loopresul.accounttype == "M" %] Sundry - [% ELSIF loopresul.accounttype == "L" || loopresul.accounttype == "LR" %] + [% ELSIF loopresul.accounttype == "LOST" %] Lost item [% ELSIF loopresul.accounttype == "N" %] New card 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 b339085448..8235962d20 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc @@ -43,12 +43,11 @@ [% CASE 'HE' %]Hold waiting too long [% CASE 'Rent' %]Rental fee [% CASE 'FOR' %]Forgiven - [% CASE 'LR' %]Lost item fee refund [% CASE 'PF' %]Lost item processing fee [% CASE 'PAY' %]Payment [% CASE 'WO' %]Writeoff [% CASE 'C' %]Credit - [% CASE 'CR' %]Credit + [% CASE 'LOST_RETURN' %]Lost item fee refund [%-CASE 'Res' %]Hold fee [% CASE %][% ACCOUNT_LINE.accounttype | html %] [%- END -%] diff --git a/reports/cash_register_stats.pl b/reports/cash_register_stats.pl index b030f6684e..33922b803f 100755 --- a/reports/cash_register_stats.pl +++ b/reports/cash_register_stats.pl @@ -118,11 +118,11 @@ if ($do_it) { $row->{date} = dt_from_string($row->{date}, 'sql'); push (@loopresult, $row); - if($transaction_type eq 'ACT' && ($row->{accounttype} !~ /^C$|^CR$|^LR$|^Pay$/)){ + if($transaction_type eq 'ACT' && ($row->{accounttype} !~ /^C$|^CR$|^Pay$/)){ pop @loopresult; next; } - if($row->{accounttype} =~ /^C$|^CR$|^LR$/){ + if($row->{accounttype} =~ /^C$|^CR$/){ $grantotal -= abs($row->{amount}); $row->{amount} = '-' . $row->{amount}; }elsif($row->{accounttype} eq 'FORW' || $row->{accounttype} eq 'W'){ -- 2.20.1 (Apple Git-117)