Bug 22563: (follow-up) Items LOST should not be RETURNED
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 18 Apr 2019 07:45:54 +0000 (08:45 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 15 Jul 2019 10:28:01 +0000 (11:28 +0100)
Up until now we marked lost items as returned in the accountlines, now
we have the oportunity to mark these distinctly with an appropriate
status we should.

Test Plan
1) Find an overdue with fines
2) Ensure you are not forgiving fines when an item is marked as lost
3) Mark the item as lost
4) Confirm the Fine is given a status of 'Lost'

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-tmpl/intranet-tmpl/prog/en/includes/accounts.inc
koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc

index 329f7e9..3b000cb 100644 (file)
@@ -2030,7 +2030,7 @@ sub AddReturn {
 
     # fix up the overdues in accounts...
     if ($borrowernumber) {
-        my $fix = _FixOverduesOnReturn( $borrowernumber, $item->itemnumber, $exemptfine );
+        my $fix = _FixOverduesOnReturn( $borrowernumber, $item->itemnumber, $exemptfine, 'RETURNED' );
         defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->itemnumber...) failed!";  # zero is OK, check defined
 
         if ( $issue and $issue->is_overdue ) {
@@ -2314,7 +2314,7 @@ sub _debar_user_on_return {
 
 =head2 _FixOverduesOnReturn
 
-   &_FixOverduesOnReturn($borrowernumber, $itemnumber, $exemptfine);
+   &_FixOverduesOnReturn($borrowernumber, $itemnumber, $exemptfine, $status);
 
 C<$borrowernumber> borrowernumber
 
@@ -2322,12 +2322,14 @@ C<$itemnumber> itemnumber
 
 C<$exemptfine> BOOL -- remove overdue charge associated with this issue. 
 
+C<$status> ENUM -- reason for fix [ RETURNED, RENEWED, LOST, FORGIVEN ]
+
 Internal function
 
 =cut
 
 sub _FixOverduesOnReturn {
-    my ( $borrowernumber, $item, $exemptfine ) = @_;
+    my ( $borrowernumber, $item, $exemptfine, $status ) = @_;
     unless( $borrowernumber ) {
         warn "_FixOverduesOnReturn() not supplied valid borrowernumber";
         return;
@@ -2336,6 +2338,10 @@ sub _FixOverduesOnReturn {
         warn "_FixOverduesOnReturn() not supplied valid itemnumber";
         return;
     }
+    unless( $status ) {
+        warn "_FixOverduesOnReturn() not supplied valid status";
+        return;
+    }
 
     my $schema = Koha::Database->schema;
 
@@ -2376,7 +2382,7 @@ sub _FixOverduesOnReturn {
                     &logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item");
                 }
             } else {
-                $accountline->status('RETURNED');
+                $accountline->status($status);
             }
 
             return $accountline->store();
@@ -2867,7 +2873,7 @@ sub AddRenewal {
     if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) {
         _CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed } );
     }
-    _FixOverduesOnReturn( $borrowernumber, $itemnumber );
+    _FixOverduesOnReturn( $borrowernumber, $itemnumber, undef, 'RENEWED' );
 
     # If the due date wasn't specified, calculate it by adding the
     # book's loan length to today's date or the current due date
@@ -3712,7 +3718,7 @@ sub LostItem{
     if ( my $borrowernumber = $issues->{borrowernumber} ){
         my $patron = Koha::Patrons->find( $borrowernumber );
 
-        my $fix = _FixOverduesOnReturn($borrowernumber, $itemnumber, C4::Context->preference('WhenLostForgiveFine'), 0); # 1, 0 = exemptfine, no-dropbox
+        my $fix = _FixOverduesOnReturn($borrowernumber, $itemnumber, C4::Context->preference('WhenLostForgiveFine'), 'LOST');
         defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $itemnumber...) failed!";  # zero is OK, check defined
 
         if (C4::Context->preference('WhenLostChargeReplacementFee')){
index dfce02b..e221af6 100644 (file)
@@ -44,6 +44,7 @@
         [%- CASE 'REPLACED'   -%]<span> (Replaced)</span>
         [%- CASE 'FORGIVEN'   -%]<span> (Forgiven)</span>
         [%- CASE 'VOID'       -%]<span> (Voided)</span>
+        [%- CASE 'LOST'       -%]<span> (Lost)</span>
         [%- CASE              -%]
     [%- END -%]
 [%- END -%]
index 549e945..230ff9c 100644 (file)
         [%- CASE 'REPLACED'   -%]<span> (Replaced)</span>
         [%- CASE 'FORGIVEN'   -%]<span> (Forgiven)</span>
         [%- CASE 'VOID'       -%]<span> (Voided)</span>
+        [%- CASE 'LOST'       -%]<span> (Lost)</span>
         [%- CASE              -%]
     [%- END -%]
 [%- END -%]