Bug 27835: Revert "Bug 27180: (follow-up) Remove unused %is_holiday"

This reverts commit a26d529a2b.

Revert "Bug 27180: Update fines on holidays"

This reverts commit 80e1b4e66f.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2021-03-16 09:55:10 +01:00
parent ec4bb0539a
commit 1c4b4cbd91
1 changed files with 16 additions and 2 deletions

View File

@ -101,6 +101,7 @@ my $control = C4::Context->preference('CircControl');
my $mode = C4::Context->preference('finesMode');
my $delim = "\t"; # ? C4::Context->preference('CSVDelimiter') || "\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 ) {