Bugzilla – Attachment 58127 Details for
Bug 16387
Incorrect loan period calculation when using decreaseLoanHighHolds feature
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16387: Fix default shortened loan period time
Bug-16387-Fix-default-shortened-loan-period-time.patch (text/plain), 3.13 KB, created by
Lari Taskula
on 2016-12-12 15:21:37 UTC
(
hide
)
Description:
Bug 16387: Fix default shortened loan period time
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2016-12-12 15:21:37 UTC
Size:
3.13 KB
patch
obsolete
>From 7e992a082faba60e06c394a587aa1f88b1ad2fc0 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Mon, 12 Dec 2016 16:49:44 +0200 >Subject: [PATCH] Bug 16387: Fix default shortened loan period time > >When a loan period is shortened due to using decreaseLoanHighHolds* the time is >always set to the current time in X days, even if the original loan period is >given in days and not in hours. > >It should default to 23:59 as is normal for loan periods given in days. > >As original due date time defaults to 23:59 when given in days, this patch >modifies the hours and minutes of shortened due date to be equal to original due >date. > >To test: >1. prove t/db_dependent/DecreaseLoanHighHolds.t >--- > C4/Circulation.pm | 3 +++ > t/db_dependent/DecreaseLoanHighHolds.t | 14 +++++++++++++- > 2 files changed, 16 insertions(+), 1 deletion(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index b505031..db816f9 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1209,6 +1209,9 @@ sub checkHighHolds { > my $decreaseLoanHighHoldsDuration = C4::Context->preference('decreaseLoanHighHoldsDuration'); > > my $reduced_datedue = $calendar->addDate( $issuedate, $decreaseLoanHighHoldsDuration ); >+ $reduced_datedue->set_hour($orig_due->hour); >+ $reduced_datedue->set_minute($orig_due->minute); >+ $reduced_datedue->truncate( to => 'minute' ); > > if ( DateTime->compare( $reduced_datedue, $orig_due ) == -1 ) { > $return_data->{exceeded} = 1; >diff --git a/t/db_dependent/DecreaseLoanHighHolds.t b/t/db_dependent/DecreaseLoanHighHolds.t >index b6a175c..d4faaa3 100755 >--- a/t/db_dependent/DecreaseLoanHighHolds.t >+++ b/t/db_dependent/DecreaseLoanHighHolds.t >@@ -27,7 +27,7 @@ use Koha::Hold; > use t::lib::TestBuilder; > use t::lib::Mocks; > >-use Test::More tests => 14; >+use Test::More tests => 17; > > my $dbh = C4::Context->dbh; > my $schema = Koha::Database->new()->schema(); >@@ -104,6 +104,13 @@ $builder->build( > my $item = pop(@items); > my $patron = pop(@patrons); > >+my $orig_due = C4::Circulation::CalcDateDue( >+ DateTime->now(time_zone => C4::Context->tz()), >+ $item->effective_itemtype, >+ $patron->branchcode, >+ $patron->unblessed >+); >+ > t::lib::Mocks::mock_preference( 'decreaseLoanHighHolds', 1 ); > t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsDuration', 1 ); > t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsValue', 1 ); >@@ -119,6 +126,11 @@ is( $data->{outstanding}, 6, "Should have 5 outstanding holds" ); > is( $data->{duration}, 1, "Should have duration of 1" ); > is( ref( $data->{due_date} ), 'DateTime', "due_date should be a DateTime object" ); > >+my $duedate = $data->{due_date}; >+is($duedate->hour, $orig_due->hour, 'New due hour is equal to original due hour.'); >+is($duedate->min, $orig_due->min, 'New due minute is equal to original due minute.'); >+is($duedate->sec, 0, 'New due date second is zero.'); >+ > t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsControl', 'dynamic' ); > $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); > is( $data->{exceeded}, 0, "Should not exceed threshold" ); >-- >1.9.1
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 16387
:
58127
|
59278
|
59285
|
59619