Bugzilla – Attachment 22574 Details for
Bug 9180
Default rules are not always used for overdues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9180: All branches should be returned if a default rule exists
Bug-9180-All-branches-should-be-returned-if-a-defa.patch (text/plain), 3.76 KB, created by
Jonathan Druart
on 2013-10-30 09:52:36 UTC
(
hide
)
Description:
Bug 9180: All branches should be returned if a default rule exists
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-10-30 09:52:36 UTC
Size:
3.76 KB
patch
obsolete
>From 182ca9f6e2707a77ba7fe8d753a62be8ae373ab3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 30 Oct 2013 10:50:13 +0100 >Subject: [PATCH] Bug 9180: All branches should be returned if a default rule > exists > >The C4::Overdues::GetBranchcodesWithOverdueRules routine has a bug. >If a default rule *and* a specific rule exist, only the branchcode for >the specific rule is returned. > >Test plan: >prove t/db_dependent/Overdues.t >and verify the unit tests are consistent. >--- > C4/Overdues.pm | 18 ++++++++++------- > t/db_dependent/Overdues.pl | 47 ++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 58 insertions(+), 7 deletions(-) > create mode 100644 t/db_dependent/Overdues.pl > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 4fd0b84..c1b03ce 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -749,14 +749,18 @@ returns a list of branch codes for branches with overdue rules defined. > > sub GetBranchcodesWithOverdueRules { > my $dbh = C4::Context->dbh; >- my $rqoverduebranches = $dbh->prepare("SELECT DISTINCT branchcode FROM overduerules WHERE delay1 IS NOT NULL AND branchcode <> '' ORDER BY branchcode"); >- $rqoverduebranches->execute; >- my @branches = map { shift @$_ } @{ $rqoverduebranches->fetchall_arrayref }; >- if (!$branches[0]) { >- my $availbranches = C4::Branch::GetBranches(); >- @branches = keys %$availbranches; >+ my @branchcodes = $dbh->selectrow_array(q| >+ SELECT DISTINCT(branchcode) >+ FROM overduerules >+ WHERE delay1 IS NOT NULL >+ ORDER BY branchcode >+ |); >+ if ( $branchcodes[0] eq '' ) { >+ # If a default rule exists, all branches should be returned >+ my $availbranches = C4::Branch::GetBranches(); >+ return keys %$availbranches; > } >- return @branches; >+ return @branchcodes; > } > > =head2 CheckBorrowerDebarred >diff --git a/t/db_dependent/Overdues.pl b/t/db_dependent/Overdues.pl >new file mode 100644 >index 0000000..64c284a >--- /dev/null >+++ b/t/db_dependent/Overdues.pl >@@ -0,0 +1,47 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+use Test::More tests => 3; >+ >+use C4::Branch; >+use C4::Context; >+use C4::Overdues; >+ >+my $dbh = C4::Context->dbh; >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+$dbh->do(q|DELETE FROM overduerules|); >+$dbh->do(q| >+ INSERT INTO overduerules >+ ( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) >+ VALUES >+ ( '', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) >+|); >+ >+my $all_branches = C4::Branch::GetBranches; >+my @branchcodes = keys %$all_branches; >+ >+my @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules; >+is_deeply( \@overdue_branches, \@branchcodes, 'If a default rule exists, all branches should be returned' ); >+ >+$dbh->do(q| >+ INSERT INTO overduerules >+ ( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) >+ VALUES >+ ( 'CPL', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) >+|); >+ >+@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules; >+is_deeply( \@overdue_branches, \@branchcodes, 'If a default rule exists and a specific rule exists, all branches should be returned' ); >+ >+$dbh->do(q|DELETE FROM overduerules|); >+$dbh->do(q| >+ INSERT INTO overduerules >+ ( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) >+ VALUES >+ ( 'CPL', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) >+|); >+ >+@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules; >+is_deeply( \@overdue_branches, ['CPL'] , 'If only a specific rule exist, only 1 branch should be returned' ); >-- >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 9180
:
13799
|
22574
|
25947
|
27427
|
29548
|
30392