From b954dce9dd2c25c8659aec78154a127b468999fd 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 Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize --- C4/Circulation.pm | 9 ++-- Koha/Account.pm | 2 +- .../prog/en/includes/accounts.inc | 41 +++++++++---------- .../en/modules/reports/cash_register_stats.tt | 2 +- reports/cash_register_stats.pl | 4 +- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 3f9e392c25..329f7e9f9f 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2390,7 +2390,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,6 +2410,7 @@ sub _FixAccountForLostAndReturned { { itemnumber => $itemnumber, accounttype => 'LOST', + status => [ undef, { '<>' => 'RETURNED' } ] }, { order_by => { -desc => [ 'date', 'accountlines_id' ] } @@ -2458,8 +2461,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 a041600988..ddee843390 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -721,7 +721,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/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.39.5