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

(-)a/C4/Circulation.pm (-3 / +19 lines)
Lines 1244-1258 sub checkHighHolds { Link Here
1244
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branchcode, $borrower );
1244
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branchcode, $borrower );
1245
1245
1246
        my $decreaseLoanHighHoldsDuration = C4::Context->preference('decreaseLoanHighHoldsDuration');
1246
        my $decreaseLoanHighHoldsDuration = C4::Context->preference('decreaseLoanHighHoldsDuration');
1247
1247
        my $rule = Koha::CirculationRules->get_effective_rule(
1248
        my $reduced_datedue = $calendar->addDate( $issuedate, $decreaseLoanHighHoldsDuration );
1248
            {
1249
                categorycode => $borrower->{categorycode},
1250
                itemtype     => $item_object->effective_itemtype,
1251
                branchcode   => $branchcode,
1252
                rule_name    => 'decreaseloanholds',
1253
            }
1254
        );
1255
        my $reduced_datedue;
1256
        my $duration;
1257
        if ( defined($rule) && $rule->rule_value ne '' ){
1258
            # overrides decreaseLoanHighHoldsDuration syspref
1259
            $duration = $rule->rule_value;
1260
            $reduced_datedue = $calendar->addDate( $issuedate, $rule->rule_value );
1261
        } else {
1262
            $duration = $decreaseLoanHighHoldsDuration;
1263
            $reduced_datedue = $calendar->addDate( $issuedate, $decreaseLoanHighHoldsDuration );
1264
        }
1249
        $reduced_datedue->set_hour($orig_due->hour);
1265
        $reduced_datedue->set_hour($orig_due->hour);
1250
        $reduced_datedue->set_minute($orig_due->minute);
1266
        $reduced_datedue->set_minute($orig_due->minute);
1251
        $reduced_datedue->truncate( to => 'minute' );
1267
        $reduced_datedue->truncate( to => 'minute' );
1252
1268
1253
        if ( DateTime->compare( $reduced_datedue, $orig_due ) == -1 ) {
1269
        if ( DateTime->compare( $reduced_datedue, $orig_due ) == -1 ) {
1254
            $return_data->{exceeded} = 1;
1270
            $return_data->{exceeded} = 1;
1255
            $return_data->{duration} = $decreaseLoanHighHoldsDuration;
1271
            $return_data->{duration} = $duration;
1256
            $return_data->{due_date} = $reduced_datedue;
1272
            $return_data->{due_date} = $reduced_datedue;
1257
        }
1273
        }
1258
    }
1274
    }
(-)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
    decreaseloanholds => {
161
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
162
    },
160
    # Not included (deprecated?):
163
    # Not included (deprecated?):
161
    #   * accountsent
164
    #   * accountsent
162
    #   * reservecharge
165
    #   * reservecharge
(-)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 $decreaseloanholds = $input->param('decreaseloanholds') || undef;
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
        decreaseloanholds             => $decreaseloanholds,
323
    };
325
    };
324
326
325
    Koha::CirculationRules->set_rules(
327
    Koha::CirculationRules->set_rules(
(-)a/installer/data/mysql/atomicupdate/bug_14866-add_decreaseloanholds_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, 'decreaseloanholds', NULL) });
4
5
    NewVersion( $DBversion, 14866, "Add decreaseloanholds 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
                decreaseloanholds                => undef,
286
              }
287
              }
287
        };
288
        };
288
289
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +6 lines)
Lines 117-122 Link Here
117
                <th>OPAC item level holds</th>
117
                <th>OPAC item level holds</th>
118
                <th>Article requests</th>
118
                <th>Article requests</th>
119
                <th>Rental discount (%)</th>
119
                <th>Rental discount (%)</th>
120
                <th>Decrease loan holds (day)</th>
120
                <th>Actions</th>
121
                <th>Actions</th>
121
            </tr>
122
            </tr>
122
            </thead>
123
            </thead>
Lines 155-162 Link Here
155
                        [% SET opacitemholds = all_rules.$c.$i.opacitemholds %]
156
                        [% SET opacitemholds = all_rules.$c.$i.opacitemholds %]
