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

(-)a/C4/ILSDI/Services.pm (-6 / +20 lines)
Lines 680-686 sub HoldTitle { Link Here
680
    #    $constraint, $bibitems,  $priority, $resdate, $expdate, $notes,
680
    #    $constraint, $bibitems,  $priority, $resdate, $expdate, $notes,
681
    #    $title,      $checkitem, $found
681
    #    $title,      $checkitem, $found
682
    my $priority= C4::Reserves::CalculatePriority( $biblionumber );
682
    my $priority= C4::Reserves::CalculatePriority( $biblionumber );
683
    AddReserve( $branch, $borrowernumber, $biblionumber, undef, $priority, undef, undef, undef, $title, undef, undef );
683
    AddReserve(
684
        {
685
            branch         => $branch,
686
            borrowernumber => $borrowernumber,
687
            biblionumber   => $biblionumber,
688
            priority       => $priority,
689
            title          => $title,
690
        }
691
    );
684
692
685
    # Hashref building
693
    # Hashref building
686
    my $out;
694
    my $out;
Lines 753-763 sub HoldItem { Link Here
753
    }
761
    }
754
762
755
    # Add the reserve
763
    # Add the reserve
756
    #    $branch,    $borrowernumber, $biblionumber,
764
    my $priority = C4::Reserves::CalculatePriority($biblionumber);
757
    #    $constraint, $bibitems,  $priority, $resdate, $expdate, $notes,
765
    AddReserve(
758
    #    $title,      $checkitem, $found
766
        {
759
    my $priority= C4::Reserves::CalculatePriority( $biblionumber );
767
            branch         => $branch,
760
    AddReserve( $branch, $borrowernumber, $biblionumber, undef, $priority, undef, undef, undef, $title, $itemnumber, undef );
768
            borrowernumber => $borrowernumber,
769
            biblionumber   => $biblionumber,
770
            priority       => $priority,
771
            title          => $title,
772
            checkitem      => $itemnumber,
773
        }
774
    );
761
775
762
    # Hashref building
776
    # Hashref building
763
    my $out;
777
    my $out;
(-)a/C4/Reserves.pm (-6 / +27 lines)
Lines 144-150 BEGIN { Link Here
144
144
145
=head2 AddReserve
145
=head2 AddReserve
146
146
147
    AddReserve($branch,$borrowernumber,$biblionumber,$bibitems,$priority,$resdate,$expdate,$notes,$title,$checkitem,$found)
147
    AddReserve(
148
        {
149
            branch         => $branchcode,
150
            borrowernumber => $borrowernumber,
151
            biblionumber   => $biblionumber,
152
            priority       => $priority,
153
            resdate        => $reservation_date,
154
            expdate        => $expiration_date,
155
            notes          => $notes,
156
            title          => $title,
157
            checkitem      => $itemnumber,
158
            found          => $found,
159
            itemtype       => $itemtype,
160
        }
161
    );
148
162
149
Adds reserve and generates HOLDPLACED message.
163
Adds reserve and generates HOLDPLACED message.
150
164
Lines 160-170 The following tables are available witin the HOLDPLACED message: Link Here
160
=cut
174
=cut
161
175
162
sub AddReserve {
176
sub AddReserve {
163
    my (
177
    my ($params)       = @_;
164
        $branch,   $borrowernumber, $biblionumber, $bibitems,
178
    my $branch         = $params->{branchcode};
165
        $priority, $resdate,        $expdate,      $notes,
179
    my $borrowernumber = $params->{borrowernumber};
166
        $title,    $checkitem,      $found,        $itemtype
180
    my $biblionumber   = $params->{biblionumber};
167
    ) = @_;
181
    my $priority       = $params->{priority};
182
    my $resdate        = $params->{reservation_date};
183
    my $expdate        = $params->{expiration_date};
184
    my $notes          = $params->{notes};
185
    my $title          = $params->{title};
186
    my $checkitem      = $params->{itemnumber};
187
    my $found          = $params->{found};
188
    my $itemtype       = $params->{itemtype};
168
189
169
    $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' })
190
    $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' })
170
        or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
191
        or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
(-)a/C4/SIP/ILS/Transaction/Hold.pm (-1 / +7 lines)
Lines 60-66 sub do_hold { Link Here
60
        $self->ok(0);
60
        $self->ok(0);
61
        return $self;
61
        return $self;
62
    }
62
    }
63
    AddReserve( $branch, $patron->borrowernumber, $item->biblionumber );
63
    AddReserve(
64
        {
65
            branch         => $branch,
66
            borrowernumber => $patron->borrowernumber,
67
            biblionumber   => $item->biblionumber
68
        }
69
    );
64
70
65
    # unfortunately no meaningful return value
71
    # unfortunately no meaningful return value
66
    $self->ok(1);
72
    $self->ok(1);
(-)a/Koha/REST/V1/Hold.pm (-3 / +12 lines)
Lines 103-111 sub add { Link Here
103
        $expirationdate = output_pref(dt_from_string($expirationdate, 'iso'));
103
        $expirationdate = output_pref(dt_from_string($expirationdate, 'iso'));
104
    }
104
    }
105
105
106
    my $reserve_id = C4::Reserves::AddReserve($branchcode, $borrowernumber,
106
    my $reserve_id = C4::Reserves::AddReserve(
107
        $biblionumber, undef, $priority, undef, $expirationdate, undef,
107
        {
108
        $biblio->title, $itemnumber, undef, $itemtype);
108
            branchcode      => $branchcode,
109
            borrowernumber  => $borrowernumber,
110
            biblionumber    => $biblionumber,
111
            priority        => $priority,
112
            expiration_date => $expirationdate,
113
            title           => $biblio->title,
114
            itemnumber      => $itemnumber,
115
            itemtype        => $itemtype
116
        }
117
    );
109
118
110
    unless ($reserve_id) {
119
    unless ($reserve_id) {
111
        return $c->render( status => 500, openapi => {
120
        return $c->render( status => 500, openapi => {
(-)a/opac/opac-reserve.pl (-4 / +13 lines)
Lines 300-309 if ( $query->param('place_reserve') ) { Link Here
300
        # Here we actually do the reserveration. Stage 3.
300
        # Here we actually do the reserveration. Stage 3.
301
        if ($canreserve) {
301
        if ($canreserve) {
302
            my $reserve_id = AddReserve(
302
            my $reserve_id = AddReserve(
303
                $branch,          $borrowernumber, $biblioNum,
303
                {
304
                [$biblioNum],     $rank,           $startdate,
304
                    branchcode       => $branch,
305
                $expiration_date, $notes,          $biblioData->{title},
305
                    borrowernumber   => $borrowernumber,
306
                $itemNum,         $found,          $itemtype,
306
                    biblionumber     => $biblioNum,
307
                    priority         => $rank,
308
                    reservation_date => $startdate,
309
                    expiration_date  => $expiration_date,
310
                    notes            => $notes,
311
                    title            => $biblioData->{title},
312
                    itemnumber       => $itemNum,
313
                    found            => $found,
314
                    itemtype         => $itemtype,
315
                }
307
            );
316
            );
308
            $failed_holds++ unless $reserve_id;
317
            $failed_holds++ unless $reserve_id;
309
            ++$reserve_cnt;
318
            ++$reserve_cnt;
(-)a/reserve/placerequest.pl (-5 / +29 lines)
Lines 95-108 if ( $type eq 'str8' && $borrower ) { Link Here
95
95
96
        if ($multi_hold) {
96
        if ($multi_hold) {
97
            my $bibinfo = $bibinfos{$biblionumber};
97
            my $bibinfo = $bibinfos{$biblionumber};
98
            AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,[$biblionumber],
98
            AddReserve(
99
                       $bibinfo->{rank},$startdate,$expirationdate,$notes,$bibinfo->{title},$checkitem,$found);
99
                {
100
                    branchcode       => $branch,
101
                    borrowernumber   => $borrower->{'borrowernumber'},
102
                    biblionumber     => $biblionumber,
103
                    priority         => $bibinfo->{rank},
104
                    reservation_date => $startdate,
105
                    expiration_date  => $expirationdate,
106
                    notes            => $notes,
107
                    title            => $bibinfo->{title},
108
                    itemnumber       => $checkitem,
109
                    found            => $found,
110
                }
111
            );
100
        } else {
112
        } else {
101
            # place a request on 1st available
113
            # place a request on 1st available
102
            for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) {
114
            for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) {
103
                AddReserve( $branch, $borrower->{'borrowernumber'},
115
                AddReserve(
104
                    $biblionumber, \@realbi, $rank[0], $startdate, $expirationdate, $notes, $title,
116
                    {
105
                    $checkitem, $found, $itemtype );
117
                        branchcode       => $branch,
118
                        borrowernumber   => $borrower->{'borrowernumber'},
119
                        biblionumber     => $biblionumber,
120
                        priority         => $rank[0],
121
                        reservation_date => $startdate,
122
                        expiration_date  => $expirationdate,
123
                        notes            => $notes,
124
                        title            => $title,
125
                        itemnumber       => $checkitem,
126
                        found            => $found,
127
                        itemtype         => $itemtype,
128
                    }
129
                );
106
            }
130
            }
107
        }
131
        }
108
    }
132
    }
(-)a/serials/routing-preview.pl (-1 / +10 lines)
Lines 94-100 if($ok){ Link Here
94
                    branchcode     => $branch
94
                    branchcode     => $branch
95
                });
95
                });
96
            } else {
96
            } else {
97
                AddReserve($branch,$routing->{borrowernumber},$biblionumber,undef,$routing->{ranking}, undef, undef, $notes,$title);
97
                AddReserve(
98
                    {
99
                        branchcode     => $branch,
100
                        borrowernumber => $routing->{borrowernumber},
101
                        biblionumber   => $biblionumber,
102
                        priority       => $routing->{ranking},
103
                        notes          => $notes,
104
                        title          => $title,
105
                    }
106
                );
98
        }
107
        }
99
    }
108
    }
100
	}
109
	}
(-)a/t/db_dependent/Circulation.t (-17 / +61 lines)
Lines 343-351 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
343
343
344
    # Biblio-level hold, renewal test
344
    # Biblio-level hold, renewal test
345
    AddReserve(
345
    AddReserve(
346
        $branch, $reserving_borrowernumber, $biblionumber,
346
        {
347
        $bibitems,  $priority, $resdate, $expdate, $notes,
347
            branchcode       => $branch,
348
        $title, $checkitem, $found
348
            borrowernumber   => $reserving_borrowernumber,
349
            biblionumber     => $biblionumber,
350
            priority         => $priority,
351
            reservation_date => $resdate,
352
            expiration_date  => $expdate,
353
            notes            => $notes,
354
            title            => $title,
355
            itemnumber       => $checkitem,
356
            found            => $found,
357
        }
349
    );
358
    );
350
359
351
    # Testing of feature to allow the renewal of reserved items if other items on the record can fill all needed holds
360
    # Testing of feature to allow the renewal of reserved items if other items on the record can fill all needed holds
Lines 408-416 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
408
417
409
    # Item-level hold, renewal test
418
    # Item-level hold, renewal test
410
    AddReserve(
419
    AddReserve(
411
        $branch, $reserving_borrowernumber, $biblionumber,
420
        {
412
        $bibitems,  $priority, $resdate, $expdate, $notes,
421
            branchcode       => $branch,
413
        $title, $itemnumber, $found
422
            borrowernumber   => $reserving_borrowernumber,
423
            biblionumber     => $biblionumber,
424
            priority         => $priority,
425
            reservation_date => $resdate,
426
            expiration_date  => $expdate,
427
            notes            => $notes,
428
            title            => $title,
429
            itemnumber       => $itemnumber,
430
            found            => $found,
431
        }
414
    );
432
    );
