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

(-)a/C4/Reserves.pm (-5 / +5 lines)
Lines 910-916 sub CheckReserves { Link Here
910
    # Find this item in the reserves
910
    # Find this item in the reserves
911
    my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber, $lookahead_days, $ignore_borrowers);
911
    my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber, $lookahead_days, $ignore_borrowers);
912
    # When IndependentBranchesTransfers is activate remove the reserve made from other branches
912
    # When IndependentBranchesTransfers is activate remove the reserve made from other branches
913
    @reserves = _Removereserve( @reserves );
913
    @reserves = _FilterHoldsForIndependentBranches( @reserves );
914
914
915
    # $priority and $highest are used to find the most important item
915
    # $priority and $highest are used to find the most important item
916
    # in the list returned by &_Findgroupreserve. (The lower $priority,
916
    # in the list returned by &_Findgroupreserve. (The lower $priority,
Lines 1845-1863 sub _Findgroupreserve { Link Here
1845
    return @results;
1845
    return @results;
1846
}
1846
}
1847
1847
1848
=head2 _Removereserve
1848
=head2 _FilterHoldsForIndependentBranches
1849
1849
1850
  @reserves = &_Removereserve( @reserves );
1850
  @reserves = &_FilterHoldsForIndependentBranches( @reserves );
1851
1851
1852
Check transfers is allowed from system preference and remove the reserves made from other branches
1852
Check transfers is allowed from system preference and remove the reserves made from other branches
1853
1853
1854
C<&_Removereserve> returns :
1854
C<&_FilterHoldsForIndependentBranches> returns :
1855
C<@results> is an array of references-to-hash whose keys are mostly
1855
C<@results> is an array of references-to-hash whose keys are mostly
1856
fields from the reserves table of the Koha database, plus
1856
fields from the reserves table of the Koha database, plus
1857
1857
1858
=cut
1858
=cut
1859
1859
1860
sub _Removereserve {
1860
sub _FilterHoldsForIndependentBranches {
1861
    my ( @reserves) = @_;
1861
    my ( @reserves) = @_;
1862
    if ( C4::Context->preference("IndependentBranchesTransfers") && !C4::Context->IsSuperLibrarian() && scalar @reserves) {
1862
    if ( C4::Context->preference("IndependentBranchesTransfers") && !C4::Context->IsSuperLibrarian() && scalar @reserves) {
1863
        my @results;
1863
        my @results;
(-)a/t/db_dependent/Reserves.t (-2 / +22 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 77;
20
use Test::More tests => 83;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 131-136 is($status, "Reserved", "CheckReserves Test 2"); Link Here
131
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode);
131
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode);
132
is($status, "Reserved", "CheckReserves Test 3");
132
is($status, "Reserved", "CheckReserves Test 3");
133
133
134
# Set the preference 'IndependentBranchesTransfers' is set to 'yes'
135
# the userenv branch and the branche code are not the same holds should be filtered 
136
t::lib::Mocks::mock_preference( 'IndependentBranchesTransfers', 1 );
137
($status) = CheckReserves($item->itemnumber, $barcode);
138
is( $status, "", 'Reserves is filtered');
139
($status, $reserve, $all_reserves) = CheckReserves($item->itemnumber);
140
is( $status, "", 'Reserves is filtered');
141
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode);
142
is( $status, "", 'Reserves is filtered');
143
144
# Set the userenv branchcode to be the same to the item branchcode.
145
t::lib::Mocks::mock_userenv({ branchcode => $branchcode });
146
($status) = CheckReserves($item->itemnumber, $barcode);
147
is( $status, "Reserved", 'Reserves should not be filtered');
148
($status, $reserve, $all_reserves) = CheckReserves($item->itemnumber);
149
is( $status, "Reserved", 'Reserves should not be filtered');
150
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode);
151
is( $status, "Reserved", 'Reserves should not be filtered');
152
153
t::lib::Mocks::mock_userenv({ branchcode => $branch_1 });
154
t::lib::Mocks::mock_preference( 'IndependentBranchesTransfers', 0 );
134
my $ReservesControlBranch = C4::Context->preference('ReservesControlBranch');
155
my $ReservesControlBranch = C4::Context->preference('ReservesControlBranch');
135
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
156
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
136
ok(
157
ok(
137
- 

Return to bug 33200