Bug 42310: (follow-up) Move Koha::Calendar tree under Koha::Library::Calendar
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 <tomascohen@theke.io>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
7a8a220842
commit
811d8bfd37
|
|
@ -21,7 +21,7 @@ use vars qw(@EXPORT);
|
||||||
|
|
||||||
use Carp qw( croak );
|
use Carp qw( croak );
|
||||||
use Date::Calc qw( Today );
|
use Date::Calc qw( Today );
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
|
|
||||||
use C4::Context;
|
use C4::Context;
|
||||||
use Koha::Caches;
|
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 {
|
sub insert_week_day_holiday {
|
||||||
my $self = shift @_;
|
my $self = shift @_;
|
||||||
my %options = @_;
|
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},
|
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 {
|
sub insert_day_month_holiday {
|
||||||
my $self = shift @_;
|
my $self = shift @_;
|
||||||
my %options = @_;
|
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},
|
day => $options{day}, month => $options{month}, title => $options{title},
|
||||||
description => $options{description},
|
description => $options{description},
|
||||||
|
|
@ -274,7 +274,7 @@ sub insert_single_holiday {
|
||||||
unless ($date) {
|
unless ($date) {
|
||||||
$date = sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} );
|
$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},
|
date => $date, title => $options{title}, description => $options{description},
|
||||||
}
|
}
|
||||||
|
|
@ -311,7 +311,7 @@ sub insert_exception_holiday {
|
||||||
unless ($date) {
|
unless ($date) {
|
||||||
$date = sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} );
|
$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},
|
date => $date, title => $options{title}, description => $options{description},
|
||||||
}
|
}
|
||||||
|
|
@ -337,8 +337,8 @@ sub ModWeekdayholiday {
|
||||||
my $self = shift @_;
|
my $self = shift @_;
|
||||||
my %options = @_;
|
my %options = @_;
|
||||||
my $closure =
|
my $closure =
|
||||||
Koha::Calendar::WeeklyClosures->search( { library_id => $self->{branchcode}, weekday => $options{weekday} } )
|
Koha::Library::Calendar::WeeklyClosures->search(
|
||||||
->next;
|
{ library_id => $self->{branchcode}, weekday => $options{weekday} } )->next;
|
||||||
$closure->title( $options{title} )->description( $options{description} )->store if $closure;
|
$closure->title( $options{title} )->description( $options{description} )->store if $closure;
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
@ -365,7 +365,7 @@ C<$description> The description to be update for the holiday.
|
||||||
sub ModDaymonthholiday {
|
sub ModDaymonthholiday {
|
||||||
my $self = shift @_;
|
my $self = shift @_;
|
||||||
my %options = @_;
|
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;
|
{ library_id => $self->{branchcode}, day => $options{day}, month => $options{month} } )->next;
|
||||||
$closure->title( $options{title} )->description( $options{description} )->store if $closure;
|
$closure->title( $options{title} )->description( $options{description} )->store if $closure;
|
||||||
return $self;
|
return $self;
|
||||||
|
|
@ -397,7 +397,8 @@ sub ModSingleholiday {
|
||||||
my $self = shift @_;
|
my $self = shift @_;
|
||||||
my %options = @_;
|
my %options = @_;
|
||||||
my $date = $options{date} || sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} );
|
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) {
|
if ($closure) {
|
||||||
$closure->title( $options{title} )->description( $options{description} )->store;
|
$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
|
=cut
|
||||||
|
|
||||||
sub ModExceptionholiday {
|
sub ModExceptionholiday {
|
||||||
my $self = shift @_;
|
my $self = shift @_;
|
||||||
my %options = @_;
|
my %options = @_;
|
||||||
my $date = $options{date} || sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} );
|
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 $exception =
|
||||||
|
Koha::Library::Calendar::Exceptions->search( { library_id => $self->{branchcode}, date => $date } )->next;
|
||||||
if ($exception) {
|
if ($exception) {
|
||||||
$exception->title( $options{title} )->description( $options{description} )->store;
|
$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 {
|
sub delete_holiday {
|
||||||
my $self = shift @_;
|
my $self = shift @_;
|
||||||
my %options = @_;
|
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} ) {
|
if ( $options{day} && $options{month} && $options{year} ) {
|
||||||
my $date = sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} );
|
my $date = sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} );
|
||||||
|
|
||||||
# Try single closure first
|
# 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 } );
|
$cal->delete_single_closure( { date => $date } );
|
||||||
}
|
}
|
||||||
|
|
||||||
# Also remove any exception for this 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}
|
if (
|
||||||
&& Koha::Calendar::WeeklyClosures->search( { library_id => $self->{branchcode}, weekday => $options{weekday} } )
|
defined $options{weekday}
|
||||||
->count )
|
&& Koha::Library::Calendar::WeeklyClosures->search(
|
||||||
|
{ library_id => $self->{branchcode}, weekday => $options{weekday} }
|
||||||
|
)->count
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$cal->delete_weekly_closure( { weekday => $options{weekday} } );
|
$cal->delete_weekly_closure( { weekday => $options{weekday} } );
|
||||||
} elsif (
|
} elsif (
|
||||||
$options{day}
|
$options{day}
|
||||||
&& $options{month}
|
&& $options{month}
|
||||||
&& Koha::Calendar::RepeatingClosures->search(
|
&& Koha::Library::Calendar::RepeatingClosures->search(
|
||||||
{ library_id => $self->{branchcode}, day => $options{day}, month => $options{month} }
|
{ library_id => $self->{branchcode}, day => $options{day}, month => $options{month} }
|
||||||
)->count
|
)->count
|
||||||
)
|
)
|
||||||
|
|
@ -512,7 +519,7 @@ sub delete_holiday_range {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %options = @_;
|
my %options = @_;
|
||||||
my $date = $options{date} || sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} );
|
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
|
=head2 delete_holiday_range_repeatable
|
||||||
|
|
@ -531,7 +538,7 @@ C<$month> Is month to make the date to delete.
|
||||||
sub delete_holiday_range_repeatable {
|
sub delete_holiday_range_repeatable {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %options = @_;
|
my %options = @_;
|
||||||
Koha::Calendar->new( branchcode => $self->{branchcode} )
|
Koha::Library::Calendar->new( branchcode => $self->{branchcode} )
|
||||||
->delete_repeating_closure( { day => $options{day}, month => $options{month} } );
|
->delete_repeating_closure( { day => $options{day}, month => $options{month} } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -556,7 +563,7 @@ sub delete_exception_holiday_range {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %options = @_;
|
my %options = @_;
|
||||||
my $date = $options{date} || sprintf( ISO_DATE_FORMAT, $options{year}, $options{month}, $options{day} );
|
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
|
=head2 isHoliday
|
||||||
|
|
@ -607,7 +614,7 @@ sub isHoliday {
|
||||||
|
|
||||||
sub copy_to_branch {
|
sub copy_to_branch {
|
||||||
my ( $self, $target_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;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ use Koha::AuthorisedValues;
|
||||||
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
|
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
|
||||||
use Koha::Biblioitems;
|
use Koha::Biblioitems;
|
||||||
use Koha::DateUtils qw( dt_from_string );
|
use Koha::DateUtils qw( dt_from_string );
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
use Koha::Checkouts;
|
use Koha::Checkouts;
|
||||||
use Koha::ILL::Requests;
|
use Koha::ILL::Requests;
|
||||||
use Koha::ILL::ISO18626::Requests;
|
use Koha::ILL::ISO18626::Requests;
|
||||||
|
|
@ -1612,7 +1612,7 @@ sub checkHighHolds {
|
||||||
branchcode => $branchcode,
|
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 );
|
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
|
# Use the calendar or not to calculate the debarment date
|
||||||
if ( C4::Context->preference('SuspensionsCalendar') eq 'noSuspensionsWhenClosed' ) {
|
if ( C4::Context->preference('SuspensionsCalendar') eq 'noSuspensionsWhenClosed' ) {
|
||||||
my $calendar = Koha::Calendar->new(
|
my $calendar = Koha::Library::Calendar->new(
|
||||||
branchcode => $branchcode,
|
branchcode => $branchcode,
|
||||||
days_mode => 'Calendar'
|
days_mode => 'Calendar'
|
||||||
);
|
);
|
||||||
|
|
@ -4520,7 +4520,7 @@ sub CalcDateDue {
|
||||||
} else { # days
|
} else { # days
|
||||||
$dur = DateTime::Duration->new( days => $loanlength->{$length_key} );
|
$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;
|
$datedue = $calendar->addDuration( $datedue, $dur, $loanlength->{lengthunit} ) if $dur;
|
||||||
if ( $loanlength->{lengthunit} eq 'days' ) {
|
if ( $loanlength->{lengthunit} eq 'days' ) {
|
||||||
$datedue->set_hour(23);
|
$datedue->set_hour(23);
|
||||||
|
|
@ -4558,7 +4558,7 @@ sub CalcDateDue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $daysmode ne 'Days' ) {
|
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) ) {
|
if ( $calendar->is_holiday($datedue) ) {
|
||||||
|
|
||||||
# Don't return on a closed day
|
# Don't return on a closed day
|
||||||
|
|
|
||||||
|
|
@ -1257,7 +1257,8 @@ sub load_branches_to_pull_from {
|
||||||
|
|
||||||
my $today = dt_from_string();
|
my $today = dt_from_string();
|
||||||
if ( C4::Context->preference('HoldsQueueSkipClosed') ) {
|
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;
|
return \@branches_to_use;
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,7 @@ sub get_chargeable_units {
|
||||||
|
|
||||||
if ( $unit eq 'hours' ) {
|
if ( $unit eq 'hours' ) {
|
||||||
if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) {
|
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 );
|
$charge_duration = $calendar->hours_between( $date_due, $date_returned );
|
||||||
} else {
|
} else {
|
||||||
$charge_duration = $date_returned->delta_ms($date_due);
|
$charge_duration = $date_returned->delta_ms($date_due);
|
||||||
|
|
@ -361,7 +361,7 @@ sub get_chargeable_units {
|
||||||
return $charge_duration->in_units('hours');
|
return $charge_duration->in_units('hours');
|
||||||
} else { # days
|
} else { # days
|
||||||
if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) {
|
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 );
|
$charge_duration = $calendar->days_between( $date_due, $date_returned );
|
||||||
} else {
|
} else {
|
||||||
$charge_duration = $date_returned->delta_days($date_due);
|
$charge_duration = $date_returned->delta_days($date_due);
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ use C4::Members;
|
||||||
use Koha::Account::Lines;
|
use Koha::Account::Lines;
|
||||||
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
|
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
|
||||||
use Koha::Biblios;
|
use Koha::Biblios;
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
use Koha::Cache::Memory::Lite;
|
use Koha::Cache::Memory::Lite;
|
||||||
use Koha::CirculationRules;
|
use Koha::CirculationRules;
|
||||||
use Koha::Database;
|
use Koha::Database;
|
||||||
|
|
@ -1089,7 +1089,7 @@ sub CancelExpiredReserves {
|
||||||
my $cache_key = sprintf "Calendar_CancelExpiredReserves:%s", $hold->branchcode;
|
my $cache_key = sprintf "Calendar_CancelExpiredReserves:%s", $hold->branchcode;
|
||||||
my $calendar = $cache->get_from_cache($cache_key);
|
my $calendar = $cache->get_from_cache($cache_key);
|
||||||
if ( !$calendar ) {
|
if ( !$calendar ) {
|
||||||
$calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
|
$calendar = Koha::Library::Calendar->new( branchcode => $hold->branchcode );
|
||||||
$cache->set_in_cache( $cache_key, $calendar );
|
$cache->set_in_cache( $cache_key, $calendar );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ use Modern::Perl;
|
||||||
|
|
||||||
use Carp;
|
use Carp;
|
||||||
|
|
||||||
use Koha::Calendar;
|
|
||||||
use Koha::DateUtils qw( dt_from_string );
|
use Koha::DateUtils qw( dt_from_string );
|
||||||
use Koha::Exceptions;
|
use Koha::Exceptions;
|
||||||
|
use Koha::Library::Calendar;
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ sub accumulate_rentalcharge {
|
||||||
return 0 unless $rentalcharge_increment && $rentalcharge_increment > 0;
|
return 0 unless $rentalcharge_increment && $rentalcharge_increment > 0;
|
||||||
|
|
||||||
my $duration;
|
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 ( $units eq 'hours' ) {
|
||||||
if ( $itemtype->rentalcharge_hourly_calendar ) {
|
if ( $itemtype->rentalcharge_hourly_calendar ) {
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ sub calculate_dropbox_date {
|
||||||
branchcode => $branchcode,
|
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 $today = dt_from_string;
|
||||||
my $dropbox_date = $calendar->addDuration( $today, -1 );
|
my $dropbox_date = $calendar->addDuration( $today, -1 );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ use base qw(Koha::Object);
|
||||||
use C4::Circulation qw( CanBookBeIssued AddIssue );
|
use C4::Circulation qw( CanBookBeIssued AddIssue );
|
||||||
use C4::Members::Messaging qw( GetMessagingPreferences );
|
use C4::Members::Messaging qw( GetMessagingPreferences );
|
||||||
use C4::Letters qw( GetPreparedLetter EnqueueLetter );
|
use C4::Letters qw( GetPreparedLetter EnqueueLetter );
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
use Koha::DateUtils qw( dt_from_string );
|
use Koha::DateUtils qw( dt_from_string );
|
||||||
use Koha::Patron;
|
use Koha::Patron;
|
||||||
use Koha::Library;
|
use Koha::Library;
|
||||||
|
|
@ -56,7 +56,7 @@ sub new {
|
||||||
Koha::Exceptions::CurbsidePickup::NotEnabled->throw
|
Koha::Exceptions::CurbsidePickup::NotEnabled->throw
|
||||||
unless $policy && $policy->enabled;
|
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
|
Koha::Exceptions::CurbsidePickup::LibraryIsClosed->throw
|
||||||
if $calendar->is_holiday( $params->{scheduled_pickup_datetime} );
|
if $calendar->is_holiday( $params->{scheduled_pickup_datetime} );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ use Koha::Biblios;
|
||||||
use Koha::Hold::CancellationRequests;
|
use Koha::Hold::CancellationRequests;
|
||||||
use Koha::Items;
|
use Koha::Items;
|
||||||
use Koha::Libraries;
|
use Koha::Libraries;
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
use Koha::Plugins;
|
use Koha::Plugins;
|
||||||
use Koha::ILL::ISO18626::Request;
|
use Koha::ILL::ISO18626::Request;
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ sub age {
|
||||||
my $age;
|
my $age;
|
||||||
|
|
||||||
if ($use_calendar) {
|
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 );
|
$age = $calendar->days_between( dt_from_string( $self->reservedate ), $today );
|
||||||
} else {
|
} else {
|
||||||
$age = $today->delta_days( dt_from_string( $self->reservedate ) );
|
$age = $today->delta_days( dt_from_string( $self->reservedate ) );
|
||||||
|
|
@ -428,7 +428,7 @@ sub set_waiting {
|
||||||
branchcode => $self->branchcode,
|
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 );
|
$new_expiration_date = $calendar->days_forward( dt_from_string( $self->waitingdate ), $max_pickup_delay );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package Koha::Calendar;
|
package Koha::Library::Calendar;
|
||||||
|
|
||||||
use Modern::Perl;
|
use Modern::Perl;
|
||||||
|
|
||||||
|
|
@ -11,10 +11,10 @@ use Koha::Database;
|
||||||
use Koha::DateUtils qw( dt_from_string );
|
use Koha::DateUtils qw( dt_from_string );
|
||||||
use Koha::Exceptions;
|
use Koha::Exceptions;
|
||||||
use Koha::Exceptions::Calendar;
|
use Koha::Exceptions::Calendar;
|
||||||
use Koha::Calendar::WeeklyClosures;
|
use Koha::Library::Calendar::WeeklyClosures;
|
||||||
use Koha::Calendar::RepeatingClosures;
|
use Koha::Library::Calendar::RepeatingClosures;
|
||||||
use Koha::Calendar::SingleClosures;
|
use Koha::Library::Calendar::SingleClosures;
|
||||||
use Koha::Calendar::Exceptions;
|
use Koha::Library::Calendar::Exceptions;
|
||||||
|
|
||||||
# This limit avoids an infinite loop when searching for an open day in an
|
# This limit avoids an infinite loop when searching for an open day in an
|
||||||
# always closed library
|
# always closed library
|
||||||
|
|
@ -33,7 +33,7 @@ sub new {
|
||||||
$self->{$o} = $options{$o_name};
|
$self->{$o} = $options{$o_name};
|
||||||
}
|
}
|
||||||
if ( !defined $self->{branchcode} ) {
|
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();
|
$self->_init();
|
||||||
return $self;
|
return $self;
|
||||||
|
|
@ -44,13 +44,13 @@ sub _init {
|
||||||
my $branch = $self->{branchcode};
|
my $branch = $self->{branchcode};
|
||||||
|
|
||||||
$self->{weekly_closed_days} = [ 0, 0, 0, 0, 0, 0, 0 ];
|
$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 ) {
|
while ( my $row = $weekly->next ) {
|
||||||
$self->{weekly_closed_days}->[ $row->weekday ] = 1;
|
$self->{weekly_closed_days}->[ $row->weekday ] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{day_month_closed_days} = {};
|
$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 ) {
|
while ( my $row = $repeating->next ) {
|
||||||
$self->{day_month_closed_days}->{ $row->month }->{ $row->day } = 1;
|
$self->{day_month_closed_days}->{ $row->month }->{ $row->day } = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -76,13 +76,13 @@ sub _holidays {
|
||||||
unless ($holidays) {
|
unless ($holidays) {
|
||||||
$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 ) {
|
while ( my $row = $single->next ) {
|
||||||
( my $datestring = $row->date ) =~ s/-//g;
|
( my $datestring = $row->date ) =~ s/-//g;
|
||||||
$holidays->{$datestring} = 1;
|
$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 ) {
|
while ( my $row = $exceptions->next ) {
|
||||||
( my $datestring = $row->date ) =~ s/-//g;
|
( my $datestring = $row->date ) =~ s/-//g;
|
||||||
$holidays->{$datestring} = 0;
|
$holidays->{$datestring} = 0;
|
||||||
|
|
@ -426,27 +426,27 @@ sub clear_weekly_closed_days {
|
||||||
|
|
||||||
sub add_weekly_closure {
|
sub add_weekly_closure {
|
||||||
my ( $self, $params ) = @_;
|
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 {
|
sub add_repeating_closure {
|
||||||
my ( $self, $params ) = @_;
|
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 {
|
sub add_single_closure {
|
||||||
my ( $self, $params ) = @_;
|
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 {
|
sub add_exception {
|
||||||
my ( $self, $params ) = @_;
|
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 {
|
sub delete_weekly_closure {
|
||||||
my ( $self, $params ) = @_;
|
my ( $self, $params ) = @_;
|
||||||
my $row = Koha::Calendar::WeeklyClosures->search(
|
my $row = Koha::Library::Calendar::WeeklyClosures->search(
|
||||||
{ library_id => $self->{branchcode}, weekday => $params->{weekday} },
|
{ library_id => $self->{branchcode}, weekday => $params->{weekday} },
|
||||||
{ rows => 1 }
|
{ rows => 1 }
|
||||||
)->single;
|
)->single;
|
||||||
|
|
@ -456,7 +456,7 @@ sub delete_weekly_closure {
|
||||||
|
|
||||||
sub delete_repeating_closure {
|
sub delete_repeating_closure {
|
||||||
my ( $self, $params ) = @_;
|
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} },
|
{ library_id => $self->{branchcode}, day => $params->{day}, month => $params->{month} },
|
||||||
{ rows => 1 }
|
{ rows => 1 }
|
||||||
)->single;
|
)->single;
|
||||||
|
|
@ -466,7 +466,7 @@ sub delete_repeating_closure {
|
||||||
|
|
||||||
sub delete_single_closure {
|
sub delete_single_closure {
|
||||||
my ( $self, $params ) = @_;
|
my ( $self, $params ) = @_;
|
||||||
my $row = Koha::Calendar::SingleClosures->search(
|
my $row = Koha::Library::Calendar::SingleClosures->search(
|
||||||
{ library_id => $self->{branchcode}, date => $params->{date} },
|
{ library_id => $self->{branchcode}, date => $params->{date} },
|
||||||
{ rows => 1 }
|
{ rows => 1 }
|
||||||
)->single;
|
)->single;
|
||||||
|
|
@ -476,7 +476,7 @@ sub delete_single_closure {
|
||||||
|
|
||||||
sub delete_exception {
|
sub delete_exception {
|
||||||
my ( $self, $params ) = @_;
|
my ( $self, $params ) = @_;
|
||||||
my $row = Koha::Calendar::Exceptions->search(
|
my $row = Koha::Library::Calendar::Exceptions->search(
|
||||||
{ library_id => $self->{branchcode}, date => $params->{date} },
|
{ library_id => $self->{branchcode}, date => $params->{date} },
|
||||||
{ rows => 1 }
|
{ rows => 1 }
|
||||||
)->single;
|
)->single;
|
||||||
|
|
@ -525,12 +525,12 @@ sub copy_to {
|
||||||
|
|
||||||
$schema->txn_do(
|
$schema->txn_do(
|
||||||
sub {
|
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 ) {
|
while ( my $row = $weekly->next ) {
|
||||||
next
|
next
|
||||||
if Koha::Calendar::WeeklyClosures->search(
|
if Koha::Library::Calendar::WeeklyClosures->search(
|
||||||
{ library_id => $target_branchcode, weekday => $row->weekday } )->count;
|
{ library_id => $target_branchcode, weekday => $row->weekday } )->count;
|
||||||
Koha::Calendar::WeeklyClosure->new(
|
Koha::Library::Calendar::WeeklyClosure->new(
|
||||||
{
|
{
|
||||||
library_id => $target_branchcode, weekday => $row->weekday,
|
library_id => $target_branchcode, weekday => $row->weekday,
|
||||||
title => $row->title, description => $row->description,
|
title => $row->title, description => $row->description,
|
||||||
|
|
@ -538,12 +538,12 @@ sub copy_to {
|
||||||
)->store;
|
)->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 ) {
|
while ( my $row = $repeating->next ) {
|
||||||
next
|
next
|
||||||
if Koha::Calendar::RepeatingClosures->search(
|
if Koha::Library::Calendar::RepeatingClosures->search(
|
||||||
{ library_id => $target_branchcode, day => $row->day, month => $row->month } )->count;
|
{ 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,
|
library_id => $target_branchcode, day => $row->day, month => $row->month,
|
||||||
title => $row->title, description => $row->description,
|
title => $row->title, description => $row->description,
|
||||||
|
|
@ -551,13 +551,13 @@ sub copy_to {
|
||||||
)->store;
|
)->store;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $singles = Koha::Calendar::SingleClosures->search(
|
my $singles = Koha::Library::Calendar::SingleClosures->search(
|
||||||
{ library_id => $self->{branchcode}, date => { '>=' => $today } } );
|
{ library_id => $self->{branchcode}, date => { '>=' => $today } } );
|
||||||
while ( my $row = $singles->next ) {
|
while ( my $row = $singles->next ) {
|
||||||
next
|
next
|
||||||
if Koha::Calendar::SingleClosures->search(
|
if Koha::Library::Calendar::SingleClosures->search(
|
||||||
{ library_id => $target_branchcode, date => $row->date } )->count;
|
{ library_id => $target_branchcode, date => $row->date } )->count;
|
||||||
Koha::Calendar::SingleClosure->new(
|
Koha::Library::Calendar::SingleClosure->new(
|
||||||
{
|
{
|
||||||
library_id => $target_branchcode, date => $row->date,
|
library_id => $target_branchcode, date => $row->date,
|
||||||
title => $row->title, description => $row->description,
|
title => $row->title, description => $row->description,
|
||||||
|
|
@ -566,12 +566,12 @@ sub copy_to {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $exceptions =
|
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 ) {
|
while ( my $row = $exceptions->next ) {
|
||||||
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;
|
->count;
|
||||||
Koha::Calendar::Exception->new(
|
Koha::Library::Calendar::Exception->new(
|
||||||
{
|
{
|
||||||
library_id => $target_branchcode, date => $row->date,
|
library_id => $target_branchcode, date => $row->date,
|
||||||
title => $row->title, description => $row->description,
|
title => $row->title, description => $row->description,
|
||||||
|
|
@ -595,13 +595,13 @@ __END__
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
Koha::Calendar - Object containing a branches calendar
|
Koha::Library::Calendar - Object containing a library's calendar
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=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();
|
my $dt = dt_from_string();
|
||||||
|
|
||||||
# are we open
|
# are we open
|
||||||
|
|
@ -632,7 +632,7 @@ C<YYYYMMDD> date strings. Results are cached.
|
||||||
|
|
||||||
=head2 new : Create a calendar object
|
=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
|
The option branchcode is required
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package Koha::Calendar::Exception;
|
package Koha::Library::Calendar::Exception;
|
||||||
|
|
||||||
# Copyright 2026 Theke Solutions
|
# Copyright 2026 Theke Solutions
|
||||||
#
|
#
|
||||||
|
|
@ -26,7 +26,7 @@ use base qw(Koha::Object);
|
||||||
|
|
||||||
=head1 NAME
|
=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
|
=head1 API
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package Koha::Calendar::Exceptions;
|
package Koha::Library::Calendar::Exceptions;
|
||||||
|
|
||||||
# Copyright 2026 Theke Solutions
|
# Copyright 2026 Theke Solutions
|
||||||
#
|
#
|
||||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
||||||
|
|
||||||
use Koha::Database;
|
use Koha::Database;
|
||||||
|
|
||||||
use Koha::Calendar::Exception;
|
use Koha::Library::Calendar::Exception;
|
||||||
|
|
||||||
use base qw(Koha::Objects);
|
use base qw(Koha::Objects);
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
Koha::Calendar::Exceptions - Koha closure exception Object set class
|
Koha::Library::Calendar::Exceptions - Koha closure exception Object set class
|
||||||
|
|
||||||
=head1 API
|
=head1 API
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ sub _type {
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub object_class {
|
sub object_class {
|
||||||
return 'Koha::Calendar::Exception';
|
return 'Koha::Library::Calendar::Exception';
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package Koha::Calendar::RepeatingClosure;
|
package Koha::Library::Calendar::RepeatingClosure;
|
||||||
|
|
||||||
# Copyright 2026 Theke Solutions
|
# Copyright 2026 Theke Solutions
|
||||||
#
|
#
|
||||||
|
|
@ -25,7 +25,7 @@ use base qw(Koha::Object);
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
Koha::Calendar::RepeatingClosure - Koha annual repeating closure Object class
|
Koha::Library::Calendar::RepeatingClosure - Koha annual repeating closure Object class
|
||||||
|
|
||||||
=head1 API
|
=head1 API
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package Koha::Calendar::RepeatingClosures;
|
package Koha::Library::Calendar::RepeatingClosures;
|
||||||
|
|
||||||
# Copyright 2026 Theke Solutions
|
# Copyright 2026 Theke Solutions
|
||||||
#
|
#
|
||||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
||||||
|
|
||||||
use Koha::Database;
|
use Koha::Database;
|
||||||
|
|
||||||
use Koha::Calendar::RepeatingClosure;
|
use Koha::Library::Calendar::RepeatingClosure;
|
||||||
|
|
||||||
use base qw(Koha::Objects);
|
use base qw(Koha::Objects);
|
||||||
|
|
||||||
=head1 NAME
|
=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
|
=head1 API
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ sub _type {
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub object_class {
|
sub object_class {
|
||||||
return 'Koha::Calendar::RepeatingClosure';
|
return 'Koha::Library::Calendar::RepeatingClosure';
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package Koha::Calendar::SingleClosure;
|
package Koha::Library::Calendar::SingleClosure;
|
||||||
|
|
||||||
# Copyright 2026 Theke Solutions
|
# Copyright 2026 Theke Solutions
|
||||||
#
|
#
|
||||||
|
|
@ -26,7 +26,7 @@ use base qw(Koha::Object);
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
Koha::Calendar::SingleClosure - Koha single-date closure Object class
|
Koha::Library::Calendar::SingleClosure - Koha single-date closure Object class
|
||||||
|
|
||||||
=head1 API
|
=head1 API
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package Koha::Calendar::SingleClosures;
|
package Koha::Library::Calendar::SingleClosures;
|
||||||
|
|
||||||
# Copyright 2026 Theke Solutions
|
# Copyright 2026 Theke Solutions
|
||||||
#
|
#
|
||||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
||||||
|
|
||||||
use Koha::Database;
|
use Koha::Database;
|
||||||
|
|
||||||
use Koha::Calendar::SingleClosure;
|
use Koha::Library::Calendar::SingleClosure;
|
||||||
|
|
||||||
use base qw(Koha::Objects);
|
use base qw(Koha::Objects);
|
||||||
|
|
||||||
=head1 NAME
|
=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
|
=head1 API
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ sub _type {
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub object_class {
|
sub object_class {
|
||||||
return 'Koha::Calendar::SingleClosure';
|
return 'Koha::Library::Calendar::SingleClosure';
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package Koha::Calendar::WeeklyClosure;
|
package Koha::Library::Calendar::WeeklyClosure;
|
||||||
|
|
||||||
# Copyright 2026 Theke Solutions
|
# Copyright 2026 Theke Solutions
|
||||||
#
|
#
|
||||||
|
|
@ -25,7 +25,7 @@ use base qw(Koha::Object);
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
Koha::Calendar::WeeklyClosure - Koha weekly closure Object class
|
Koha::Library::Calendar::WeeklyClosure - Koha weekly closure Object class
|
||||||
|
|
||||||
=head1 API
|
=head1 API
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package Koha::Calendar::WeeklyClosures;
|
package Koha::Library::Calendar::WeeklyClosures;
|
||||||
|
|
||||||
# Copyright 2026 Theke Solutions
|
# Copyright 2026 Theke Solutions
|
||||||
#
|
#
|
||||||
|
|
@ -21,13 +21,13 @@ use Modern::Perl;
|
||||||
|
|
||||||
use Koha::Database;
|
use Koha::Database;
|
||||||
|
|
||||||
use Koha::Calendar::WeeklyClosure;
|
use Koha::Library::Calendar::WeeklyClosure;
|
||||||
|
|
||||||
use base qw(Koha::Objects);
|
use base qw(Koha::Objects);
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
Koha::Calendar::WeeklyClosures - Koha weekly closure Object set class
|
Koha::Library::Calendar::WeeklyClosures - Koha weekly closure Object set class
|
||||||
|
|
||||||
=head1 API
|
=head1 API
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ sub _type {
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub object_class {
|
sub object_class {
|
||||||
return 'Koha::Calendar::WeeklyClosure';
|
return 'Koha::Library::Calendar::WeeklyClosure';
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
@ -1468,7 +1468,7 @@ sub has_restricting_overdues {
|
||||||
next DELAY unless $overdue_rules->{ "overdue_$i" . '_restrict' };
|
next DELAY unless $overdue_rules->{ "overdue_$i" . '_restrict' };
|
||||||
|
|
||||||
if ( C4::Context->preference('OverdueNoticeCalendar') ) {
|
if ( C4::Context->preference('OverdueNoticeCalendar') ) {
|
||||||
$calendar = Koha::Calendar->new( branchcode => $branchcode );
|
$calendar = Koha::Library::Calendar->new( branchcode => $branchcode );
|
||||||
}
|
}
|
||||||
|
|
||||||
my $days_between =
|
my $days_between =
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ use Modern::Perl;
|
||||||
|
|
||||||
use Mojo::Base 'Mojolicious::Controller';
|
use Mojo::Base 'Mojolicious::Controller';
|
||||||
use C4::Context;
|
use C4::Context;
|
||||||
use Koha::Libraries;
|
|
||||||
use Koha::Calendar;
|
|
||||||
use Koha::DateUtils qw( dt_from_string );
|
use Koha::DateUtils qw( dt_from_string );
|
||||||
|
use Koha::Libraries;
|
||||||
|
use Koha::Library::Calendar;
|
||||||
|
|
||||||
use Scalar::Util qw( blessed );
|
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 $holidays = $calendar->_holidays;
|
||||||
my $weekly = $calendar->{weekly_closed_days};
|
my $weekly = $calendar->{weekly_closed_days};
|
||||||
my $day_month = $calendar->{day_month_closed_days};
|
my $day_month = $calendar->{day_month_closed_days};
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ __PACKAGE__->belongs_to(
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub koha_objects_class {
|
sub koha_objects_class {
|
||||||
'Koha::Calendar::Exceptions';
|
'Koha::Library::Calendar::Exceptions';
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 koha_object_class
|
=head2 koha_object_class
|
||||||
|
|
@ -141,7 +141,7 @@ sub koha_objects_class {
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub koha_object_class {
|
sub koha_object_class {
|
||||||
'Koha::Calendar::Exception';
|
'Koha::Library::Calendar::Exception';
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ __PACKAGE__->belongs_to(
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub koha_objects_class {
|
sub koha_objects_class {
|
||||||
'Koha::Calendar::RepeatingClosures';
|
'Koha::Library::Calendar::RepeatingClosures';
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 koha_object_class
|
=head2 koha_object_class
|
||||||
|
|
@ -151,7 +151,7 @@ sub koha_objects_class {
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub koha_object_class {
|
sub koha_object_class {
|
||||||
'Koha::Calendar::RepeatingClosure';
|
'Koha::Library::Calendar::RepeatingClosure';
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ __PACKAGE__->belongs_to(
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub koha_objects_class {
|
sub koha_objects_class {
|
||||||
'Koha::Calendar::SingleClosures';
|
'Koha::Library::Calendar::SingleClosures';
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 koha_object_class
|
=head2 koha_object_class
|
||||||
|
|
@ -141,7 +141,7 @@ sub koha_objects_class {
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub koha_object_class {
|
sub koha_object_class {
|
||||||
'Koha::Calendar::SingleClosure';
|
'Koha::Library::Calendar::SingleClosure';
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ __PACKAGE__->belongs_to(
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub koha_objects_class {
|
sub koha_objects_class {
|
||||||
'Koha::Calendar::WeeklyClosures';
|
'Koha::Library::Calendar::WeeklyClosures';
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 koha_object_class
|
=head2 koha_object_class
|
||||||
|
|
@ -140,7 +140,7 @@ sub koha_objects_class {
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub koha_object_class {
|
sub koha_object_class {
|
||||||
'Koha::Calendar::WeeklyClosure';
|
'Koha::Library::Calendar::WeeklyClosure';
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ use C4::RotatingCollections;
|
||||||
use Koha::AuthorisedValues;
|
use Koha::AuthorisedValues;
|
||||||
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
|
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
|
||||||
use Koha::BiblioFrameworks;
|
use Koha::BiblioFrameworks;
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
use Koha::Checkouts;
|
use Koha::Checkouts;
|
||||||
use Koha::CirculationRules;
|
use Koha::CirculationRules;
|
||||||
use Koha::DateUtils qw( dt_from_string );
|
use Koha::DateUtils qw( dt_from_string );
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use Koha::Installer::Output qw(say_warning say_success say_info);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bug_number => "42310",
|
bug_number => "42310",
|
||||||
description => "Normalize calendar tables into Koha::Calendar::* schema",
|
description => "Normalize calendar tables into Koha::Library::Calendar::* schema",
|
||||||
up => sub {
|
up => sub {
|
||||||
my ($args) = @_;
|
my ($args) = @_;
|
||||||
my ( $dbh, $out ) = @$args{qw(dbh out)};
|
my ( $dbh, $out ) = @$args{qw(dbh out)};
|
||||||
|
|
|
||||||
|
|
@ -17811,7 +17811,7 @@ if ( CheckVersion($DBversion) ) {
|
||||||
|
|
||||||
$DBversion = '16.12.00.032';
|
$DBversion = '16.12.00.032';
|
||||||
if ( CheckVersion($DBversion) ) {
|
if ( CheckVersion($DBversion) ) {
|
||||||
require Koha::Calendar;
|
require Koha::Library::Calendar;
|
||||||
|
|
||||||
$dbh->do(
|
$dbh->do(
|
||||||
q{
|
q{
|
||||||
|
|
@ -17844,7 +17844,7 @@ if ( CheckVersion($DBversion) ) {
|
||||||
|
|
||||||
my $expirationdate = dt_from_string( $hold->{waitingdate} );
|
my $expirationdate = dt_from_string( $hold->{waitingdate} );
|
||||||
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
|
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
|
||||||
my $calendar = Koha::Calendar->new(
|
my $calendar = Koha::Library::Calendar->new(
|
||||||
branchcode => $hold->{branchcode},
|
branchcode => $hold->{branchcode},
|
||||||
days_mode => C4::Context->preference('useDaysMode')
|
days_mode => C4::Context->preference('useDaysMode')
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ use Carp qw( carp croak );
|
||||||
use File::Spec;
|
use File::Spec;
|
||||||
use Try::Tiny qw( catch try );
|
use Try::Tiny qw( catch try );
|
||||||
|
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
use Koha::DateUtils qw( dt_from_string output_pref );
|
use Koha::DateUtils qw( dt_from_string output_pref );
|
||||||
use Koha::Patrons;
|
use Koha::Patrons;
|
||||||
use C4::Log qw( cronlogaction );
|
use C4::Log qw( cronlogaction );
|
||||||
|
|
@ -212,7 +212,7 @@ EOM
|
||||||
sub set_holiday {
|
sub set_holiday {
|
||||||
my ( $branch, $dt ) = @_;
|
my ( $branch, $dt ) = @_;
|
||||||
|
|
||||||
my $calendar = Koha::Calendar->new( branchcode => $branch );
|
my $calendar = Koha::Library::Calendar->new( branchcode => $branch );
|
||||||
return $calendar->is_holiday($dt);
|
return $calendar->is_holiday($dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ use Pod::Usage qw( pod2usage );
|
||||||
use Koha::Script -cron;
|
use Koha::Script -cron;
|
||||||
use C4::Reserves;
|
use C4::Reserves;
|
||||||
use Koha::Holds;
|
use Koha::Holds;
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
use Koha::Libraries;
|
use Koha::Libraries;
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ use DateTime::Duration;
|
||||||
use C4::Context;
|
use C4::Context;
|
||||||
use C4::Letters;
|
use C4::Letters;
|
||||||
use Koha::DateUtils qw( dt_from_string );
|
use Koha::DateUtils qw( dt_from_string );
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
use Koha::Libraries;
|
use Koha::Libraries;
|
||||||
use Koha::Notice::Templates;
|
use Koha::Notice::Templates;
|
||||||
use Koha::Patrons;
|
use Koha::Patrons;
|
||||||
|
|
@ -237,7 +237,7 @@ foreach my $branchcode (@branchcodes) { #BEGIN BRANCH LOOP
|
||||||
# If respecting calendar get the correct waiting since date
|
# If respecting calendar get the correct waiting since date
|
||||||
my $waiting_date;
|
my $waiting_date;
|
||||||
if ($use_calendar) {
|
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
|
#if today is a holiday skip sending the message
|
||||||
next if $calendar->is_holiday($date_to_run);
|
next if $calendar->is_holiday($date_to_run);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ use C4::Overdues qw( parse_overdues_letter );
|
||||||
use C4::Log qw( cronlogaction );
|
use C4::Log qw( cronlogaction );
|
||||||
use Koha::Patron::Debarments qw( AddUniqueDebarment );
|
use Koha::Patron::Debarments qw( AddUniqueDebarment );
|
||||||
use Koha::DateUtils qw( dt_from_string output_pref );
|
use Koha::DateUtils qw( dt_from_string output_pref );
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
use Koha::Libraries;
|
use Koha::Libraries;
|
||||||
use Koha::Acquisition::Currencies;
|
use Koha::Acquisition::Currencies;
|
||||||
use Koha::Patrons;
|
use Koha::Patrons;
|
||||||
|
|
@ -521,7 +521,7 @@ my @output_chunks;
|
||||||
foreach my $branchcode (@branches) {
|
foreach my $branchcode (@branches) {
|
||||||
my $calendar;
|
my $calendar;
|
||||||
if ( C4::Context->preference('OverdueNoticeCalendar') ) {
|
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) ) {
|
if ( $calendar->is_holiday($date_to_run) ) {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ use Koha::Script -cron;
|
||||||
use C4::Context;
|
use C4::Context;
|
||||||
use C4::Letters;
|
use C4::Letters;
|
||||||
use C4::Overdues;
|
use C4::Overdues;
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
use Koha::DateUtils qw( dt_from_string output_pref );
|
use Koha::DateUtils qw( dt_from_string output_pref );
|
||||||
use Koha::Patrons;
|
use Koha::Patrons;
|
||||||
use Koha::Libraries;
|
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' );
|
my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ use t::lib::TestBuilder;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use DateTime::Duration;
|
use DateTime::Duration;
|
||||||
use Koha::Caches;
|
use Koha::Caches;
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
use Koha::Database;
|
use Koha::Database;
|
||||||
use Koha::DateUtils qw( dt_from_string );
|
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 $mpl = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode;
|
||||||
my $cpl = $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::Library::Calendar::WeeklyClosures->search( { library_id => [ $mpl, $cpl ] } )->delete;
|
||||||
Koha::Calendar::RepeatingClosures->search( { library_id => [ $mpl, $cpl ] } )->delete;
|
Koha::Library::Calendar::RepeatingClosures->search( { library_id => [ $mpl, $cpl ] } )->delete;
|
||||||
Koha::Calendar::SingleClosures->search( { library_id => [ $mpl, $cpl ] } )->delete;
|
Koha::Library::Calendar::SingleClosures->search( { library_id => [ $mpl, $cpl ] } )->delete;
|
||||||
Koha::Calendar::Exceptions->search( { library_id => [ $mpl, $cpl ] } )->delete;
|
Koha::Library::Calendar::Exceptions->search( { library_id => [ $mpl, $cpl ] } )->delete;
|
||||||
|
|
||||||
# Weekly closures
|
# Weekly closures
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::WeeklyClosures',
|
class => 'Koha::Library::Calendar::WeeklyClosures',
|
||||||
value => { library_id => $mpl, weekday => 0, title => '', description => '' }
|
value => { library_id => $mpl, weekday => 0, title => '', description => '' }
|
||||||
}
|
}
|
||||||
); # sundays
|
); # sundays
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::WeeklyClosures',
|
class => 'Koha::Library::Calendar::WeeklyClosures',
|
||||||
value => { library_id => $mpl, weekday => 6, title => '', description => '' }
|
value => { library_id => $mpl, weekday => 6, title => '', description => '' }
|
||||||
}
|
}
|
||||||
); # saturdays
|
); # saturdays
|
||||||
|
|
@ -79,13 +79,13 @@ subtest 'Original tests from t' => sub {
|
||||||
# Repeating annual closures
|
# Repeating annual closures
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::RepeatingClosures',
|
class => 'Koha::Library::Calendar::RepeatingClosures',
|
||||||
value => { library_id => $mpl, day => 1, month => 1, title => '', description => '' }
|
value => { library_id => $mpl, day => 1, month => 1, title => '', description => '' }
|
||||||
}
|
}
|
||||||
); # new year
|
); # new year
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::RepeatingClosures',
|
class => 'Koha::Library::Calendar::RepeatingClosures',
|
||||||
value => { library_id => $mpl, day => 25, month => 12, title => '', description => '' }
|
value => { library_id => $mpl, day => 25, month => 12, title => '', description => '' }
|
||||||
}
|
}
|
||||||
); # christmas
|
); # christmas
|
||||||
|
|
@ -93,25 +93,25 @@ subtest 'Original tests from t' => sub {
|
||||||
# Single closures
|
# Single closures
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value => { library_id => $mpl, date => '2011-06-01', title => '', description => '' }
|
value => { library_id => $mpl, date => '2011-06-01', title => '', description => '' }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value => { library_id => $mpl, date => '2012-07-04', title => '', description => '' }
|
value => { library_id => $mpl, date => '2012-07-04', title => '', description => '' }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value => { library_id => $cpl, date => '2012-08-06', title => '', description => '' }
|
value => { library_id => $cpl, date => '2012-08-06', title => '', description => '' }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value => { library_id => $mpl, date => '2012-07-07', title => '', description => '' }
|
value => { library_id => $mpl, date => '2012-07-07', title => '', description => '' }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -119,13 +119,13 @@ subtest 'Original tests from t' => sub {
|
||||||
# Exceptions (open overrides)
|
# Exceptions (open overrides)
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::Exceptions',
|
class => 'Koha::Library::Calendar::Exceptions',
|
||||||
value => { library_id => $mpl, date => '2012-11-11', title => '', description => '' }
|
value => { library_id => $mpl, date => '2012-11-11', title => '', description => '' }
|
||||||
}
|
}
|
||||||
); # sunday exception
|
); # sunday exception
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::Exceptions',
|
class => 'Koha::Library::Calendar::Exceptions',
|
||||||
value => { library_id => $mpl, date => '2012-07-07', title => '', description => '' }
|
value => { library_id => $mpl, date => '2012-07-07', title => '', description => '' }
|
||||||
}
|
}
|
||||||
); # holiday exception
|
); # holiday exception
|
||||||
|
|
@ -135,9 +135,9 @@ subtest 'Original tests from t' => sub {
|
||||||
$cache->clear_from_cache( $cpl . '_holidays' );
|
$cache->clear_from_cache( $cpl . '_holidays' );
|
||||||
|
|
||||||
# $mpl branch is arbitrary, is not used at all but is needed for initialization
|
# $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(
|
my $saturday = DateTime->new(
|
||||||
year => 2012,
|
year => 2012,
|
||||||
|
|
@ -272,7 +272,7 @@ subtest 'Original tests from t' => sub {
|
||||||
|
|
||||||
{ ## 'Datedue' tests
|
{ ## 'Datedue' tests
|
||||||
|
|
||||||
$cal = Koha::Calendar->new( branchcode => $mpl, days_mode => 'Datedue' );
|
$cal = Koha::Library::Calendar->new( branchcode => $mpl, days_mode => 'Datedue' );
|
||||||
|
|
||||||
is(
|
is(
|
||||||
$cal->addDuration( $dt, $one_day_dur, 'days' ), # tuesday
|
$cal->addDuration( $dt, $one_day_dur, 'days' ), # tuesday
|
||||||
|
|
@ -317,7 +317,7 @@ subtest 'Original tests from t' => sub {
|
||||||
|
|
||||||
{ ## 'Calendar' tests'
|
{ ## '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' );
|
$dt = dt_from_string( '2012-07-03', 'iso' );
|
||||||
|
|
||||||
|
|
@ -356,7 +356,7 @@ subtest 'Original tests from t' => sub {
|
||||||
|
|
||||||
{ ## 'Days' tests
|
{ ## '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' );
|
$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($single_holiday), 0, 'Single holiday for MPL, not CPL' );
|
||||||
is(
|
is(
|
||||||
$cal->is_holiday($holiday_for_another_branch), 1,
|
$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' );
|
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| );
|
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 $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(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value =>
|
value =>
|
||||||
{ library_id => $library->branchcode, date => $holiday_dt->ymd, title => 'My holiday', description => '' }
|
{ 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;
|
plan tests => 2;
|
||||||
|
|
||||||
my $library = $builder->build_object( { class => 'Koha::Libraries' } );
|
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 {
|
subtest 'Same hours' => sub {
|
||||||
|
|
||||||
|
|
@ -568,14 +568,14 @@ subtest 'hours_between | days_between' => sub {
|
||||||
# Wednesdays are closed
|
# Wednesdays are closed
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::WeeklyClosures',
|
class => 'Koha::Library::Calendar::WeeklyClosures',
|
||||||
value => {
|
value => {
|
||||||
library_id => $library->branchcode, weekday => 3, title => 'Closed on Wednesday', description => '',
|
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 {
|
subtest 'Same hours' => sub {
|
||||||
plan tests => 12;
|
plan tests => 12;
|
||||||
|
|
@ -719,7 +719,7 @@ subtest 'is_holiday' => sub {
|
||||||
# Closed this day of the week
|
# Closed this day of the week
|
||||||
my $closure = $builder->build_object(
|
my $closure = $builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::WeeklyClosures',
|
class => 'Koha::Library::Calendar::WeeklyClosures',
|
||||||
value => {
|
value => {
|
||||||
library_id => $library->branchcode, weekday => $dow, title => 'TEST', description => '',
|
library_id => $library->branchcode, weekday => $dow, title => 'TEST', description => '',
|
||||||
}
|
}
|
||||||
|
|
@ -728,7 +728,7 @@ subtest 'is_holiday' => sub {
|
||||||
|
|
||||||
# Iterate 7 days
|
# Iterate 7 days
|
||||||
for my $i ( 0 .. 6 ) {
|
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" );
|
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
|
# Closed this day of the week
|
||||||
my $closure = $builder->build_object(
|
my $closure = $builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::WeeklyClosures',
|
class => 'Koha::Library::Calendar::WeeklyClosures',
|
||||||
value => {
|
value => {
|
||||||
library_id => $library->branchcode, weekday => $dow, title => 'TEST', description => '',
|
library_id => $library->branchcode, weekday => $dow, title => 'TEST', description => '',
|
||||||
}
|
}
|
||||||
|
|
@ -767,7 +767,7 @@ subtest 'get_push_amt' => sub {
|
||||||
|
|
||||||
# Iterate 7 days
|
# Iterate 7 days
|
||||||
for my $i ( 0 .. 6 ) {
|
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;
|
my $npa;
|
||||||
eval {
|
eval {
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ $special_holiday1_dt->add( days => 2 );
|
||||||
|
|
||||||
my $holiday = $builder->build_object(
|
my $holiday = $builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value => {
|
value => {
|
||||||
library_id => 'LIB1', date => $special_holiday1_dt->ymd, title => 'My special holiday', description => ''
|
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(
|
my $holiday2 = $builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value => {
|
value => {
|
||||||
library_id => 'LIB1', date => $special_holiday2_dt->ymd, title => 'My special holiday 2', description => ''
|
library_id => 'LIB1', date => $special_holiday2_dt->ymd, title => 'My special holiday 2', description => ''
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
# 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.
|
# the holiday will get set in cache correctly, but not if we let C4::HoldsQueue call is_holiday instead.
|
||||||
is(
|
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'
|
'Is today a holiday for pickup branch'
|
||||||
);
|
);
|
||||||
C4::HoldsQueue::CreateQueue();
|
C4::HoldsQueue::CreateQueue();
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ use Koha::Database;
|
||||||
use Koha::DateUtils qw( dt_from_string );
|
use Koha::DateUtils qw( dt_from_string );
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
use_ok('Koha::Calendar');
|
use_ok('Koha::Library::Calendar');
|
||||||
use_ok('C4::Calendar');
|
use_ok('C4::Calendar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ subtest 'is_holiday timezone tests' => sub {
|
||||||
tzset;
|
tzset;
|
||||||
|
|
||||||
my $branch = $builder->build( { source => 'Branch' } )->{branchcode};
|
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(
|
C4::Calendar->new( branchcode => $branch )->insert_exception_holiday(
|
||||||
day => 6,
|
day => 6,
|
||||||
|
|
@ -109,11 +109,11 @@ C4::Calendar->new( branchcode => $branch_1 )->insert_day_month_holiday(
|
||||||
description => 'Christmas',
|
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 );
|
my $c4_calendar = C4::Calendar->new( branchcode => $branch_1 );
|
||||||
|
|
||||||
isa_ok( $koha_calendar, 'Koha::Calendar', 'Koha::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' );
|
isa_ok( $c4_calendar, 'C4::Calendar', 'C4::Calendar class returned' );
|
||||||
|
|
||||||
my $sunday = DateTime->new(
|
my $sunday = DateTime->new(
|
||||||
year => 2011,
|
year => 2011,
|
||||||
|
|
@ -159,8 +159,14 @@ C4::Calendar->new( branchcode => $branch_2 )->insert_single_holiday(
|
||||||
description => "$today",
|
description => "$today",
|
||||||
);
|
);
|
||||||
|
|
||||||
is( Koha::Calendar->new( branchcode => $branch_2 )->is_holiday($today), 1, "Today is a holiday for $branch_2" );
|
is(
|
||||||
is( Koha::Calendar->new( branchcode => $branch_1 )->is_holiday($today), 0, "Today is not a holiday for $branch_1" );
|
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;
|
$schema->storage->txn_rollback;
|
||||||
|
|
||||||
|
|
@ -303,12 +309,12 @@ subtest 'with a library that is never open' => sub {
|
||||||
my $now = dt_from_string;
|
my $now = dt_from_string;
|
||||||
|
|
||||||
subtest 'next_open_days should throw an exception' => sub {
|
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';
|
throws_ok { $kcalendar->next_open_days( $now, 1 ) } 'Koha::Exceptions::Calendar::NoOpenDays';
|
||||||
};
|
};
|
||||||
|
|
||||||
subtest 'prev_open_days should throw an exception' => sub {
|
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';
|
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 => '' );
|
$calendar->insert_exception_holiday( date => $open_day_in_the_past->ymd, title => '', description => '' );
|
||||||
|
|
||||||
subtest 'next_open_days should find the open day' => sub {
|
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 );
|
my $next_open_day = $kcalendar->next_open_days( $now, 1 );
|
||||||
is( $next_open_day->ymd, $open_day_in_the_future->ymd );
|
is( $next_open_day->ymd, $open_day_in_the_future->ymd );
|
||||||
};
|
};
|
||||||
|
|
||||||
subtest 'prev_open_days should find the open day' => sub {
|
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 );
|
my $prev_open_day = $kcalendar->prev_open_days( $now, 1 );
|
||||||
is( $prev_open_day->ymd, $open_day_in_the_past->ymd );
|
is( $prev_open_day->ymd, $open_day_in_the_past->ymd );
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ use Test::Exception;
|
||||||
use C4::Calendar;
|
use C4::Calendar;
|
||||||
use Koha::CurbsidePickups;
|
use Koha::CurbsidePickups;
|
||||||
use Koha::CurbsidePickupPolicies;
|
use Koha::CurbsidePickupPolicies;
|
||||||
use Koha::Calendar;
|
use Koha::Library::Calendar;
|
||||||
use Koha::Database;
|
use Koha::Database;
|
||||||
use Koha::DateUtils qw( dt_from_string );
|
use Koha::DateUtils qw( dt_from_string );
|
||||||
|
|
||||||
|
|
@ -157,7 +157,7 @@ subtest 'Create a pickup' => sub {
|
||||||
title => '',
|
title => '',
|
||||||
description => 'Mondays',
|
description => 'Mondays',
|
||||||
);
|
);
|
||||||
my $calendar = Koha::Calendar->new( branchcode => $library->branchcode );
|
my $calendar = Koha::Library::Calendar->new( branchcode => $library->branchcode );
|
||||||
throws_ok {
|
throws_ok {
|
||||||
Koha::CurbsidePickup->new( { %$params, scheduled_pickup_datetime => $schedule_dt } )->store;
|
Koha::CurbsidePickup->new( { %$params, scheduled_pickup_datetime => $schedule_dt } )->store;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,14 @@ use Test::NoWarnings;
|
||||||
use Koha::Caches;
|
use Koha::Caches;
|
||||||
use Koha::Database;
|
use Koha::Database;
|
||||||
use Koha::DateUtils qw( dt_from_string );
|
use Koha::DateUtils qw( dt_from_string );
|
||||||
use Koha::Calendar::WeeklyClosures;
|
use Koha::Library::Calendar::WeeklyClosures;
|
||||||
use Koha::Calendar::RepeatingClosures;
|
use Koha::Library::Calendar::RepeatingClosures;
|
||||||
use Koha::Calendar::SingleClosures;
|
use Koha::Library::Calendar::SingleClosures;
|
||||||
use Koha::Calendar::Exceptions;
|
use Koha::Library::Calendar::Exceptions;
|
||||||
use t::lib::TestBuilder;
|
use t::lib::TestBuilder;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
use_ok('Koha::Calendar');
|
use_ok('Koha::Library::Calendar');
|
||||||
}
|
}
|
||||||
|
|
||||||
my $schema = Koha::Database->schema;
|
my $schema = Koha::Database->schema;
|
||||||
|
|
@ -60,7 +60,7 @@ subtest 'has_business_days_between' => sub {
|
||||||
# Make Wednesday a holiday
|
# Make Wednesday a holiday
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value =>
|
value =>
|
||||||
{ library_id => $branchcode, date => $wednesday->ymd, title => 'Wednesday Holiday', description => '' }
|
{ 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)
|
# Make Saturday and Sunday holidays (weekend)
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value =>
|
value =>
|
||||||
{ library_id => $branchcode, date => $saturday->ymd, title => 'Saturday Holiday', description => '' }
|
{ library_id => $branchcode, date => $saturday->ymd, title => 'Saturday Holiday', description => '' }
|
||||||
}
|
}
|
||||||
|
|
@ -77,12 +77,12 @@ subtest 'has_business_days_between' => sub {
|
||||||
|
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value => { library_id => $branchcode, date => $sunday->ymd, title => 'Sunday Holiday', description => '' }
|
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
|
# Test 1: Business day between two business days
|
||||||
is(
|
is(
|
||||||
|
|
@ -130,40 +130,40 @@ subtest 'CRUD methods' => sub {
|
||||||
$schema->storage->txn_begin;
|
$schema->storage->txn_begin;
|
||||||
|
|
||||||
my $library = $builder->build_object( { class => 'Koha::Libraries' } );
|
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
|
# add_weekly_closure
|
||||||
my $weekly = $calendar->add_weekly_closure( { weekday => 0, title => 'Sundays', description => 'Closed' } );
|
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(
|
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'
|
'Weekly closure created'
|
||||||
);
|
);
|
||||||
|
|
||||||
# add_repeating_closure
|
# add_repeating_closure
|
||||||
my $repeating =
|
my $repeating =
|
||||||
$calendar->add_repeating_closure( { day => 25, month => 12, title => 'Christmas', description => '' } );
|
$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(
|
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'
|
'Repeating closure created'
|
||||||
);
|
);
|
||||||
|
|
||||||
# add_single_closure
|
# add_single_closure
|
||||||
my $single = $calendar->add_single_closure( { date => '2026-06-15', title => 'Staff day', description => '' } );
|
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(
|
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'
|
'Single closure created'
|
||||||
);
|
);
|
||||||
|
|
||||||
# add_exception
|
# add_exception
|
||||||
my $exception = $calendar->add_exception( { date => '2026-12-25', title => 'Special opening', description => '' } );
|
my $exception = $calendar->add_exception( { date => '2026-12-25', title => 'Special opening', description => '' } );
|
||||||
isa_ok( $exception, 'Koha::Calendar::Exception', 'add_exception returns object' );
|
isa_ok( $exception, 'Koha::Library::Calendar::Exception', 'add_exception returns object' );
|
||||||
is( Koha::Calendar::Exceptions->search( { library_id => $library->branchcode } )->count, 1, 'Exception created' );
|
is( Koha::Library::Calendar::Exceptions->search( { library_id => $library->branchcode } )->count, 1, 'Exception created' );
|
||||||
|
|
||||||
# Verify is_holiday uses the new data
|
# 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
|
my $sunday = dt_from_string('2026-06-14'); # a Sunday
|
||||||
is( $cal->is_holiday($sunday), 1, 'Sunday is closed after add_weekly_closure' );
|
is( $cal->is_holiday($sunday), 1, 'Sunday is closed after add_weekly_closure' );
|
||||||
|
|
||||||
|
|
@ -176,24 +176,24 @@ subtest 'CRUD methods' => sub {
|
||||||
# delete methods
|
# delete methods
|
||||||
$calendar->delete_weekly_closure( { weekday => 0 } );
|
$calendar->delete_weekly_closure( { weekday => 0 } );
|
||||||
is(
|
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'
|
'Weekly closure deleted'
|
||||||
);
|
);
|
||||||
|
|
||||||
$calendar->delete_repeating_closure( { day => 25, month => 12 } );
|
$calendar->delete_repeating_closure( { day => 25, month => 12 } );
|
||||||
is(
|
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'
|
'Repeating closure deleted'
|
||||||
);
|
);
|
||||||
|
|
||||||
$calendar->delete_single_closure( { date => '2026-06-15' } );
|
$calendar->delete_single_closure( { date => '2026-06-15' } );
|
||||||
is(
|
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'
|
'Single closure deleted'
|
||||||
);
|
);
|
||||||
|
|
||||||
$calendar->delete_exception( { date => '2026-12-25' } );
|
$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
|
# copy_to
|
||||||
$calendar->add_weekly_closure( { weekday => 6, title => 'Saturdays', description => '' } );
|
$calendar->add_weekly_closure( { weekday => 6, title => 'Saturdays', description => '' } );
|
||||||
|
|
@ -203,27 +203,27 @@ subtest 'CRUD methods' => sub {
|
||||||
$calendar->copy_to( $library2->branchcode );
|
$calendar->copy_to( $library2->branchcode );
|
||||||
|
|
||||||
is(
|
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'
|
'Weekly closure copied'
|
||||||
);
|
);
|
||||||
is(
|
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'
|
'Single closure copied'
|
||||||
);
|
);
|
||||||
|
|
||||||
# copy_to should not duplicate
|
# copy_to should not duplicate
|
||||||
$calendar->copy_to( $library2->branchcode );
|
$calendar->copy_to( $library2->branchcode );
|
||||||
is(
|
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'
|
'No duplicate after second copy'
|
||||||
);
|
);
|
||||||
is(
|
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'
|
'No duplicate single after second copy'
|
||||||
);
|
);
|
||||||
|
|
||||||
# Verify is_holiday after deletions and re-init
|
# 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' );
|
is( $cal2->is_holiday($june15), 0, 'Deleted single closure no longer a holiday' );
|
||||||
|
|
||||||
$schema->storage->txn_rollback;
|
$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,
|
# Sunday closed every week, 25 December every year, 2026-06-15 single,
|
||||||
# 2026-12-25 open exception (overrides the repeating rule).
|
# 2026-12-25 open exception (overrides the repeating rule).
|
||||||
$builder->build_object(
|
$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(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::RepeatingClosures',
|
class => 'Koha::Library::Calendar::RepeatingClosures',
|
||||||
value => { library_id => $branchcode, day => 25, month => 12 }
|
value => { library_id => $branchcode, day => 25, month => 12 }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$builder->build_object(
|
$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(
|
$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') );
|
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' );
|
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_key = $branchcode . '_holidays';
|
||||||
my $cache = Koha::Caches->get_instance;
|
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->add_single_closure( { date => '2027-07-04', title => 'Independence', description => '' } );
|
||||||
$calendar->is_holiday( dt_from_string('2027-07-04') ); # warm cache
|
$calendar->is_holiday( dt_from_string('2027-07-04') ); # warm cache
|
||||||
|
|
@ -93,7 +93,7 @@ subtest 'CancelExpiredReserves tests incl. holidays' => sub {
|
||||||
Koha::Caches->get_instance()->flush_all();
|
Koha::Caches->get_instance()->flush_all();
|
||||||
my $holiday = $builder->build_object(
|
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 => '' }
|
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)
|
# Make Wednesday a holiday (but Monday and Tuesday are business days)
|
||||||
my $wednesday_holiday = $builder->build_object(
|
my $wednesday_holiday = $builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value => {
|
value => {
|
||||||
library_id => $library->branchcode, date => $wednesday->ymd, title => 'Wednesday Holiday',
|
library_id => $library->branchcode, date => $wednesday->ymd, title => 'Wednesday Holiday',
|
||||||
description => ''
|
description => ''
|
||||||
|
|
@ -355,7 +355,7 @@ subtest 'Holiday logic edge cases' => sub {
|
||||||
# Make Monday a holiday
|
# Make Monday a holiday
|
||||||
my $monday_holiday = $builder->build_object(
|
my $monday_holiday = $builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value => {
|
value => {
|
||||||
library_id => $library->branchcode, date => $monday->ymd, title => 'Monday Holiday',
|
library_id => $library->branchcode, date => $monday->ymd, title => 'Monday Holiday',
|
||||||
description => ''
|
description => ''
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,10 @@ use t::lib::Mocks;
|
||||||
use List::Util qw(min);
|
use List::Util qw(min);
|
||||||
|
|
||||||
use Koha::Caches;
|
use Koha::Caches;
|
||||||
use Koha::Calendar::WeeklyClosures;
|
use Koha::Library::Calendar::WeeklyClosures;
|
||||||
use Koha::Calendar::RepeatingClosures;
|
use Koha::Library::Calendar::RepeatingClosures;
|
||||||
use Koha::Calendar::SingleClosures;
|
use Koha::Library::Calendar::SingleClosures;
|
||||||
use Koha::Calendar::Exceptions;
|
use Koha::Library::Calendar::Exceptions;
|
||||||
use Koha::Libraries;
|
use Koha::Libraries;
|
||||||
use Koha::Database;
|
use Koha::Database;
|
||||||
|
|
||||||
|
|
@ -465,17 +465,17 @@ subtest 'list_closed_dates() tests' => sub {
|
||||||
my $cache = Koha::Caches->get_instance();
|
my $cache = Koha::Caches->get_instance();
|
||||||
|
|
||||||
# Clear all closure data so we fully control what exists
|
# Clear all closure data so we fully control what exists
|
||||||
Koha::Calendar::WeeklyClosures->search( { library_id => $branchcode } )->delete;
|
Koha::Library::Calendar::WeeklyClosures->search( { library_id => $branchcode } )->delete;
|
||||||
Koha::Calendar::RepeatingClosures->search( { library_id => $branchcode } )->delete;
|
Koha::Library::Calendar::RepeatingClosures->search( { library_id => $branchcode } )->delete;
|
||||||
Koha::Calendar::SingleClosures->search( { library_id => $branchcode } )->delete;
|
Koha::Library::Calendar::SingleClosures->search( { library_id => $branchcode } )->delete;
|
||||||
Koha::Calendar::Exceptions->search( { library_id => $branchcode } )->delete;
|
Koha::Library::Calendar::Exceptions->search( { library_id => $branchcode } )->delete;
|
||||||
$cache->clear_from_cache( $branchcode . '_holidays' );
|
$cache->clear_from_cache( $branchcode . '_holidays' );
|
||||||
|
|
||||||
# Weekly closure: Saturday (6)
|
# Weekly closure: Saturday (6)
|
||||||
# 2026-06-13 and 2026-06-20 are Saturdays
|
# 2026-06-13 and 2026-06-20 are Saturdays
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::WeeklyClosures',
|
class => 'Koha::Library::Calendar::WeeklyClosures',
|
||||||
value => {
|
value => {
|
||||||
library_id => $branchcode, weekday => 6, title => 'Saturdays', description => '',
|
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)
|
# Single closure: 2026-06-15 (a Monday)
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::SingleClosures',
|
class => 'Koha::Library::Calendar::SingleClosures',
|
||||||
value => {
|
value => {
|
||||||
library_id => $branchcode, date => '2026-06-15', title => 'Test', description => '',
|
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)
|
# Exception: 2026-06-20 (a Saturday — normally closed, but open this day)
|
||||||
$builder->build_object(
|
$builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Calendar::Exceptions',
|
class => 'Koha::Library::Calendar::Exceptions',
|
||||||
value => {
|
value => {
|
||||||
library_id => $branchcode, date => '2026-06-20', title => 'Exception', description => '',
|
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
|
# Defaults work (no from/to) — fresh library with no closures at all
|
||||||
my $lib2 = $builder->build_object( { class => 'Koha::Libraries' } );
|
my $lib2 = $builder->build_object( { class => 'Koha::Libraries' } );
|
||||||
my $branchcode2 = $lib2->branchcode;
|
my $branchcode2 = $lib2->branchcode;
|
||||||
Koha::Calendar::WeeklyClosures->search( { library_id => $branchcode2 } )->delete;
|
Koha::Library::Calendar::WeeklyClosures->search( { library_id => $branchcode2 } )->delete;
|
||||||
Koha::Calendar::RepeatingClosures->search( { library_id => $branchcode2 } )->delete;
|
Koha::Library::Calendar::RepeatingClosures->search( { library_id => $branchcode2 } )->delete;
|
||||||
Koha::Calendar::SingleClosures->search( { library_id => $branchcode2 } )->delete;
|
Koha::Library::Calendar::SingleClosures->search( { library_id => $branchcode2 } )->delete;
|
||||||
Koha::Calendar::Exceptions->search( { library_id => $branchcode2 } )->delete;
|
Koha::Library::Calendar::Exceptions->search( { library_id => $branchcode2 } )->delete;
|
||||||
$cache->clear_from_cache( $branchcode2 . '_holidays' );
|
$cache->clear_from_cache( $branchcode2 . '_holidays' );
|
||||||
$t->get_ok("//$userid:$password\@/api/v1/libraries/$branchcode2/closed_dates")
|
$t->get_ok("//$userid:$password\@/api/v1/libraries/$branchcode2/closed_dates")
|
||||||
->status_is(200)
|
->status_is(200)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue