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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 1166-1172 sub CanBookBeIssued { Link Here
1166
            $needsconfirmation{ressurname} = $patron->surname;
1166
            $needsconfirmation{ressurname} = $patron->surname;
1167
            $needsconfirmation{rescardnumber} = $patron->cardnumber;
1167
            $needsconfirmation{rescardnumber} = $patron->cardnumber;
1168
            $needsconfirmation{resborrowernumber} = $patron->borrowernumber;
1168
            $needsconfirmation{resborrowernumber} = $patron->borrowernumber;
1169
            $needsconfirmation{resbranchname} = $branchname;
1169
            $needsconfirmation{resbranchcode} = $patron->branchcode;
1170
            $needsconfirmation{resreservedate} = $reserve->{reservedate};
1170
            $needsconfirmation{resreservedate} = $reserve->{reservedate};
1171
            $needsconfirmation{reserve_id} = $reserve->{reserve_id};
1171
            $needsconfirmation{reserve_id} = $reserve->{reserve_id};
1172
        }
1172
        }
Lines 2854-2860 sub CanBookBeRenewed { Link Here
2854
        my $patron_unblessed = $patron->unblessed;
2854
        my $patron_unblessed = $patron->unblessed;
2855
        $date_due = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
2855
        $date_due = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
2856
                                        dt_from_string( $issue->date_due, 'sql' ) :
2856
                                        dt_from_string( $issue->date_due, 'sql' ) :
2857
                                        DateTime->now( time_zone => C4::Context->tz());
2857
                                        dt_from_string();
2858
        $date_due =  CalcDateDue($date_due, $itemtype, _GetCircControlBranch($item->unblessed(), $patron_unblessed), $patron_unblessed, 'is a renewal');
2858
        $date_due =  CalcDateDue($date_due, $itemtype, _GetCircControlBranch($item->unblessed(), $patron_unblessed), $patron_unblessed, 'is a renewal');
2859
    }
2859
    }
2860
2860
(-)a/reserve/placerequest.pl (-1 / +2 lines)
Lines 40-46 my ($template, $loggedinuser, $cookie) = get_template_and_user({ Link Here
40
    template_name   => 'reserve/placerequest.tt',
40
    template_name   => 'reserve/placerequest.tt',
41
    query           => $input,
41
    query           => $input,
42
    type            => 'intranet',
42
    type            => 'intranet',
43
    authnotrequired => 0,
44
    flagsrequired   => { reserveforothers => 'place_holds' },
43
    flagsrequired   => { reserveforothers => 'place_holds' },
45
});
44
});
46
45
Lines 69-74 my @bad_bibs = split '/', $bad_bibs_param; Link Here
69
my $holds_to_place_count = $input->param('holds_to_place_count') || 1;
68
my $holds_to_place_count = $input->param('holds_to_place_count') || 1;
70
69
71
my %bibinfos = ();
70
my %bibinfos = ();
71
my $multi_hold = @biblionumbers > 1;
72
72
foreach my $bibnum (@biblionumbers) {
73
foreach my $bibnum (@biblionumbers) {
73
    my %bibinfo = ();
74
    my %bibinfo = ();
74
    $bibinfo{title}  = $input->param("title_$bibnum");
75
    $bibinfo{title}  = $input->param("title_$bibnum");
(-)a/t/db_dependent/Circulation.t (-2 / +1 lines)
Lines 524-530 subtest "CanBookBeRenewed tests" => sub { Link Here
524
    my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $item_1->itemnumber } )->borrowernumber;
524
    my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $item_1->itemnumber } )->borrowernumber;
525
    is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}");
525
    is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}");
526
526
527
    t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary');
528
    my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1);
527
    my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1);
529
    is( $renewokay, 1, 'Can renew, no holds for this title or item');
528
    is( $renewokay, 1, 'Can renew, no holds for this title or item');
530
529
Lines 1724-1730 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
1724
    # Don't allow renewing on reserve period with PreventCheckoutOnSameReservePeriod enabled
