From 716e3f482d42ea7bc17197b76164fab5767cfa1c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 16 Mar 2021 09:55:10 +0100 Subject: [PATCH] Bug 27835: Revert "Bug 27180: (follow-up) Remove unused %is_holiday" This reverts commit a26d529a2bc7faee3743b4cd1e603ba29411a0b9. Revert "Bug 27180: Update fines on holidays" This reverts commit 80e1b4e66f01a07cad9bf37625d879f649edf52a. Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 1c4b4cbd91cc9888e9cdbdf1fe43a10c91bd157b) Signed-off-by: Fridolin Somers (cherry picked from commit 0cdd5ec6cd34095394a4b6f243ea7ec015df4205) Signed-off-by: Andrew Fuerste-Henry --- misc/cronjobs/fines.pl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index 717c0d5fa2..9f61c0f598 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -101,6 +101,7 @@ my $control = C4::Context->preference('CircControl'); my $mode = C4::Context->preference('finesMode'); my $delim = "\t"; # ? C4::Context->preference('delimiter') || "\t"; +my %is_holiday; my $today = dt_from_string(); my $filename; if ($log or $output_dir) { @@ -130,7 +131,11 @@ for my $overdue ( @{$overdues} ) { ( $control eq 'ItemHomeLibrary' ) ? $overdue->{homebranch} : ( $control eq 'PatronLibrary' ) ? $patron->branchcode : $overdue->{branchcode}; - # In final case, CircControl must be PickupLibrary. (branchcode comes from issues table here). + +# In final case, CircControl must be PickupLibrary. (branchcode comes from issues table here). + if ( !exists $is_holiday{$branchcode} ) { + $is_holiday{$branchcode} = set_holiday( $branchcode, $today ); + } my $datedue = dt_from_string( $overdue->{date_due} ); if ( DateTime->compare( $datedue, $today ) == 1 ) { @@ -142,7 +147,9 @@ for my $overdue ( @{$overdues} ) { CalcFine( $overdue, $patron->categorycode, $branchcode, $datedue, $today ); - if ( $mode eq 'production' ) { + # Don't update the fine if today is a holiday. + # This ensures that dropbox mode will remove the correct amount of fine. + if ( $mode eq 'production' && !$is_holiday{$branchcode} ) { if ( $amount && $amount > 0 ) { UpdateFine( { @@ -186,6 +193,13 @@ Number of Overdue Items: EOM } +sub set_holiday { + my ( $branch, $dt ) = @_; + + my $calendar = Koha::Calendar->new( branchcode => $branch ); + return $calendar->is_holiday($dt); +} + sub get_filename { my $directory = shift; if ( !$directory ) { -- 2.39.5