415
433
416
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber, 1);
434
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber, 1);
Lines 1096-1104 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
1096
    is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with no hold on the record' );
1114
    is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with no hold on the record' );
1097
1115
1098
    AddReserve(
1116
    AddReserve(
1099
        $library2->{branchcode}, $borrowernumber2, $biblionumber,
1117
        {
1100
        '',  1, undef, undef, '',
1118
            branchcode     => $library2->{branchcode},
1101
        undef, undef, undef
1119
            borrowernumber => $borrowernumber2,
1120
            biblionumber   => $biblionumber,
1121
            priority       => 1,
1122
        }
1102
    );
1123
    );
1103
1124
1104
    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0");
1125
    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0");
Lines 1522-1530 subtest 'MultipleReserves' => sub { Link Here
1522
    );
1543
    );
1523
    my $reserving_borrowernumber1 = Koha::Patron->new(\%reserving_borrower_data1)->store->borrowernumber;
1544
    my $reserving_borrowernumber1 = Koha::Patron->new(\%reserving_borrower_data1)->store->borrowernumber;
1524
    AddReserve(
1545
    AddReserve(
1525
        $branch, $reserving_borrowernumber1, $biblionumber,
1546
        {
1526
        $bibitems,  $priority, $resdate, $expdate, $notes,
1547
            branchcode       => $branch,
1527
        $title, $checkitem, $found
1548
            borrowernumber   => $reserving_borrowernumber1,
1549
            biblionumber     => $biblionumber,
1550
            priority         => $priority,
1551
            reservation_date => $resdate,
1552
            expiration_date  => $expdate,
1553
            notes            => $notes,
1554
            title            => $title,
1555
            itemnumber       => $checkitem,
1556
            found            => $found,
1557
        }
1528
    );
1558
    );
1529
1559
1530
    my %reserving_borrower_data2 = (
1560
    my %reserving_borrower_data2 = (
Lines 1535-1543 subtest 'MultipleReserves' => sub { Link Here
1535
    );
1565
    );
1536
    my $reserving_borrowernumber2 = Koha::Patron->new(\%reserving_borrower_data2)->store->borrowernumber;
1566
    my $reserving_borrowernumber2 = Koha::Patron->new(\%reserving_borrower_data2)->store->borrowernumber;
1537
    AddReserve(
1567
    AddReserve(
1538
        $branch, $reserving_borrowernumber2, $biblionumber,
1568
        {
1539
        $bibitems,  $priority, $resdate, $expdate, $notes,
1569
            branchcode       => $branch,
1540
        $title, $checkitem, $found
1570
            borrowernumber   => $reserving_borrowernumber2,
1571
            biblionumber     => $biblionumber,
1572
            priority         => $priority,
1573
            reservation_date => $resdate,
1574
            expiration_date  => $expdate,
1575
            notes            => $notes,
1576
            title            => $title,
1577
            itemnumber       => $checkitem,
1578
            found            => $found,
1579
        }
1541
    );
1580
    );
1542
1581
1543
    {
1582
    {
Lines 2133-2140 subtest 'Set waiting flag' => sub { Link Here
2133
2172
2134
    set_userenv( $library_2 );
2173
    set_userenv( $library_2 );
2135
    my $reserve_id = AddReserve(
2174
    my $reserve_id = AddReserve(
2136
        $library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber},
2175
        {
2137
        '', 1, undef, undef, '', undef, $item->{itemnumber},
2176
            branchcode     => $library_2->{branchcode},
2177
            borrowernumber => $patron_2->{borrowernumber},
2178
            biblionumber   => $biblioitem->{biblionumber},
2179
            priority       => 1,
2180
            itemnumber     => $item->{itemnumber},
2181
        }
2138
    );
2182
    );
2139
2183
2140
    set_userenv( $library_1 );
2184
    set_userenv( $library_1 );
(-)a/t/db_dependent/Circulation/issue.t (-2 / +10 lines)
Lines 371-378 $item = GetItem( $itemnumber ); Link Here
371
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} );
371
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} );
372
372
373
# Bug 14640 - Cancel the hold on checking out if asked
373
# Bug 14640 - Cancel the hold on checking out if asked
374
my $reserve_id = AddReserve($branchcode_1, $borrower_id1, $biblionumber,
374
my $reserve_id = AddReserve(
375
    undef,  1, undef, undef, "a note", "a title", undef, '');
375
    {
376
        branchcode     => $branchcode_1,
377
        borrowernumber => $borrower_id1,
378
        biblionumber   => $biblionumber,
379
        priority       => 1,
380
        notes          => "a note",
381
        title          => "a title",
382
    }
383
);
376
ok( $reserve_id, 'The reserve should have been inserted' );
384
ok( $reserve_id, 'The reserve should have been inserted' );
377
AddIssue( $borrower_2, $barcode_1, dt_from_string, 'cancel' );
385
AddIssue( $borrower_2, $barcode_1, dt_from_string, 'cancel' );
378
my $hold = Koha::Holds->find( $reserve_id );
386
my $hold = Koha::Holds->find( $reserve_id );
(-)a/t/db_dependent/Holds.t (-33 / +57 lines)
Lines 72-88 my $biblionumber = $bibnum; Link Here
72
# Create five item level holds
72
# Create five item level holds
73
foreach my $borrowernumber ( @borrowernumbers ) {
73
foreach my $borrowernumber ( @borrowernumbers ) {
74
    AddReserve(
74
    AddReserve(
75
        $branch_1,
75
        {
76
        $borrowernumber,
76
            branchcode     => $branch_1,
77
        $biblionumber,
77
            borrowernumber => $borrowernumber,
78
        my $bibitems = q{},
78
            biblionumber   => $biblionumber,
79
        my $priority = C4::Reserves::CalculatePriority( $biblionumber ),
79
            priority       => C4::Reserves::CalculatePriority( $biblionumber ),
80
        my $resdate,
80
            title          => $title,
81
        my $expdate,
81
            itemnumber     => $itemnumber,
82
        my $notes = q{},
82
        }
83
        $title,
84
        my $checkitem = $itemnumber,
85
        my $found,
86
    );
83
    );
87
}
84
}
88
85
Lines 188-206 is( $hold->suspend, 0, "Test resuming with SuspendAll()" ); Link Here
188
is( $hold->suspend_until, undef, "Test resuming with SuspendAll(), should have no suspend until date" );
185
is( $hold->suspend_until, undef, "Test resuming with SuspendAll(), should have no suspend until date" );
189
186
190
# Add a new hold for the borrower whose hold we canceled earlier, this time at the bib level
187
# Add a new hold for the borrower whose hold we canceled earlier, this time at the bib level
191
AddReserve(
188
    AddReserve(
192
    $branch_1,
189
        {
193
    $borrowernumbers[0],
190
            branchcode     => $branch_1,
194
    $biblionumber,
191
            borrowernumber => $borrowernumbers[0],
195
    my $bibitems = q{},
192
            biblionumber   => $biblionumber,
196
    my $priority,
193
            title          => $title,
197
    my $resdate,
194
        }
198
    my $expdate,
195
    );
199
    my $notes = q{},
196
200
    $title,
201
    my $checkitem,
202
    my $found,
203
);
204
$patron = Koha::Patrons->find( $borrowernumber );
197
$patron = Koha::Patrons->find( $borrowernumber );
205
$holds = $patron->holds;
198
$holds = $patron->holds;
206
my $reserveid = Koha::Holds->search({ biblionumber => $bibnum, borrowernumber => $borrowernumbers[0] })->next->reserve_id;
199
my $reserveid = Koha::Holds->search({ biblionumber => $bibnum, borrowernumber => $borrowernumbers[0] })->next->reserve_id;
Lines 284-294 ok( Link Here
284
    # Regression test for bug 11336 # Test if ModReserve correctly recalculate the priorities
277
    # Regression test for bug 11336 # Test if ModReserve correctly recalculate the priorities
285
    ($bibnum, $title, $bibitemnum) = create_helper_biblio('DUMMY');
278
    ($bibnum, $title, $bibitemnum) = create_helper_biblio('DUMMY');
286
    ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $bibnum);
279
    ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $bibnum);
287
    my $reserveid1 = AddReserve($branch_1, $borrowernumbers[0], $bibnum, '', 1);
280
    my $reserveid1 = AddReserve(
281
        {
282
            branchcode     => $branch_1,
283
            borrowernumber => $borrowernumbers[0],
284
            biblionumber   => $bibnum,
285
            priority       => 1
286
        }
287
    );
288
    ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $bibnum);
288
    ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $bibnum);
289
    my $reserveid2 = AddReserve($branch_1, $borrowernumbers[1], $bibnum, '', 2);
289
    my $reserveid2 = AddReserve(
290
        {
291
            branchcode     => $branch_1,
292
            borrowernumber => $borrowernumbers[1],
293
            biblionumber   => $bibnum,
294
            priority       => 2
295
        }
296
    );
297
290
    ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $bibnum);
298
    ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $bibnum);
291
    my $reserveid3 = AddReserve($branch_1, $borrowernumbers[2], $bibnum, '', 3);
299
    my $reserveid3 = AddReserve(
300
        {
301
            branchcode     => $branch_1,
302
            borrowernumber => $borrowernumbers[2],
303
            biblionumber   => $bibnum,
304
            priority       => 3
305
        }
306
    );
307
292
    my $hhh = Koha::Holds->search({ biblionumber => $bibnum });
308
    my $hhh = Koha::Holds->search({ biblionumber => $bibnum });
293
    my $hold3 = Koha::Holds->find( $reserveid3 );
309
    my $hold3 = Koha::Holds->find( $reserveid3 );
294
    is( $hold3->priority, 3, "The 3rd hold should have a priority set to 3" );
310
    is( $hold3->priority, 3, "The 3rd hold should have a priority set to 3" );
