From 1e1cba35a574e940657d21bfe2cf63526896d171 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 20 Nov 2019 15:04:41 -0500 Subject: [PATCH] Bug 24075: Backdating a return to the exact due date and time results in the fine not being refunded When you use the date picker or book drop mode and check in an item that is due on that date, a fine is assessed and not refunded. For example: item 12345 is due on 11/19/2109 23:59. On 11/20/2019 I check the item in using date picker/book drop setting the check in date to 11/19/2019 23:59, the patron is charged a fine, and the fine is not cleared as would be expected, since the item is being checked in before it is overdue. Test Plan: 1) Back date a checkout so it is overdue 2) Run fines.pl to generate the fine 3) Return the item, backdating to the same date/time is was due 4) Note the fine was not removed 5) Apply this patch 6) Repeat steps 1-3 7) Fine should be zeroed out now! --- C4/Circulation.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index ad617c846e..7105666da5 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1844,7 +1844,10 @@ sub AddReturn { undef $branch; } $branch = C4::Context->userenv->{'branch'} unless $branch; # we trust userenv to be a safe fallback/default + + my $return_date_is_forced = $return_date ? 1 : 0; $return_date //= dt_from_string(); + my $messages; my $patron; my $doreturn = 1; @@ -1963,7 +1966,7 @@ sub AddReturn { MarkIssueReturned( $borrowernumber, $item->itemnumber, $return_date, $patron->privacy ); }; unless ( $@ ) { - if ( C4::Context->preference('CalculateFinesOnReturn') && $is_overdue && !$item->itemlost ) { + if ( C4::Context->preference('CalculateFinesOnReturn') && ( $return_date_is_forced || $is_overdue ) && !$item->itemlost ) { _CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed, return_date => $return_date } ); } } else { -- 2.21.0 (Apple Git-122.2)