View | Details | Raw Unified | Return to bug 9180
Collapse All | Expand All

(-)a/C4/Overdues.pm (-3 / +3 lines)
Lines 749-766 returns a list of branch codes for branches with overdue rules defined. Link Here
749
749
750
sub GetBranchcodesWithOverdueRules {
750
sub GetBranchcodesWithOverdueRules {
751
    my $dbh               = C4::Context->dbh;
751
    my $dbh               = C4::Context->dbh;
752
    my @branchcodes = $dbh->selectrow_array(q|
752
    my $branchcodes = $dbh->selectcol_arrayref(q|
753
        SELECT DISTINCT(branchcode)
753
        SELECT DISTINCT(branchcode)
754
        FROM overduerules
754
        FROM overduerules
755
        WHERE delay1 IS NOT NULL
755
        WHERE delay1 IS NOT NULL
756
        ORDER BY branchcode
756
        ORDER BY branchcode
757
    |);
757
    |);
758
    if ( $branchcodes[0] eq '' ) {
758
    if ( $branchcodes->[0] eq '' ) {
759
        # If a default rule exists, all branches should be returned
759
        # If a default rule exists, all branches should be returned
760
        my $availbranches = C4::Branch::GetBranches();
760
        my $availbranches = C4::Branch::GetBranches();
761
        return keys %$availbranches;
761
        return keys %$availbranches;
762
    }
762
    }
763
    return @branchcodes;
763
    return @$branchcodes;
764
}
764
}
765
765
766
=head2 CheckItemNotify
766
=head2 CheckItemNotify
(-)a/t/db_dependent/Overdues.pl (-2 / +13 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Test::More tests => 3;
4
use Test::More tests => 4;
5
5
6
use C4::Branch;
6
use C4::Branch;
7
use C4::Context;
7
use C4::Context;
Lines 45-47 $dbh->do(q| Link Here
45
45
46
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules;
46
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules;
47
is_deeply( \@overdue_branches, ['CPL'] , 'If only a specific rule exist, only 1 branch should be returned' );
47
is_deeply( \@overdue_branches, ['CPL'] , 'If only a specific rule exist, only 1 branch should be returned' );
48
- 
48
49
$dbh->do(q|DELETE FROM overduerules|);
50
$dbh->do(q|
51
    INSERT INTO overduerules
52
        ( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 )
53
        VALUES
54
        ( 'CPL', '', 1, 'LETTER_CODE1_CPL', 1, 5, 'LETTER_CODE2_CPL', 1, 10, 'LETTER_CODE3_CPL', 1 ),
55
        ( 'MPL', '', 1, 'LETTER_CODE1_MPL', 1, 5, 'LETTER_CODE2_MPL', 1, 10, 'LETTER_CODE3_MPL', 1 )
56
|);
57
58
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules;
59
is_deeply( \@overdue_branches, ['CPL', 'MPL'] , 'If only 2 specific rules exist, 2 branches should be returned' );

Return to bug 9180