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

(-)a/Koha/CirculationRules.pm (+3 lines)
Lines 157-162 our $RULE_KINDS = { Link Here
157
    note => { # This is not really a rule. Maybe we will want to separate this later.
157
    note => { # This is not really a rule. Maybe we will want to separate this later.
158
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
158
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
159
    },
159
    },
160
    holds_pickup_period => {
161
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
162
    },
160
    # Not included (deprecated?):
163
    # Not included (deprecated?):
161
    #   * accountsent
164
    #   * accountsent
162
    #   * reservecharge
165
    #   * reservecharge
(-)a/Koha/Hold.pm (+12 lines)
Lines 181-186 sub set_waiting { Link Here
181
    my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
181
    my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
182
182
183
    my $expirationdate = $today->clone;
183
    my $expirationdate = $today->clone;
184
185
    my $rule = Koha::CirculationRules->get_effective_rule({
186
        categorycode => $self->borrower->categorycode,
187
        itemtype => $self->item->effective_itemtype,
188
        branchcode => $self->branchcode,
189
        rule_name => 'holds_pickup_period',
190
    });
191
    if ( defined($rule) and $rule->rule_value ne '' ){
192
        # circulation rule overrides ReservesMaxPickUpDelay
193
        $max_pickup_delay = $rule->rule_value;
194
    }
195
184
    $expirationdate->add(days => $max_pickup_delay);
196
    $expirationdate->add(days => $max_pickup_delay);
185
197
186
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
198
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
(-)a/admin/smart-rules.pl (+2 lines)
Lines 288-293 elsif ($op eq 'add') { Link Here
288
    my $overduefinescap = $input->param('overduefinescap') || '';
288
    my $overduefinescap = $input->param('overduefinescap') || '';
289
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
289
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
290
    my $note = $input->param('note');
290
    my $note = $input->param('note');
291
    my $holds_pickup_period = strip_non_numeric($input->param('holds_pickup_period'));
291
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
292
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
292
293
293
    my $rules = {
294
    my $rules = {
Lines 320-325 elsif ($op eq 'add') { Link Here
320
        cap_fine_to_replacement_price => $cap_fine_to_replacement_price,
321
        cap_fine_to_replacement_price => $cap_fine_to_replacement_price,
321
        article_requests              => $article_requests,
322
        article_requests              => $article_requests,
322
        note                          => $note,
323
        note                          => $note,
324
        holds_pickup_period           => $holds_pickup_period,
323
    };
325
    };
324
326
325
    Koha::CirculationRules->set_rules(
327
    Koha::CirculationRules->set_rules(
(-)a/installer/data/mysql/atomicupdate/bug_8367-add_holds_pickup_period_circrule.perl (+6 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{INSERT IGNORE INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value) VALUES (NULL, NULL, NULL, 'holds_pickup_period', NULL) });
4
5
    NewVersion( $DBversion, 8367, "Add holds_pickup_period circulation rule" );
6
}
(-)a/installer/onboarding.pl (+1 lines)
Lines 283-288 if ( $step == 5 ) { Link Here
283
                rentaldiscount                   => 0,
283
                rentaldiscount                   => 0,
284
                reservesallowed                  => $reservesallowed,
284
                reservesallowed                  => $reservesallowed,
285
                suspension_chargeperiod          => undef,
285
                suspension_chargeperiod          => undef,
286
                holds_pickup_period              => undef,
286
              }
287
              }
287
        };
288
        };
288
289
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +6 lines)
Lines 115-120 Link Here
115
                <th>Holds per record (count)</th>
115
                <th>Holds per record (count)</th>
116
                <th>On shelf holds allowed</th>
116
                <th>On shelf holds allowed</th>
117
                <th>OPAC item level holds</th>
117
                <th>OPAC item level holds</th>
118
                <th>Holds pickup period (day)</th>
118
                <th>Article requests</th>
119
                <th>Article requests</th>
119
                <th>Rental discount (%)</th>
120
                <th>Rental discount (%)</th>
120
                <th>Actions</th>
121
                <th>Actions</th>
Lines 153-162 Link Here
153
                        [% SET holds_per_record = all_rules.$c.$i.holds_per_record %]
154
                        [% SET holds_per_record = all_rules.$c.$i.holds_per_record %]
154
                        [% SET onshelfholds = all_rules.$c.$i.onshelfholds %]
