Bugzilla – Attachment 39577 Details for
Bug 14045
Add specific quotas to on-site checkout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14045: Make GetBranchBorrowerCircRule return maxonsiteissueqty
Bug-14045-Make-GetBranchBorrowerCircRule-return-ma.patch (text/plain), 10.60 KB, created by
Nicolas Legrand
on 2015-05-27 10:37:42 UTC
(
hide
)
Description:
Bug 14045: Make GetBranchBorrowerCircRule return maxonsiteissueqty
Filename:
MIME Type:
Creator:
Nicolas Legrand
Created:
2015-05-27 10:37:42 UTC
Size:
10.60 KB
patch
obsolete
>From 5fd917313664e341366c9dfca058f42f0c01bb18 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@koha-community.org> >Date: Wed, 13 May 2015 17:08:03 +0200 >Subject: [PATCH] Bug 14045: Make GetBranchBorrowerCircRule return > maxonsiteissueqty > >GetBranchBorrowerCircRule should return the value for maxissueqty and >maxonsiteissueqty. It's what this patch does. > >Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr> >--- > C4/Circulation.pm | 71 ++++++++++++++---------------- > t/db_dependent/Circulation_Branch.t | 53 ++++++++++++++-------- > t/db_dependent/Circulation_Issuingrule.t | 9 +++- > 3 files changed, 76 insertions(+), 57 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index f413aa9..b110bca 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1573,6 +1573,10 @@ maxissueqty - maximum number of loans that a > patron of the given category can have at the given > branch. If the value is undef, no limit. > >+maxonsiteissueqty - maximum of on-site checkouts that a >+patron of the given category can have at the given >+branch. If the value is undef, no limit. >+ > This will first check for a specific branch and > category match from branch_borrower_circ_rules. > >@@ -1586,6 +1590,7 @@ If no rule has been found in the database, it will default to > the buillt in rule: > > maxissueqty - undef >+maxonsiteissueqty - undef > > C<$branchcode> and C<$categorycode> should contain the > literal branch code and patron category code, respectively - no >@@ -1594,53 +1599,45 @@ wildcards. > =cut > > sub GetBranchBorrowerCircRule { >- my $branchcode = shift; >- my $categorycode = shift; >+ my ( $branchcode, $categorycode ) = @_; > >- my $branch_cat_query = "SELECT maxissueqty >- FROM branch_borrower_circ_rules >- WHERE branchcode = ? >- AND categorycode = ?"; >+ my $rules; > my $dbh = C4::Context->dbh(); >- my $sth = $dbh->prepare($branch_cat_query); >- $sth->execute($branchcode, $categorycode); >- my $result; >- if ($result = $sth->fetchrow_hashref()) { >- return $result; >- } >+ $rules = $dbh->selectrow_hashref( q| >+ SELECT maxissueqty, maxonsiteissueqty >+ FROM branch_borrower_circ_rules >+ WHERE branchcode = ? >+ AND categorycode = ? >+ |, {}, $branchcode, $categorycode ) ; >+ return $rules if $rules; > > # try same branch, default borrower category >- my $branch_query = "SELECT maxissueqty >- FROM default_branch_circ_rules >- WHERE branchcode = ?"; >- $sth = $dbh->prepare($branch_query); >- $sth->execute($branchcode); >- if ($result = $sth->fetchrow_hashref()) { >- return $result; >- } >+ $rules = $dbh->selectrow_hashref( q| >+ SELECT maxissueqty, maxonsiteissueqty >+ FROM default_branch_circ_rules >+ WHERE branchcode = ? >+ |, {}, $branchcode ) ; >+ return $rules if $rules; > > # try default branch, same borrower category >- my $category_query = "SELECT maxissueqty >- FROM default_borrower_circ_rules >- WHERE categorycode = ?"; >- $sth = $dbh->prepare($category_query); >- $sth->execute($categorycode); >- if ($result = $sth->fetchrow_hashref()) { >- return $result; >- } >- >+ $rules = $dbh->selectrow_hashref( q| >+ SELECT maxissueqty, maxonsiteissueqty >+ FROM default_borrower_circ_rules >+ WHERE categorycode = ? >+ |, {}, $categorycode ) ; >+ return $rules if $rules; >+ > # try default branch, default borrower category >- my $default_query = "SELECT maxissueqty >- FROM default_circ_rules"; >- $sth = $dbh->prepare($default_query); >- $sth->execute(); >- if ($result = $sth->fetchrow_hashref()) { >- return $result; >- } >- >+ $rules = $dbh->selectrow_hashref( q| >+ SELECT maxissueqty, maxonsiteissueqty >+ FROM default_circ_rules >+ |, {} ); >+ return $rules if $rules; >+ > # built-in default circulation rule > return { > maxissueqty => undef, >+ maxonsiteissueqty => undef, > }; > } > >diff --git a/t/db_dependent/Circulation_Branch.t b/t/db_dependent/Circulation_Branch.t >index ee26458..68752e9 100644 >--- a/t/db_dependent/Circulation_Branch.t >+++ b/t/db_dependent/Circulation_Branch.t >@@ -8,7 +8,7 @@ use C4::Circulation; > use C4::Items; > use C4::Context; > >-use Test::More tests => 10; >+use Test::More tests => 11; > > BEGIN { > use_ok('C4::Circulation'); >@@ -160,20 +160,35 @@ $sth->execute( > $sampleitemtype2->{imageurl}, $sampleitemtype2->{summary} > ); > >-$query = >-"INSERT INTO branch_borrower_circ_rules (branchcode,categorycode,maxissueqty) VALUES( ?,?,?)"; >+is_deeply( >+ GetBranchBorrowerCircRule(), >+ { maxissueqty => undef, maxonsiteissueqty => undef }, >+"Without parameter, GetBranchBorrower returns undef (unilimited) for maxissueqty and maxonsiteissueqty if no rules defined" >+); >+ >+$query = q| >+ INSERT INTO branch_borrower_circ_rules >+ (branchcode, categorycode, maxissueqty, maxonsiteissueqty) >+ VALUES( ?, ?, ?, ?) >+|; > $dbh->do( > $query, {}, > $samplebranch1->{branchcode}, >- $samplecat->{categorycode}, 5 >+ $samplecat->{categorycode}, 5, 6 > ); >-$query = >-"INSERT INTO default_branch_circ_rules (branchcode,maxissueqty,holdallowed,returnbranch) VALUES( ?,?,?,?)"; >+$query = q| >+ INSERT INTO default_branch_circ_rules >+ (branchcode, maxissueqty, maxonsiteissueqty, holdallowed, returnbranch) >+ VALUES( ?, ?, ?, ?, ?) >+|; > $dbh->do( $query, {}, $samplebranch2->{branchcode}, >- 3, 1, $samplebranch2->{branchcode} ); >-$query = >-"INSERT INTO default_circ_rules (singleton,maxissueqty,holdallowed,returnbranch) VALUES( ?,?,?,?)"; >-$dbh->do( $query, {}, 'singleton', 4, 3, $samplebranch1->{branchcode} ); >+ 3, 2, 1, $samplebranch2->{branchcode} ); >+$query = q| >+ INSERT INTO default_circ_rules >+ (singleton, maxissueqty, maxonsiteissueqty, holdallowed, returnbranch) >+ VALUES( ?, ?, ?, ?, ? ) >+|; >+$dbh->do( $query, {}, 'singleton', 4, 5, 3, $samplebranch1->{branchcode} ); > > $query = > "INSERT INTO branch_item_rules (branchcode,itemtype,holdallowed,returnbranch) VALUES( ?,?,?,?)"; >@@ -192,26 +207,26 @@ $sth->execute( > #Test GetBranchBorrowerCircRule > is_deeply( > GetBranchBorrowerCircRule(), >- { maxissueqty => 4 }, >-"Without parameter, GetBranchBorrower returns the maxissueqty of default_circ_rules" >+ { maxissueqty => 4, maxonsiteissueqty => 5 }, >+"Without parameter, GetBranchBorrower returns the maxissueqty and maxonsiteissueqty of default_circ_rules" > ); > is_deeply( > GetBranchBorrowerCircRule( $samplebranch2->{branchcode} ), >- { maxissueqty => 3 }, >-"Without only the branchcode specified, GetBranchBorrower returns the maxissueqty corresponding" >+ { maxissueqty => 3, maxonsiteissueqty => 2 }, >+"Without only the branchcode specified, GetBranchBorrower returns the maxissueqty and maxonsiteissueqty corresponding" > ); > is_deeply( > GetBranchBorrowerCircRule( > $samplebranch1->{branchcode}, > $samplecat->{categorycode} > ), >- { maxissueqty => 5 }, >- "GetBranchBorrower returns the maxissueqty of the branch1 and the category1" >+ { maxissueqty => 5, maxonsiteissueqty => 6 }, >+ "GetBranchBorrower returns the maxissueqty and maxonsiteissueqty of the branch1 and the category1" > ); > is_deeply( > GetBranchBorrowerCircRule( -1, -1 ), >- { maxissueqty => 4 }, >-"GetBranchBorrower with wrong parameters returns tthe maxissueqty of default_circ_rules" >+ { maxissueqty => 4, maxonsiteissueqty => 5 }, >+"GetBranchBorrower with wrong parameters returns the maxissueqty and maxonsiteissueqty of default_circ_rules" > ); > > #Test GetBranchItemRule >@@ -236,7 +251,7 @@ is_deeply( > is_deeply( > GetBranchItemRule( -1, -1 ), > { returnbranch => $samplebranch1->{branchcode}, holdallowed => 3 }, >- "With only one parametern GetBranchItemRule returns default values" >+ "With only one parameter GetBranchItemRule returns default values" > ); > > $dbh->rollback; >diff --git a/t/db_dependent/Circulation_Issuingrule.t b/t/db_dependent/Circulation_Issuingrule.t >index b1d9d72..a89624b 100644 >--- a/t/db_dependent/Circulation_Issuingrule.t >+++ b/t/db_dependent/Circulation_Issuingrule.t >@@ -113,6 +113,7 @@ my $sampleissuingrule1 = { > restrictedtype => 0, > accountsent => 0, > maxissueqty => 5, >+ maxonsiteissueqty => 4, > finedays => 0, > lengthunit => 'Null', > renewalperiod => 5, >@@ -140,6 +141,7 @@ my $sampleissuingrule2 = { > categorycode => $samplecat->{categorycode}, > itemtype => 'BOOK', > maxissueqty => 2, >+ maxonsiteissueqty => 1, > renewalsallowed => 'Null', > renewalperiod => 2, > norenewalbefore => 7, >@@ -168,6 +170,7 @@ my $sampleissuingrule3 = { > categorycode => $samplecat->{categorycode}, > itemtype => 'DVD', > maxissueqty => 3, >+ maxonsiteissueqty => 2, > renewalsallowed => 'Null', > renewalperiod => 3, > norenewalbefore => 8, >@@ -196,6 +199,7 @@ $query = 'INSERT INTO issuingrules ( > categorycode, > itemtype, > maxissueqty, >+ maxonsiteissueqty, > renewalsallowed, > renewalperiod, > norenewalbefore, >@@ -216,13 +220,14 @@ $query = 'INSERT INTO issuingrules ( > chargename, > restrictedtype, > maxsuspensiondays >- ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'; >+ ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'; > my $sth = $dbh->prepare($query); > $sth->execute( > $sampleissuingrule1->{branchcode}, > $sampleissuingrule1->{categorycode}, > $sampleissuingrule1->{itemtype}, > $sampleissuingrule1->{maxissueqty}, >+ $sampleissuingrule1->{maxonsiteissueqty}, > $sampleissuingrule1->{renewalsallowed}, > $sampleissuingrule1->{renewalperiod}, > $sampleissuingrule1->{norenewalbefore}, >@@ -249,6 +254,7 @@ $sth->execute( > $sampleissuingrule2->{categorycode}, > $sampleissuingrule2->{itemtype}, > $sampleissuingrule2->{maxissueqty}, >+ $sampleissuingrule2->{maxonsiteissueqty}, > $sampleissuingrule2->{renewalsallowed}, > $sampleissuingrule2->{renewalperiod}, > $sampleissuingrule2->{norenewalbefore}, >@@ -275,6 +281,7 @@ $sth->execute( > $sampleissuingrule3->{categorycode}, > $sampleissuingrule3->{itemtype}, > $sampleissuingrule3->{maxissueqty}, >+ $sampleissuingrule3->{maxonsiteissueqty}, > $sampleissuingrule3->{renewalsallowed}, > $sampleissuingrule3->{renewalperiod}, > $sampleissuingrule3->{norenewalbefore}, >-- >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 14045
:
39147
|
39148
|
39149
|
39150
|
39151
|
39152
|
39572
|
39573
|
39574
|
39575
|
39576
|
39577
|
39578
|
39579
|
42317
|
42318
|
42319
|
42320
|
42321
|
42322
|
43178
|
43326
|
43327
|
43328
|
43329
|
43330
|
43331
|
43332
|
43423
|
44557