Bug 22563: Update lost handling to use accountline.status
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 22 Mar 2019 16:28:52 +0000 (16:28 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 15 Jul 2019 10:28:01 +0000 (11:28 +0100)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

C4/Circulation.pm
Koha/Account.pm
koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc
koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt
reports/cash_register_stats.pl

index 3f9e392..329f7e9 100644 (file)
@@ -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 } );
index a041600..ddee843 100644 (file)
@@ -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'
 };
index 9b17ba0..dfce02b 100644 (file)
@@ -1,26 +1,25 @@
 [%- BLOCK account_type_description -%]
     [%- SWITCH account.accounttype -%]
-        [%- CASE 'Pay'     -%]<span>Payment
-        [%- CASE 'Pay00'   -%]<span>Payment (cash via SIP2)
-        [%- CASE 'Pay01'   -%]<span>Payment (VISA via SIP2)
-        [%- CASE 'Pay02'   -%]<span>Payment (credit card via SIP2)
-        [%- CASE 'N'       -%]<span>New card
-        [%- CASE 'OVERDUE' -%]<span>Fine
-        [%- CASE 'A'       -%]<span>Account management fee
-        [%- CASE 'M'       -%]<span>Sundry
-        [%- CASE 'LOST'    -%]<span>Lost item
-        [%- CASE 'W'       -%]<span>Writeoff
-        [%- CASE 'HE'      -%]<span>Hold waiting too long
-        [%- CASE 'Rent'    -%]<span>Rental fee
-        [%- CASE 'FOR'     -%]<span>Forgiven
-        [%- CASE 'LR'      -%]<span>Lost item fee refund
-        [%- CASE 'PF'      -%]<span>Lost item processing fee
-        [%- CASE 'PAY'     -%]<span>Payment
-        [%- CASE 'WO'      -%]<span>Writeoff
-        [%- CASE 'C'       -%]<span>Credit
-        [%- CASE 'CR'      -%]<span>Credit
-        [%- CASE 'Res'     -%]<span>Hold fee
-        [%- CASE           -%]<span>[% account.accounttype | html %]
+        [%- CASE 'Pay'         -%]<span>Payment
+        [%- CASE 'Pay00'       -%]<span>Payment (cash via SIP2)
+        [%- CASE 'Pay01'       -%]<span>Payment (VISA via SIP2)
+        [%- CASE 'Pay02'       -%]<span>Payment (credit card via SIP2)
+        [%- CASE 'N'           -%]<span>New card
+        [%- CASE 'OVERDUE'     -%]<span>Fine
+        [%- CASE 'A'           -%]<span>Account management fee
+        [%- CASE 'M'           -%]<span>Sundry
+        [%- CASE 'LOST'        -%]<span>Lost item
+        [%- CASE 'W'           -%]<span>Writeoff
+        [%- CASE 'HE'          -%]<span>Hold waiting too long
+        [%- CASE 'Rent'        -%]<span>Rental fee
+        [%- CASE 'FOR'         -%]<span>Forgiven
+        [%- CASE 'PF'          -%]<span>Lost item processing fee
+        [%- CASE 'PAY'         -%]<span>Payment
+        [%- CASE 'WO'          -%]<span>Writeoff
+        [%- CASE 'C'           -%]<span>Credit
+        [%- CASE 'LOST_RETURN' -%]<span>Lost item fee refund
+        [%- CASE 'Res'         -%]<span>Hold fee
+        [%- CASE               -%]<span>[% account.accounttype | html %]
     [%- END -%]
     [%- PROCESS account_status_description account=account -%]</span>
 [%- END -%]
index 1aca2fb..88f6a8d 100644 (file)
                         <span>Account management fee</span>
                     [% ELSIF loopresul.accounttype == "M" %]
                         <span>Sundry</span>
-                    [% ELSIF loopresul.accounttype == "L" || loopresul.accounttype == "LR" %]
+                    [% ELSIF loopresul.accounttype == "LOST" %]
                         <span>Lost item</span>
                     [% ELSIF loopresul.accounttype == "N" %]
                         <span>New card</span>
index b030f66..33922b8 100755 (executable)
@@ -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'){