Bugzilla – Attachment 102556 Details for
Bug 24159
Allow daysMode for calculating due and renewal dates to be set at the circulation rules level
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24159: Throw an exception if days_mode option is not given when needed
Bug-24159-Throw-an-exception-if-daysmode-option-is.patch (text/plain), 4.25 KB, created by
PTFS Europe Sandboxes
on 2020-04-08 11:47:46 UTC
(
hide
)
Description:
Bug 24159: Throw an exception if days_mode option is not given when needed
Filename:
MIME Type:
Creator:
PTFS Europe Sandboxes
Created:
2020-04-08 11:47:46 UTC
Size:
4.25 KB
patch
obsolete
>From f6fb5dc965ea5b7d35ab4eb0f12e69e6dde7b475 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 28 Feb 2020 13:33:13 +0100 >Subject: [PATCH] Bug 24159: Throw an exception if days_mode option is not > given when needed > >Sponsored-by: Institute of Technology Carlow > >Signed-off-by: Simon Perry <simon.perry@itcarlow.ie> >--- > Koha/Calendar.pm | 33 +++++++++++++++++++++++++++------ > Koha/CirculationRules.pm | 3 +++ > 2 files changed, 30 insertions(+), 6 deletions(-) > >diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm >index dfc358d240..6865ac75ac 100644 >--- a/Koha/Calendar.pm >+++ b/Koha/Calendar.pm >@@ -1,14 +1,14 @@ > package Koha::Calendar; >-use strict; >-use warnings; >-use 5.010; > >+use Modern::Perl; >+ >+use Carp; > use DateTime; > use DateTime::Set; > use DateTime::Duration; > use C4::Context; > use Koha::Caches; >-use Carp; >+use Koha::Exceptions; > > sub new { > my ( $classname, %options ) = @_; >@@ -47,7 +47,6 @@ sub _init { > 1; > } > >- $self->{days_mode} ||= C4::Context->preference('useDaysMode'); > $self->{test} = 0; > return; > } >@@ -137,6 +136,10 @@ sub single_holidays { > sub addDate { > my ( $self, $startdate, $add_duration, $unit ) = @_; > >+ >+ Koha::Exceptions::MissingParameter->throw("Missing mandatory option for Koha:Calendar->addDate: days_mode") >+ unless exists $self->{days_mode}; >+ > # Default to days duration (legacy support I guess) > if ( ref $add_duration ne 'DateTime::Duration' ) { > $add_duration = DateTime::Duration->new( days => $add_duration ); >@@ -165,6 +168,9 @@ sub addHours { > # If we are using the calendar behave for now as if Datedue > # was the chosen option (current intended behaviour) > >+ Koha::Exceptions::MissingParameter->throw("Missing mandatory option for Koha:Calendar->addHours: days_mode") >+ unless exists $self->{days_mode}; >+ > if ( $self->{days_mode} ne 'Days' && > $self->is_holiday($base_date) ) { > >@@ -185,7 +191,8 @@ sub addDays { > my ( $self, $startdate, $days_duration ) = @_; > my $base_date = $startdate->clone(); > >- $self->{days_mode} ||= q{}; >+ Koha::Exceptions::MissingParameter->throw("Missing mandatory option for Koha:Calendar->addDays: days_mode") >+ unless exists $self->{days_mode}; > > if ( $self->{days_mode} eq 'Calendar' ) { > # use the calendar to skip all days the library is closed >@@ -235,6 +242,9 @@ sub addDays { > sub get_push_amt { > my ( $self, $base_date) = @_; > >+ Koha::Exceptions::MissingParameter->throw("Missing mandatory option for Koha:Calendar->get_push_amt: days_mode") >+ unless exists $self->{days_mode}; >+ > my $dow = $base_date->day_of_week; > return ( > # We're using Dayweek useDaysMode option >@@ -288,6 +298,10 @@ sub is_holiday { > > sub next_open_days { > my ( $self, $dt, $to_add ) = @_; >+ >+ Koha::Exceptions::MissingParameter->throw("Missing mandatory option for Koha:Calendar->next_open_days: days_mode") >+ unless exists $self->{days_mode}; >+ > my $base_date = $dt->clone(); > > $base_date->add(days => $to_add); >@@ -300,6 +314,10 @@ sub next_open_days { > > sub prev_open_days { > my ( $self, $dt, $to_sub ) = @_; >+ >+ Koha::Exceptions::MissingParameter->throw("Missing mandatory option for Koha:Calendar->get_open_days: days_mode") >+ unless exists $self->{days_mode}; >+ > my $base_date = $dt->clone(); > > # It feels logical to be passed a positive number, though we're >@@ -323,6 +341,9 @@ sub days_forward { > my $start_dt = shift; > my $num_days = shift; > >+ Koha::Exceptions::MissingParameter->throw("Missing mandatory option for Koha:Calendar->days_forward: days_mode") >+ unless exists $self->{days_mode}; >+ > return $start_dt unless $num_days > 0; > > my $base_dt = $start_dt->clone(); >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index df68310aee..17e7674130 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -109,6 +109,9 @@ our $RULE_KINDS = { > issuelength => { > scope => [ 'branchcode', 'categorycode', 'itemtype' ], > }, >+ useDaysMode => { >+ scope => [ 'branchcode', 'categorycode', 'itemtype' ], >+ }, > lengthunit => { > scope => [ 'branchcode', 'categorycode', 'itemtype' ], > }, >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24159
:
99758
|
99759
|
99760
|
99761
|
99762
|
100608
|
100609
|
100610
|
100611
|
100612
|
100613
|
100614
|
100615
|
101053
|
101054
|
101556
|
101649
|
101698
|
102009
|
102148
|
102303
|
102554
|
102555
|
102556
|
102557
|
102558
|
102559
|
102560
|
102561
|
102562
|
102563
|
104197
|
104198
|
104199
|
104200
|
104201
|
104202
|
104203
|
104204
|
106007
|
106008
|
106013
|
106014
|
106015
|
106016
|
106017
|
106018
|
106019
|
106020
|
106021
|
106022