Lines 322-332 ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for d Link Here
322
($bibnum, $title, $bibitemnum) = create_helper_biblio('CANNOT');
338
($bibnum, $title, $bibitemnum) = create_helper_biblio('CANNOT');
323
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $bibnum);
339
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $bibnum);
324
AddReserve(
340
AddReserve(
325
    $branch_1,
341
    {
326
    $borrowernumbers[0],
342
        branchcode     => $branch_1,
327
    $bibnum,
343
        borrowernumber => $borrowernumbers[0],
328
    '',
344
        biblionumber   => $bibnum,
329
    1,
345
        priority       => 1,
346
    }
330
);
347
);
331
is(
348
is(
332
    CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'tooManyReserves',
349
    CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'tooManyReserves',
Lines 406-412 $dbh->do( Link Here
406
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
423
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
407
    'OK', 'Patron can reserve item with hold limit of 1, no holds placed' );
424
    'OK', 'Patron can reserve item with hold limit of 1, no holds placed' );
408
425
409
my $res_id = AddReserve( $branch_1, $borrowernumbers[0], $bibnum, '', 1, );
426
my $res_id = AddReserve(
427
    {
428
        branchcode     => $branch_1,
429
        borrowernumber => $borrowernumbers[0],
430
        biblionumber   => $bibnum,
431
        priority       => 1,
432
    }
433
);
410
434
411
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
435
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
412
    'tooManyReserves', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' );
436
    'tooManyReserves', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' );
(-)a/t/db_dependent/Holds/HoldFulfillmentPolicy.t (-9 / +72 lines)
Lines 77-95 $dbh->do("DELETE FROM default_circ_rules"); Link Here
77
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )");
77
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )");
78
78
79
# Home branch matches pickup branch
79
# Home branch matches pickup branch
80
my $reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
80
my $reserve_id = AddReserve(
81
    {
82
        branchcode     => $library_A,
83
        borrowernumber => $borrowernumber,
84
        biblionumber   => $biblionumber,
85
        priority       => 1,
86
    }
87
);
81
my ( $status ) = CheckReserves($itemnumber);
88
my ( $status ) = CheckReserves($itemnumber);
82
is( $status, 'Reserved', "Hold where pickup branch matches home branch targeted" );
89
is( $status, 'Reserved', "Hold where pickup branch matches home branch targeted" );
83
Koha::Holds->find( $reserve_id )->cancel;
90
Koha::Holds->find( $reserve_id )->cancel;
84
91
85
# Holding branch matches pickup branch
92
# Holding branch matches pickup branch
86
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 );
93
$reserve_id = AddReserve(
94
    {
95
        branchcode     => $library_B,
96
        borrowernumber => $borrowernumber,
97
        biblionumber   => $biblionumber,
98
        priority       => 1,
99
    }
100
);
87
( $status ) = CheckReserves($itemnumber);
101
( $status ) = CheckReserves($itemnumber);
88
is($status, q{}, "Hold where pickup ne home, pickup eq home not targeted" );
102
is($status, q{}, "Hold where pickup ne home, pickup eq home not targeted" );
89
Koha::Holds->find( $reserve_id )->cancel;
103
Koha::Holds->find( $reserve_id )->cancel;
90
104
91
# Neither branch matches pickup branch
105
# Neither branch matches pickup branch
92
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 );
106
$reserve_id = AddReserve(
107
    {
108
        branchcode     => $library_C,
109
        borrowernumber => $borrowernumber,
110
        biblionumber   => $biblionumber,
111
        priority       => 1,
112
    }
113
);
93
( $status ) = CheckReserves($itemnumber);
114
( $status ) = CheckReserves($itemnumber);
94
is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" );
115
is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" );
95
Koha::Holds->find( $reserve_id )->cancel;
116
Koha::Holds->find( $reserve_id )->cancel;
Lines 99-117 $dbh->do("DELETE FROM default_circ_rules"); Link Here
99
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'holdingbranch' )");
120
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'holdingbranch' )");
100
121
101
# Home branch matches pickup branch
122
# Home branch matches pickup branch
102
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
123
$reserve_id = AddReserve(
124
    {
125
        branchcode     => $library_A,
126
        borrowernumber => $borrowernumber,
127
        biblionumber   => $biblionumber,
128
        priority       => 1,
129
    }
130
);
103
( $status ) = CheckReserves($itemnumber);
131
( $status ) = CheckReserves($itemnumber);
104
is( $status, q{}, "Hold where pickup eq home, pickup ne holding not targeted" );
132
is( $status, q{}, "Hold where pickup eq home, pickup ne holding not targeted" );
105
Koha::Holds->find( $reserve_id )->cancel;
133
Koha::Holds->find( $reserve_id )->cancel;
106
134
107
# Holding branch matches pickup branch
135
# Holding branch matches pickup branch
108
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 );
136
$reserve_id = AddReserve(
137
    {
138
        branchcode     => $library_B,
139
        borrowernumber => $borrowernumber,
140
        biblionumber   => $biblionumber,
141
        priority       => 1,
142
    }
143
);
109
( $status ) = CheckReserves($itemnumber);
144
( $status ) = CheckReserves($itemnumber);
110
is( $status, 'Reserved', "Hold where pickup ne home, pickup eq holding targeted" );
145
is( $status, 'Reserved', "Hold where pickup ne home, pickup eq holding targeted" );
111
Koha::Holds->find( $reserve_id )->cancel;
146
Koha::Holds->find( $reserve_id )->cancel;
112
147
113
# Neither branch matches pickup branch
148
# Neither branch matches pickup branch
114
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 );
149
$reserve_id = AddReserve(
150
    {
151
        branchcode     => $library_C,
152
        borrowernumber => $borrowernumber,
153
        biblionumber   => $biblionumber,
154
        priority       => 1,
155
    }
156
);
115
( $status ) = CheckReserves($itemnumber);
157
( $status ) = CheckReserves($itemnumber);
116
is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" );
158
is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" );
117
Koha::Holds->find( $reserve_id )->cancel;
159
Koha::Holds->find( $reserve_id )->cancel;
Lines 121-139 $dbh->do("DELETE FROM default_circ_rules"); Link Here
121
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
163
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
122
164
123
# Home branch matches pickup branch
165
# Home branch matches pickup branch
124
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
166
$reserve_id = AddReserve(
167
    {
168
        branchcode     => $library_A,
169
        borrowernumber => $borrowernumber,
170
        biblionumber   => $biblionumber,
171
        priority       => 1,
172
    }
173
);
125
( $status ) = CheckReserves($itemnumber);
174
( $status ) = CheckReserves($itemnumber);
126
is( $status, 'Reserved', "Hold where pickup eq home, pickup ne holding targeted" );
175
is( $status, 'Reserved', "Hold where pickup eq home, pickup ne holding targeted" );
127
Koha::Holds->find( $reserve_id )->cancel;
176
Koha::Holds->find( $reserve_id )->cancel;
128
177
129
# Holding branch matches pickup branch
178
# Holding branch matches pickup branch
130
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 );
179
$reserve_id = AddReserve(
180
    {
181
        branchcode     => $library_B,
182
        borrowernumber => $borrowernumber,
183
        biblionumber   => $biblionumber,
184
        priority       => 1,
185
    }
186
);
131
( $status ) = CheckReserves($itemnumber);
187
( $status ) = CheckReserves($itemnumber);
132
is( $status, 'Reserved', "Hold where pickup ne home, pickup eq holding targeted" );
188
is( $status, 'Reserved', "Hold where pickup ne home, pickup eq holding targeted" );
133
Koha::Holds->find( $reserve_id )->cancel;
189
Koha::Holds->find( $reserve_id )->cancel;
134
190
135
# Neither branch matches pickup branch
191
# Neither branch matches pickup branch
136
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 );
192
$reserve_id = AddReserve(
193
    {
194
        branchcode     => $library_C,
195
        borrowernumber => $borrowernumber,
196
        biblionumber   => $biblionumber,
197
        priority       => 1,
198
    }
199
);
137
( $status ) = CheckReserves($itemnumber);
200
( $status ) = CheckReserves($itemnumber);
138
is( $status, 'Reserved', "Hold where pickup ne home, pickup ne holding targeted" );
201
is( $status, 'Reserved', "Hold where pickup ne home, pickup ne holding targeted" );
139
Koha::Holds->find( $reserve_id )->cancel;
202
Koha::Holds->find( $reserve_id )->cancel;
(-)a/t/db_dependent/Holds/HoldItemtypeLimit.t (-3 / +27 lines)
Lines 93-111 $dbh->do("DELETE FROM default_circ_rules"); Link Here
93
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
93
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
94
94
95
# Itemtypes match
95
# Itemtypes match
96
my $reserve_id = AddReserve( $branchcode, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $right_itemtype );
96
my $reserve_id = AddReserve(
97
    {
98
        branchcode     => $branchcode,
99
        borrowernumber => $borrowernumber,
100
        biblionumber   => $biblionumber,
101
        priority       => 1,
102
        itemtype       => $right_itemtype,
103
    }
104
);
97
my ( $status ) = CheckReserves($itemnumber);
105
my ( $status ) = CheckReserves($itemnumber);
98
is( $status, 'Reserved', "Hold where itemtype matches item's itemtype targed" );
106
is( $status, 'Reserved', "Hold where itemtype matches item's itemtype targed" );
99
Koha::Holds->find( $reserve_id )->cancel;
107
Koha::Holds->find( $reserve_id )->cancel;
100
108
101
# Itemtypes don't match
109
# Itemtypes don't match
102
$reserve_id = AddReserve( $branchcode, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $wrong_itemtype );
110
$reserve_id = AddReserve(
111
    {
112
        branchcode     => $branchcode,
113
        borrowernumber => $borrowernumber,
114
        biblionumber   => $biblionumber,
115
        priority       => 1,
116
        itemtype       => $wrong_itemtype,
117
    }
118
);
119
103
( $status ) = CheckReserves($itemnumber);
120
( $status ) = CheckReserves($itemnumber);
104
is($status, q{}, "Hold where itemtype does not match item's itemtype not targeted" );
121
is($status, q{}, "Hold where itemtype does not match item's itemtype not targeted" );
105
Koha::Holds->find( $reserve_id )->cancel;
122
Koha::Holds->find( $reserve_id )->cancel;
106
123
107
# No itemtype set
124
# No itemtype set
108
$reserve_id = AddReserve( $branchcode, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, undef );
125
$reserve_id = AddReserve(
126
    {
127
        branchcode     => $branchcode,
128
        borrowernumber => $borrowernumber,
129
        biblionumber   => $biblionumber,
130
        priority       => 1,
131
    }
132
);
109
( $status ) = CheckReserves($itemnumber);
133
( $status ) = CheckReserves($itemnumber);
110
is( $status, 'Reserved', "Item targeted with no hold itemtype set" );
134
is( $status, 'Reserved', "Item targeted with no hold itemtype set" );
111
Koha::Holds->find( $reserve_id )->cancel;
135
Koha::Holds->find( $reserve_id )->cancel;
(-)a/t/db_dependent/Holds/LocalHoldsPriority.t (-11 / +7 lines)
Lines 73-89 my $biblionumber = $bibnum; Link Here
73
my $i = 1;
73
my $i = 1;
74
foreach my $borrowernumber (@borrowernumbers) {
74
foreach my $borrowernumber (@borrowernumbers) {
75
    AddReserve(
75
    AddReserve(
76
        $branchcodes[$i],
76
        {
77
        $borrowernumber,
77
            branchcode     => $branchcodes[$i],
78
        $biblionumber,
78
            borrowernumber => $borrowernumber,
79
        my $bibitems   = q{},
79
            biblionumber   => $biblionumber,
80
        my $priority = $i,
80
            priority       => $i,
81
        my $resdate,
81
            title          => $title,
82
        my $expdate,
82
        }
83
        my $notes = q{},
84
        $title,
85
        my $checkitem,
86
        my $found,
87
    );
83
    );
88
84
89
    $i++;
85
    $i++;
(-)a/t/db_dependent/Holds/RevertWaitingStatus.t (-11 / +6 lines)
Lines 84-100 my $biblionumber = $bibnum; Link Here
84
# Create five item level holds
84
# Create five item level holds
85
foreach my $borrowernumber (@borrowernumbers) {
85
foreach my $borrowernumber (@borrowernumbers) {
86
    AddReserve(
86
    AddReserve(
87
        $branchcode,
87
        {
88
        $borrowernumber,
88
            branchcode     => $branchcode,
89
        $biblionumber,
89
            borrowernumber => $borrowernumber,
90
        my $bibitems   = q{},
90
            biblionumber   => $biblionumber,
91
        my $priority,
91
            title          => $title,
92
        my $resdate,
92
        }
93
        my $expdate,
94
        my $notes = q{},
95
        $title,
96
        my $checkitem,
97
        my $found,
98
    );
93
    );
99
}
94
}
100
95
(-)a/t/db_dependent/HoldsQueue.t (-16 / +145 lines)
Lines 109-115 $dbh->do("DELETE FROM reserves"); Link Here
109
my $bibitems = undef;
109
my $bibitems = undef;
110
my $priority = 1;
110
my $priority = 1;
111
# Make a reserve
111
# Make a reserve
112
AddReserve ( $borrower_branchcode, $borrowernumber, $biblionumber, $bibitems,  $priority );
112
AddReserve(
113
    {
114
        branchcode     => $borrower_branchcode,
115
        borrowernumber => $borrowernumber,
116
        biblionumber   => $biblionumber,
117
        priority       => $priority,
118
    }
119
);
113
#                           $resdate, $expdate, $notes, $title, $checkitem, $found
120
#                           $resdate, $expdate, $notes, $title, $checkitem, $found
114
$dbh->do("UPDATE reserves SET reservedate = DATE_SUB( reservedate, INTERVAL 1 DAY )");
121
$dbh->do("UPDATE reserves SET reservedate = DATE_SUB( reservedate, INTERVAL 1 DAY )");
115
122
Lines 464-470 $dbh->do( "UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQ Link Here
464
    undef, join( ',', $library_B, $library_A, $library_C ) );
471
    undef, join( ',', $library_B, $library_A, $library_C ) );
465
$dbh->do( "UPDATE systempreferences SET value = 0 WHERE variable = 'RandomizeHoldsQueueWeight'" );
472
$dbh->do( "UPDATE systempreferences SET value = 0 WHERE variable = 'RandomizeHoldsQueueWeight'" );
466
473
467
my $reserve_id = AddReserve ( $library_C, $borrowernumber, $biblionumber, '', 1 );
474
my $reserve_id = AddReserve(
475
    {
476
        branchcode     => $library_C,
477
        borrowernumber => $borrowernumber,
478
        biblionumber   => $biblionumber,
479
        priority       => 1,
480
    }
481
);
468
C4::HoldsQueue::CreateQueue();
482
C4::HoldsQueue::CreateQueue();
469
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
483
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
470
is( @$holds_queue, 1, "Bug 14297 - Holds Queue building ignoring holds where pickup & home branch don't match and item is not from le");
484
is( @$holds_queue, 1, "Bug 14297 - Holds Queue building ignoring holds where pickup & home branch don't match and item is not from le");
Lines 512-518 $dbh->do(" Link Here
512
    VALUES ($biblionumber, $biblioitemnumber, '$library_A', '$library_A', 0, 0, 0, 0, NULL, '$itemtype')
526
    VALUES ($biblionumber, $biblioitemnumber, '$library_A', '$library_A', 0, 0, 0, 0, NULL, '$itemtype')
513
");
527
");
514
528
515
$reserve_id = AddReserve ( $library_B, $borrowernumber, $biblionumber, '', 1 );
529
$reserve_id = AddReserve(
530
    {
531
        branchcode     => $library_B,
532
        borrowernumber => $borrowernumber,
533
        biblionumber   => $biblionumber,
534
        priority       => 1,
535
    }
536
);
537
516
C4::HoldsQueue::CreateQueue();
538
C4::HoldsQueue::CreateQueue();
517
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
539
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
518
is( @$holds_queue, 0, "Bug 15062 - Holds queue with Transport Cost Matrix will transfer item even if transfers disabled");
540
is( @$holds_queue, 0, "Bug 15062 - Holds queue with Transport Cost Matrix will transfer item even if transfers disabled");
Lines 558-578 $dbh->do("DELETE FROM default_circ_rules"); Link Here
558
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )");
580
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )");
559
581
560
# Home branch matches pickup branch
582
# Home branch matches pickup branch
561
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
583
$reserve_id = AddReserve(
584
    {
585
        branchcode     => $library_A,
586
        borrowernumber => $borrowernumber,
587
        biblionumber   => $biblionumber,
588
        priority       => 1,
589
    }
590
);
591
562
C4::HoldsQueue::CreateQueue();
592
C4::HoldsQueue::CreateQueue();
563
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
593
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
564
is( @$holds_queue, 1, "Hold where pickup branch matches home branch targeted" );
594
is( @$holds_queue, 1, "Hold where pickup branch matches home branch targeted" );
565
Koha::Holds->find( $reserve_id )->cancel;
595
Koha::Holds->find( $reserve_id )->cancel;
566
596
567
# Holding branch matches pickup branch
597
# Holding branch matches pickup branch
568
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 );
598
$reserve_id = AddReserve(
599
    {
600
        branchcode     => $library_B,
601
        borrowernumber => $borrowernumber,
602
        biblionumber   => $biblionumber,
603
        priority       => 1,
604
    }
605
);
606
607
569
C4::HoldsQueue::CreateQueue();
608
C4::HoldsQueue::CreateQueue();
570
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
609
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
571
is( @$holds_queue, 0, "Hold where pickup ne home, pickup eq home not targeted" );
610
is( @$holds_queue, 0, "Hold where pickup ne home, pickup eq home not targeted" );
572
Koha::Holds->find( $reserve_id )->cancel;
611
Koha::Holds->find( $reserve_id )->cancel;
573
612
574
# Neither branch matches pickup branch
613
# Neither branch matches pickup branch
575
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 );
614
$reserve_id = AddReserve(
615
    {
616
        branchcode     => $library_C,
617
        borrowernumber => $borrowernumber,
618
        biblionumber   => $biblionumber,
619
        priority       => 1,
620
    }
621
);
622
576
C4::HoldsQueue::CreateQueue();
623
C4::HoldsQueue::CreateQueue();
577
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
624
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
578
is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted" );
625
is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted" );
Lines 583-603 $dbh->do("DELETE FROM default_circ_rules"); Link Here
583
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'holdingbranch' )");
630
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'holdingbranch' )");
584
631
585
# Home branch matches pickup branch
632
# Home branch matches pickup branch
586
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
633
$reserve_id = AddReserve(
634
    {
635
        branchcode     => $library_A,
636
        borrowernumber => $borrowernumber,
637
        biblionumber   => $biblionumber,
638
        priority       => 1,
639
    }
640
);
641
587
C4::HoldsQueue::CreateQueue();
642
C4::HoldsQueue::CreateQueue();
588
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
643
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
589
is( @$holds_queue, 0, "Hold where pickup eq home, pickup ne holding not targeted" );
644
is( @$holds_queue, 0, "Hold where pickup eq home, pickup ne holding not targeted" );
590
Koha::Holds->find( $reserve_id )->cancel;
645
Koha::Holds->find( $reserve_id )->cancel;
591
646
592
# Holding branch matches pickup branch
647
# Holding branch matches pickup branch
593
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 );
648
$reserve_id = AddReserve(
649
    {
650
        branchcode     => $library_B,
651
        borrowernumber => $borrowernumber,
652
        biblionumber   => $biblionumber,
653
        priority       => 1,
654
    }
655
);
656
594
C4::HoldsQueue::CreateQueue();
657
C4::HoldsQueue::CreateQueue();
595
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
658
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
596
is( @$holds_queue, 1, "Hold where pickup ne home, pickup eq holding targeted" );
659
is( @$holds_queue, 1, "Hold where pickup ne home, pickup eq holding targeted" );
597
Koha::Holds->find( $reserve_id )->cancel;
660
Koha::Holds->find( $reserve_id )->cancel;
598
661
599
# Neither branch matches pickup branch
662
# Neither branch matches pickup branch
600
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 );
663
$reserve_id = AddReserve(
664
    {
665
        branchcode     => $library_C,
666
        borrowernumber => $borrowernumber,
667
        biblionumber   => $biblionumber,
668
        priority       => 1,
669
    }
670
);
671
601
C4::HoldsQueue::CreateQueue();
672
C4::HoldsQueue::CreateQueue();
602
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
673
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
603
is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted" );
674
is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted" );
Lines 608-628 $dbh->do("DELETE FROM default_circ_rules"); Link Here
608
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
679
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
609
680
610
# Home branch matches pickup branch
681
# Home branch matches pickup branch
611
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
682
$reserve_id = AddReserve(
683
    {
684
        branchcode     => $library_A,
685
        borrowernumber => $borrowernumber,
686
        biblionumber   => $biblionumber,
687
        priority       => 1,
688
    }
689
);
690
612
C4::HoldsQueue::CreateQueue();
691
C4::HoldsQueue::CreateQueue();
613
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
692
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
614
is( @$holds_queue, 1, "Hold where pickup eq home, pickup ne holding targeted" );
693
is( @$holds_queue, 1, "Hold where pickup eq home, pickup ne holding targeted" );
615
Koha::Holds->find( $reserve_id )->cancel;
694
Koha::Holds->find( $reserve_id )->cancel;
616
695
617
# Holding branch matches pickup branch
696
# Holding branch matches pickup branch
618
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 );
697
$reserve_id = AddReserve(
698
    {
699
        branchcode     => $library_B,
700
        borrowernumber => $borrowernumber,
701
        biblionumber   => $biblionumber,
702
        priority       => 1,
703
    }
704
);
705
619
C4::HoldsQueue::CreateQueue();
706
C4::HoldsQueue::CreateQueue();
620
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
707
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
621
is( @$holds_queue, 1, "Hold where pickup ne home, pickup eq holding targeted" );
708
is( @$holds_queue, 1, "Hold where pickup ne home, pickup eq holding targeted" );
622
Koha::Holds->find( $reserve_id )->cancel;
709
Koha::Holds->find( $reserve_id )->cancel;
623
710
624
# Neither branch matches pickup branch
711
# Neither branch matches pickup branch
625
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 );
712
$reserve_id = AddReserve(
713
    {
714
        branchcode     => $library_C,
715
        borrowernumber => $borrowernumber,
716
        biblionumber   => $biblionumber,
717
        priority       => 1,
718
    }
719
);
720
626
C4::HoldsQueue::CreateQueue();
721
C4::HoldsQueue::CreateQueue();
627
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
722
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
628
is( @$holds_queue, 1, "Hold where pickup ne home, pickup ne holding targeted" );
723
is( @$holds_queue, 1, "Hold where pickup ne home, pickup ne holding targeted" );
Lines 670-690 $dbh->do("DELETE FROM default_circ_rules"); Link Here
670
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
765
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
671
766
672
# Home branch matches pickup branch
767
# Home branch matches pickup branch
673
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $wrong_itemtype );
768
$reserve_id = AddReserve(
769
    {
770
        branchcode     => $library_A,
771
        borrowernumber => $borrowernumber,
772
        biblionumber   => $biblionumber,
773
        priority       => 1,
774
        itemtype       => $wrong_itemtype,
775
    }
776
);
777
674
C4::HoldsQueue::CreateQueue();
778
C4::HoldsQueue::CreateQueue();
675
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
779
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
676
is( @$holds_queue, 0, "Item with incorrect itemtype not targeted" );
780
is( @$holds_queue, 0, "Item with incorrect itemtype not targeted" );
677
Koha::Holds->find( $reserve_id )->cancel;
781
Koha::Holds->find( $reserve_id )->cancel;
678
782
679
# Holding branch matches pickup branch
783
# Holding branch matches pickup branch
680
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $right_itemtype );
784
$reserve_id = AddReserve(
785
    {
786
        branchcode     => $library_A,
787
        borrowernumber => $borrowernumber,
788
        biblionumber   => $biblionumber,
789
        priority       => 1,
790
        itemtype       => $right_itemtype,
791
    }
792
);
793
681
C4::HoldsQueue::CreateQueue();
794
C4::HoldsQueue::CreateQueue();
682
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
795
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
683
is( @$holds_queue, 1, "Item with matching itemtype is targeted" );
796
is( @$holds_queue, 1, "Item with matching itemtype is targeted" );
684
Koha::Holds->find( $reserve_id )->cancel;
797
Koha::Holds->find( $reserve_id )->cancel;
685
798
686
# Neither branch matches pickup branch
799
# Neither branch matches pickup branch
687
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, undef );
800
$reserve_id = AddReserve(
801
    {
802
        branchcode     => $library_A,
803
        borrowernumber => $borrowernumber,
804
        biblionumber   => $biblionumber,
805
        priority       => 1,
806
    }
807
);
808
688
C4::HoldsQueue::CreateQueue();
809
C4::HoldsQueue::CreateQueue();
689
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
810
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } );
690
is( @$holds_queue, 1, "Item targeted when hold itemtype is not set" );
811
is( @$holds_queue, 1, "Item targeted when hold itemtype is not set" );
Lines 718-724 my $item3 = Koha::Item->new( $item->unblessed ); Link Here
718
$item3->itemnumber( undef );
839
$item3->itemnumber( undef );
719
$item3->store();
840
$item3->store();
720
841
721
$reserve_id = AddReserve( $item->homebranch, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, undef );
842
$reserve_id = AddReserve(
843
    {
844
        branchcode     => $item->homebranch,
845
        borrowernumber => $borrowernumber,
846
        biblionumber   => $biblionumber,
847
        priority       => 1,
848
    }
849
);
850
722
851
723
C4::HoldsQueue::CreateQueue();
852
C4::HoldsQueue::CreateQueue();
724
853
(-)a/t/db_dependent/Koha/Biblios.t (-2 / +15 lines)
Lines 61-67 subtest 'store' => sub { Link Here
61
61
62
subtest 'holds + current_holds' => sub {
62
subtest 'holds + current_holds' => sub {
63
    plan tests => 5;
63
    plan tests => 5;
64
    C4::Reserves::AddReserve( $patron->branchcode, $patron->borrowernumber, $biblio->biblionumber );
64
    C4::Reserves::AddReserve(
65
        {
66
            branchcode     => $patron->branchcode,
67
            borrowernumber => $patron->borrowernumber,
68
            biblionumber   => $biblio->biblionumber,
69
        }
70
    );
65
    my $holds = $biblio->holds;
71
    my $holds = $biblio->holds;
66
    is( ref($holds), 'Koha::Holds', '->holds should return a Koha::Holds object' );
72
    is( ref($holds), 'Koha::Holds', '->holds should return a Koha::Holds object' );
67
    is( $holds->count, 1, '->holds should only return 1 hold' );
73
    is( $holds->count, 1, '->holds should only return 1 hold' );
Lines 69-75 subtest 'holds + current_holds' => sub { Link Here
69
    $holds->delete;
75
    $holds->delete;
70
76
71
    # Add a hold in the future
77
    # Add a hold in the future
72
    C4::Reserves::AddReserve( $patron->branchcode, $patron->borrowernumber, $biblio->biblionumber, undef, undef, dt_from_string->add( days => 2 ) );
78
    C4::Reserves::AddReserve(
79
        {
80
            branchcode       => $patron->branchcode,
81
            borrowernumber   => $patron->borrowernumber,
82
            biblionumber     => $biblio->biblionumber,
83
            reservation_date => dt_from_string->add( days => 2 ),
84
        }
85
    );
73
    $holds = $biblio->holds;
86
    $holds = $biblio->holds;
74
    is( $holds->count, 1, '->holds should return future holds' );
87
    is( $holds->count, 1, '->holds should return future holds' );
75
    $holds = $biblio->current_holds;
88
    $holds = $biblio->current_holds;
(-)a/t/db_dependent/Koha/Holds.t (-38 / +47 lines)
Lines 58-68 subtest 'cancel' => sub { Link Here
58
            }
58
            }
59
        );
59
        );
60
        my $reserve_id = C4::Reserves::AddReserve(
60
        my $reserve_id = C4::Reserves::AddReserve(
61
            $library->branchcode, $patron->borrowernumber,
61
            {
62
            $item->biblionumber,  '',
62
                branchcode     => $library->branchcode,
63
            $priority,            undef,
63
                borrowernumber => $patron->borrowernumber,
64
            undef,                '',
64
                biblionumber   => $item->biblionumber,
65
            "title for fee",      $item->itemnumber,
65
                priority       => $priority,
66
                title          => "title for fee",
67
                itemnumber     => $item->itemnumber,
68
            }
66
        );
69
        );
67
        my $hold = Koha::Holds->find($reserve_id);
70
        my $hold = Koha::Holds->find($reserve_id);
68
        push @patrons, $patron;
71
        push @patrons, $patron;
Lines 105-134 subtest 'cancel' => sub { Link Here
105
        my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $patron_category->categorycode } });
