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

(-)a/C4/ILSDI/Services.pm (-2 / +2 lines)
Lines 613-619 sub HoldTitle { Link Here
613
    return { code => 'NotHoldable' } if AlreadyReserved($biblionumber, $borrowernumber);
613
    return { code => 'NotHoldable' } if AlreadyReserved($biblionumber, $borrowernumber);
614
614
615
    # Check if the biblio can be reserved
615
    # Check if the biblio can be reserved
616
    return { code => 'NotHoldable' } unless CanBookBeReserved( $borrowernumber, $biblionumber ) eq 'OK';
616
    return { code => 'NotHoldable' } unless C4::Reserves::CanBookBeReserved( $borrowernumber, $biblionumber ) eq 'OK';
617
617
618
    my $branch;
618
    my $branch;
619
619
Lines 628-634 sub HoldTitle { Link Here
628
628
629
    # Add the reserve
629
    # Add the reserve
630
    #    $branch,    $borrowernumber, $biblionumber,
630
    #    $branch,    $borrowernumber, $biblionumber,
631
    #    $constraint, $bibitems,  $priority, $resdate, $expdate, $notes,
631
    #    $bibitems,  $priority, $resdate, $expdate, $notes,
632
    #    $title,      $checkitem, $found
632
    #    $title,      $checkitem, $found
633
    my $priority= C4::Reserves::CalculatePriority( $biblionumber );
633
    my $priority= C4::Reserves::CalculatePriority( $biblionumber );
634
    AddReserve( $branch, $borrowernumber, $biblionumber, undef, $priority, undef, undef, undef, $title, undef, undef );
634
    AddReserve( $branch, $borrowernumber, $biblionumber, undef, $priority, undef, undef, undef, $title, undef, undef );
(-)a/C4/Reserves.pm (-1 / +1 lines)
Lines 1060-1066 sub ReachedMaxReserves { Link Here
1060
1060
1061
    return 0 unless C4::Context->preference('maxreserves');
1061
    return 0 unless C4::Context->preference('maxreserves');
1062
1062
1063
    if ( $number_reserves + $number_wanted >= C4::Context->preference('maxreserves') ) {
1063
    if ( $number_reserves + $number_wanted > C4::Context->preference('maxreserves') ) {
1064
        return 1;
1064
        return 1;
1065
    }
1065
    }
1066
1066
(-)a/t/db_dependent/ILSDI_Services.t (-1 / +31 lines)
Lines 25-30 $dbh->{RaiseError} = 1; Link Here
25
my $maxallowedreserves = 3;
25
my $maxallowedreserves = 3;
26
t::lib::Mocks::mock_preference('maxreserves', $maxallowedreserves);
26
t::lib::Mocks::mock_preference('maxreserves', $maxallowedreserves);
27
27
28
my $context = new Test::MockModule('C4::Context');
29
mock_marcfromkohafield();
30
31
my $reserves_module = new Test::MockModule('C4::Reserves');
32
$reserves_module->mock('CanBookBeReserved',
33
    sub {
34
        return 'OK';
35
    }
36
);
37
38
$reserves_module->mock('CanItemBeReserved',
39
    sub {
40
        return 'OK';
41
    }
42
);
43
28
# Create patron
44
# Create patron
29
my %data = (
45
my %data = (
30
    firstname =>  'my firstname',
46
    firstname =>  'my firstname',
Lines 71-77 my %item_branch_infos = ( Link Here
71
);
87
);
72
88
73
my $record = MARC::Record->new;
89
my $record = MARC::Record->new;
74
my $title = MARC::Field->new('200','','','a' => 'Hello world.');
90
my $title = MARC::Field->new('245','','','a' => 'Hello world.');
75
$record->append_fields($title);
91
$record->append_fields($title);
76
92
77
my ($biblionumber) = AddBiblio($record, '');
93
my ($biblionumber) = AddBiblio($record, '');
Lines 163-165 my $itemnumber4 = AddItem({ barcode => '0401', %item_branch_infos }, $biblionumb Link Here
163
    $reply = C4::ILSDI::Services::HoldItem($query);
179
    $reply = C4::ILSDI::Services::HoldItem($query);
164
    is($reply->{'pickup_location'}, 'Unit test library', 'Joe John hold an item - ILSDI');
180
    is($reply->{'pickup_location'}, 'Unit test library', 'Joe John hold an item - ILSDI');
165
}
181
}
182
183
sub mock_marcfromkohafield {
184
185
    $context->mock('marcfromkohafield',
186
        sub {
187
            return  {
188
                '' => {
189
                    'biblio.title' => [ '245', 'a' ],
190
                    'biblio.biblionumber' => [ '999', 'c' ],
191
                    'biblioitems.biblioitemnumber' => [ '999', 'd' ]
192
                }
193
            };
194
        });
195
}
(-)a/t/db_dependent/Reserves.t (-8 / +11 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 => 79;
21
use Test::Warn;
21
use Test::Warn;
22
22
23
use MARC::Record;
23
use MARC::Record;
Lines 168-180 t::lib::Mocks::mock_preference('maxreserves', 3); Link Here
168
168
169
ok(!ReachedMaxReserves($borrowernumber), 'First borrower doesn\'t reached max reserves');
169
ok(!ReachedMaxReserves($borrowernumber), 'First borrower doesn\'t reached max reserves');
170
170
171
AddReserve($branch,    $borrowernumber, $miniaturist_id,
171
ok(!ReachedMaxReserves($borrowernumber, 2), 'First borrower asking for 2 documents doesn\'t reached max reserves');
172
        $constraint, $bibitems,  $priority, $resdate, $expdate, $notes,
173
        $title_14155a,      $checkitem, $found);
174
172
175
AddReserve($branch,    $borrowernumber, $broken_id,
173
ok(ReachedMaxReserves($borrowernumber, 3), 'First borrower asking for 3 documents reached max reserves');
176
        $constraint, $bibitems,  $priority, $resdate, $expdate, $notes,
174
177
        $title_14155b,      $checkitem, $found);
175
AddReserve($branch, $borrowernumber, $miniaturist_id,
176
           $bibitems, $priority, $resdate, $expdate, $notes,
177
           $title_14155a, $checkitem, $found);
178
179
AddReserve($branch, $borrowernumber, $broken_id,
180
           $bibitems, $priority, $resdate, $expdate, $notes,
181
           $title_14155b, $checkitem, $found);
178
182
179
ok(ReachedMaxReserves($borrowernumber), 'First borrower reached max reserves');
183
ok(ReachedMaxReserves($borrowernumber), 'First borrower reached max reserves');
180
184
181
- 

Return to bug 14155