155
                        [% SET onshelfholds = all_rules.$c.$i.onshelfholds %]
155
                        [% SET opacitemholds = all_rules.$c.$i.opacitemholds %]
156
                        [% SET opacitemholds = all_rules.$c.$i.opacitemholds %]
157
                        [% SET holds_pickup_period = all_rules.$c.$i.holds_pickup_period %]
156
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
158
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
157
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
159
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
158
160
159
                        [% SET show_rule = maxissueqty || maxonsiteissueqty || issuelength || lengthunit || hardduedate || hardduedatebefore || hardduedateexact || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || renewalsallowed || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || article_requests %]
161
                        [% SET show_rule = maxissueqty || maxonsiteissueqty || issuelength || lengthunit || hardduedate || hardduedatebefore || hardduedateexact || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || renewalsallowed || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || article_requests || holds_pickup_period %]
160
                        [% IF show_rule %]
162
                        [% IF show_rule %]
161
                            [% SET row_count = row_count + 1 %]
163
                            [% SET row_count = row_count + 1 %]
162
                            <tr row_countd="row_[% row_count | html %]">
164
                            <tr row_countd="row_[% row_count | html %]">
Lines 289-294 Link Here
289
                                            <span>Don't allow</span>
291
                                            <span>Don't allow</span>
290
                                        [% END %]
292
                                        [% END %]
291
                                    </td>
293
                                    </td>
294
                                    <td>[% holds_pickup_period | html %]</td>
292
                                    <td>
295
                                    <td>
293
                                        [% IF article_requests == 'no' %]
296
                                        [% IF article_requests == 'no' %]
294
                                            <span>No</span>
297
                                            <span>No</span>
Lines 395-400 Link Here
395
                            <option value="F">Force</option>
398
                            <option value="F">Force</option>
396
                        </select>
399
                        </select>
397
                    </td>
400
                    </td>
401
                    <td><input type="text" name="holds_pickup_period" id="holds_pickup_period" size="2" /></td>
398
                    <td>
402
                    <td>
399
                        <select id="article_requests" name="article_requests">
403
                        <select id="article_requests" name="article_requests">
400
                            <option value="no">No</option>
404
                            <option value="no">No</option>
Lines 441-446 Link Here
441
                      <th>Holds per record (count)</th>
445
                      <th>Holds per record (count)</th>
442
                      <th>On shelf holds allowed</th>
446
                      <th>On shelf holds allowed</th>
443
                      <th>OPAC item level holds</th>
447
                      <th>OPAC item level holds</th>
448
                      <th>Holds pickup period (day)</th>
444
                      <th>Article requests</th>
449
                      <th>Article requests</th>
445
                      <th>Rental discount (%)</th>
450
                      <th>Rental discount (%)</th>
446
                      <th>&nbsp;</th>
451
                      <th>&nbsp;</th>
