From 9c57ca4a82548b7891379d8129218bf2cbd8678f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 21 Mar 2022 12:33:31 +0100 Subject: [PATCH] Bug 18855: Move the condition at the top of the iteration - skip the CalcFine call - use Koha::Checkout->is_overdue --- misc/cronjobs/fines.pl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index 5a472f8db70..0fe90d112ad 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -127,6 +127,14 @@ for my $overdue ( @{$overdues} ) { "ERROR in Getoverdues : issues.borrowernumber IS NULL. Repair 'issues' table now! Skipping record.\n"; next; } + + # 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} ); + + my $datedue = dt_from_string( $overdue->{date_due} ); + next unless $issue->is_overdue( $datedue ); + my $patron = Koha::Patrons->find( $overdue->{borrowernumber} ); my $branchcode = ( $control eq 'ItemHomeLibrary' ) ? $overdue->{homebranch} @@ -138,10 +146,6 @@ for my $overdue ( @{$overdues} ) { $is_holiday{$branchcode} = set_holiday( $branchcode, $today ); } - my $datedue = dt_from_string( $overdue->{date_due} ); - if ( DateTime->compare( $datedue, $today ) == 1 ) { - next; # not overdue - } ++$counted; my ( $amount, $unitcounttotal, $unitcount ) = @@ -157,9 +161,6 @@ 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