Bugzilla – Attachment 63093 Details for
Bug 12063
Change date calculation for reserve expiration to skip all holidays
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12063 - Keep patron's requested expiration date if it is prior to the calculated one
Bug-12063---Keep-patrons-requested-expiration-date.patch (text/plain), 4.07 KB, created by
Marcel de Rooy
on 2017-05-04 12:23:04 UTC
(
hide
)
Description:
Bug 12063 - Keep patron's requested expiration date if it is prior to the calculated one
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-05-04 12:23:04 UTC
Size:
4.07 KB
patch
obsolete
>From 142bca3a09751003a6f8f1738975402e1d05b506 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Wed, 18 Jan 2017 14:13:33 +0000 >Subject: [PATCH] Bug 12063 - Keep patron's requested expiration date if it is > prior to the calculated one >MIME-Version: 1.0 >Content-Type: text/plain; charset=utf-8 >Content-Transfer-Encoding: 8bit >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Andreas Hedström Mace <andreas.hedstrom.mace@sub.su.se> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Hold.pm | 10 ++++++++- > t/db_dependent/Holds/WaitingReserves.t | 38 ++++++++++++++++++++++++++++++++-- > 2 files changed, 45 insertions(+), 3 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index c125bfc..1e2e730 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -127,6 +127,11 @@ sub set_waiting { > waitingdate => $today->ymd, > }; > >+ my $requested_expiration; >+ if ($self->expirationdate) { >+ $requested_expiration = dt_from_string($self->expirationdate); >+ } >+ > if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) { > my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); > my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); >@@ -139,7 +144,10 @@ sub set_waiting { > $expirationdate = $calendar->days_forward( dt_from_string($self->waitingdate), $max_pickup_delay ); > } > >- $values->{expirationdate} = $expirationdate->ymd; >+ # If patron's requested expiration date is prior to the >+ # calculated one, we keep the patron's one. >+ my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0; >+ $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd; > } > > $self->set($values)->store(); >diff --git a/t/db_dependent/Holds/WaitingReserves.t b/t/db_dependent/Holds/WaitingReserves.t >index 6167f43..ccd677c 100644 >--- a/t/db_dependent/Holds/WaitingReserves.t >+++ b/t/db_dependent/Holds/WaitingReserves.t >@@ -8,7 +8,7 @@ use Koha::DateUtils; > use t::lib::Mocks; > use t::lib::TestBuilder; > >-use Test::More tests => 10; >+use Test::More tests => 11; > > use_ok('C4::Reserves'); > >@@ -77,6 +77,12 @@ my $biblio3 = $builder->build({ > title => 'Title 3', }, > }); > >+my $biblio4 = $builder->build({ >+ source => 'Biblio', >+ value => { >+ title => 'Title 4', }, >+}); >+ > my $item1 = $builder->build({ > source => 'Item', > value => { >@@ -98,6 +104,13 @@ my $item3 = $builder->build({ > }, > }); > >+my $item4 = $builder->build({ >+ source => 'Item', >+ value => { >+ biblionumber => $biblio4->{biblionumber}, >+ }, >+}); >+ > my $today = dt_from_string(); > > my $reserve1_reservedate = $today->clone; >@@ -167,7 +180,6 @@ my $reserve3 = $builder->build({ > my $special_holiday1_dt = $today->clone; > $special_holiday1_dt->add(days => 2); > >-Koha::Cache->get_instance()->flush_all(); > my $holiday = $builder->build({ > source => 'SpecialHoliday', > value => { >@@ -205,4 +217,26 @@ $expected_expiration->add(days => 8); > my $r3 = Koha::Holds->find($reserve3->{reserve_id}); > is($r3->expirationdate, $expected_expiration->ymd, 'Expiration date should be set to today + 7' ); > >+my $reserve4_reservedate = $today->clone; >+my $requested_expiredate = $today->clone()->add(days => 6); >+ >+my $reserve4 = $builder->build({ >+ source => 'Reserve', >+ value => { >+ borrowernumber => $patron2->{borrowernumber}, >+ reservedate => $reserve4_reservedate->ymd, >+ expirationdate => $requested_expiredate->ymd, >+ biblionumber => $biblio4->{biblionumber}, >+ branchcode => 'LIB1', >+ priority => 1, >+ found => '', >+ }, >+}); >+ >+t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 10); >+ModReserveAffect( $item4->{itemnumber}, $patron2->{borrowernumber}, 0, $reserve4->{reserve_id}); >+ >+my $r4 = Koha::Holds->find($reserve4->{reserve_id}); >+is($r4->expirationdate, $requested_expiredate->ymd, 'Requested expiration date should be kept' ); >+ > $dbh->rollback; >\ No newline at end of file >-- >2.1.4
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 12063
:
26966
|
52558
|
52949
|
52950
|
53100
|
53101
|
59161
|
59162
|
59163
|
59165
|
61401
|
61440
|
61461
|
61735
|
62001
|
62002
|
62003
|
62004
|
62005
|
62474
|
63057
|
63091
|
63092
| 63093 |
63094
|
63095
|
63096
|
63097
|
63098
|
63099