1723
    # Don't allow renewing on reserve period with PreventCheckoutOnSameReservePeriod enabled
1725
    t::lib::Mocks::mock_preference( 'PreventCheckoutOnSameReservePeriod', 1 );
1724
    t::lib::Mocks::mock_preference( 'PreventCheckoutOnSameReservePeriod', 1 );
1726
1725
1727
    my $start_issue_dt = DateTime->now();
1726
    my $start_issue_dt = dt_from_string();
1728
    $start_issue_dt->subtract( days => 15);
1727
    $start_issue_dt->subtract( days => 15);
1729
    my $due_date = $start_issue_dt->clone;
1728
    my $due_date = $start_issue_dt->clone;
1730
    $due_date->add( days => 17 );
1729
    $due_date->add( days => 17 );
(-)a/t/db_dependent/Circulation/CanBookBeIssued.t (-9 / +31 lines)
Lines 23-28 use C4::Reserves; Link Here
23
use C4::Circulation;
23
use C4::Circulation;
24
use Koha::DateUtils;
24
use Koha::DateUtils;
25
25
26
use t::lib::Mocks;
26
use t::lib::TestBuilder;
27
use t::lib::TestBuilder;
27
28
28
my $schema  = Koha::Database->new->schema;
29
my $schema  = Koha::Database->new->schema;
Lines 31-40 $schema->storage->txn_begin; Link Here
31
my $builder = t::lib::TestBuilder->new();
32
my $builder = t::lib::TestBuilder->new();
32
33
33
subtest 'Tests for CanBookBeIssued with overlap reserves' => sub {
34
subtest 'Tests for CanBookBeIssued with overlap reserves' => sub {
34
    plan tests => 6;
35
    plan tests => 7;
36
37
    Koha::CirculationRules->set_rules(
38
    {
39
        branchcode   => undef,
40
        categorycode => undef,
41
        itemtype     => undef,
42
        rules        => {
43
            reservesallowed => 25,
44
            holds_per_record => 1,
45
        }
46
    }
47
    );
35
48
49
    t::lib::Mocks::mock_preference('PreventCheckoutOnSameReservePeriod', 1);
36
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
50
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
37
    my $branch = $builder->build({ source => 'Branch' });
51
    my $branch = $builder->build({ source => 'Branch', value => { branchcode => 'BRC'} });
38
    my $branchcode = $branch->{branchcode};
52
    my $branchcode = $branch->{branchcode};
39
53
40
    my $borrower = $builder->build_object({
54
    my $borrower = $builder->build_object({
Lines 70-78 subtest 'Tests for CanBookBeIssued with overlap reserves' => sub { Link Here
70
    my $expdate = $startdate->clone();
84
    my $expdate = $startdate->clone();
71
    $expdate->add_duration(DateTime::Duration->new(days => 10));
85
    $expdate->add_duration(DateTime::Duration->new(days => 10));
72
86
73
    my $reserveid = AddReserve($branchcode, $borrowernumber,
87
    my $reserveid = AddReserve(
74
        $item->{biblionumber}, undef,  1, $startdate->ymd(), $expdate->ymd,
88
        {
75
        undef, undef, undef, undef);
89
            branchcode => $branchcode,
90
            borrowernumber => $borrowernumber,
91
            biblionumber => $item->{biblionumber},
92
            priority => 1,
93
            reservation_date => $startdate->ymd,
94
            expiration_date => $expdate->ymd,
95
        }
96
        );
97
    is(defined $reserveid, 1, "Hold has been placed");
76
98
77
    my $non_overlap_duedate = dt_from_string();
99
    my $non_overlap_duedate = dt_from_string();
78
    $non_overlap_duedate->add_duration(DateTime::Duration->new(days => 2));
100
    $non_overlap_duedate->add_duration(DateTime::Duration->new(days => 2));
Lines 94-105 subtest 'Tests for CanBookBeIssued with overlap reserves' => sub { Link Here
94
        resfirstname => $borrower->firstname,
116
        resfirstname => $borrower->firstname,
95
        ressurname => $borrower->surname,
117
        ressurname => $borrower->surname,
96
        rescardnumber => $borrower->cardnumber,
118
        rescardnumber => $borrower->cardnumber,
97
        resborrowernumber => $borrower->borrowernumber,
119
        resborrowernumber => $borrowernumber,
98
        resbranchname => $branch->{branchname},
120
        resbranchcode => $borrower->branchcode,
99
        resreservedate => $startdate->ymd,
121
        resreservedate => $startdate->ymd,
100
        resreserveid => $reserveid,
122
        reserve_id => $reserveid,
101
    };
123
    };
102
    is_deeply($question, $expected, "");
124
    is_deeply($question, $expected, "Need confirmation");
103
    is_deeply($alerts, {}, "");
125
    is_deeply($alerts, {}, "");
104
};
126
};
105
127
(-)a/t/db_dependent/Reserves/ReserveDate.t (-32 / +48 lines)
Lines 28-33 use C4::Items; Link Here
28
use C4::Members;
28
use C4::Members;
29
use C4::Circulation;
29
use C4::Circulation;
30
use Koha::Holds;
30
use Koha::Holds;
31
use t::lib::Mocks;
31
use t::lib::TestBuilder;
32
use t::lib::TestBuilder;
32
33
33
use Koha::DateUtils;
34
use Koha::DateUtils;
Lines 35-49 use Koha::DateUtils; Link Here
35
36
36
use_ok('C4::Reserves');
37
use_ok('C4::Reserves');
37
38
38
my $dbh = C4::Context->dbh;
39
39
40
# Start transaction
40
# Start transaction
41
my $database = Koha::Database->new();
42
my $schema = $database->schema();
43
$schema->storage->txn_begin();
44
my $dbh = C4::Context->dbh;
45
$dbh->do('DELETE FROM circulation_rules');
46
41
$dbh->{AutoCommit} = 0;
47
$dbh->{AutoCommit} = 0;
42
$dbh->{RaiseError} = 1;
48
$dbh->{RaiseError} = 1;
43
49
44
my $builder = t::lib::TestBuilder->new();
50
my $builder = t::lib::TestBuilder->new;
51
45
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
52
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
46
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode };
53
my $library = $builder->build({ source => 'Branch' })->{ branchcode };
54
my $branchcode = Koha::Libraries->search->next->branchcode;
55
56
my $frameworkcode = q//;
47
57
48
my $borrower = $builder->build({
58
my $borrower = $builder->build({
49
    source => 'Borrower',
59
    source => 'Borrower',
Lines 64-108 my $borrower2 = $builder->build({ Link Here
64
my $borrowernumber = $borrower->{borrowernumber};
74
my $borrowernumber = $borrower->{borrowernumber};
65
my $borrowernumber2 = $borrower2->{borrowernumber};
75
my $borrowernumber2 = $borrower2->{borrowernumber};
66
76
67
# Create a helper biblio
77
# Create a helper biblio and item
68
my $biblio = MARC::Record->new();
78
my $bibnum = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber;
69
my $title = 'Alone in the Dark';
79
my $item = $builder->build_sample_item({ biblionumber => $bibnum, library => $branchcode, barcode => '333' });
70
my $author = 'Karen Rose';
80
my ($item_bibnum, $bibitemnum, $itemnumber) = ($bibnum, $item->biblioitemnumber, $item->itemnumber);
71
if( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
72
    $biblio->append_fields(
73
        MARC::Field->new('600', '', '1', a => $author),
74
        MARC::Field->new('200', '', '', a => $title),
75
    );
76
}
77
else {
78
    $biblio->append_fields(
79
        MARC::Field->new('100', '', '', a => $author),
80
        MARC::Field->new('245', '', '', a => $title),
81
    );
82
}
83
my ($bibnum, $bibitemnum);
84
($bibnum, $title, $bibitemnum) = AddBiblio($biblio, '');
85
86
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branchcode, holdingbranch => $branchcode, barcode => '333' } , $bibnum);
87
81
88
C4::Context->set_preference('AllowHoldDateInFuture', 1);
82
C4::Context->set_preference('AllowHoldDateInFuture', 1);
89
83
t::lib::Mocks::mock_preference('PreventReservesOnSamePeriod', 1);
90
AddReserve($branchcode, $borrowernumber, $bibnum,
84
91
           $bibitemnum,  1, '2015-11-01', '2015-11-20', undef,
85
AddReserve(
92
           undef, undef, undef);
86
    {
87
        branchcode => $branchcode,
88
        borrowernumber => $borrowernumber,
89
        biblionumber => $bibnum,
90
        biblioitemnumber => $bibitemnum,
91
        priority => 1,
92
        reservation_date => '2015-11-01',
93
        expiration_date => '2015-11-20',
94
    }
95
);
93
96
94
is(ReservesOnSamePeriod($bibnum, undef, '2015-11-25', '2015-11-30'), undef, "Period doesn't overlaps");
97
is(ReservesOnSamePeriod($bibnum, undef, '2015-11-25', '2015-11-30'), undef, "Period doesn't overlaps");
95
98
96
ok(ReservesOnSamePeriod($bibnum, undef, '2015-11-02', '2015-11-10'), "Period overlaps");
99
ok(ReservesOnSamePeriod($bibnum, undef, '2015-11-02', '2015-11-10'), "Period overlaps");
97
100
98
my ($item_bibnum2, $item_bibitemnum2, $itemnumber2) = AddItem({ homebranch => $branchcode, holdingbranch => $branchcode, barcode => '444' } , $bibnum);
101
my $item2 = $builder->build_sample_item({ biblionumber => $bibnum, homebranch => $branchcode, holdingbranch => $branchcode, barcode => '444' });
102
my ($item_bibnum2, $bibitemnum2, $itemnumber2) = ($bibnum, $item2->biblioitemnumber, $item2->itemnumber);
103
99
is(ReservesOnSamePeriod($bibnum, undef, '2015-11-02', '2015-11-10'), undef, "Period overlaps but there is 2 items");
104
is(ReservesOnSamePeriod($bibnum, undef, '2015-11-02', '2015-11-10'), undef, "Period overlaps but there is 2 items");
100
105
101
AddReserve($branchcode, $borrowernumber2, $bibnum,
106
102
           $bibitemnum,  1, '2016-02-01', '2016-02-10', undef,
107
AddReserve(
103
           undef, $itemnumber, undef);
108
    {
109
        branchcode => $branchcode,
110
        borrowernumber => $borrowernumber2,
111
        biblionumber => $bibnum,
112
        biblioitemnumber => $bibitemnum,
113
        priority => 1,
114
        reservation_date => '2016-02-01',
115
        expiration_date => '2016-02-10',
116
        itemnumber => $itemnumber,
117
    }
118
);
119
104
is(ReservesOnSamePeriod($bibnum, $itemnumber, '02/12/2015', '10/12/2015'), undef, "Period on item does not overlap (with metric date format)");
120
is(ReservesOnSamePeriod($bibnum, $itemnumber, '02/12/2015', '10/12/2015'), undef, "Period on item does not overlap (with metric date format)");
105
121
106
my $reserve = ReservesOnSamePeriod($bibnum, $itemnumber, '2016-01-31', '2016-02-05');
122
my $reserve = ReservesOnSamePeriod($bibnum, $itemnumber, '2016-01-31', '2016-02-05');
107
is($reserve->[0]->{itemnumber}, $itemnumber, 'Period on item overlaps');
123
is($reserve->[0]->{itemnumber}, $itemnumber, 'Period on item overlaps');
124
108
$dbh->rollback;
125
$dbh->rollback;
109
- 

Return to bug 15261