From b65f6313c917d188b7e25c89744c1b1913367e39 Mon Sep 17 00:00:00 2001 From: The Minh Luong Date: Mon, 14 Mar 2022 11:57:08 -0400 Subject: [PATCH] Bug 17015: DiscreteCalendar->new() method is now in a HASH This patch adds missing curly brackets in all new() calls. All tests in t/ should pass too (The one that don't pass are not passing before the patch) TEST PLAN: 1- Apply the patch 2- Run installer/data/mysql/updatedatabase.pl 3- Run misc/cronjobs/add_days_discrete_calendar.pl 4- Check that the max date is today + 1 day 5- Attempt a checkout ~ The error "Can't use string ("branchcode") as a HASH ref while "strict refs" in use at /kohadevbox/koha/Koha/DiscreteCalendar.pm line 79" is no longer here 5- Run t/db_dependent/DiscreteCalendar.t (prove -l t/db_dependent/DiscreteCalendar.t) 6- Run all koha test in t/ (prove t). All tests should pass 7- Use Discrete Calendar in Tools->Calendar USING THE DISCRETE CALENDAR: 1- New UI a) Calendar on the left b) Holidays list on the right 2- New color system for holiday types: a) Working day : white b) Unique holiday: red c) Holiday repeating weekly: yellow d) Holiday repeating yearly: orange e) Floating holiday: green f) Need validation: blue 3- When clicking on a date in the calendar, opening, closing hours and holiday type are displayed. 4- All the fields are editable 5- New radio button to Edit selected dates or Copy to different dates 6- Option to copy the calendar to another branch --- C4/Circulation.pm | 10 +++++----- C4/HoldsQueue.pm | 4 ++-- Koha/Charges/Fees.pm | 2 +- Koha/Checkouts.pm | 2 +- Koha/DiscreteCalendar.pm | 4 ++-- Koha/Hold.pm | 2 +- installer/data/mysql/updatedatabase.pl | 2 +- misc/cronjobs/fines.pl | 2 +- misc/cronjobs/holds/holds_reminder.pl | 2 +- misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0f5396e32f..9d3fa2b062 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1410,7 +1410,7 @@ sub checkHighHolds { branchcode => $branchcode, } ); - my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode, days_mode => $daysmode ); + my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branchcode, days_mode => $daysmode }); my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branchcode, $patron->unblessed ); @@ -2629,10 +2629,10 @@ sub _calculate_new_debar_dt { my $new_debar_dt; # Use the calendar or not to calculate the debarment date if ( C4::Context->preference('SuspensionsCalendar') eq 'noSuspensionsWhenClosed' ) { - my $calendar = Koha::DiscreteCalendar->new( + my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branchcode, days_mode => 'Calendar' - ); + }); $new_debar_dt = $calendar->addDuration( $return_date, $suspension_days ); } else { @@ -3795,7 +3795,7 @@ sub CalcDateDue { else { # days $dur = DateTime::Duration->new( days => $loanlength->{$length_key}); } - my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch, days_mode => $daysmode ); + my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branch, days_mode => $daysmode }); $datedue = $calendar->addDuration( $datedue, $dur, $loanlength->{lengthunit} ); if ($loanlength->{lengthunit} eq 'days') { $datedue->set_hour(23); @@ -3834,7 +3834,7 @@ sub CalcDateDue { } } if ( $daysmode ne 'Days' ) { - my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch, days_mode => $daysmode ); + my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branch, days_mode => $daysmode }); if ( $calendar->is_holiday($datedue) ) { # Don't return on a closed day $datedue = $calendar->prev_open_days( $datedue )->set(hour => 23, minute => 59); diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 6ecdc601a3..40fc186798 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -79,8 +79,8 @@ sub TransportCostMatrix { disable_transfer => $disabled }; - if ( !$ignore_holds_queue_skip_closed && C4::Context->preference("HoldsQueueSkipClosed") ) { - $calendars->{$from} ||= Koha::DiscreteCalendar->new( branchcode => $from ); + if ( !my $ignore_holds_queue_skip_closed && C4::Context->preference("HoldsQueueSkipClosed") ) { + my $calendars->{$from} ||= Koha::DiscreteCalendar->new({ branchcode => $from }); $transport_cost_matrix{$to}{$from}{disable_transfer} ||= $calendars->{$from}->is_holiday( $today ); } diff --git a/Koha/Charges/Fees.pm b/Koha/Charges/Fees.pm index 034e320a02..ed17b200fd 100644 --- a/Koha/Charges/Fees.pm +++ b/Koha/Charges/Fees.pm @@ -109,7 +109,7 @@ sub accumulate_rentalcharge { return 0 unless $rentalcharge_increment && $rentalcharge_increment > 0; my $duration; - my $calendar = Koha::DiscreteCalendar->new( branchcode => $self->library->id ); + my $calendar = Koha::DiscreteCalendar->new({ branchcode => $self->library->id }); if ( $units eq 'hours' ) { if ( $itemtype->rentalcharge_hourly_calendar ) { diff --git a/Koha/Checkouts.pm b/Koha/Checkouts.pm index 1872479ad7..69263e7d95 100644 --- a/Koha/Checkouts.pm +++ b/Koha/Checkouts.pm @@ -55,7 +55,7 @@ sub calculate_dropbox_date { branchcode => $branchcode, } ); - my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode, days_mode => $daysmode ); + my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branchcode, days_mode => $daysmode }); my $today = dt_from_string; my $dropbox_date = $calendar->addDuration( $today, -1 ); my $dateInfo = $calendar->get_date_info($dropbox_date); diff --git a/Koha/DiscreteCalendar.pm b/Koha/DiscreteCalendar.pm index 17c633eab9..9ee432e6ad 100644 --- a/Koha/DiscreteCalendar.pm +++ b/Koha/DiscreteCalendar.pm @@ -277,7 +277,7 @@ sub get_date_info { my $maxDate = $calendar->get_max_date(); -Returns the furthest date available in the databse of current branch. +Returns the furthest date available in the database of current branch. =cut @@ -303,7 +303,7 @@ sub get_max_date { my $minDate = $calendar->get_min_date(); -Returns the oldest date available in the databse of current branch. +Returns the oldest date available in the database of current branch. =cut diff --git a/Koha/Hold.pm b/Koha/Hold.pm index af286bc7fc..dd88bd3894 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -231,7 +231,7 @@ sub set_waiting { branchcode => $self->branchcode, } ); - my $calendar = Koha::DiscreteCalendar->new( branchcode => $self->branchcode, days_mode => $daysmode ); + my $calendar = Koha::DiscreteCalendar->new({ branchcode => $self->branchcode, days_mode => $daysmode }); $new_expiration_date = $calendar->days_forward( dt_from_string(), $max_pickup_delay ); } diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 737d5f8316..3a8af59f3c 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -14371,7 +14371,7 @@ if( CheckVersion( $DBversion ) ) { my $expirationdate = dt_from_string($hold->{waitingdate}); if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { - my $calendar = Koha::DiscreteCalendar->new( branchcode => $hold->{branchcode}, days_mode => C4::Context->preference('useDaysMode') ); + my $calendar = Koha::DiscreteCalendar->new({ branchcode => $hold->{branchcode}, days_mode => C4::Context->preference('useDaysMode') }); $expirationdate = $calendar->days_forward( $expirationdate, $max_pickup_delay ); } else { $expirationdate->add( days => $max_pickup_delay ); diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index 2ede371105..897c773005 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -203,7 +203,7 @@ EOM sub set_holiday { my ( $branch, $dt ) = @_; - my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch ); + my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branch }); return $calendar->is_holiday($dt); } diff --git a/misc/cronjobs/holds/holds_reminder.pl b/misc/cronjobs/holds/holds_reminder.pl index 8c8ad780ce..390ecd041d 100755 --- a/misc/cronjobs/holds/holds_reminder.pl +++ b/misc/cronjobs/holds/holds_reminder.pl @@ -246,7 +246,7 @@ foreach my $branchcode (@branchcodes) { #BEGIN BRANCH LOOP # If respecting calendar get the correct waiting since date my $waiting_date; if( $use_calendar ){ - my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); + my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branchcode, days_mode => 'Calendar' }); my $duration = DateTime::Duration->new( days => -$days ); $waiting_date = $calendar->addDays($date_to_run,$duration); #Add negative of days } else { diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl index 94b3b62f54..3fe64bb29c 100755 --- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl +++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl @@ -335,7 +335,7 @@ sub GetWaitingHolds { } ); - my $calendar = Koha::DiscreteCalendar->new( branchcode => $issue->{'site'}, days_mode => $daysmode ); + my $calendar = Koha::DiscreteCalendar->new({ branchcode => $issue->{'site'}, days_mode => $daysmode }); my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' ); my $pickup_date = $waiting_date->clone->add( days => $pickupdelay ); -- 2.25.1