108
        my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $patron_category->categorycode } });
106
        is( $patron->account->balance, 0, 'A new patron does not have any charges' );
109
        is( $patron->account->balance, 0, 'A new patron does not have any charges' );
107
110
108
        my @hold_info = (
111
        my $hold_info = {
109
            $library->branchcode, $patron->borrowernumber,
112
            branchcode     => $library->branchcode,
110
            $item->biblionumber,  '',
113
            borrowernumber => $patron->borrowernumber,
111
            1,                    undef,
114
            biblionumber   => $item->biblionumber,
112
            undef,                '',
115
            priority       => 1,
113
            "title for fee",      $item->itemnumber,
116
            title          => "title for fee",
114
        );
117
            itemnumber     => $item->itemnumber,
118
        };
115
119
116
        # First, test cancelling a reserve when there's no charge configured.
120
        # First, test cancelling a reserve when there's no charge configured.
117
        t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelayCharge', 0);
121
        t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelayCharge', 0);
118
        my $reserve_id = C4::Reserves::AddReserve( @hold_info );
122
        my $reserve_id = C4::Reserves::AddReserve( $hold_info );
119
        Koha::Holds->find( $reserve_id )->cancel( { charge_cancel_fee => 1 } );
123
        Koha::Holds->find( $reserve_id )->cancel( { charge_cancel_fee => 1 } );