(-)a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl (+12 lines)
Lines 335-340 sub GetWaitingHolds { Link Here
335
        my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'} );
335
        my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'} );
336
336
337
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
337
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
338
        my $item = Koha::Items->find({ barcode => $issue->{barcode} });
339
        my $rule = Koha::CirculationRules->get_effective_rule({
340
            categorycode => $issue->{categorycode},
341
            itemtype => $item->effective_itemtype,
342
            branchcode => $issue->{branchcode},
343
            rule_name => 'holds_pickup_period',
344
        });
345
        if ( defined($rule) and $rule->rule_value ne '' ){
346
            # circulation rule overrides ReservesMaxPickUpDelay
347
            $pickupdelay = $rule->rule_value;
348
        }
349
338
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
350
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
339
        if ( $calendar->is_holiday($pickup_date) ) {
351
        if ( $calendar->is_holiday($pickup_date) ) {
340
            $pickup_date = $calendar->next_open_days( $pickup_date, 1 );
352
            $pickup_date = $calendar->next_open_days( $pickup_date, 1 );
(-)a/t/db_dependent/Holds/WaitingReserves.t (-2 / +89 lines)
Lines 8-14 use Koha::DateUtils; Link Here
8
use t::lib::Mocks;
8
use t::lib::Mocks;
9
use t::lib::TestBuilder;
9
use t::lib::TestBuilder;
10
10
11
use Test::More tests => 11;
11
use Test::More tests => 13;
12
12
13
use_ok('C4::Reserves');
13
use_ok('C4::Reserves');
14
14
Lines 83-88 my $biblio4 = $builder->build({ Link Here
83
        title => 'Title 4',    },
83
        title => 'Title 4',    },
84
});
84
});
85
85
86
my $biblio5 = $builder->build({
87
    source => 'Biblio',
88
    value  => {
89
        title => 'Title 5',    },
90
});
91
92
my $biblio6 = $builder->build({
93
    source => 'Biblio',
94
    value  => {
95
        title => 'Title 6',    },
96
});
97
86
my $item1 = $builder->build({
98
my $item1 = $builder->build({
87
    source => 'Item',
99
    source => 'Item',
88
    value  => {
100
    value  => {
Lines 111-116 my $item4 = $builder->build({ Link Here
111
    },
123
    },
112
});
124
});
113
125
126
my $item5 = $builder->build({
127
    source => 'Item',
128
    value  => {
129
        biblionumber => $biblio5->{biblionumber},
130
    },
131
});
132
133
my $item6 = $builder->build({
134
    source => 'Item',
135
    value  => {
136
        biblionumber => $biblio6->{biblionumber},
137
    },
138
});
139
140
Koha::CirculationRules->set_rules({
141
    categorycode => undef,
142
    itemtype => undef,
143
    branchcode => undef,
144
    rules => {
145
        holds_pickup_period => undef,
146
    }
147
});
148
114
my $today = dt_from_string();
149
my $today = dt_from_string();
115
150
116
my $reserve1_reservedate = $today->clone;
151
my $reserve1_reservedate = $today->clone;
Lines 241-244 ModReserveAffect( $item4->{itemnumber}, $patron2->{borrowernumber}, 0, $reserve4 Link Here
241
my $r4 = Koha::Holds->find($reserve4->{reserve_id});
276
my $r4 = Koha::Holds->find($reserve4->{reserve_id});
242
is($r4->expirationdate, $requested_expiredate->ymd, 'Requested expiration date should be kept' );
277
is($r4->expirationdate, $requested_expiredate->ymd, 'Requested expiration date should be kept' );
243
278
279
Koha::CirculationRules->set_rules({
280
    categorycode => $patron1->{categorycode},
281
    itemtype => undef,
282
    branchcode => undef,
283
    rules => {
284
        holds_pickup_period => '3',
285
    }
286
});
287
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 7);
288
289
my $reserve5_reservedate = $today->clone;
290
my $reserve5_expirationdate = $reserve5_reservedate->add(days => 3);
291
292
my $reserve5 = $builder->build({
293
    source => 'Reserve',
294
    value => {
295
        borrowernumber => $patron1->{borrowernumber},
296
        reservedate => $reserve5_reservedate->ymd,
297
        expirationdate => undef,
298
        biblionumber => $biblio5->{biblionumber},
299
        branchcode => 'LIB2',
300
        priority => 1,
301
        found => '',
302
    },
303
});
304
305
ModReserveAffect( $item5->{itemnumber}, $patron1->{borrowernumber});
306
my $r5 = Koha::Holds->find($reserve5->{reserve_id});
307
308
is($r5->expirationdate, $reserve5_expirationdate->ymd, 'Expiration date should be set to today + 3 based on circulation rules' );
309
310
my $reserve6_reservedate = $today->clone;
311
# add 3 days of pickup + 1 day of holiday
312
my $reserve6_expirationdate = $reserve6_reservedate->add(days => 5);
313
314
my $reserve6 = $builder->build({
315
    source => 'Reserve',
316
    value => {
317
        borrowernumber => $patron1->{borrowernumber},
318
        reservedate => $reserve6_reservedate->ymd,
319
        expirationdate => undef,
320
        biblionumber => $biblio6->{biblionumber},
321
        branchcode => 'LIB1',
322
        priority => 1,
323
        found => '',
324
    },
325
});
326
327
ModReserveAffect( $item6->{itemnumber}, $patron1->{borrowernumber});
328
my $r6 = Koha::Holds->find($reserve6->{reserve_id});
329
330
is($r6->expirationdate, $reserve6_expirationdate->ymd, 'Expiration date should be set to today + 4 based on circulation rules and including a holiday' );
331
244
$schema->storage->txn_rollback;
332
$schema->storage->txn_rollback;
245
- 

Return to bug 8367