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

(-)a/C4/Reserves.pm (-5 / +5 lines)
Lines 911-917 sub CheckReserves { Link Here
911
    # Find this item in the reserves
911
    # Find this item in the reserves
912
    my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber, $lookahead_days, $ignore_borrowers);
912
    my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber, $lookahead_days, $ignore_borrowers);
913
    # When IndependentBranchesTransfers is activate remove the reserve made from other branches
913
    # When IndependentBranchesTransfers is activate remove the reserve made from other branches
914
    @reserves = _Removereserve( @reserves );
914
    @reserves = _FilterHoldsForIndependentBranches( @reserves );
915
915
916
    # $priority and $highest are used to find the most important item
916
    # $priority and $highest are used to find the most important item
917
    # in the list returned by &_Findgroupreserve. (The lower $priority,
917
    # in the list returned by &_Findgroupreserve. (The lower $priority,
Lines 1846-1864 sub _Findgroupreserve { Link Here
1846
    return @results;
1846
    return @results;
1847
}
1847
}
1848
1848
1849
=head2 _Removereserve
1849
=head2 _FilterHoldsForIndependentBranches
1850
1850
1851
  @reserves = &_Removereserve( @reserves );
1851
  @reserves = &_FilterHoldsForIndependentBranches( @reserves );
1852
1852
1853
Check transfers is allowed from system preference and remove the reserves made from other branches
1853
Check transfers is allowed from system preference and remove the reserves made from other branches
1854
1854
1855
C<&_Removereserve> returns :
1855
C<&_FilterHoldsForIndependentBranches> returns :
1856
C<@results> is an array of references-to-hash whose keys are mostly
1856
C<@results> is an array of references-to-hash whose keys are mostly
1857
fields from the reserves table of the Koha database, plus
1857
fields from the reserves table of the Koha database, plus
1858
1858
1859
=cut
1859
=cut
1860
1860
1861
sub _Removereserve {
1861
sub _FilterHoldsForIndependentBranches {
1862
    my ( @reserves) = @_;
1862
    my ( @reserves) = @_;
1863
    if ( C4::Context->preference("IndependentBranchesTransfers") && !C4::Context->IsSuperLibrarian() && scalar @reserves) {
1863
    if ( C4::Context->preference("IndependentBranchesTransfers") && !C4::Context->IsSuperLibrarian() && scalar @reserves) {
1864
        my @results;
1864
        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 => 78;
20
use Test::More tests => 84;
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