120
        is( $patron->account->balance, 0, 'ExpireReservesMaxPickUpDelayCharge=0 - The patron should not have been charged' );
124
        is( $patron->account->balance, 0, 'ExpireReservesMaxPickUpDelayCharge=0 - The patron should not have been charged' );
121
125
122
        # Then, test cancelling a reserve when there's no charge desired.
126
        # Then, test cancelling a reserve when there's no charge desired.
123
        t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelayCharge', 42);
127
        t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelayCharge', 42);
124
        $reserve_id = C4::Reserves::AddReserve( @hold_info );
128
        $reserve_id = C4::Reserves::AddReserve( $hold_info );
125
        Koha::Holds->find( $reserve_id )->cancel(); # charge_cancel_fee => 0
129
        Koha::Holds->find( $reserve_id )->cancel(); # charge_cancel_fee => 0
126
        is( $patron->account->balance, 0, 'ExpireReservesMaxPickUpDelayCharge=42, but charge_cancel_fee => 0, The patron should not have been charged' );
130
        is( $patron->account->balance, 0, 'ExpireReservesMaxPickUpDelayCharge=42, but charge_cancel_fee => 0, The patron should not have been charged' );
127
131
128
132
129
        # Finally, test cancelling a reserve when there's a charge desired and configured.
133
        # Finally, test cancelling a reserve when there's a charge desired and configured.
130
        t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelayCharge', 42);
134
        t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelayCharge', 42);
131
        $reserve_id = C4::Reserves::AddReserve( @hold_info );
135
        $reserve_id = C4::Reserves::AddReserve( $hold_info );
132
        Koha::Holds->find( $reserve_id )->cancel( { charge_cancel_fee => 1 } );
136
        Koha::Holds->find( $reserve_id )->cancel( { charge_cancel_fee => 1 } );
133
        is( int($patron->account->balance), 42, 'ExpireReservesMaxPickUpDelayCharge=42 and charge_cancel_fee => 1, The patron should have been charged!' );
137
        is( int($patron->account->balance), 42, 'ExpireReservesMaxPickUpDelayCharge=42 and charge_cancel_fee => 1, The patron should have been charged!' );
134
    };
138
    };
Lines 137-148 subtest 'cancel' => sub { Link Here
137
        plan tests => 1;
141
        plan tests => 1;
138
        my $patron = $builder->build_object({ class => 'Koha::Patrons' });
142
        my $patron = $builder->build_object({ class => 'Koha::Patrons' });
139
        my $reserve_id = C4::Reserves::AddReserve(
143
        my $reserve_id = C4::Reserves::AddReserve(
140
            $library->branchcode, $patron->borrowernumber,
144
            {
141
            $item->biblionumber,  '',
145
                branchcode     => $library->branchcode,
142
            1,                    undef,
146
                borrowernumber => $patron->borrowernumber,
143
            undef,                '',
147
                biblionumber   => $item->biblionumber,
144
            "title for fee",      $item->itemnumber,
148
                priority       => 1,
145
            'W',
149
                title          => "title for fee",
150
                itemnumber     => $item->itemnumber,
151
                found          => 'W',
152
            }
146
        );
153
        );
147
        Koha::Holds->find( $reserve_id )->cancel;
154
        Koha::Holds->find( $reserve_id )->cancel;
148
        my $hold_old = Koha::Old::Holds->find( $reserve_id );
155
        my $hold_old = Koha::Old::Holds->find( $reserve_id );
Lines 152-173 subtest 'cancel' => sub { Link Here
152
    subtest 'HoldsLog' => sub {
159
    subtest 'HoldsLog' => sub {
153
        plan tests => 2;
160
        plan tests => 2;
154
        my $patron = $builder->build_object({ class => 'Koha::Patrons' });
161
        my $patron = $builder->build_object({ class => 'Koha::Patrons' });
155
        my @hold_info = (
162
        my $hold_info = {
156
            $library->branchcode, $patron->borrowernumber,
163
            branchcode     => $library->branchcode,
157
            $item->biblionumber,  '',
164
            borrowernumber => $patron->borrowernumber,
158
            1,                    undef,
165
            biblionumber   => $item->biblionumber,
159
            undef,                '',
166
            priority       => 1,
160
            "title for fee",      $item->itemnumber,
167
            title          => "title for fee",
161
        );
168
            itemnumber     => $item->itemnumber,
169
        };
162
170
163
        t::lib::Mocks::mock_preference('HoldsLog', 0);
171
        t::lib::Mocks::mock_preference('HoldsLog', 0);
164
        my $reserve_id = C4::Reserves::AddReserve(@hold_info);
172
        my $reserve_id = C4::Reserves::AddReserve($hold_info);
165
        Koha::Holds->find( $reserve_id )->cancel;
173
        Koha::Holds->find( $reserve_id )->cancel;
166
        my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } )->count;
174
        my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } )->count;
167
        is( $number_of_logs, 0, 'Without HoldsLog, Koha::Hold->cancel should not have logged' );
175
        is( $number_of_logs, 0, 'Without HoldsLog, Koha::Hold->cancel should not have logged' );
168
176
169
        t::lib::Mocks::mock_preference('HoldsLog', 1);
177
        t::lib::Mocks::mock_preference('HoldsLog', 1);
170
        $reserve_id = C4::Reserves::AddReserve(@hold_info);
178
        $reserve_id = C4::Reserves::AddReserve($hold_info);
171
        Koha::Holds->find( $reserve_id )->cancel;
179
        Koha::Holds->find( $reserve_id )->cancel;
172
        $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } )->count;