156
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
157
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
157
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
158
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
159
                        [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %]
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 || decreaseloanholds %]
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 301-306 Link Here
301
                                        [% END %]
303
                                        [% END %]
302
                                    </td>
304
                                    </td>
303
                                    <td>[% rentaldiscount | html %]</td>
305
                                    <td>[% rentaldiscount | html %]</td>
306
                                    <td>[% decreaseloanholds | html %]</td>
304
                                    <td class="actions">
307
                                    <td class="actions">
305
                                      <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
308
                                      <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
306
                                      <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% i || '*' | uri %]&amp;categorycode=[% c || '*' | uri %]&amp;branch=[% current_branch | uri %]"><i class="fa fa-trash"></i> Delete</a>
309
                                      <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% i || '*' | uri %]&amp;categorycode=[% c || '*' | uri %]&amp;branch=[% current_branch | uri %]"><i class="fa fa-trash"></i> Delete</a>
Lines 404-409 Link Here
404
                        </select>
407
                        </select>
405
                    </td>
408
                    </td>
406
                    <td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
409
                    <td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
410
                    <td><input type="text" name="decreaseloanholds" id="decreaseloanholds" size="2" /></td>
407
                    <td class="actions">
411
                    <td class="actions">
408
                        <input type="hidden" name="branch" value="[% current_branch | html %]"/>
412
                        <input type="hidden" name="branch" value="[% current_branch | html %]"/>
409
                        <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
413
                        <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
Lines 443-448 Link Here
443
                      <th>OPAC item level holds</th>
447
                      <th>OPAC item level holds</th>
444
                      <th>Article requests</th>
448
                      <th>Article requests</th>
445
                      <th>Rental discount (%)</th>
449
                      <th>Rental discount (%)</th>
450
                      <th>Decrease loan holds (day)</th>
446
                      <th>&nbsp;</th>
451
                      <th>&nbsp;</th>
447
                    </tr>
452
                    </tr>
448
                  </tfoot>
453
                  </tfoot>
(-)a/t/db_dependent/DecreaseLoanHighHolds.t (-2 / +15 lines)
Lines 30-36 use Koha::CirculationRules; Link Here
30
use t::lib::TestBuilder;
30
use t::lib::TestBuilder;
31
use t::lib::Mocks;
31
use t::lib::Mocks;
32
32
33
use Test::More tests => 17;
33
use Test::More tests => 18;
34
34
35
my $dbh    = C4::Context->dbh;
35
my $dbh    = C4::Context->dbh;
36
my $schema = Koha::Database->new()->schema();
36
my $schema = Koha::Database->new()->schema();
Lines 106-111 Koha::CirculationRules->set_rules( Link Here
106
            lengthunit      => 'days',
106
            lengthunit      => 'days',
107
            reservesallowed => '99',
107
            reservesallowed => '99',
108
            holds_per_record => '99',
108
            holds_per_record => '99',
109
            decreaseloanholds => 0,
109
        }
110
        }
110
    }
111
    }
111
);
112
);
Lines 197-200 ok( $needsconfirmation->{HIGHHOLDS}, "High holds checkout needs confirmation" ); Link Here
197
( undef, $needsconfirmation ) = CanBookBeIssued( $patron_object, $item->barcode, undef, undef, undef, { override_high_holds => 1 } );
198
( undef, $needsconfirmation ) = CanBookBeIssued( $patron_object, $item->barcode, undef, undef, undef, { override_high_holds => 1 } );
198
ok( !$needsconfirmation->{HIGHHOLDS}, "High holds checkout does not need confirmation" );
199
ok( !$needsconfirmation->{HIGHHOLDS}, "High holds checkout does not need confirmation" );
199
200
201
Koha::CirculationRules->set_rule(
202
    {
203
        branchcode   => undef,
204
        categorycode => undef,
205
        itemtype     => $item->itype,
206
        rule_name    => 'decreaseloanholds',
207
        rule_value   => 2,
208
    }
209
);
210
211
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
212
is( $data->{duration}, 2, "Circulation rules override system preferences" );
213
200
$schema->storage->txn_rollback();
214
$schema->storage->txn_rollback();
201
- 

Return to bug 14866