From 811d8bfd37dc190a999ae8b2078872d3236062af Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 17 Apr 2026 16:41:21 +0100 Subject: [PATCH] Bug 42310: (follow-up) Move Koha::Calendar tree under Koha::Library::Calendar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Koha::Calendar is, by construction, a per-library object — it croaks without a branchcode argument and every method is branch-scoped. The top-level namespace hides that. Move the whole tree under Koha::Library::Calendar to match the actual semantics, the existing /libraries/{library_id}/calendar REST routes, and the established Koha::Library::* convention (Group, Hour, FloatLimit, OverDriveInfo). This commit: - renames the Koha::Calendar(::*) tree to Koha::Library::Calendar(::*) - updates package declarations, POD and internal 'use' statements within the moved tree - updates the four DBIC Schema Result overrides (koha_object_class / koha_objects_class) to the new namespace - updates callers inside C4::* modules (Calendar, Circulation, Reserves, Overdues, HoldsQueue), Koha::{Patron,Hold,Checkouts, CurbsidePickup}, circ/returns.pl, the installer and cronjobs - updates the 42310-owned tests (Calendar tests, HoldsQueue.t, Holds/WaitingReserves.t, Holidays.t, Koha/CurbsidePickups.t, Reserves/CancelExpiredReserves.t and the libraries.t CRUD block) Koha::Library->calendar, the REST controllers and the 42311 tests are updated in separate follow-up commits under their respective bugs. Test plan: - prove t/db_dependent/Koha/Library/Calendar.t - prove t/db_dependent/Calendar.t - prove t/db_dependent/Holidays.t t/db_dependent/HoldsQueue.t - prove t/db_dependent/Holds/WaitingReserves.t - prove t/db_dependent/Reserves/CancelExpiredReserves.t Signed-off-by: Tomás Cohen Arazi Signed-off-by: Pedro Amorim --- C4/Calendar.pm | 55 ++++++++------- C4/Circulation.pm | 10 +-- C4/HoldsQueue.pm | 3 +- C4/Overdues.pm | 4 +- C4/Reserves.pm | 4 +- Koha/Charges/Fees.pm | 4 +- Koha/Checkouts.pm | 2 +- Koha/CurbsidePickup.pm | 4 +- Koha/Hold.pm | 6 +- Koha/{ => Library}/Calendar.pm | 68 +++++++++---------- Koha/{ => Library}/Calendar/Exception.pm | 4 +- Koha/{ => Library}/Calendar/Exceptions.pm | 8 +-- .../Calendar/RepeatingClosure.pm | 4 +- .../Calendar/RepeatingClosures.pm | 8 +-- Koha/{ => Library}/Calendar/SingleClosure.pm | 4 +- Koha/{ => Library}/Calendar/SingleClosures.pm | 8 +-- Koha/{ => Library}/Calendar/WeeklyClosure.pm | 4 +- Koha/{ => Library}/Calendar/WeeklyClosures.pm | 8 +-- Koha/Patron.pm | 2 +- Koha/REST/V1/Libraries.pm | 6 +- Koha/Schema/Result/LibraryClosureException.pm | 4 +- Koha/Schema/Result/LibraryRepeatingClosure.pm | 4 +- Koha/Schema/Result/LibrarySingleClosure.pm | 4 +- Koha/Schema/Result/LibraryWeeklyClosure.pm | 4 +- circ/returns.pl | 2 +- .../data/mysql/atomicupdate/bug_42310.pl | 2 +- installer/data/mysql/updatedatabase.pl | 4 +- misc/cronjobs/fines.pl | 4 +- misc/cronjobs/holds/cancel_unfilled_holds.pl | 2 +- misc/cronjobs/holds/holds_reminder.pl | 4 +- misc/cronjobs/overdue_notices.pl | 4 +- .../thirdparty/TalkingTech_itiva_outbound.pl | 4 +- t/db_dependent/Calendar.t | 62 ++++++++--------- t/db_dependent/Holds/WaitingReserves.t | 4 +- t/db_dependent/HoldsQueue.t | 2 +- t/db_dependent/Holidays.t | 28 +++++--- t/db_dependent/Koha/CurbsidePickups.t | 4 +- t/db_dependent/Koha/{ => Library}/Calendar.t | 68 +++++++++---------- .../Reserves/CancelExpiredReserves.t | 6 +- t/db_dependent/api/v1/libraries.t | 30 ++++---- 40 files changed, 238 insertions(+), 224 deletions(-) rename Koha/{ => Library}/Calendar.pm (90%) rename Koha/{ => Library}/Calendar/Exception.pm (92%) rename Koha/{ => Library}/Calendar/Exceptions.pm (81%) rename Koha/{ => Library}/Calendar/RepeatingClosure.pm (86%) rename Koha/{ => Library}/Calendar/RepeatingClosures.pm (78%) rename Koha/{ => Library}/Calendar/SingleClosure.pm (92%) rename Koha/{ => Library}/Calendar/SingleClosures.pm (79%) rename Koha/{ => Library}/Calendar/WeeklyClosure.pm (87%) rename Koha/{ => Library}/Calendar/WeeklyClosures.pm (80%) rename t/db_dependent/Koha/{ => Library}/Calendar.t (74%) diff --git a/C4/Calendar.pm b/C4/Calendar.pm index 54f422c916..3e92b0130b 100644 --- a/C4/Calendar.pm +++ b/C4/Calendar.pm @@ -21,7 +21,7 @@ use vars qw(@EXPORT); use Carp qw( croak ); use Date::Calc qw( Today ); -use Koha::Calendar; +use Koha::Library::Calendar; use C4::Context; use Koha::Caches; @@ -202,7 +202,7 @@ C<$description> Is the description to store for the holiday formed by $year/$mon sub insert_week_day_holiday { my $self = shift @_; my %options = @_; - Koha::Calendar->new( branchcode => $self->{branchcode} )->add_weekly_closure( + Koha::Library::Calendar->new( branchcode => $self->{branchcode} )->add_weekly_closure( { weekday => $options{weekday}, title => $options{title}, description => $options{description}, } @@ -234,7 +234,7 @@ C<$description> Is the description to store for the holiday formed by $year/$mon sub insert_day_month_holiday { my $self = shift @_; my %options = @_; - Koha::Calendar->new( branchcode => $self->{branchcode} )->add_repeating_closure( + Koha::Library::Calendar->new( branchcode => $self->{branchcode} )->add_repeating_closure( { day => $options{day}, month => $options{month}, title => $options{title}, description => $options{description}, @@ -274,7 +274,7 @@ sub insert_single_holiday { unless ($date) { $date = sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} ); } - Koha::Calendar->new( branchcode => $self->{branchcode} )->add_single_closure( + Koha::Library::Calendar->new( branchcode => $self->{branchcode} )->add_single_closure( { date => $date, title => $options{title}, description => $options{description}, } @@ -311,7 +311,7 @@ sub insert_exception_holiday { unless ($date) { $date = sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} ); } - Koha::Calendar->new( branchcode => $self->{branchcode} )->add_exception( + Koha::Library::Calendar->new( branchcode => $self->{branchcode} )->add_exception( { date => $date, title => $options{title}, description => $options{description}, } @@ -337,8 +337,8 @@ sub ModWeekdayholiday { my $self = shift @_; my %options = @_; my $closure = - Koha::Calendar::WeeklyClosures->search( { library_id => $self->{branchcode}, weekday => $options{weekday} } ) - ->next; + Koha::Library::Calendar::WeeklyClosures->search( + { library_id => $self->{branchcode}, weekday => $options{weekday} } )->next; $closure->title( $options{title} )->description( $options{description} )->store if $closure; return $self; } @@ -365,7 +365,7 @@ C<$description> The description to be update for the holiday. sub ModDaymonthholiday { my $self = shift @_; my %options = @_; - my $closure = Koha::Calendar::RepeatingClosures->search( + my $closure = Koha::Library::Calendar::RepeatingClosures->search( { library_id => $self->{branchcode}, day => $options{day}, month => $options{month} } )->next; $closure->title( $options{title} )->description( $options{description} )->store if $closure; return $self; @@ -397,7 +397,8 @@ sub ModSingleholiday { my $self = shift @_; my %options = @_; my $date = $options{date} || sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} ); - my $closure = Koha::Calendar::SingleClosures->search( { library_id => $self->{branchcode}, date => $date } )->next; + my $closure = + Koha::Library::Calendar::SingleClosures->search( { library_id => $self->{branchcode}, date => $date } )->next; if ($closure) { $closure->title( $options{title} )->description( $options{description} )->store; } @@ -427,10 +428,11 @@ C<$description> Is the description to be modified for the holiday formed by $yea =cut sub ModExceptionholiday { - my $self = shift @_; - my %options = @_; - my $date = $options{date} || sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} ); - my $exception = Koha::Calendar::Exceptions->search( { library_id => $self->{branchcode}, date => $date } )->next; + my $self = shift @_; + my %options = @_; + my $date = $options{date} || sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} ); + my $exception = + Koha::Library::Calendar::Exceptions->search( { library_id => $self->{branchcode}, date => $date } )->next; if ($exception) { $exception->title( $options{title} )->description( $options{description} )->store; } @@ -459,29 +461,34 @@ C<$year> Is year to make the date to delete. sub delete_holiday { my $self = shift @_; my %options = @_; - my $cal = Koha::Calendar->new( branchcode => $self->{branchcode} ); + my $cal = Koha::Library::Calendar->new( branchcode => $self->{branchcode} ); if ( $options{day} && $options{month} && $options{year} ) { my $date = sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} ); # Try single closure first - if ( Koha::Calendar::SingleClosures->search( { library_id => $self->{branchcode}, date => $date } )->count ) { + if ( Koha::Library::Calendar::SingleClosures->search( { library_id => $self->{branchcode}, date => $date } ) + ->count ) + { $cal->delete_single_closure( { date => $date } ); } # Also remove any exception for this date - Koha::Calendar::Exceptions->search( { library_id => $self->{branchcode}, date => $date } )->delete; + Koha::Library::Calendar::Exceptions->search( { library_id => $self->{branchcode}, date => $date } )->delete; } - if ( defined $options{weekday} - && Koha::Calendar::WeeklyClosures->search( { library_id => $self->{branchcode}, weekday => $options{weekday} } ) - ->count ) + if ( + defined $options{weekday} + && Koha::Library::Calendar::WeeklyClosures->search( + { library_id => $self->{branchcode}, weekday => $options{weekday} } + )->count + ) { $cal->delete_weekly_closure( { weekday => $options{weekday} } ); } elsif ( $options{day} && $options{month} - && Koha::Calendar::RepeatingClosures->search( + && Koha::Library::Calendar::RepeatingClosures->search( { library_id => $self->{branchcode}, day => $options{day}, month => $options{month} } )->count ) @@ -512,7 +519,7 @@ sub delete_holiday_range { my $self = shift; my %options = @_; my $date = $options{date} || sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} ); - Koha::Calendar->new( branchcode => $self->{branchcode} )->delete_single_closure( { date => $date } ); + Koha::Library::Calendar->new( branchcode => $self->{branchcode} )->delete_single_closure( { date => $date } ); } =head2 delete_holiday_range_repeatable @@ -531,7 +538,7 @@ C<$month> Is month to make the date to delete. sub delete_holiday_range_repeatable { my $self = shift; my %options = @_; - Koha::Calendar->new( branchcode => $self->{branchcode} ) + Koha::Library::Calendar->new( branchcode => $self->{branchcode} ) ->delete_repeating_closure( { day => $options{day}, month => $options{month} } ); } @@ -556,7 +563,7 @@ sub delete_exception_holiday_range { my $self = shift; my %options = @_; my $date = $options{date} || sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} ); - Koha::Calendar->new( branchcode => $self->{branchcode} )->delete_exception( { date => $date } ); + Koha::Library::Calendar->new( branchcode => $self->{branchcode} )->delete_exception( { date => $date } ); } =head2 isHoliday @@ -607,7 +614,7 @@ sub isHoliday { sub copy_to_branch { my ( $self, $target_branch ) = @_; - return Koha::Calendar->new( branchcode => $self->{branchcode} )->copy_to($target_branch); + return Koha::Library::Calendar->new( branchcode => $self->{branchcode} )->copy_to($target_branch); } 1; diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 2fd7cdfc54..66f2ffcae1 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -100,7 +100,7 @@ use Koha::AuthorisedValues; use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; use Koha::Biblioitems; use Koha::DateUtils qw( dt_from_string ); -use Koha::Calendar; +use Koha::Library::Calendar; use Koha::Checkouts; use Koha::ILL::Requests; use Koha::ILL::ISO18626::Requests; @@ -1612,7 +1612,7 @@ sub checkHighHolds { branchcode => $branchcode, } ); - my $calendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => $daysmode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $branchcode, days_mode => $daysmode ); my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branchcode, $patron ); @@ -3181,7 +3181,7 @@ sub _calculate_new_debar_dt { # Use the calendar or not to calculate the debarment date if ( C4::Context->preference('SuspensionsCalendar') eq 'noSuspensionsWhenClosed' ) { - my $calendar = Koha::Calendar->new( + my $calendar = Koha::Library::Calendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); @@ -4520,7 +4520,7 @@ sub CalcDateDue { } else { # days $dur = DateTime::Duration->new( days => $loanlength->{$length_key} ); } - my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $daysmode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $branch, days_mode => $daysmode ); $datedue = $calendar->addDuration( $datedue, $dur, $loanlength->{lengthunit} ) if $dur; if ( $loanlength->{lengthunit} eq 'days' ) { $datedue->set_hour(23); @@ -4558,7 +4558,7 @@ sub CalcDateDue { } } if ( $daysmode ne 'Days' ) { - my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $daysmode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $branch, days_mode => $daysmode ); if ( $calendar->is_holiday($datedue) ) { # Don't return on a closed day diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 6a842c9297..1962a8e7aa 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -1257,7 +1257,8 @@ sub load_branches_to_pull_from { my $today = dt_from_string(); if ( C4::Context->preference('HoldsQueueSkipClosed') ) { - @branches_to_use = grep { !Koha::Calendar->new( branchcode => $_ )->is_holiday($today) } @branches_to_use; + @branches_to_use = + grep { !Koha::Library::Calendar->new( branchcode => $_ )->is_holiday($today) } @branches_to_use; } return \@branches_to_use; diff --git a/C4/Overdues.pm b/C4/Overdues.pm index e09067ec4d..71d74e76c5 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -350,7 +350,7 @@ sub get_chargeable_units { if ( $unit eq 'hours' ) { if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) { - my $calendar = Koha::Calendar->new( branchcode => $branchcode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $branchcode ); $charge_duration = $calendar->hours_between( $date_due, $date_returned ); } else { $charge_duration = $date_returned->delta_ms($date_due); @@ -361,7 +361,7 @@ sub get_chargeable_units { return $charge_duration->in_units('hours'); } else { # days if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) { - my $calendar = Koha::Calendar->new( branchcode => $branchcode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $branchcode ); $charge_duration = $calendar->days_between( $date_due, $date_returned ); } else { $charge_duration = $date_returned->delta_days($date_due); diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 94a1fa3441..f04b2971bb 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -77,7 +77,7 @@ use C4::Members; use Koha::Account::Lines; use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; use Koha::Biblios; -use Koha::Calendar; +use Koha::Library::Calendar; use Koha::Cache::Memory::Lite; use Koha::CirculationRules; use Koha::Database; @@ -1089,7 +1089,7 @@ sub CancelExpiredReserves { my $cache_key = sprintf "Calendar_CancelExpiredReserves:%s", $hold->branchcode; my $calendar = $cache->get_from_cache($cache_key); if ( !$calendar ) { - $calendar = Koha::Calendar->new( branchcode => $hold->branchcode ); + $calendar = Koha::Library::Calendar->new( branchcode => $hold->branchcode ); $cache->set_in_cache( $cache_key, $calendar ); } diff --git a/Koha/Charges/Fees.pm b/Koha/Charges/Fees.pm index 53ff799d1c..2f897828a0 100644 --- a/Koha/Charges/Fees.pm +++ b/Koha/Charges/Fees.pm @@ -21,9 +21,9 @@ use Modern::Perl; use Carp; -use Koha::Calendar; use Koha::DateUtils qw( dt_from_string ); use Koha::Exceptions; +use Koha::Library::Calendar; =head1 NAME @@ -108,7 +108,7 @@ sub accumulate_rentalcharge { return 0 unless $rentalcharge_increment && $rentalcharge_increment > 0; my $duration; - my $calendar = Koha::Calendar->new( branchcode => $self->library->id ); + my $calendar = Koha::Library::Calendar->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 11a97d9e60..bb615248e4 100644 --- a/Koha/Checkouts.pm +++ b/Koha/Checkouts.pm @@ -55,7 +55,7 @@ sub calculate_dropbox_date { branchcode => $branchcode, } ); - my $calendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => $daysmode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $branchcode, days_mode => $daysmode ); my $today = dt_from_string; my $dropbox_date = $calendar->addDuration( $today, -1 ); diff --git a/Koha/CurbsidePickup.pm b/Koha/CurbsidePickup.pm index 01d1b88d10..5c31bf07f5 100644 --- a/Koha/CurbsidePickup.pm +++ b/Koha/CurbsidePickup.pm @@ -26,7 +26,7 @@ use base qw(Koha::Object); use C4::Circulation qw( CanBookBeIssued AddIssue ); use C4::Members::Messaging qw( GetMessagingPreferences ); use C4::Letters qw( GetPreparedLetter EnqueueLetter ); -use Koha::Calendar; +use Koha::Library::Calendar; use Koha::DateUtils qw( dt_from_string ); use Koha::Patron; use Koha::Library; @@ -56,7 +56,7 @@ sub new { Koha::Exceptions::CurbsidePickup::NotEnabled->throw unless $policy && $policy->enabled; - my $calendar = Koha::Calendar->new( branchcode => $params->{branchcode} ); + my $calendar = Koha::Library::Calendar->new( branchcode => $params->{branchcode} ); Koha::Exceptions::CurbsidePickup::LibraryIsClosed->throw if $calendar->is_holiday( $params->{scheduled_pickup_datetime} ); diff --git a/Koha/Hold.pm b/Koha/Hold.pm index f50466387f..7f0ba5e877 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -34,7 +34,7 @@ use Koha::Biblios; use Koha::Hold::CancellationRequests; use Koha::Items; use Koha::Libraries; -use Koha::Calendar; +use Koha::Library::Calendar; use Koha::Plugins; use Koha::ILL::ISO18626::Request; @@ -72,7 +72,7 @@ sub age { my $age; if ($use_calendar) { - my $calendar = Koha::Calendar->new( branchcode => $self->branchcode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $self->branchcode ); $age = $calendar->days_between( dt_from_string( $self->reservedate ), $today ); } else { $age = $today->delta_days( dt_from_string( $self->reservedate ) ); @@ -428,7 +428,7 @@ sub set_waiting { branchcode => $self->branchcode, } ); - my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode ); $new_expiration_date = $calendar->days_forward( dt_from_string( $self->waitingdate ), $max_pickup_delay ); } diff --git a/Koha/Calendar.pm b/Koha/Library/Calendar.pm similarity index 90% rename from Koha/Calendar.pm rename to Koha/Library/Calendar.pm index b82b1f5f3a..5971c78387 100644 --- a/Koha/Calendar.pm +++ b/Koha/Library/Calendar.pm @@ -1,4 +1,4 @@ -package Koha::Calendar; +package Koha::Library::Calendar; use Modern::Perl; @@ -11,10 +11,10 @@ use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Exceptions; use Koha::Exceptions::Calendar; -use Koha::Calendar::WeeklyClosures; -use Koha::Calendar::RepeatingClosures; -use Koha::Calendar::SingleClosures; -use Koha::Calendar::Exceptions; +use Koha::Library::Calendar::WeeklyClosures; +use Koha::Library::Calendar::RepeatingClosures; +use Koha::Library::Calendar::SingleClosures; +use Koha::Library::Calendar::Exceptions; # This limit avoids an infinite loop when searching for an open day in an # always closed library @@ -33,7 +33,7 @@ sub new { $self->{$o} = $options{$o_name}; } if ( !defined $self->{branchcode} ) { - croak 'No branchcode argument passed to Koha::Calendar->new'; + croak 'No branchcode argument passed to Koha::Library::Calendar->new'; } $self->_init(); return $self; @@ -44,13 +44,13 @@ sub _init { my $branch = $self->{branchcode}; $self->{weekly_closed_days} = [ 0, 0, 0, 0, 0, 0, 0 ]; - my $weekly = Koha::Calendar::WeeklyClosures->search( { library_id => $branch } ); + my $weekly = Koha::Library::Calendar::WeeklyClosures->search( { library_id => $branch } ); while ( my $row = $weekly->next ) { $self->{weekly_closed_days}->[ $row->weekday ] = 1; } $self->{day_month_closed_days} = {}; - my $repeating = Koha::Calendar::RepeatingClosures->search( { library_id => $branch } ); + my $repeating = Koha::Library::Calendar::RepeatingClosures->search( { library_id => $branch } ); while ( my $row = $repeating->next ) { $self->{day_month_closed_days}->{ $row->month }->{ $row->day } = 1; } @@ -76,13 +76,13 @@ sub _holidays { unless ($holidays) { $holidays = {}; - my $single = Koha::Calendar::SingleClosures->search( { library_id => $self->{branchcode} } ); + my $single = Koha::Library::Calendar::SingleClosures->search( { library_id => $self->{branchcode} } ); while ( my $row = $single->next ) { ( my $datestring = $row->date ) =~ s/-//g; $holidays->{$datestring} = 1; } - my $exceptions = Koha::Calendar::Exceptions->search( { library_id => $self->{branchcode} } ); + my $exceptions = Koha::Library::Calendar::Exceptions->search( { library_id => $self->{branchcode} } ); while ( my $row = $exceptions->next ) { ( my $datestring = $row->date ) =~ s/-//g; $holidays->{$datestring} = 0; @@ -426,27 +426,27 @@ sub clear_weekly_closed_days { sub add_weekly_closure { my ( $self, $params ) = @_; - return Koha::Calendar::WeeklyClosure->new( { library_id => $self->{branchcode}, %$params } )->store; + return Koha::Library::Calendar::WeeklyClosure->new( { library_id => $self->{branchcode}, %$params } )->store; } sub add_repeating_closure { my ( $self, $params ) = @_; - return Koha::Calendar::RepeatingClosure->new( { library_id => $self->{branchcode}, %$params } )->store; + return Koha::Library::Calendar::RepeatingClosure->new( { library_id => $self->{branchcode}, %$params } )->store; } sub add_single_closure { my ( $self, $params ) = @_; - return Koha::Calendar::SingleClosure->new( { library_id => $self->{branchcode}, %$params } )->store; + return Koha::Library::Calendar::SingleClosure->new( { library_id => $self->{branchcode}, %$params } )->store; } sub add_exception { my ( $self, $params ) = @_; - return Koha::Calendar::Exception->new( { library_id => $self->{branchcode}, %$params } )->store; + return Koha::Library::Calendar::Exception->new( { library_id => $self->{branchcode}, %$params } )->store; } sub delete_weekly_closure { my ( $self, $params ) = @_; - my $row = Koha::Calendar::WeeklyClosures->search( + my $row = Koha::Library::Calendar::WeeklyClosures->search( { library_id => $self->{branchcode}, weekday => $params->{weekday} }, { rows => 1 } )->single; @@ -456,7 +456,7 @@ sub delete_weekly_closure { sub delete_repeating_closure { my ( $self, $params ) = @_; - my $row = Koha::Calendar::RepeatingClosures->search( + my $row = Koha::Library::Calendar::RepeatingClosures->search( { library_id => $self->{branchcode}, day => $params->{day}, month => $params->{month} }, { rows => 1 } )->single; @@ -466,7 +466,7 @@ sub delete_repeating_closure { sub delete_single_closure { my ( $self, $params ) = @_; - my $row = Koha::Calendar::SingleClosures->search( + my $row = Koha::Library::Calendar::SingleClosures->search( { library_id => $self->{branchcode}, date => $params->{date} }, { rows => 1 } )->single; @@ -476,7 +476,7 @@ sub delete_single_closure { sub delete_exception { my ( $self, $params ) = @_; - my $row = Koha::Calendar::Exceptions->search( + my $row = Koha::Library::Calendar::Exceptions->search( { library_id => $self->{branchcode}, date => $params->{date} }, { rows => 1 } )->single; @@ -525,12 +525,12 @@ sub copy_to { $schema->txn_do( sub { - my $weekly = Koha::Calendar::WeeklyClosures->search( { library_id => $self->{branchcode} } ); + my $weekly = Koha::Library::Calendar::WeeklyClosures->search( { library_id => $self->{branchcode} } ); while ( my $row = $weekly->next ) { next - if Koha::Calendar::WeeklyClosures->search( + if Koha::Library::Calendar::WeeklyClosures->search( { library_id => $target_branchcode, weekday => $row->weekday } )->count; - Koha::Calendar::WeeklyClosure->new( + Koha::Library::Calendar::WeeklyClosure->new( { library_id => $target_branchcode, weekday => $row->weekday, title => $row->title, description => $row->description, @@ -538,12 +538,12 @@ sub copy_to { )->store; } - my $repeating = Koha::Calendar::RepeatingClosures->search( { library_id => $self->{branchcode} } ); + my $repeating = Koha::Library::Calendar::RepeatingClosures->search( { library_id => $self->{branchcode} } ); while ( my $row = $repeating->next ) { next - if Koha::Calendar::RepeatingClosures->search( + if Koha::Library::Calendar::RepeatingClosures->search( { library_id => $target_branchcode, day => $row->day, month => $row->month } )->count; - Koha::Calendar::RepeatingClosure->new( + Koha::Library::Calendar::RepeatingClosure->new( { library_id => $target_branchcode, day => $row->day, month => $row->month, title => $row->title, description => $row->description, @@ -551,13 +551,13 @@ sub copy_to { )->store; } - my $singles = Koha::Calendar::SingleClosures->search( + my $singles = Koha::Library::Calendar::SingleClosures->search( { library_id => $self->{branchcode}, date => { '>=' => $today } } ); while ( my $row = $singles->next ) { next - if Koha::Calendar::SingleClosures->search( + if Koha::Library::Calendar::SingleClosures->search( { library_id => $target_branchcode, date => $row->date } )->count; - Koha::Calendar::SingleClosure->new( + Koha::Library::Calendar::SingleClosure->new( { library_id => $target_branchcode, date => $row->date, title => $row->title, description => $row->description, @@ -566,12 +566,12 @@ sub copy_to { } my $exceptions = - Koha::Calendar::Exceptions->search( { library_id => $self->{branchcode}, date => { '>=' => $today } } ); + Koha::Library::Calendar::Exceptions->search( { library_id => $self->{branchcode}, date => { '>=' => $today } } ); while ( my $row = $exceptions->next ) { next - if Koha::Calendar::Exceptions->search( { library_id => $target_branchcode, date => $row->date } ) + if Koha::Library::Calendar::Exceptions->search( { library_id => $target_branchcode, date => $row->date } ) ->count; - Koha::Calendar::Exception->new( + Koha::Library::Calendar::Exception->new( { library_id => $target_branchcode, date => $row->date, title => $row->title, description => $row->description, @@ -595,13 +595,13 @@ __END__ =head1 NAME -Koha::Calendar - Object containing a branches calendar +Koha::Library::Calendar - Object containing a library's calendar =head1 SYNOPSIS - use Koha::Calendar + use Koha::Library::Calendar - my $c = Koha::Calendar->new( branchcode => 'MAIN' ); + my $c = Koha::Library::Calendar->new( branchcode => 'MAIN' ); my $dt = dt_from_string(); # are we open @@ -632,7 +632,7 @@ C date strings. Results are cached. =head2 new : Create a calendar object -my $calendar = Koha::Calendar->new( branchcode => 'MAIN' ); +my $calendar = Koha::Library::Calendar->new( branchcode => 'MAIN' ); The option branchcode is required diff --git a/Koha/Calendar/Exception.pm b/Koha/Library/Calendar/Exception.pm similarity index 92% rename from Koha/Calendar/Exception.pm rename to Koha/Library/Calendar/Exception.pm index b9d935420d..598c23d020 100644 --- a/Koha/Calendar/Exception.pm +++ b/Koha/Library/Calendar/Exception.pm @@ -1,4 +1,4 @@ -package Koha::Calendar::Exception; +package Koha::Library::Calendar::Exception; # Copyright 2026 Theke Solutions # @@ -26,7 +26,7 @@ use base qw(Koha::Object); =head1 NAME -Koha::Calendar::Exception - Koha closure exception (open override) Object class +Koha::Library::Calendar::Exception - Koha closure exception (open override) Object class =head1 API diff --git a/Koha/Calendar/Exceptions.pm b/Koha/Library/Calendar/Exceptions.pm similarity index 81% rename from Koha/Calendar/Exceptions.pm rename to Koha/Library/Calendar/Exceptions.pm index 67c748ca0e..1bc42a2c31 100644 --- a/Koha/Calendar/Exceptions.pm +++ b/Koha/Library/Calendar/Exceptions.pm @@ -1,4 +1,4 @@ -package Koha::Calendar::Exceptions; +package Koha::Library::Calendar::Exceptions; # Copyright 2026 Theke Solutions # @@ -21,13 +21,13 @@ use Modern::Perl; use Koha::Database; -use Koha::Calendar::Exception; +use Koha::Library::Calendar::Exception; use base qw(Koha::Objects); =head1 NAME -Koha::Calendar::Exceptions - Koha closure exception Object set class +Koha::Library::Calendar::Exceptions - Koha closure exception Object set class =head1 API @@ -46,7 +46,7 @@ sub _type { =cut sub object_class { - return 'Koha::Calendar::Exception'; + return 'Koha::Library::Calendar::Exception'; } 1; diff --git a/Koha/Calendar/RepeatingClosure.pm b/Koha/Library/Calendar/RepeatingClosure.pm similarity index 86% rename from Koha/Calendar/RepeatingClosure.pm rename to Koha/Library/Calendar/RepeatingClosure.pm index 215656abf1..bedd0b708f 100644 --- a/Koha/Calendar/RepeatingClosure.pm +++ b/Koha/Library/Calendar/RepeatingClosure.pm @@ -1,4 +1,4 @@ -package Koha::Calendar::RepeatingClosure; +package Koha::Library::Calendar::RepeatingClosure; # Copyright 2026 Theke Solutions # @@ -25,7 +25,7 @@ use base qw(Koha::Object); =head1 NAME -Koha::Calendar::RepeatingClosure - Koha annual repeating closure Object class +Koha::Library::Calendar::RepeatingClosure - Koha annual repeating closure Object class =head1 API diff --git a/Koha/Calendar/RepeatingClosures.pm b/Koha/Library/Calendar/RepeatingClosures.pm similarity index 78% rename from Koha/Calendar/RepeatingClosures.pm rename to Koha/Library/Calendar/RepeatingClosures.pm index 6a3513bab1..3233b81269 100644 --- a/Koha/Calendar/RepeatingClosures.pm +++ b/Koha/Library/Calendar/RepeatingClosures.pm @@ -1,4 +1,4 @@ -package Koha::Calendar::RepeatingClosures; +package Koha::Library::Calendar::RepeatingClosures; # Copyright 2026 Theke Solutions # @@ -21,13 +21,13 @@ use Modern::Perl; use Koha::Database; -use Koha::Calendar::RepeatingClosure; +use Koha::Library::Calendar::RepeatingClosure; use base qw(Koha::Objects); =head1 NAME -Koha::Calendar::RepeatingClosures - Koha annual repeating closure Object set class +Koha::Library::Calendar::RepeatingClosures - Koha annual repeating closure Object set class =head1 API @@ -46,7 +46,7 @@ sub _type { =cut sub object_class { - return 'Koha::Calendar::RepeatingClosure'; + return 'Koha::Library::Calendar::RepeatingClosure'; } 1; diff --git a/Koha/Calendar/SingleClosure.pm b/Koha/Library/Calendar/SingleClosure.pm similarity index 92% rename from Koha/Calendar/SingleClosure.pm rename to Koha/Library/Calendar/SingleClosure.pm index fa7817a1db..079d712d28 100644 --- a/Koha/Calendar/SingleClosure.pm +++ b/Koha/Library/Calendar/SingleClosure.pm @@ -1,4 +1,4 @@ -package Koha::Calendar::SingleClosure; +package Koha::Library::Calendar::SingleClosure; # Copyright 2026 Theke Solutions # @@ -26,7 +26,7 @@ use base qw(Koha::Object); =head1 NAME -Koha::Calendar::SingleClosure - Koha single-date closure Object class +Koha::Library::Calendar::SingleClosure - Koha single-date closure Object class =head1 API diff --git a/Koha/Calendar/SingleClosures.pm b/Koha/Library/Calendar/SingleClosures.pm similarity index 79% rename from Koha/Calendar/SingleClosures.pm rename to Koha/Library/Calendar/SingleClosures.pm index f39a16a824..d9c3537ec5 100644 --- a/Koha/Calendar/SingleClosures.pm +++ b/Koha/Library/Calendar/SingleClosures.pm @@ -1,4 +1,4 @@ -package Koha::Calendar::SingleClosures; +package Koha::Library::Calendar::SingleClosures; # Copyright 2026 Theke Solutions # @@ -21,13 +21,13 @@ use Modern::Perl; use Koha::Database; -use Koha::Calendar::SingleClosure; +use Koha::Library::Calendar::SingleClosure; use base qw(Koha::Objects); =head1 NAME -Koha::Calendar::SingleClosures - Koha single-date closure Object set class +Koha::Library::Calendar::SingleClosures - Koha single-date closure Object set class =head1 API @@ -46,7 +46,7 @@ sub _type { =cut sub object_class { - return 'Koha::Calendar::SingleClosure'; + return 'Koha::Library::Calendar::SingleClosure'; } 1; diff --git a/Koha/Calendar/WeeklyClosure.pm b/Koha/Library/Calendar/WeeklyClosure.pm similarity index 87% rename from Koha/Calendar/WeeklyClosure.pm rename to Koha/Library/Calendar/WeeklyClosure.pm index 5c949718cb..8229e2005c 100644 --- a/Koha/Calendar/WeeklyClosure.pm +++ b/Koha/Library/Calendar/WeeklyClosure.pm @@ -1,4 +1,4 @@ -package Koha::Calendar::WeeklyClosure; +package Koha::Library::Calendar::WeeklyClosure; # Copyright 2026 Theke Solutions # @@ -25,7 +25,7 @@ use base qw(Koha::Object); =head1 NAME -Koha::Calendar::WeeklyClosure - Koha weekly closure Object class +Koha::Library::Calendar::WeeklyClosure - Koha weekly closure Object class =head1 API diff --git a/Koha/Calendar/WeeklyClosures.pm b/Koha/Library/Calendar/WeeklyClosures.pm similarity index 80% rename from Koha/Calendar/WeeklyClosures.pm rename to Koha/Library/Calendar/WeeklyClosures.pm index 3e77e4d71b..3943dff98a 100644 --- a/Koha/Calendar/WeeklyClosures.pm +++ b/Koha/Library/Calendar/WeeklyClosures.pm @@ -1,4 +1,4 @@ -package Koha::Calendar::WeeklyClosures; +package Koha::Library::Calendar::WeeklyClosures; # Copyright 2026 Theke Solutions # @@ -21,13 +21,13 @@ use Modern::Perl; use Koha::Database; -use Koha::Calendar::WeeklyClosure; +use Koha::Library::Calendar::WeeklyClosure; use base qw(Koha::Objects); =head1 NAME -Koha::Calendar::WeeklyClosures - Koha weekly closure Object set class +Koha::Library::Calendar::WeeklyClosures - Koha weekly closure Object set class =head1 API @@ -46,7 +46,7 @@ sub _type { =cut sub object_class { - return 'Koha::Calendar::WeeklyClosure'; + return 'Koha::Library::Calendar::WeeklyClosure'; } 1; diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 6aca03d081..d47ac9784e 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1468,7 +1468,7 @@ sub has_restricting_overdues { next DELAY unless $overdue_rules->{ "overdue_$i" . '_restrict' }; if ( C4::Context->preference('OverdueNoticeCalendar') ) { - $calendar = Koha::Calendar->new( branchcode => $branchcode ); + $calendar = Koha::Library::Calendar->new( branchcode => $branchcode ); } my $days_between = diff --git a/Koha/REST/V1/Libraries.pm b/Koha/REST/V1/Libraries.pm index 913ba56c35..96585d0612 100644 --- a/Koha/REST/V1/Libraries.pm +++ b/Koha/REST/V1/Libraries.pm @@ -19,9 +19,9 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; use C4::Context; -use Koha::Libraries; -use Koha::Calendar; use Koha::DateUtils qw( dt_from_string ); +use Koha::Libraries; +use Koha::Library::Calendar; use Scalar::Util qw( blessed ); @@ -248,7 +248,7 @@ sub list_closed_dates { ); } - my $calendar = Koha::Calendar->new( branchcode => $library_id ); + my $calendar = Koha::Library::Calendar->new( branchcode => $library_id ); my $holidays = $calendar->_holidays; my $weekly = $calendar->{weekly_closed_days}; my $day_month = $calendar->{day_month_closed_days}; diff --git a/Koha/Schema/Result/LibraryClosureException.pm b/Koha/Schema/Result/LibraryClosureException.pm index 8b332992e7..e38d3493c1 100644 --- a/Koha/Schema/Result/LibraryClosureException.pm +++ b/Koha/Schema/Result/LibraryClosureException.pm @@ -133,7 +133,7 @@ __PACKAGE__->belongs_to( =cut sub koha_objects_class { - 'Koha::Calendar::Exceptions'; + 'Koha::Library::Calendar::Exceptions'; } =head2 koha_object_class @@ -141,7 +141,7 @@ sub koha_objects_class { =cut sub koha_object_class { - 'Koha::Calendar::Exception'; + 'Koha::Library::Calendar::Exception'; } 1; diff --git a/Koha/Schema/Result/LibraryRepeatingClosure.pm b/Koha/Schema/Result/LibraryRepeatingClosure.pm index 72741d6d9e..1dedc7671b 100644 --- a/Koha/Schema/Result/LibraryRepeatingClosure.pm +++ b/Koha/Schema/Result/LibraryRepeatingClosure.pm @@ -143,7 +143,7 @@ __PACKAGE__->belongs_to( =cut sub koha_objects_class { - 'Koha::Calendar::RepeatingClosures'; + 'Koha::Library::Calendar::RepeatingClosures'; } =head2 koha_object_class @@ -151,7 +151,7 @@ sub koha_objects_class { =cut sub koha_object_class { - 'Koha::Calendar::RepeatingClosure'; + 'Koha::Library::Calendar::RepeatingClosure'; } 1; diff --git a/Koha/Schema/Result/LibrarySingleClosure.pm b/Koha/Schema/Result/LibrarySingleClosure.pm index 1ffe7e11f7..a66bc73faf 100644 --- a/Koha/Schema/Result/LibrarySingleClosure.pm +++ b/Koha/Schema/Result/LibrarySingleClosure.pm @@ -133,7 +133,7 @@ __PACKAGE__->belongs_to( =cut sub koha_objects_class { - 'Koha::Calendar::SingleClosures'; + 'Koha::Library::Calendar::SingleClosures'; } =head2 koha_object_class @@ -141,7 +141,7 @@ sub koha_objects_class { =cut sub koha_object_class { - 'Koha::Calendar::SingleClosure'; + 'Koha::Library::Calendar::SingleClosure'; } 1; diff --git a/Koha/Schema/Result/LibraryWeeklyClosure.pm b/Koha/Schema/Result/LibraryWeeklyClosure.pm index 21503d4f78..ae5ff48859 100644 --- a/Koha/Schema/Result/LibraryWeeklyClosure.pm +++ b/Koha/Schema/Result/LibraryWeeklyClosure.pm @@ -132,7 +132,7 @@ __PACKAGE__->belongs_to( =cut sub koha_objects_class { - 'Koha::Calendar::WeeklyClosures'; + 'Koha::Library::Calendar::WeeklyClosures'; } =head2 koha_object_class @@ -140,7 +140,7 @@ sub koha_objects_class { =cut sub koha_object_class { - 'Koha::Calendar::WeeklyClosure'; + 'Koha::Library::Calendar::WeeklyClosure'; } 1; diff --git a/circ/returns.pl b/circ/returns.pl index 0c88893d3a..31178e6d36 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -45,7 +45,7 @@ use C4::RotatingCollections; use Koha::AuthorisedValues; use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; use Koha::BiblioFrameworks; -use Koha::Calendar; +use Koha::Library::Calendar; use Koha::Checkouts; use Koha::CirculationRules; use Koha::DateUtils qw( dt_from_string ); diff --git a/installer/data/mysql/atomicupdate/bug_42310.pl b/installer/data/mysql/atomicupdate/bug_42310.pl index c2abdbbf4a..690c6e6e27 100755 --- a/installer/data/mysql/atomicupdate/bug_42310.pl +++ b/installer/data/mysql/atomicupdate/bug_42310.pl @@ -3,7 +3,7 @@ use Koha::Installer::Output qw(say_warning say_success say_info); return { bug_number => "42310", - description => "Normalize calendar tables into Koha::Calendar::* schema", + description => "Normalize calendar tables into Koha::Library::Calendar::* schema", up => sub { my ($args) = @_; my ( $dbh, $out ) = @$args{qw(dbh out)}; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 7d7b7bb4df..e722f50f1d 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -17811,7 +17811,7 @@ if ( CheckVersion($DBversion) ) { $DBversion = '16.12.00.032'; if ( CheckVersion($DBversion) ) { - require Koha::Calendar; + require Koha::Library::Calendar; $dbh->do( q{ @@ -17844,7 +17844,7 @@ if ( CheckVersion($DBversion) ) { my $expirationdate = dt_from_string( $hold->{waitingdate} ); if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { - my $calendar = Koha::Calendar->new( + my $calendar = Koha::Library::Calendar->new( branchcode => $hold->{branchcode}, days_mode => C4::Context->preference('useDaysMode') ); diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index 65ac8b2a31..49773702b1 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -38,7 +38,7 @@ use Carp qw( carp croak ); use File::Spec; use Try::Tiny qw( catch try ); -use Koha::Calendar; +use Koha::Library::Calendar; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Patrons; use C4::Log qw( cronlogaction ); @@ -212,7 +212,7 @@ EOM sub set_holiday { my ( $branch, $dt ) = @_; - my $calendar = Koha::Calendar->new( branchcode => $branch ); + my $calendar = Koha::Library::Calendar->new( branchcode => $branch ); return $calendar->is_holiday($dt); } diff --git a/misc/cronjobs/holds/cancel_unfilled_holds.pl b/misc/cronjobs/holds/cancel_unfilled_holds.pl index 7a9d850f29..dce0b0c3bc 100755 --- a/misc/cronjobs/holds/cancel_unfilled_holds.pl +++ b/misc/cronjobs/holds/cancel_unfilled_holds.pl @@ -24,7 +24,7 @@ use Pod::Usage qw( pod2usage ); use Koha::Script -cron; use C4::Reserves; use Koha::Holds; -use Koha::Calendar; +use Koha::Library::Calendar; use Koha::Libraries; =head1 NAME diff --git a/misc/cronjobs/holds/holds_reminder.pl b/misc/cronjobs/holds/holds_reminder.pl index 870f966a46..f2bee6d634 100755 --- a/misc/cronjobs/holds/holds_reminder.pl +++ b/misc/cronjobs/holds/holds_reminder.pl @@ -25,7 +25,7 @@ use DateTime::Duration; use C4::Context; use C4::Letters; use Koha::DateUtils qw( dt_from_string ); -use Koha::Calendar; +use Koha::Library::Calendar; use Koha::Libraries; use Koha::Notice::Templates; use Koha::Patrons; @@ -237,7 +237,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::Calendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); + my $calendar = Koha::Library::Calendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); #if today is a holiday skip sending the message next if $calendar->is_holiday($date_to_run); diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 17e17157d1..da42ba7678 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -33,7 +33,7 @@ use C4::Overdues qw( parse_overdues_letter ); use C4::Log qw( cronlogaction ); use Koha::Patron::Debarments qw( AddUniqueDebarment ); use Koha::DateUtils qw( dt_from_string output_pref ); -use Koha::Calendar; +use Koha::Library::Calendar; use Koha::Libraries; use Koha::Acquisition::Currencies; use Koha::Patrons; @@ -521,7 +521,7 @@ my @output_chunks; foreach my $branchcode (@branches) { my $calendar; if ( C4::Context->preference('OverdueNoticeCalendar') ) { - $calendar = Koha::Calendar->new( branchcode => $branchcode ); + $calendar = Koha::Library::Calendar->new( branchcode => $branchcode ); if ( $calendar->is_holiday($date_to_run) ) { next; } diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl index efeb82efe8..029b6c8fe4 100755 --- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl +++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl @@ -27,7 +27,7 @@ use Koha::Script -cron; use C4::Context; use C4::Letters; use C4::Overdues; -use Koha::Calendar; +use Koha::Library::Calendar; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Patrons; use Koha::Libraries; @@ -378,7 +378,7 @@ sub GetWaitingHolds { } ); - my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'}, days_mode => $daysmode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $issue->{'site'}, days_mode => $daysmode ); my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' ); diff --git a/t/db_dependent/Calendar.t b/t/db_dependent/Calendar.t index 623c2d4dbc..d6752b9da4 100755 --- a/t/db_dependent/Calendar.t +++ b/t/db_dependent/Calendar.t @@ -27,7 +27,7 @@ use t::lib::TestBuilder; use DateTime; use DateTime::Duration; use Koha::Caches; -use Koha::Calendar; +use Koha::Library::Calendar; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); @@ -57,21 +57,21 @@ subtest 'Original tests from t' => sub { my $mpl = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode; my $cpl = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode; - Koha::Calendar::WeeklyClosures->search( { library_id => [ $mpl, $cpl ] } )->delete; - Koha::Calendar::RepeatingClosures->search( { library_id => [ $mpl, $cpl ] } )->delete; - Koha::Calendar::SingleClosures->search( { library_id => [ $mpl, $cpl ] } )->delete; - Koha::Calendar::Exceptions->search( { library_id => [ $mpl, $cpl ] } )->delete; + Koha::Library::Calendar::WeeklyClosures->search( { library_id => [ $mpl, $cpl ] } )->delete; + Koha::Library::Calendar::RepeatingClosures->search( { library_id => [ $mpl, $cpl ] } )->delete; + Koha::Library::Calendar::SingleClosures->search( { library_id => [ $mpl, $cpl ] } )->delete; + Koha::Library::Calendar::Exceptions->search( { library_id => [ $mpl, $cpl ] } )->delete; # Weekly closures $builder->build_object( { - class => 'Koha::Calendar::WeeklyClosures', + class => 'Koha::Library::Calendar::WeeklyClosures', value => { library_id => $mpl, weekday => 0, title => '', description => '' } } ); # sundays $builder->build_object( { - class => 'Koha::Calendar::WeeklyClosures', + class => 'Koha::Library::Calendar::WeeklyClosures', value => { library_id => $mpl, weekday => 6, title => '', description => '' } } ); # saturdays @@ -79,13 +79,13 @@ subtest 'Original tests from t' => sub { # Repeating annual closures $builder->build_object( { - class => 'Koha::Calendar::RepeatingClosures', + class => 'Koha::Library::Calendar::RepeatingClosures', value => { library_id => $mpl, day => 1, month => 1, title => '', description => '' } } ); # new year $builder->build_object( { - class => 'Koha::Calendar::RepeatingClosures', + class => 'Koha::Library::Calendar::RepeatingClosures', value => { library_id => $mpl, day => 25, month => 12, title => '', description => '' } } ); # christmas @@ -93,25 +93,25 @@ subtest 'Original tests from t' => sub { # Single closures $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => $mpl, date => '2011-06-01', title => '', description => '' } } ); $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => $mpl, date => '2012-07-04', title => '', description => '' } } ); $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => $cpl, date => '2012-08-06', title => '', description => '' } } ); $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => $mpl, date => '2012-07-07', title => '', description => '' } } ); @@ -119,13 +119,13 @@ subtest 'Original tests from t' => sub { # Exceptions (open overrides) $builder->build_object( { - class => 'Koha::Calendar::Exceptions', + class => 'Koha::Library::Calendar::Exceptions', value => { library_id => $mpl, date => '2012-11-11', title => '', description => '' } } ); # sunday exception $builder->build_object( { - class => 'Koha::Calendar::Exceptions', + class => 'Koha::Library::Calendar::Exceptions', value => { library_id => $mpl, date => '2012-07-07', title => '', description => '' } } ); # holiday exception @@ -135,9 +135,9 @@ subtest 'Original tests from t' => sub { $cache->clear_from_cache( $cpl . '_holidays' ); # $mpl branch is arbitrary, is not used at all but is needed for initialization - my $cal = Koha::Calendar->new( branchcode => $mpl ); + my $cal = Koha::Library::Calendar->new( branchcode => $mpl ); - isa_ok( $cal, 'Koha::Calendar', 'Calendar class returned' ); + isa_ok( $cal, 'Koha::Library::Calendar', 'Calendar class returned' ); my $saturday = DateTime->new( year => 2012, @@ -272,7 +272,7 @@ subtest 'Original tests from t' => sub { { ## 'Datedue' tests - $cal = Koha::Calendar->new( branchcode => $mpl, days_mode => 'Datedue' ); + $cal = Koha::Library::Calendar->new( branchcode => $mpl, days_mode => 'Datedue' ); is( $cal->addDuration( $dt, $one_day_dur, 'days' ), # tuesday @@ -317,7 +317,7 @@ subtest 'Original tests from t' => sub { { ## 'Calendar' tests' - $cal = Koha::Calendar->new( branchcode => $mpl, days_mode => 'Calendar' ); + $cal = Koha::Library::Calendar->new( branchcode => $mpl, days_mode => 'Calendar' ); $dt = dt_from_string( '2012-07-03', 'iso' ); @@ -356,7 +356,7 @@ subtest 'Original tests from t' => sub { { ## 'Days' tests - $cal = Koha::Calendar->new( branchcode => $mpl, days_mode => 'Days' ); + $cal = Koha::Library::Calendar->new( branchcode => $mpl, days_mode => 'Days' ); $dt = dt_from_string( '2012-07-03', 'iso' ); @@ -397,7 +397,7 @@ subtest 'Original tests from t' => sub { } { - $cal = Koha::Calendar->new( branchcode => $cpl ); + $cal = Koha::Library::Calendar->new( branchcode => $cpl ); is( $cal->is_holiday($single_holiday), 0, 'Single holiday for MPL, not CPL' ); is( $cal->is_holiday($holiday_for_another_branch), 1, @@ -410,7 +410,7 @@ subtest 'Original tests from t' => sub { t::lib::Mocks::mock_preference( 'useDaysMode', 'Days' ); - $cal = Koha::Calendar->new( branchcode => $cpl, days_mode => 'Calendar' ); + $cal = Koha::Library::Calendar->new( branchcode => $cpl, days_mode => 'Calendar' ); is( $cal->{days_mode}, 'Calendar', q|If set, days_mode is correctly set| ); }; @@ -419,10 +419,10 @@ subtest 'Original tests from t' => sub { }; my $library = $builder->build_object( { class => 'Koha::Libraries' } ); -my $calendar = Koha::Calendar->new( branchcode => $library->branchcode, days_mode => 'Calendar' ); +my $calendar = Koha::Library::Calendar->new( branchcode => $library->branchcode, days_mode => 'Calendar' ); $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => $library->branchcode, date => $holiday_dt->ymd, title => 'My holiday', description => '' } } @@ -493,7 +493,7 @@ subtest 'hours_between | days_between' => sub { plan tests => 2; my $library = $builder->build_object( { class => 'Koha::Libraries' } ); - my $calendar = Koha::Calendar->new( branchcode => $library->branchcode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $library->branchcode ); subtest 'Same hours' => sub { @@ -568,14 +568,14 @@ subtest 'hours_between | days_between' => sub { # Wednesdays are closed $builder->build_object( { - class => 'Koha::Calendar::WeeklyClosures', + class => 'Koha::Library::Calendar::WeeklyClosures', value => { library_id => $library->branchcode, weekday => 3, title => 'Closed on Wednesday', description => '', } } ); - my $calendar = Koha::Calendar->new( branchcode => $library->branchcode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $library->branchcode ); subtest 'Same hours' => sub { plan tests => 12; @@ -719,7 +719,7 @@ subtest 'is_holiday' => sub { # Closed this day of the week my $closure = $builder->build_object( { - class => 'Koha::Calendar::WeeklyClosures', + class => 'Koha::Library::Calendar::WeeklyClosures', value => { library_id => $library->branchcode, weekday => $dow, title => 'TEST', description => '', } @@ -728,7 +728,7 @@ subtest 'is_holiday' => sub { # Iterate 7 days for my $i ( 0 .. 6 ) { - my $calendar = Koha::Calendar->new( branchcode => $library->branchcode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $library->branchcode ); is( $calendar->is_holiday($day), 1, $day->day_name() . " works as a repeatable holiday" ); @@ -758,7 +758,7 @@ subtest 'get_push_amt' => sub { # Closed this day of the week my $closure = $builder->build_object( { - class => 'Koha::Calendar::WeeklyClosures', + class => 'Koha::Library::Calendar::WeeklyClosures', value => { library_id => $library->branchcode, weekday => $dow, title => 'TEST', description => '', } @@ -767,7 +767,7 @@ subtest 'get_push_amt' => sub { # Iterate 7 days for my $i ( 0 .. 6 ) { - my $calendar = Koha::Calendar->new( branchcode => $library->branchcode, days_mode => 'Dayweek' ); + my $calendar = Koha::Library::Calendar->new( branchcode => $library->branchcode, days_mode => 'Dayweek' ); my $npa; eval { diff --git a/t/db_dependent/Holds/WaitingReserves.t b/t/db_dependent/Holds/WaitingReserves.t index 766b2bccba..1865adec1f 100755 --- a/t/db_dependent/Holds/WaitingReserves.t +++ b/t/db_dependent/Holds/WaitingReserves.t @@ -174,7 +174,7 @@ $special_holiday1_dt->add( days => 2 ); my $holiday = $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => 'LIB1', date => $special_holiday1_dt->ymd, title => 'My special holiday', description => '' } @@ -186,7 +186,7 @@ $special_holiday2_dt->add( days => 4 ); my $holiday2 = $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => 'LIB1', date => $special_holiday2_dt->ymd, title => 'My special holiday 2', description => '' } diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t index 71f00212d7..285dcce8e2 100755 --- a/t/db_dependent/HoldsQueue.t +++ b/t/db_dependent/HoldsQueue.t @@ -403,7 +403,7 @@ C4::Calendar->new( branchcode => $branchcodes[0] )->insert_single_holiday( # If the test below is removed, another tests using the holiday will fail. For some reason if we call is_holiday now # the holiday will get set in cache correctly, but not if we let C4::HoldsQueue call is_holiday instead. is( - Koha::Calendar->new( branchcode => $branchcodes[0] )->is_holiday($today), 1, + Koha::Library::Calendar->new( branchcode => $branchcodes[0] )->is_holiday($today), 1, 'Is today a holiday for pickup branch' ); C4::HoldsQueue::CreateQueue(); diff --git a/t/db_dependent/Holidays.t b/t/db_dependent/Holidays.t index 46feb3693b..d864dd9304 100755 --- a/t/db_dependent/Holidays.t +++ b/t/db_dependent/Holidays.t @@ -30,7 +30,7 @@ use Koha::Database; use Koha::DateUtils qw( dt_from_string ); BEGIN { - use_ok('Koha::Calendar'); + use_ok('Koha::Library::Calendar'); use_ok('C4::Calendar'); } @@ -56,7 +56,7 @@ subtest 'is_holiday timezone tests' => sub { tzset; my $branch = $builder->build( { source => 'Branch' } )->{branchcode}; - my $calendar = Koha::Calendar->new( branchcode => $branch ); + my $calendar = Koha::Library::Calendar->new( branchcode => $branch ); C4::Calendar->new( branchcode => $branch )->insert_exception_holiday( day => 6, @@ -109,11 +109,11 @@ C4::Calendar->new( branchcode => $branch_1 )->insert_day_month_holiday( description => 'Christmas', ); -my $koha_calendar = Koha::Calendar->new( branchcode => $branch_1 ); +my $koha_calendar = Koha::Library::Calendar->new( branchcode => $branch_1 ); my $c4_calendar = C4::Calendar->new( branchcode => $branch_1 ); -isa_ok( $koha_calendar, 'Koha::Calendar', 'Koha::Calendar class returned' ); -isa_ok( $c4_calendar, 'C4::Calendar', 'C4::Calendar class returned' ); +isa_ok( $koha_calendar, 'Koha::Library::Calendar', 'Koha::Library::Calendar class returned' ); +isa_ok( $c4_calendar, 'C4::Calendar', 'C4::Calendar class returned' ); my $sunday = DateTime->new( year => 2011, @@ -159,8 +159,14 @@ C4::Calendar->new( branchcode => $branch_2 )->insert_single_holiday( description => "$today", ); -is( Koha::Calendar->new( branchcode => $branch_2 )->is_holiday($today), 1, "Today is a holiday for $branch_2" ); -is( Koha::Calendar->new( branchcode => $branch_1 )->is_holiday($today), 0, "Today is not a holiday for $branch_1" ); +is( + Koha::Library::Calendar->new( branchcode => $branch_2 )->is_holiday($today), 1, + "Today is a holiday for $branch_2" +); +is( + Koha::Library::Calendar->new( branchcode => $branch_1 )->is_holiday($today), 0, + "Today is not a holiday for $branch_1" +); $schema->storage->txn_rollback; @@ -303,12 +309,12 @@ subtest 'with a library that is never open' => sub { my $now = dt_from_string; subtest 'next_open_days should throw an exception' => sub { - my $kcalendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); + my $kcalendar = Koha::Library::Calendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); throws_ok { $kcalendar->next_open_days( $now, 1 ) } 'Koha::Exceptions::Calendar::NoOpenDays'; }; subtest 'prev_open_days should throw an exception' => sub { - my $kcalendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); + my $kcalendar = Koha::Library::Calendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); throws_ok { $kcalendar->prev_open_days( $now, 1 ) } 'Koha::Exceptions::Calendar::NoOpenDays'; }; @@ -333,13 +339,13 @@ subtest 'with a library that is *almost* never open' => sub { $calendar->insert_exception_holiday( date => $open_day_in_the_past->ymd, title => '', description => '' ); subtest 'next_open_days should find the open day' => sub { - my $kcalendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); + my $kcalendar = Koha::Library::Calendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); my $next_open_day = $kcalendar->next_open_days( $now, 1 ); is( $next_open_day->ymd, $open_day_in_the_future->ymd ); }; subtest 'prev_open_days should find the open day' => sub { - my $kcalendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); + my $kcalendar = Koha::Library::Calendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); my $prev_open_day = $kcalendar->prev_open_days( $now, 1 ); is( $prev_open_day->ymd, $open_day_in_the_past->ymd ); }; diff --git a/t/db_dependent/Koha/CurbsidePickups.t b/t/db_dependent/Koha/CurbsidePickups.t index 0eef295aa2..c00375856c 100755 --- a/t/db_dependent/Koha/CurbsidePickups.t +++ b/t/db_dependent/Koha/CurbsidePickups.t @@ -24,7 +24,7 @@ use Test::Exception; use C4::Calendar; use Koha::CurbsidePickups; use Koha::CurbsidePickupPolicies; -use Koha::Calendar; +use Koha::Library::Calendar; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); @@ -157,7 +157,7 @@ subtest 'Create a pickup' => sub { title => '', description => 'Mondays', ); - my $calendar = Koha::Calendar->new( branchcode => $library->branchcode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $library->branchcode ); throws_ok { Koha::CurbsidePickup->new( { %$params, scheduled_pickup_datetime => $schedule_dt } )->store; } diff --git a/t/db_dependent/Koha/Calendar.t b/t/db_dependent/Koha/Library/Calendar.t similarity index 74% rename from t/db_dependent/Koha/Calendar.t rename to t/db_dependent/Koha/Library/Calendar.t index e0157638b0..10639c01b4 100755 --- a/t/db_dependent/Koha/Calendar.t +++ b/t/db_dependent/Koha/Library/Calendar.t @@ -26,14 +26,14 @@ use Test::NoWarnings; use Koha::Caches; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); -use Koha::Calendar::WeeklyClosures; -use Koha::Calendar::RepeatingClosures; -use Koha::Calendar::SingleClosures; -use Koha::Calendar::Exceptions; +use Koha::Library::Calendar::WeeklyClosures; +use Koha::Library::Calendar::RepeatingClosures; +use Koha::Library::Calendar::SingleClosures; +use Koha::Library::Calendar::Exceptions; use t::lib::TestBuilder; BEGIN { - use_ok('Koha::Calendar'); + use_ok('Koha::Library::Calendar'); } my $schema = Koha::Database->schema; @@ -60,7 +60,7 @@ subtest 'has_business_days_between' => sub { # Make Wednesday a holiday $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => $branchcode, date => $wednesday->ymd, title => 'Wednesday Holiday', description => '' } } @@ -69,7 +69,7 @@ subtest 'has_business_days_between' => sub { # Make Saturday and Sunday holidays (weekend) $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => $branchcode, date => $saturday->ymd, title => 'Saturday Holiday', description => '' } } @@ -77,12 +77,12 @@ subtest 'has_business_days_between' => sub { $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => $branchcode, date => $sunday->ymd, title => 'Sunday Holiday', description => '' } } ); - my $calendar = Koha::Calendar->new( branchcode => $branchcode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $branchcode ); # Test 1: Business day between two business days is( @@ -130,40 +130,40 @@ subtest 'CRUD methods' => sub { $schema->storage->txn_begin; my $library = $builder->build_object( { class => 'Koha::Libraries' } ); - my $calendar = Koha::Calendar->new( branchcode => $library->branchcode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $library->branchcode ); # add_weekly_closure my $weekly = $calendar->add_weekly_closure( { weekday => 0, title => 'Sundays', description => 'Closed' } ); - isa_ok( $weekly, 'Koha::Calendar::WeeklyClosure', 'add_weekly_closure returns object' ); + isa_ok( $weekly, 'Koha::Library::Calendar::WeeklyClosure', 'add_weekly_closure returns object' ); is( - Koha::Calendar::WeeklyClosures->search( { library_id => $library->branchcode } )->count, 1, + Koha::Library::Calendar::WeeklyClosures->search( { library_id => $library->branchcode } )->count, 1, 'Weekly closure created' ); # add_repeating_closure my $repeating = $calendar->add_repeating_closure( { day => 25, month => 12, title => 'Christmas', description => '' } ); - isa_ok( $repeating, 'Koha::Calendar::RepeatingClosure', 'add_repeating_closure returns object' ); + isa_ok( $repeating, 'Koha::Library::Calendar::RepeatingClosure', 'add_repeating_closure returns object' ); is( - Koha::Calendar::RepeatingClosures->search( { library_id => $library->branchcode } )->count, 1, + Koha::Library::Calendar::RepeatingClosures->search( { library_id => $library->branchcode } )->count, 1, 'Repeating closure created' ); # add_single_closure my $single = $calendar->add_single_closure( { date => '2026-06-15', title => 'Staff day', description => '' } ); - isa_ok( $single, 'Koha::Calendar::SingleClosure', 'add_single_closure returns object' ); + isa_ok( $single, 'Koha::Library::Calendar::SingleClosure', 'add_single_closure returns object' ); is( - Koha::Calendar::SingleClosures->search( { library_id => $library->branchcode } )->count, 1, + Koha::Library::Calendar::SingleClosures->search( { library_id => $library->branchcode } )->count, 1, 'Single closure created' ); # add_exception my $exception = $calendar->add_exception( { date => '2026-12-25', title => 'Special opening', description => '' } ); - isa_ok( $exception, 'Koha::Calendar::Exception', 'add_exception returns object' ); - is( Koha::Calendar::Exceptions->search( { library_id => $library->branchcode } )->count, 1, 'Exception created' ); + isa_ok( $exception, 'Koha::Library::Calendar::Exception', 'add_exception returns object' ); + is( Koha::Library::Calendar::Exceptions->search( { library_id => $library->branchcode } )->count, 1, 'Exception created' ); # Verify is_holiday uses the new data - my $cal = Koha::Calendar->new( branchcode => $library->branchcode ); + my $cal = Koha::Library::Calendar->new( branchcode => $library->branchcode ); my $sunday = dt_from_string('2026-06-14'); # a Sunday is( $cal->is_holiday($sunday), 1, 'Sunday is closed after add_weekly_closure' ); @@ -176,24 +176,24 @@ subtest 'CRUD methods' => sub { # delete methods $calendar->delete_weekly_closure( { weekday => 0 } ); is( - Koha::Calendar::WeeklyClosures->search( { library_id => $library->branchcode } )->count, 0, + Koha::Library::Calendar::WeeklyClosures->search( { library_id => $library->branchcode } )->count, 0, 'Weekly closure deleted' ); $calendar->delete_repeating_closure( { day => 25, month => 12 } ); is( - Koha::Calendar::RepeatingClosures->search( { library_id => $library->branchcode } )->count, 0, + Koha::Library::Calendar::RepeatingClosures->search( { library_id => $library->branchcode } )->count, 0, 'Repeating closure deleted' ); $calendar->delete_single_closure( { date => '2026-06-15' } ); is( - Koha::Calendar::SingleClosures->search( { library_id => $library->branchcode } )->count, 0, + Koha::Library::Calendar::SingleClosures->search( { library_id => $library->branchcode } )->count, 0, 'Single closure deleted' ); $calendar->delete_exception( { date => '2026-12-25' } ); - is( Koha::Calendar::Exceptions->search( { library_id => $library->branchcode } )->count, 0, 'Exception deleted' ); + is( Koha::Library::Calendar::Exceptions->search( { library_id => $library->branchcode } )->count, 0, 'Exception deleted' ); # copy_to $calendar->add_weekly_closure( { weekday => 6, title => 'Saturdays', description => '' } ); @@ -203,27 +203,27 @@ subtest 'CRUD methods' => sub { $calendar->copy_to( $library2->branchcode ); is( - Koha::Calendar::WeeklyClosures->search( { library_id => $library2->branchcode } )->count, 1, + Koha::Library::Calendar::WeeklyClosures->search( { library_id => $library2->branchcode } )->count, 1, 'Weekly closure copied' ); is( - Koha::Calendar::SingleClosures->search( { library_id => $library2->branchcode } )->count, 1, + Koha::Library::Calendar::SingleClosures->search( { library_id => $library2->branchcode } )->count, 1, 'Single closure copied' ); # copy_to should not duplicate $calendar->copy_to( $library2->branchcode ); is( - Koha::Calendar::WeeklyClosures->search( { library_id => $library2->branchcode } )->count, 1, + Koha::Library::Calendar::WeeklyClosures->search( { library_id => $library2->branchcode } )->count, 1, 'No duplicate after second copy' ); is( - Koha::Calendar::SingleClosures->search( { library_id => $library2->branchcode } )->count, 1, + Koha::Library::Calendar::SingleClosures->search( { library_id => $library2->branchcode } )->count, 1, 'No duplicate single after second copy' ); # Verify is_holiday after deletions and re-init - my $cal2 = Koha::Calendar->new( branchcode => $library->branchcode ); + my $cal2 = Koha::Library::Calendar->new( branchcode => $library->branchcode ); is( $cal2->is_holiday($june15), 0, 'Deleted single closure no longer a holiday' ); $schema->storage->txn_rollback; @@ -241,19 +241,19 @@ subtest 'closed_dates_in_range' => sub { # Sunday closed every week, 25 December every year, 2026-06-15 single, # 2026-12-25 open exception (overrides the repeating rule). $builder->build_object( - { class => 'Koha::Calendar::WeeklyClosures', value => { library_id => $branchcode, weekday => 0 } } ); + { class => 'Koha::Library::Calendar::WeeklyClosures', value => { library_id => $branchcode, weekday => 0 } } ); $builder->build_object( { - class => 'Koha::Calendar::RepeatingClosures', + class => 'Koha::Library::Calendar::RepeatingClosures', value => { library_id => $branchcode, day => 25, month => 12 } } ); $builder->build_object( - { class => 'Koha::Calendar::SingleClosures', value => { library_id => $branchcode, date => '2026-06-15' } } ); + { class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => $branchcode, date => '2026-06-15' } } ); $builder->build_object( - { class => 'Koha::Calendar::Exceptions', value => { library_id => $branchcode, date => '2026-12-25' } } ); + { class => 'Koha::Library::Calendar::Exceptions', value => { library_id => $branchcode, date => '2026-12-25' } } ); - my $calendar = Koha::Calendar->new( branchcode => $branchcode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $branchcode ); my $closed = $calendar->closed_dates_in_range( dt_from_string('2026-06-14'), dt_from_string('2026-06-16') ); is_deeply( $closed, [ '2026-06-14', '2026-06-15' ], 'Sunday and single closure returned' ); @@ -283,7 +283,7 @@ subtest 'delete_*_closure clears _holidays cache' => sub { my $cache_key = $branchcode . '_holidays'; my $cache = Koha::Caches->get_instance; - my $calendar = Koha::Calendar->new( branchcode => $branchcode ); + my $calendar = Koha::Library::Calendar->new( branchcode => $branchcode ); $calendar->add_single_closure( { date => '2027-07-04', title => 'Independence', description => '' } ); $calendar->is_holiday( dt_from_string('2027-07-04') ); # warm cache diff --git a/t/db_dependent/Reserves/CancelExpiredReserves.t b/t/db_dependent/Reserves/CancelExpiredReserves.t index 04aaa42a67..fa37b5c2e2 100755 --- a/t/db_dependent/Reserves/CancelExpiredReserves.t +++ b/t/db_dependent/Reserves/CancelExpiredReserves.t @@ -93,7 +93,7 @@ subtest 'CancelExpiredReserves tests incl. holidays' => sub { Koha::Caches->get_instance()->flush_all(); my $holiday = $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => 'LIB1', date => $today->ymd, title => 'My holiday', description => '' } } ); @@ -286,7 +286,7 @@ subtest 'Holiday logic edge cases' => sub { # Make Wednesday a holiday (but Monday and Tuesday are business days) my $wednesday_holiday = $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => $library->branchcode, date => $wednesday->ymd, title => 'Wednesday Holiday', description => '' @@ -355,7 +355,7 @@ subtest 'Holiday logic edge cases' => sub { # Make Monday a holiday my $monday_holiday = $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => $library->branchcode, date => $monday->ymd, title => 'Monday Holiday', description => '' diff --git a/t/db_dependent/api/v1/libraries.t b/t/db_dependent/api/v1/libraries.t index a196d0732b..aa9f73559a 100755 --- a/t/db_dependent/api/v1/libraries.t +++ b/t/db_dependent/api/v1/libraries.t @@ -28,10 +28,10 @@ use t::lib::Mocks; use List::Util qw(min); use Koha::Caches; -use Koha::Calendar::WeeklyClosures; -use Koha::Calendar::RepeatingClosures; -use Koha::Calendar::SingleClosures; -use Koha::Calendar::Exceptions; +use Koha::Library::Calendar::WeeklyClosures; +use Koha::Library::Calendar::RepeatingClosures; +use Koha::Library::Calendar::SingleClosures; +use Koha::Library::Calendar::Exceptions; use Koha::Libraries; use Koha::Database; @@ -465,17 +465,17 @@ subtest 'list_closed_dates() tests' => sub { my $cache = Koha::Caches->get_instance(); # Clear all closure data so we fully control what exists - Koha::Calendar::WeeklyClosures->search( { library_id => $branchcode } )->delete; - Koha::Calendar::RepeatingClosures->search( { library_id => $branchcode } )->delete; - Koha::Calendar::SingleClosures->search( { library_id => $branchcode } )->delete; - Koha::Calendar::Exceptions->search( { library_id => $branchcode } )->delete; + Koha::Library::Calendar::WeeklyClosures->search( { library_id => $branchcode } )->delete; + Koha::Library::Calendar::RepeatingClosures->search( { library_id => $branchcode } )->delete; + Koha::Library::Calendar::SingleClosures->search( { library_id => $branchcode } )->delete; + Koha::Library::Calendar::Exceptions->search( { library_id => $branchcode } )->delete; $cache->clear_from_cache( $branchcode . '_holidays' ); # Weekly closure: Saturday (6) # 2026-06-13 and 2026-06-20 are Saturdays $builder->build_object( { - class => 'Koha::Calendar::WeeklyClosures', + class => 'Koha::Library::Calendar::WeeklyClosures', value => { library_id => $branchcode, weekday => 6, title => 'Saturdays', description => '', } @@ -485,7 +485,7 @@ subtest 'list_closed_dates() tests' => sub { # Single closure: 2026-06-15 (a Monday) $builder->build_object( { - class => 'Koha::Calendar::SingleClosures', + class => 'Koha::Library::Calendar::SingleClosures', value => { library_id => $branchcode, date => '2026-06-15', title => 'Test', description => '', } @@ -495,7 +495,7 @@ subtest 'list_closed_dates() tests' => sub { # Exception: 2026-06-20 (a Saturday — normally closed, but open this day) $builder->build_object( { - class => 'Koha::Calendar::Exceptions', + class => 'Koha::Library::Calendar::Exceptions', value => { library_id => $branchcode, date => '2026-06-20', title => 'Exception', description => '', } @@ -539,10 +539,10 @@ subtest 'list_closed_dates() tests' => sub { # Defaults work (no from/to) — fresh library with no closures at all my $lib2 = $builder->build_object( { class => 'Koha::Libraries' } ); my $branchcode2 = $lib2->branchcode; - Koha::Calendar::WeeklyClosures->search( { library_id => $branchcode2 } )->delete; - Koha::Calendar::RepeatingClosures->search( { library_id => $branchcode2 } )->delete; - Koha::Calendar::SingleClosures->search( { library_id => $branchcode2 } )->delete; - Koha::Calendar::Exceptions->search( { library_id => $branchcode2 } )->delete; + Koha::Library::Calendar::WeeklyClosures->search( { library_id => $branchcode2 } )->delete; + Koha::Library::Calendar::RepeatingClosures->search( { library_id => $branchcode2 } )->delete; + Koha::Library::Calendar::SingleClosures->search( { library_id => $branchcode2 } )->delete; + Koha::Library::Calendar::Exceptions->search( { library_id => $branchcode2 } )->delete; $cache->clear_from_cache( $branchcode2 . '_holidays' ); $t->get_ok("//$userid:$password\@/api/v1/libraries/$branchcode2/closed_dates") ->status_is(200)