180
        $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } )->count;
173
        is( $number_of_logs, 1, 'With HoldsLog, Koha::Hold->cancel should have logged' );
181
        is( $number_of_logs, 1, 'With HoldsLog, Koha::Hold->cancel should have logged' );
Lines 187-202 subtest 'cancel' => sub { Link Here
187
                value => { categorycode => $patron_category->categorycode }
195
                value => { categorycode => $patron_category->categorycode }
188
            }
196
            }
189
        );
197
        );
190
        my @hold_info = (
198
        my $hold_info = {
191
            $library->branchcode, $patron->borrowernumber,
199
            branchcode     => $library->branchcode,
192
            $item->biblionumber,  '',
200
            borrowernumber => $patron->borrowernumber,
193
            1,                    undef,
201
            biblionumber   => $item->biblionumber,
194
            undef,                '',
202
            priority       => 1,
195
            "title for fee",      $item->itemnumber,
203
            title          => "title for fee",
196
        );
204
            itemnumber     => $item->itemnumber,
205
        };
197
206
198
        t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelayCharge',42 );
207
        t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelayCharge',42 );
199
        my $reserve_id = C4::Reserves::AddReserve(@hold_info);
208
        my $reserve_id = C4::Reserves::AddReserve($hold_info);
200
        my $hold       = Koha::Holds->find($reserve_id);
209
        my $hold       = Koha::Holds->find($reserve_id);
201
210
202
        # Add a row with the same id to make the cancel fails
211
        # Add a row with the same id to make the cancel fails
(-)a/t/db_dependent/Koha/Patrons.t (-4 / +15 lines)
Lines 774-784 subtest 'holds and old_holds' => sub { Link Here
774
        'Koha::Patron->holds should return a Koha::Holds objects' );
774
        'Koha::Patron->holds should return a Koha::Holds objects' );
775
    is( $holds->count, 0, 'There should not be holds placed by this patron yet' );
775
    is( $holds->count, 0, 'There should not be holds placed by this patron yet' );
776
776
777
    C4::Reserves::AddReserve( $library->{branchcode},
777
    C4::Reserves::AddReserve(
778
        $patron->borrowernumber, $biblionumber_1 );
778
        {
779
            branchcode     => $library->{branchcode},
780
            borrowernumber => $patron->borrowernumber,
781
            biblionumber   => $biblionumber_1
782
        }
783
    );
779
    # In the future
784
    # In the future
780
    C4::Reserves::AddReserve( $library->{branchcode},
785
    C4::Reserves::AddReserve(
781
        $patron->borrowernumber, $biblionumber_2, undef, undef, dt_from_string->add( days => 2 ) );
786
        {
787
            branchcode      => $library->{branchcode},
788
            borrowernumber  => $patron->borrowernumber,
789
            biblionumber    => $biblionumber_2,
790
            expiration_date => dt_from_string->add( days => 2 )
791
        }
792
    );
782
793
783
    $holds = $patron->holds;
794
    $holds = $patron->holds;
784
    is( $holds->count, 2, 'There should be 2 holds placed by this patron' );
795
    is( $holds->count, 2, 'There should be 2 holds placed by this patron' );
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +19 lines)
Lines 521-528 You have [% count %] items due Link Here
521
521
522
        my $code = 'HOLD_SLIP';
522
        my $code = 'HOLD_SLIP';
523
523
524
        C4::Reserves::AddReserve( $library->{branchcode}, $patron->{borrowernumber}, $biblio1->{biblionumber}, undef, undef, undef, undef, "a note", undef, $item1->{itemnumber}, 'W' );
524
        C4::Reserves::AddReserve(
525
        C4::Reserves::AddReserve( $library->{branchcode}, $patron->{borrowernumber}, $biblio2->{biblionumber}, undef, undef, undef, undef, "another note", undef, $item2->{itemnumber} );
525
            {
526
                branchcode     => $library->{branchcode},
527
                borrowernumber => $patron->{borrowernumber},
528
                biblionumber   => $biblio1->{biblionumber},
529
                notes          => "a note",
530
                itemnumber     => $item1->{itemnumber},
531
                found          => 'W'
532
            }
533
        );
534
        C4::Reserves::AddReserve(
535
            {
536
                branchcode     => $library->{branchcode},
537
                borrowernumber => $patron->{borrowernumber},
538
                biblionumber   => $biblio2->{biblionumber},
539
                notes          => "another note",
540
                itemnumber     => $item2->{itemnumber},
541
            }
542
        );
526
543
527
        my $template = <<EOF;
544
        my $template = <<EOF;
528
<h5>Date: <<today>></h5>
545
<h5>Date: <<today>></h5>
(-)a/t/db_dependent/Reserves.t (-88 / +220 lines)
Lines 125-143 my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; Link Here
125
my $biblionumber   = $bibnum;
125
my $biblionumber   = $bibnum;
126
my $barcode        = $testbarcode;
126
my $barcode        = $testbarcode;
127
127
128
my $bibitems       = '';
129
my $priority       = '1';
130
my $resdate        = undef;
131
my $expdate        = undef;
132
my $notes          = '';
133
my $checkitem      = undef;
134
my $found          = undef;
135
136
my $branchcode = Koha::Libraries->search->next->branchcode;
128
my $branchcode = Koha::Libraries->search->next->branchcode;
137
129
138
AddReserve($branchcode,    $borrowernumber, $biblionumber,
130
AddReserve(
139
        $bibitems,  $priority, $resdate, $expdate, $notes,
131
    {
140
        $title,      $checkitem, $found);
132
        branchcode     => $branchcode,
133
        borrowernumber => $borrowernumber,
134
        biblionumber   => $biblionumber,
135
        priority       => 1,
136
    }
137
);
141
138
142
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode);
139
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode);
143
140
Lines 260-274 my ($itemnum_cpl, $itemnum_fpl); Link Here
260
# Ensure that priorities are numbered correcly when a hold is moved to waiting
257
# Ensure that priorities are numbered correcly when a hold is moved to waiting
261
# (bug 11947)
258
# (bug 11947)
262
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2));
259
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2));
263
AddReserve($branch_3,  $requesters{$branch_3}, $bibnum2,
260
AddReserve(
264
           $bibitems,  1, $resdate, $expdate, $notes,
261
    {
265
           $title,      $checkitem, $found);
262
        branchcode     => $branch_3,
266
AddReserve($branch_2,  $requesters{$branch_2}, $bibnum2,
263
        borrowernumber => $requesters{$branch_3},
267
           $bibitems,  2, $resdate, $expdate, $notes,
264
        biblionumber   => $bibnum2,
268
           $title,      $checkitem, $found);
265
        priority       => 1,
269
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum2,
266
    }
270
           $bibitems,  3, $resdate, $expdate, $notes,
267
);
271
           $title,      $checkitem, $found);
268
AddReserve(
269
    {
270
        branchcode     => $branch_2,
271
        borrowernumber => $requesters{$branch_2},
272
        biblionumber   => $bibnum2,
273
        priority       => 2,
274
    }
275
);
276
AddReserve(
277
    {
278
        branchcode     => $branch_1,
279
        borrowernumber => $requesters{$branch_1},
280
        biblionumber   => $bibnum2,
281
        priority       => 3,
282
    }
283
);
272
ModReserveAffect($itemnum_cpl, $requesters{$branch_3}, 0);
284
ModReserveAffect($itemnum_cpl, $requesters{$branch_3}, 0);
273
285
274
# Now it should have different priorities.
286
# Now it should have different priorities.
Lines 284-298 is( $reserves[0]->borrowernumber(), $requesters{$branch_3}, 'GetWaiting got the Link Here
284
296
285
297
286
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2));
298
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2));
287
AddReserve($branch_3,  $requesters{$branch_3}, $bibnum2,
299
AddReserve(
288
           $bibitems,  1, $resdate, $expdate, $notes,
300
    {
289
           $title,      $checkitem, $found);
301
        branchcode     => $branch_3,
290
AddReserve($branch_2,  $requesters{$branch_2}, $bibnum2,
302
        borrowernumber => $requesters{$branch_3},
291
           $bibitems,  2, $resdate, $expdate, $notes,
303
        biblionumber   => $bibnum2,
292
           $title,      $checkitem, $found);
304
        priority       => 1,
293
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum2,
305
    }
294
           $bibitems,  3, $resdate, $expdate, $notes,
306
);
295
           $title,      $checkitem, $found);
307
AddReserve(
308
    {
309
        branchcode     => $branch_2,
310
        borrowernumber => $requesters{$branch_2},
311
        biblionumber   => $bibnum2,
312
        priority       => 2,
313
    }
314
);
315
316
AddReserve(
317
    {
318
        branchcode     => $branch_1,
319
        borrowernumber => $requesters{$branch_1},
320
        biblionumber   => $bibnum2,
321
        priority       => 3,
322
    }
323
);
296
324
297
# Ensure that the item's home library controls hold policy lookup
325
# Ensure that the item's home library controls hold policy lookup
298
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
326
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
Lines 326-337 my $reserve_id = $holds->next->reserve_id; Link Here
326
# Tests for bug 9761 (ConfirmFutureHolds): new CheckReserves lookahead parameter, and corresponding change in AddReturn
354
# Tests for bug 9761 (ConfirmFutureHolds): new CheckReserves lookahead parameter, and corresponding change in AddReturn
327
# Note that CheckReserve uses its lookahead parameter and does not check ConfirmFutureHolds pref (it should be passed if needed like AddReturn does)
355
# Note that CheckReserve uses its lookahead parameter and does not check ConfirmFutureHolds pref (it should be passed if needed like AddReturn does)
328
# Test 9761a: Add a reserve without date, CheckReserve should return it
356
# Test 9761a: Add a reserve without date, CheckReserve should return it
329
$resdate= undef; #defaults to today in AddReserve
330
$expdate= undef; #no expdate
331
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
357
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
332
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
358
AddReserve(
333
           $bibitems,  1, $resdate, $expdate, $notes,
359
    {
334
           $title,      $checkitem, $found);
360
        branchcode     => $branch_1,
361
        borrowernumber => $requesters{$branch_1},
362
        biblionumber   => $bibnum,
363
        priority       => 1,
364
    }
365
);
335
($status)=CheckReserves($itemnumber,undef,undef);
366
($status)=CheckReserves($itemnumber,undef,undef);
336
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead');
367
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead');
337
($status)=CheckReserves($itemnumber,undef,7);
368
($status)=CheckReserves($itemnumber,undef,7);
Lines 340-352 is( $status, 'Reserved', 'CheckReserves also returns reserve with lookahead'); Link Here
340
# Test 9761b: Add a reserve with future date, CheckReserve should not return it
371
# Test 9761b: Add a reserve with future date, CheckReserve should not return it
341
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
372
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
342
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
373
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
343
$resdate= dt_from_string();
374
my $resdate= dt_from_string();
344
$resdate->add_duration(DateTime::Duration->new(days => 4));
375
$resdate->add_duration(DateTime::Duration->new(days => 4));
345
$resdate=output_pref($resdate);
376
$resdate=output_pref($resdate);
346
$expdate= undef; #no expdate
377
AddReserve(
347
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
378
    {
348
           $bibitems,  1, $resdate, $expdate, $notes,
379
        branchcode       => $branch_1,
349
           $title,      $checkitem, $found);
380
        borrowernumber   => $requesters{$branch_1},
381
        biblionumber     => $bibnum,
382
        priority         => 1,
383
        reservation_date => $resdate,
384
    }
