Bug 24380: Backdated returns do not update fines unless CalculateFinesOnReturn is...
[koha-equinox.git] / C4 / Circulation.pm
index 747d660..bb41986 100644 (file)
@@ -1854,6 +1854,7 @@ sub AddReturn {
         undef $branch;
     }
     $branch = C4::Context->userenv->{'branch'} unless $branch;  # we trust userenv to be a safe fallback/default
+    my $return_date_specified = !!$return_date;
     $return_date //= dt_from_string();
     my $messages;
     my $patron;
@@ -1972,7 +1973,7 @@ sub AddReturn {
                 MarkIssueReturned( $borrowernumber, $item->itemnumber, $return_date, $patron->privacy );
             };
             unless ( $@ ) {
-                if ( C4::Context->preference('CalculateFinesOnReturn') && !$item->itemlost ) {
+                if ( ( $return_date_specified || C4::Context->preference('CalculateFinesOnReturn') ) && !$item->itemlost ) {
                     _CalculateAndUpdateFine( { issue => $issue, item => $item->unblessed, borrower => $patron_unblessed, return_date => $return_date } );
                 }
             } else {