Bugzilla – Attachment 50114 Details for
Bug 9004
Talking Tech doesn't account for holidays when calculating a holds last pickup date
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9004: Use Koha::Calendar instead of C4::Calendar
Bug-9004-Use-KohaCalendar-instead-of-C4Calendar.patch (text/plain), 2.91 KB, created by
Jonathan Druart
on 2016-04-11 06:55:49 UTC
(
hide
)
Description:
Bug 9004: Use Koha::Calendar instead of C4::Calendar
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-04-11 06:55:49 UTC
Size:
2.91 KB
patch
obsolete
>From 60c5dda2b10801d19d782861d7ecfd2c49d705ef Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 8 Apr 2016 15:51:22 +0100 >Subject: [PATCH] Bug 9004: Use Koha::Calendar instead of C4::Calendar > >This patch tries to make the code more readable using Koha::Calendar >instead of deprecated C4::Calendar and Date::Calc >--- > .../thirdparty/TalkingTech_itiva_outbound.pl | 22 +++++++++++----------- > 1 file changed, 11 insertions(+), 11 deletions(-) > >diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >index b42cb25..1299b7d 100755 >--- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >+++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >@@ -30,13 +30,12 @@ BEGIN { > > use Getopt::Long; > use Pod::Usage; >-use Date::Calc qw(Add_Delta_Days); > > use C4::Context; > use C4::Items; > use C4::Letters; > use C4::Overdues; >-use C4::Calendar; >+use Koha::Calendar; > use Koha::DateUtils; > > sub usage { >@@ -292,22 +291,23 @@ sub GetWaitingHolds { > $sth->execute(); > my @results; > while ( my $issue = $sth->fetchrow_hashref() ) { >- my $calendar = C4::Calendar->new( branchcode => $issue->{'site'} ); >+ my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'} ); > >- my ( $waiting_year, $waiting_month, $waiting_day ) = split( /-/, $issue->{'waitingdate'} ); >- my ( $pickup_year, $pickup_month, $pickup_day ) = Add_Delta_Days( $waiting_year, $waiting_month, $waiting_day, $pickupdelay ); >- >- while ( $calendar->isHoliday( $pickup_day, $pickup_month, $pickup_year ) ) { >- ( $pickup_year, $pickup_month, $pickup_day ) = Add_Delta_Days( $pickup_year, $pickup_month, $pickup_day, 1 ); >+ 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 ); > } > >- $issue->{'date_due'} = sprintf( "%04d-%02d-%02d", $pickup_year, $pickup_month, $pickup_day ); >+ $issue->{'date_due'} = output_pref({dt => $pickup_date, dateformat => 'iso' }); > $issue->{'level'} = 1; # only one level for Hold Waiting notifications > > my $days_to_subtract = 0; >- while ( $calendar->isHoliday( reverse( Add_Delta_Days( $waiting_year, $waiting_month, $waiting_day, $days_to_subtract ) ) ) ) { >- $days_to_subtract++; >+ if ( $calendar->is_holiday($waiting_date) ) { >+ my $next_open_day = $calendar->next_open_day( $waiting_date ); >+ $days_to_subtract = $calendar->days_between($waiting_date, $next_open_day)->days; > } >+ > $issue->{'days_since_waiting'} = $issue->{'days_since_waiting'} - $days_to_subtract; > > if ( ( grep $_ eq $issue->{'days_since_waiting'}, @holds_waiting_days_to_call ) >-- >2.7.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 9004
:
13176
|
13212
|
13213
|
50042
|
50043
|
50082
|
50085
|
50086
|
50111
|
50112
|
50113
| 50114