From a89a5e7d3bd5693a7a88c2813c62cdb8df1ae097 Mon Sep 17 00:00:00 2001 From: Michael Hafen Date: Wed, 2 Mar 2022 17:10:27 -0700 Subject: [PATCH] Bug 18855: Don't create duplicate overdue fines if an issue is returned Content-Type: text/plain; charset="utf-8" If cronjobs/fines.pl is running during circulation hours, then an issue may be considered for having it's overdue fine updated after the issue has been returned and it's fine status flipped from 'UNRETURNED' to 'RETURNED'. In this case UpdateFine will create a duplicate fine because it can't find the specific accountline for the (formerly) overdue issue. This changes cronjobs/fines.pl to double check the issue before updating the fine. If the issue has changed between starting the script and updating the fine, then the script will skip it. There is a small amount of time between the check and calling UpdateFine where the issue can be changed and this problem can reoccure. The chance of that happening is so small that it's probably fine to leave as is. It is also possible that the fine won't be updated because the issue was returned. In this case the fine payed by the patron will be lower, but that is better then the patron finding later that there is more to a fine they thought they had paid all of. Test plan: 1. find an overdue fine near the end of the list of overdue fines that cronjobs/fines.pl will be considering. 2. start cronjobs/fines.pl. 3. immediately check in the overdue book. 4. once fines.pl is finished observe that a duplicate overdue fine has been created on the patrons account. 5. apply patch. 6. repeat 1 - 4 and observe that the duplicate fine was not created. --- misc/cronjobs/fines.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index 3edf6ed736..5a472f8db7 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -157,6 +157,9 @@ for my $overdue ( @{$overdues} ) { && ( $amount && $amount > 0 ) ) { + # if the issue changed before the script got to it, then pass on it. + my $issue = Koha::Checkouts->find({ issue_id => $overdue->{issue_id} }); + next if ( ! $issue or $issue->date_due ne $overdue->{date_due} ); UpdateFine( { issue_id => $overdue->{issue_id}, -- 2.25.1