Bugzilla – Attachment 94882 Details for
Bug 15260
Option for extended loan with useDaysMode
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15260: Modify next/prev_open_day
Bug-15260-Modify-nextprevopenday.patch (text/plain), 6.51 KB, created by
Josef Moravec
on 2019-10-30 18:33:55 UTC
(
hide
)
Description:
Bug 15260: Modify next/prev_open_day
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2019-10-30 18:33:55 UTC
Size:
6.51 KB
patch
obsolete
>From 62d7767c0b24a1cafd271e141851e0080dcfc1b7 Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Fri, 1 Feb 2019 12:24:54 +0000 >Subject: [PATCH] Bug 15260: Modify next/prev_open_day > >We require next_open_day & prev_open_day to be more flexible. We could >create a separate sub, but that's not very DRY given that they'll do >pretty much the same thing. > >So next_open_day becomes next_open_days and prev_open_day becomes >prev_open_days and both functions accept an additional parameter which >determines how many days they add or subtract. > >All calls of these two functions have been modified accordingly. > >Sponsored-by: Cheshire West and Chester and Cheshire East Councils >Sponsored-by: Newcastle City Council >Sponsored-by: Sefton Council > >Signed-off-by: Liz Rea <wizzyrea@gmail.com> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > C4/Circulation.pm | 2 +- > Koha/Calendar.pm | 52 ++++++++++++---------- > .../thirdparty/TalkingTech_itiva_outbound.pl | 4 +- > 3 files changed, 32 insertions(+), 26 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 5880abe691..8db38ca253 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3581,7 +3581,7 @@ sub CalcDateDue { > my $calendar = Koha::Calendar->new( branchcode => $branch ); > if ( $calendar->is_holiday($datedue) ) { > # Don't return on a closed day >- $datedue = $calendar->prev_open_day( $datedue ); >+ $datedue = $calendar->prev_open_days( $datedue, 1 ); > } > } > } >diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm >index 07faad58dd..e138ff31e9 100644 >--- a/Koha/Calendar.pm >+++ b/Koha/Calendar.pm >@@ -171,9 +171,9 @@ sub addHours { > $self->is_holiday($base_date) ) { > > if ( $hours_duration->is_negative() ) { >- $base_date = $self->prev_open_day($base_date); >+ $base_date = $self->prev_open_days($base_date, 1); > } else { >- $base_date = $self->next_open_day($base_date); >+ $base_date = $self->next_open_days($base_date, 1); > } > > $base_date->set_hour($return_by_hour); >@@ -196,12 +196,12 @@ sub addDays { > > if ( $days_duration->is_negative() ) { > while ($days) { >- $base_date = $self->prev_open_day($base_date); >+ $base_date = $self->prev_open_days($base_date, 1); > --$days; > } > } else { > while ($days) { >- $base_date = $self->next_open_day($base_date); >+ $base_date = $self->next_open_days($base_date, 1); > --$days; > } > } >@@ -270,27 +270,31 @@ sub is_holiday { > return 0; > } > >-sub next_open_day { >- my ( $self, $dt ) = @_; >+sub next_open_days { >+ my ( $self, $dt, $to_add ) = @_; > my $base_date = $dt->clone(); > >- $base_date->add(days => 1); >+ $base_date->add(days => $to_add); > > while ($self->is_holiday($base_date)) { >- $base_date->add(days => 1); >+ $base_date->add(days => $to_add); > } > > return $base_date; > } > >-sub prev_open_day { >- my ( $self, $dt ) = @_; >+sub prev_open_days { >+ my ( $self, $dt, $to_sub ) = @_; > my $base_date = $dt->clone(); > >- $base_date->add(days => -1); >+ # It feels logical to be passed a positive number, though we're >+ # subtracting, so do the right thing >+ $to_sub = $to_sub > 0 ? 0 - $to_sub : $to_sub; >+ >+ $base_date->add(days => $to_sub); > > while ($self->is_holiday($base_date)) { >- $base_date->add(days => -1); >+ $base_date->add(days => $to_sub); > } > > return $base_date; >@@ -306,7 +310,7 @@ sub days_forward { > my $base_dt = $start_dt->clone(); > > while ($num_days--) { >- $base_dt = $self->next_open_day($base_dt); >+ $base_dt = $self->next_open_days($base_dt, 1); > } > > return $base_dt; >@@ -468,21 +472,23 @@ Passed two dates returns a DateTime::Duration object measuring the length betwee > ignoring closed days. Always returns a positive number irrespective of the > relative order of the parameters > >-=head2 next_open_day >+=head2 next_open_days > >-$datetime = $calendar->next_open_day($duedate_dt) >+$datetime = $calendar->next_open_days($duedate_dt, $to_add) > >-Passed a Datetime returns another Datetime representing the next open day. It is >-intended for use to calculate the due date when useDaysMode syspref is set to either >-'Datedue' or 'Calendar'. >+Passed a Datetime and number of days, returns another Datetime representing >+the next open day after adding the passed number of days. It is intended for >+use to calculate the due date when useDaysMode syspref is set to either >+'Datedue', 'Calendar' or 'Dayweek'. > >-=head2 prev_open_day >+=head2 prev_open_days > >-$datetime = $calendar->prev_open_day($duedate_dt) >+$datetime = $calendar->prev_open_days($duedate_dt, $to_sub) > >-Passed a Datetime returns another Datetime representing the previous open day. It is >-intended for use to calculate the due date when useDaysMode syspref is set to either >-'Datedue' or 'Calendar'. >+Passed a Datetime and a number of days, returns another Datetime >+representing the previous open day after subtracting the number of passed >+days. It is intended for use to calculate the due date when useDaysMode >+syspref is set to either 'Datedue', 'Calendar' or 'Dayweek'. > > =head2 set_daysmode > >diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >index 220793456d..1131da61e2 100755 >--- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >+++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >@@ -337,7 +337,7 @@ sub GetWaitingHolds { > my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' ); > my $pickup_date = $waiting_date->clone->add( days => $pickupdelay ); > if ( $calendar->is_holiday($pickup_date) ) { >- $pickup_date = $calendar->next_open_day( $pickup_date ); >+ $pickup_date = $calendar->next_open_days( $pickup_date, 1 ); > } > > $issue->{'date_due'} = output_pref({dt => $pickup_date, dateformat => 'iso' }); >@@ -345,7 +345,7 @@ sub GetWaitingHolds { > > my $days_to_subtract = 0; > if ( $calendar->is_holiday($waiting_date) ) { >- my $next_open_day = $calendar->next_open_day( $waiting_date ); >+ my $next_open_day = $calendar->next_open_days( $waiting_date, 1 ); > $days_to_subtract = $calendar->days_between($waiting_date, $next_open_day)->days; > } > >-- >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 15260
:
87906
|
88052
|
88053
|
88054
|
88055
|
88056
|
88057
|
88059
|
88607
|
88608
|
88609
|
88610
|
88611
|
88612
|
88613
|
89178
|
89380
|
89381
|
89382
|
89383
|
89384
|
89385
|
89386
|
89387
|
89388
|
89885
|
94880
|
94881
| 94882 |
94883
|
94884
|
94885
|
94886
|
94887
|
94888
|
94889