Bugzilla – Attachment 15300 Details for
Bug 8365
Renewal duration in issuingules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8365: Add unit tests
Bug-8365-Add-unit-tests.patch (text/plain), 4.90 KB, created by
Jonathan Druart
on 2013-02-13 14:09:39 UTC
(
hide
)
Description:
Bug 8365: Add unit tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-02-13 14:09:39 UTC
Size:
4.90 KB
patch
obsolete
>From 7be9cda914f0b834c1cf3a298aa1adf18a0948bc Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 13 Feb 2013 15:08:41 +0100 >Subject: [PATCH] Bug 8365: Add unit tests > >This patch adds some unit tests for CalcDateDue and GetLoanLength >--- > C4/Circulation.pm | 38 +++++++++++--------- > .../prog/en/modules/admin/smart-rules.tt | 2 +- > 2 files changed, 22 insertions(+), 18 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index c40aa11..897a0ac 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1335,9 +1335,9 @@ sub GetLoanLength { > > # try to find issuelength & return the 1st available. > # check with borrowertype, itemtype and branchcode, then without one of those parameters >- > $sth->execute( $borrowertype, $itemtype, $branchcode ); > my $loanlength = $sth->fetchrow_hashref; >+ > return $loanlength > if defined($loanlength) && $loanlength->{issuelength}; > >@@ -2411,8 +2411,6 @@ END_SQL > > Find out whether a borrowed item may be renewed. > >-C<$dbh> is a DBI handle to the Koha database. >- > C<$borrowernumber> is the borrower number of the patron who currently > has the item on loan. > >@@ -2422,7 +2420,7 @@ C<$override_limit>, if supplied with a true value, causes > the limit on the number of times that the loan can be renewed > (as controlled by the item type) to be ignored. > >-C<$CanBookBeRenewed> returns a true value iff the item may be renewed. The >+C<$CanBookBeRenewed> returns a true value if the item may be renewed. The > item must currently be on loan to the specified borrower; renewals > must be allowed for the item's type; and the borrower must not have > already renewed the loan. $error will contain the reason the renewal can not proceed >@@ -2984,6 +2982,7 @@ C<$startdate> = C4::Dates object representing start date of loan period (assum > C<$itemtype> = itemtype code of item in question > C<$branch> = location whose calendar to use > C<$borrower> = Borrower object >+C<$isrenewal> = Boolean: is true if we want to calculate the date due for a renewal. Else is false. > > =cut > >@@ -3001,22 +3000,29 @@ sub CalcDateDue { > : qq{issuelength}; > > my $datedue; >+ if ( $startdate ) { >+ if (ref $startdate ne 'DateTime' ) { >+ $datedue = dt_from_string($datedue); >+ } else { >+ $datedue = $startdate->clone; >+ } >+ } else { >+ $datedue = >+ DateTime->now( time_zone => C4::Context->tz() ) >+ ->truncate( to => 'minute' ); >+ } >+ > > # calculate the datedue as normal > if ( C4::Context->preference('useDaysMode') eq 'Days' ) > { # ignoring calendar >- my $dt = >- DateTime->now( time_zone => C4::Context->tz() ) >- ->truncate( to => 'minute' ); > if ( $loanlength->{lengthunit} eq 'hours' ) { >- $dt->add( hours => $loanlength->{$length_key} ); >+ $datedue->add( hours => $loanlength->{$length_key} ); > } else { # days >- $dt->add( days => $loanlength->{$length_key} ); >- $dt->set_hour(23); >- $dt->set_minute(59); >+ $datedue->add( days => $loanlength->{$length_key} ); >+ $datedue->set_hour(23); >+ $datedue->set_minute(59); > } >- # break >- return $dt; > } else { > my $dur; > if ($loanlength->{lengthunit} eq 'hours') { >@@ -3025,11 +3031,8 @@ sub CalcDateDue { > else { # days > $dur = DateTime::Duration->new( days => $loanlength->{$length_key}); > } >- if (ref $startdate ne 'DateTime' ) { >- $startdate = dt_from_string($startdate); >- } > my $calendar = Koha::Calendar->new( branchcode => $branch ); >- $datedue = $calendar->addDate( $startdate, $dur, $loanlength->{lengthunit} ); >+ $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); > if ($loanlength->{lengthunit} eq 'days') { > $datedue->set_hour(23); > $datedue->set_minute(59); >@@ -3053,6 +3056,7 @@ sub CalcDateDue { > } > > # in all other cases, keep the date due as it is >+ > } > > # if ReturnBeforeExpiry ON the datedue can't be after borrower expirydate >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index d33a243..c69376f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -75,7 +75,7 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde > <th>Overdue Fines Cap ($)</th> > <th>Suspension in days (day)</th> > <th>Renewals allowed (count)</th> >- <th>Renewals period</th> >+ <th>Renewal period</th> > <th>Holds allowed (count)</th> > <th>Rental discount (%)</th> > <th> </th> >-- >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 8365
:
12054
|
12374
|
13972
|
14142
|
15300
|
15301
|
15302
|
15303
|
15360
|
15361
|
16120
|
16121
|
16213
|
16214
|
16382
|
16386
|
16396
|
16433
|
16434
|
16435
|
16436