Bugzilla – Attachment 41029 Details for
Bug 14395
Two different ways to calculate 'No renewal before' (days or hours)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14395: Code changes
Bug-14395-Code-changes.patch (text/plain), 2.94 KB, created by
Holger Meißner
on 2015-07-16 14:10:05 UTC
(
hide
)
Description:
Bug 14395: Code changes
Filename:
MIME Type:
Creator:
Holger Meißner
Created:
2015-07-16 14:10:05 UTC
Size:
2.94 KB
patch
obsolete
>From 9f9ef1205f82554c43f550644c90ec5535287959 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Holger=20Mei=C3=9Fner?= <h.meissner.82@web.de> >Date: Thu, 16 Jul 2015 15:22:55 +0200 >Subject: [PATCH] Bug 14395: Code changes >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch updates the calculation of 'No renewal before' to include the >new syspref NoRenewalBeforePrecision. > >To test: > >1) Switch syspref NoRenewalBeforePrecision to 'exact time'. > >2) Check out an item with 'No renewal before' set to 1 hour. Confirm that > you are unable to renew. Both staff client and OPAC user account should > display that renewal is allowed exactly one hour before due. > >3) Switch NoRenewalBeforePrecision to 'date'. Now the item should be > renewable immediately. (Unless you test less than an hour before > midnight) > >4) Also test with unit set to days and other values. > >Sponsored-by: Hochschule für Gesundheit (hsg), Germany >--- > C4/Circulation.pm | 28 ++++++++++++++++++---------- > 1 file changed, 18 insertions(+), 10 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index f270ce2..a05d21d 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2760,13 +2760,18 @@ sub CanBookBeRenewed { > > if ( defined $issuingrule->{norenewalbefore} ) { > >- # Get current time and add norenewalbefore. >- # If this is smaller than date_due, it's too soon for renewal. >- if ( >- DateTime->now( time_zone => C4::Context->tz() )->add( >- $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} >- ) < $itemissue->{date_due} >- ) >+ # Calculate soonest renewal by subtracting 'No renewal before' from due date >+ my $soonestrenewal = >+ $itemissue->{date_due}->clone() >+ ->subtract( >+ $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} ); >+ >+ # Depending on syspref reset the exact time, only check the date >+ if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' ) { >+ $soonestrenewal->truncate( to => 'day' ); >+ } >+ >+ if ( $soonestrenewal > DateTime->now( time_zone => C4::Context->tz() ) ) > { > return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew}; > return ( 0, "too_soon" ); >@@ -3001,11 +3006,14 @@ sub GetSoonestRenewDate { > > if ( defined $issuingrule->{norenewalbefore} ) { > my $soonestrenewal = >- $itemissue->{date_due}->subtract( >+ $itemissue->{date_due}->clone() >+ ->subtract( > $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} ); > >- $soonestrenewal = $now > $soonestrenewal ? $now : $soonestrenewal; >- return $soonestrenewal; >+ if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' ) { >+ $soonestrenewal->truncate( to => 'day' ); >+ } >+ return $soonestrenewal if $now < $soonestrenewal; > } > return $now; > } >-- >1.7.10.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 14395
:
41027
|
41028
|
41029
|
41053
|
41054
|
41189
|
41197
|
42785
|
43810
|
43811
|
43812
|
44950
|
44951
|
44952
|
47777
|
47778
|
47779