From 14ac287bbcc00f2391277ce7730db700d5d6f52d 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 --- 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 276f144580..8ea73de282 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2373,7 +2373,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. @@ -2390,7 +2392,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' ] } @@ -2436,8 +2439,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