385
);
350
($status)=CheckReserves($itemnumber,undef,undef);
386
($status)=CheckReserves($itemnumber,undef,undef);
351
is( $status, '', 'CheckReserves returns no future reserve without lookahead');
387
is( $status, '', 'CheckReserves returns no future reserve without lookahead');
352
388
Lines 401-409 t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); Link Here
401
$resdate= dt_from_string();
437
$resdate= dt_from_string();
402
$resdate->add_duration(DateTime::Duration->new(days => 2));
438
$resdate->add_duration(DateTime::Duration->new(days => 2));
403
$resdate=output_pref($resdate);
439
$resdate=output_pref($resdate);
404
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
440
AddReserve(
405
           $bibitems,  1, $resdate, $expdate, $notes,
441
    {
406
           $title,      $checkitem, $found);
442
        branchcode       => $branch_1,
443
        borrowernumber   => $requesters{$branch_1},
444
        biblionumber     => $bibnum,
445
        priority         => 1,
446
        reservation_date => $resdate,
447
    }
448
);
449
407
my $item = Koha::Items->find( $itemnumber );
450
my $item = Koha::Items->find( $itemnumber );
408
$holds = $item->current_holds;
451
$holds = $item->current_holds;
409
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
452
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
Lines 411-419 my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( d Link Here
411
is( $future_holds->count, 0, 'current_holds does not return a future next available hold');
454
is( $future_holds->count, 0, 'current_holds does not return a future next available hold');
412
# 9788b: current_holds does not return future item level hold
455
# 9788b: current_holds does not return future item level hold
413
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
456
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
414
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
457
AddReserve(
415
           $bibitems,  1, $resdate, $expdate, $notes,
458
    {
416
           $title,      $itemnumber, $found); #item level hold
459
        branchcode       => $branch_1,
460
        borrowernumber   => $requesters{$branch_1},
461
        biblionumber     => $bibnum,
462
        priority         => 1,
463
        reservation_date => $resdate,
464
        itemnumber       => $itemnumber,
465
    }
466
); #item level hold
417
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
467
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
418
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' );
468
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' );
419
# 9788c: current_holds returns future wait (confirmed future hold)
469
# 9788c: current_holds returns future wait (confirmed future hold)
Lines 426-435 $dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); Link Here
426
# Tests for CalculatePriority (bug 8918)
476
# Tests for CalculatePriority (bug 8918)
427
my $p = C4::Reserves::CalculatePriority($bibnum2);
477
my $p = C4::Reserves::CalculatePriority($bibnum2);
428
is($p, 4, 'CalculatePriority should now return priority 4');
478
is($p, 4, 'CalculatePriority should now return priority 4');
429
$resdate=undef;
479
AddReserve(
430
AddReserve($branch_1,  $requesters{'CPL2'}, $bibnum2,
480
    {
431
           $bibitems,  $p, $resdate, $expdate, $notes,
481
        branchcode     => $branch_1,
432
           $title,      $checkitem, $found);
482
        borrowernumber => $requesters{'CPL2'},
483
        biblionumber   => $bibnum2,
484
        priority       => $p,
485
    }
486
);
433
$p = C4::Reserves::CalculatePriority($bibnum2);
487
$p = C4::Reserves::CalculatePriority($bibnum2);
434
is($p, 5, 'CalculatePriority should now return priority 5');
488
is($p, 5, 'CalculatePriority should now return priority 5');
435
#some tests on bibnum
489
#some tests on bibnum
Lines 437-463 $dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); Link Here
437
$p = C4::Reserves::CalculatePriority($bibnum);
491
$p = C4::Reserves::CalculatePriority($bibnum);
438
is($p, 1, 'CalculatePriority should now return priority 1');
492
is($p, 1, 'CalculatePriority should now return priority 1');
439
#add a new reserve and confirm it to waiting
493
#add a new reserve and confirm it to waiting
440
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
494
AddReserve(
441
           $bibitems,  $p, $resdate, $expdate, $notes,
495
    {
442
           $title,      $itemnumber, $found);
496
        branchcode     => $branch_1,
497
        borrowernumber => $requesters{$branch_1},
498
        biblionumber   => $bibnum,
499
        priority       => $p,
500
        itemnumber     => $itemnumber,
501
    }
502
);
443
$p = C4::Reserves::CalculatePriority($bibnum);
503
$p = C4::Reserves::CalculatePriority($bibnum);
444
is($p, 2, 'CalculatePriority should now return priority 2');
504
is($p, 2, 'CalculatePriority should now return priority 2');
445
ModReserveAffect( $itemnumber,  $requesters{$branch_1} , 0);
505
ModReserveAffect( $itemnumber,  $requesters{$branch_1} , 0);
446
$p = C4::Reserves::CalculatePriority($bibnum);
506
$p = C4::Reserves::CalculatePriority($bibnum);
447
is($p, 1, 'CalculatePriority should now return priority 1');
507
is($p, 1, 'CalculatePriority should now return priority 1');
448
#add another biblio hold, no resdate
508
#add another biblio hold, no resdate
449
AddReserve($branch_1,  $requesters{'CPL2'}, $bibnum,
509
AddReserve(
450
           $bibitems,  $p, $resdate, $expdate, $notes,
510
    {
451
           $title,      $checkitem, $found);
511
        branchcode     => $branch_1,
512
        borrowernumber => $requesters{'CPL2'},
513
        biblionumber   => $bibnum,
514
        priority       => $p,
515
    }
516
);
452
$p = C4::Reserves::CalculatePriority($bibnum);
517
$p = C4::Reserves::CalculatePriority($bibnum);
453
is($p, 2, 'CalculatePriority should now return priority 2');
518
is($p, 2, 'CalculatePriority should now return priority 2');
454
#add another future hold
519
#add another future hold
455
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
520
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
456
$resdate= dt_from_string();
521
$resdate= dt_from_string();
457
$resdate->add_duration(DateTime::Duration->new(days => 1));
522
$resdate->add_duration(DateTime::Duration->new(days => 1));
458
AddReserve($branch_1,  $requesters{'CPL3'}, $bibnum,
523
AddReserve(
459
           $bibitems,  $p, output_pref($resdate), $expdate, $notes,
524
    {
460
           $title,      $checkitem, $found);
525
        branchcode     => $branch_1,
526
        borrowernumber => $requesters{'CPL2'},
527
        biblionumber   => $bibnum,
528
        priority       => $p,
529
        reservation_date => output_pref($resdate),
530
    }
531
);
461
$p = C4::Reserves::CalculatePriority($bibnum);
532
$p = C4::Reserves::CalculatePriority($bibnum);
462
is($p, 2, 'CalculatePriority should now still return priority 2');
533
is($p, 2, 'CalculatePriority should now still return priority 2');
463
#calc priority with future resdate
534
#calc priority with future resdate
Lines 467-475 is($p, 3, 'CalculatePriority should now return priority 3'); Link Here
467
538
468
# Tests for cancel reserves by users from OPAC.
539
# Tests for cancel reserves by users from OPAC.
469
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
540
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
470
AddReserve($branch_1,  $requesters{$branch_1}, $item_bibnum,
541
AddReserve(
471
           $bibitems,  1, undef, $expdate, $notes,
542
    {
472
           $title,      $checkitem, '');
543
        branchcode     => $branch_1,
544
        borrowernumber => $requesters{$branch_1},
545
        biblionumber   => $item_bibnum,
546
        priority       => 1,
547
    }
548
);
473
my (undef, $canres, undef) = CheckReserves($itemnumber);
549
my (undef, $canres, undef) = CheckReserves($itemnumber);
474
550
475
is( CanReserveBeCanceledFromOpac(), undef,
551
is( CanReserveBeCanceledFromOpac(), undef,
Lines 497-505 $cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$br Link Here
497
is($cancancel, 0, 'Reserve in transfer status cant be canceled');
573
is($cancancel, 0, 'Reserve in transfer status cant be canceled');
498
574
499
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
575
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
500
AddReserve($branch_1,  $requesters{$branch_1}, $item_bibnum,
576
AddReserve(
501
           $bibitems,  1, undef, $expdate, $notes,
577
    {
502
           $title,      $checkitem, '');
578
        branchcode     => $branch_1,
579
        borrowernumber => $requesters{$branch_1},
580
        biblionumber   => $item_bibnum,
581
        priority       => 1,
582
    }
583
);
503
(undef, $canres, undef) = CheckReserves($itemnumber);
584
(undef, $canres, undef) = CheckReserves($itemnumber);
504
585
505
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0);
586
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0);
Lines 548-561 ok( C4::Reserves::IsAvailableForItemLevelRequest($item, $borrower), "Reserving a Link Here
548
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
629
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
549
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0);
630
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0);
550
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
631
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
551
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
632
AddReserve(
552
    $bibitems,  1, undef, $expdate, $notes, $title, $checkitem, '');
633
    {
634
        branchcode     => $branch_1,
635
        borrowernumber => $borrowernumber,
636
        biblionumber   => $item_bibnum,
637
        priority       => 1,
638
    }
639
);
553
MoveReserve( $itemnumber, $borrowernumber );
640
MoveReserve( $itemnumber, $borrowernumber );
554
($status)=CheckReserves( $itemnumber );
641
($status)=CheckReserves( $itemnumber );
555
is( $status, '', 'MoveReserve filled hold');
642
is( $status, '', 'MoveReserve filled hold');
556
#   hold from A waiting, today, no fut holds: MoveReserve should fill it
643
#   hold from A waiting, today, no fut holds: MoveReserve should fill it
557
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
644
AddReserve(
558
   $bibitems,  1, undef, $expdate, $notes, $title, $checkitem, 'W');
645
    {
646
        branchcode     => $branch_1,
647
        borrowernumber => $borrowernumber,
648
        biblionumber   => $item_bibnum,
649
        priority       => 1,
650
        found          => 'W',
651
    }
652
);
559
MoveReserve( $itemnumber, $borrowernumber );
653
MoveReserve( $itemnumber, $borrowernumber );
560
($status)=CheckReserves( $itemnumber );
654
($status)=CheckReserves( $itemnumber );
561
is( $status, '', 'MoveReserve filled waiting hold');
655
is( $status, '', 'MoveReserve filled waiting hold');
Lines 563-584 is( $status, '', 'MoveReserve filled waiting hold'); Link Here
563
$resdate= dt_from_string();
657
$resdate= dt_from_string();
564
$resdate->add_duration(DateTime::Duration->new(days => 1));
658
$resdate->add_duration(DateTime::Duration->new(days => 1));
565
$resdate=output_pref($resdate);
659
$resdate=output_pref($resdate);
566
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
660
AddReserve(
567
    $bibitems,  1, $resdate, $expdate, $notes, $title, $checkitem, '');
661
    {
662
        branchcode     => $branch_1,
663
        borrowernumber => $borrowernumber,
664
        biblionumber   => $item_bibnum,
665
        priority       => 1,
666
        reservation_date => $resdate,
667
    }
668
);
568
MoveReserve( $itemnumber, $borrowernumber );
669
MoveReserve( $itemnumber, $borrowernumber );
569
($status)=CheckReserves( $itemnumber, undef, 1 );
670
($status)=CheckReserves( $itemnumber, undef, 1 );
570
is( $status, 'Reserved', 'MoveReserve did not fill future hold');
671
is( $status, 'Reserved', 'MoveReserve did not fill future hold');
571
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
672
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
572
#   hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it
673
#   hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it
573
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2);
674
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2);
574
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
675
AddReserve(
575
    $bibitems,  1, $resdate, $expdate, $notes, $title, $checkitem, '');
676
    {
677
        branchcode     => $branch_1,
678
        borrowernumber => $borrowernumber,
679
        biblionumber   => $item_bibnum,
680
        priority       => 1,
681
        reservation_date => $resdate,
682
    }
683
);
576
MoveReserve( $itemnumber, $borrowernumber );
684
MoveReserve( $itemnumber, $borrowernumber );
577
($status)=CheckReserves( $itemnumber, undef, 2 );
685
($status)=CheckReserves( $itemnumber, undef, 2 );
578
is( $status, '', 'MoveReserve filled future hold now');
686
is( $status, '', 'MoveReserve filled future hold now');
579
#   hold from A waiting, tomorrow, fut holds=2: MoveReserve should fill it
687
#   hold from A waiting, tomorrow, fut holds=2: MoveReserve should fill it
580
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
688
AddReserve(
581
    $bibitems,  1, $resdate, $expdate, $notes, $title, $checkitem, 'W');
689
    {
690
        branchcode     => $branch_1,
691
        borrowernumber => $borrowernumber,
692
        biblionumber   => $item_bibnum,
693
        priority       => 1,
694
        reservation_date => $resdate,
695
    }
696
);
582
MoveReserve( $itemnumber, $borrowernumber );
697
MoveReserve( $itemnumber, $borrowernumber );
583
($status)=CheckReserves( $itemnumber, undef, 2 );
698
($status)=CheckReserves( $itemnumber, undef, 2 );
584
is( $status, '', 'MoveReserve filled future waiting hold now');
699
is( $status, '', 'MoveReserve filled future waiting hold now');
Lines 586-593 is( $status, '', 'MoveReserve filled future waiting hold now'); Link Here
586
$resdate= dt_from_string();
701
$resdate= dt_from_string();
587
$resdate->add_duration(DateTime::Duration->new(days => 3));
702
$resdate->add_duration(DateTime::Duration->new(days => 3));
588
$resdate=output_pref($resdate);
703
$resdate=output_pref($resdate);
589
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
704
AddReserve(
590
    $bibitems,  1, $resdate, $expdate, $notes, $title, $checkitem, '');
705
    {
706
        branchcode     => $branch_1,
707
        borrowernumber => $borrowernumber,
708
        biblionumber   => $item_bibnum,
709
        priority       => 1,
710
        reservation_date => $resdate,
711
    }
712
);
591
MoveReserve( $itemnumber, $borrowernumber );
713
MoveReserve( $itemnumber, $borrowernumber );
592
($status)=CheckReserves( $itemnumber, undef, 3 );
714
($status)=CheckReserves( $itemnumber, undef, 3 );
593
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days');
715
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days');
Lines 648-655 subtest '_koha_notify_reserve() tests' => sub { Link Here
648
        })->{borrowernumber};
770
        })->{borrowernumber};
649
771
650
    C4::Reserves::AddReserve(
772
    C4::Reserves::AddReserve(
651
        $item->{homebranch}, $hold_borrower,
773
        {
652
        $item->{biblionumber} );
774
            branchcode     => $item->{homebranch},
775
            borrowernumber => $hold_borrower,
776
            biblionumber   => $item->{biblionumber},
777
        }
778
    );
653
779
654
    ModReserveAffect($item->{itemnumber}, $hold_borrower, 0);
780
    ModReserveAffect($item->{itemnumber}, $hold_borrower, 0);
655
    my $sms_message_address = $schema->resultset('MessageQueue')->search({
781
    my $sms_message_address = $schema->resultset('MessageQueue')->search({
Lines 694-704 subtest 'ReservesNeedReturns' => sub { Link Here
694
820
695
    t::lib::Mocks::mock_preference('ReservesNeedReturns', 0); # '0' means 'Automatically mark a hold as found and waiting'
821
    t::lib::Mocks::mock_preference('ReservesNeedReturns', 0); # '0' means 'Automatically mark a hold as found and waiting'
696
    $hold_id = C4::Reserves::AddReserve(
822
    $hold_id = C4::Reserves::AddReserve(
697
        $library->branchcode, $patron->borrowernumber,
823
        {
698
        $item->biblionumber,  '',
824
            branchcode     => $library->branchcode,
699
        $priority,            undef,
825
            borrowernumber => $patron->borrowernumber,
700
        undef,                '',
826
            biblionumber   => $item->biblionumber,
701
        "title for fee",      $item->itemnumber,
827
            priority       => $priority,
828
            title          => "title for fee",
829
            itemnumber     => $item->itemnumber,
830
        }
702
    );
831
    );
703
    $hold = Koha::Holds->find($hold_id);
832
    $hold = Koha::Holds->find($hold_id);
704
    is( $hold->priority, 0, 'If ReservesNeedReturns is 0, priority must have been set to 0' );
833
    is( $hold->priority, 0, 'If ReservesNeedReturns is 0, priority must have been set to 0' );
Lines 708-718 subtest 'ReservesNeedReturns' => sub { Link Here
708
837
709
    t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); # '0' means "Don't automatically mark a hold as found and waiting"
838
    t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); # '0' means "Don't automatically mark a hold as found and waiting"
710
    $hold_id = C4::Reserves::AddReserve(
839
    $hold_id = C4::Reserves::AddReserve(
711
        $library->branchcode, $patron->borrowernumber,
840
        {
712
        $item->biblionumber,  '',
841
            branchcode     => $library->branchcode,
713
        $priority,            undef,
842
            borrowernumber => $patron->borrowernumber,
714
        undef,                '',
843
            biblionumber   => $item->biblionumber,
715
        "title for fee",      $item->itemnumber,
844
            priority       => $priority,
845
            title          => "title for fee",
846
            itemnumber     => $item->itemnumber,
847
        }
716
    );
848
    );
717
    $hold = Koha::Holds->find($hold_id);
849
    $hold = Koha::Holds->find($hold_id);
718
    is( $hold->priority, $priority, 'If ReservesNeedReturns is 1, priority must not have been set to changed' );
850
    is( $hold->priority, $priority, 'If ReservesNeedReturns is 1, priority must not have been set to changed' );
(-)a/t/db_dependent/Reserves/GetReserveFee.t (-11 / +7 lines)
Lines 205-221 sub acctlines { #calculate number of accountlines for a patron Link Here
205
205
206
sub addreserve {
206
sub addreserve {
207
    return AddReserve(
207
    return AddReserve(
208
        $library->{branchcode},
208
        {
209
        $_[0],
209
            branchcode     => $library->{branchcode},
210
        $biblio->{biblionumber},
210
            borrowernumber => $_[0],
211
        undef,
211
            biblionumber   => $biblio->{biblionumber},
212
        '1',
212
            priority       => '1',
213
        undef,
213
            title          => $biblio->{title},
214
        undef,
214
        }
215
        '',
216
        $biblio->{title},
217
        undef,
218
        ''
219
    );
215
    );
220
}
216
}
221
217
(-)a/t/db_dependent/Reserves/MultiplePerRecord.t (-2 / +17 lines)
Lines 278-289 $rule = $rules_rs->new( Link Here
278
278
279
my $can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber});
279
my $can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber});
280
is( $can, 'OK', 'Hold can be placed with 0 holds' );
280
is( $can, 'OK', 'Hold can be placed with 0 holds' );
281
my $hold_id = AddReserve( $library->{branchcode}, $patron->{borrowernumber}, $biblio->{biblionumber}, '', 1 );
281
my $hold_id = AddReserve(
282
    {
283
        branchcode     => $library->{branchcode},
284
        borrowernumber => $patron->{borrowernumber},
285
        biblionumber   => $biblio->{biblionumber},
286
        priority       => 1
287
    }
288
);
282
ok( $hold_id, 'First hold was placed' );
289
ok( $hold_id, 'First hold was placed' );
283
290
284
$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber});
291
$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber});
285
is( $can, 'OK', 'Hold can be placed with 1 hold' );
292
is( $can, 'OK', 'Hold can be placed with 1 hold' );
286
$hold_id = AddReserve( $library->{branchcode}, $patron->{borrowernumber}, $biblio->{biblionumber}, '', 1 );
293
$hold_id = AddReserve(
294
    {
295
        branchcode     => $library->{branchcode},
296
        borrowernumber => $patron->{borrowernumber},
297
        biblionumber   => $biblio->{biblionumber},
298
        priority       => 1
299
    }
300
);
301
287
ok( $hold_id, 'Second hold was placed' );
302
ok( $hold_id, 'Second hold was placed' );
288
303
289
$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber});
304
$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber});
(-)a/t/db_dependent/UsageStats.t (-1 / +9 lines)
Lines 301-307 sub construct_objects_needed { Link Here
301
    my $issue_id1 = $dbh->last_insert_id( undef, undef, 'old_issues', undef );
301
    my $issue_id1 = $dbh->last_insert_id( undef, undef, 'old_issues', undef );
302
302
303
    # ---------- Add 1 old_reserves
303
    # ---------- Add 1 old_reserves
304
    AddReserve( $branchcode, $borrowernumber1, $biblionumber1, '', 1, undef, undef, '', 'Title', undef, undef );
304
    AddReserve(
305
        {
306
            branchcode     => $branchcode,
307
            borrowernumber => $borrowernumber1,
308
            biblionumber   => $biblionumber1,
309
            priority       => 1,
310
            title          => 'Title',
311
        }
312
    );
305
    my $biblio = Koha::Biblios->find( $biblionumber1 );
313
    my $biblio = Koha::Biblios->find( $biblionumber1 );
306
    my $holds = $biblio->holds;
314
    my $holds = $biblio->holds;
307
    $holds->next->cancel if $holds->count;
315
    $holds->next->cancel if $holds->count;
(-)a/t/db_dependent/api/v1/holds.t (-5 / +18 lines)
Lines 142-153 $dbh->do('DELETE FROM issuingrules'); Link Here
142
        VALUES (?, ?, ?, ?)
142
        VALUES (?, ?, ?, ?)
143
    }, {}, '*', '*', '*', 1);
143
    }, {}, '*', '*', '*', 1);
144
144
145
my $reserve_id = C4::Reserves::AddReserve($branchcode, $patron_1->borrowernumber,
145
my $reserve_id = C4::Reserves::AddReserve(
146
    $biblionumber, undef, 1, undef, undef, undef, '', $itemnumber);
146
    {
147
        branchcode     => $branchcode,
148
        borrowernumber => $patron_1->borrowernumber,
149
        biblionumber   => $biblionumber,
150
        priority       => 1,
151
        itemnumber     => $itemnumber,
152
    }
153
);
147
154
148
# Add another reserve to be able to change first reserve's rank
155
# Add another reserve to be able to change first reserve's rank
149
my $reserve_id2 = C4::Reserves::AddReserve($branchcode, $patron_2->borrowernumber,
156
my $reserve_id2 = C4::Reserves::AddReserve(
150
    $biblionumber, undef, 2, undef, undef, undef, '', $itemnumber);
157
    {
158
        branchcode     => $branchcode,
159
        borrowernumber => $patron_2->borrowernumber,
160
        biblionumber   => $biblionumber,
161
        priority       => 2,
162
        itemnumber     => $itemnumber,
163
    }
164
);
151
165
152
my $suspend_until = DateTime->now->add(days => 10)->ymd;
166
my $suspend_until = DateTime->now->add(days => 10)->ymd;
153
my $expirationdate = DateTime->now->add(days => 10)->ymd;
167
my $expirationdate = DateTime->now->add(days => 10)->ymd;
154
- 

Return to bug 14711