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

(-)a/admin/smart-rules.pl (-40 / +40 lines)
Lines 266-273 elsif ($op eq 'add') { Link Here
266
    my $maxonsiteissueqty = strip_non_numeric( scalar $input->param('maxonsiteissueqty') );
266
    my $maxonsiteissueqty = strip_non_numeric( scalar $input->param('maxonsiteissueqty') );
267
    my $renewalsallowed  = $input->param('renewalsallowed');
267
    my $renewalsallowed  = $input->param('renewalsallowed');
268
    my $unseen_renewals_allowed  = defined $input->param('unseen_renewals_allowed') ? strip_non_numeric( scalar $input->param('unseen_renewals_allowed') ) : q{};
268
    my $unseen_renewals_allowed  = defined $input->param('unseen_renewals_allowed') ? strip_non_numeric( scalar $input->param('unseen_renewals_allowed') ) : q{};
269
    my $renewalperiod    = $input->param('renewalperiod');
269
    my $renewalperiod   = $input->param('renewalperiod');
270
    my $norenewalbefore  = $input->param('norenewalbefore');
270
    my $norenewalbefore = $input->param('norenewalbefore');
271
    $norenewalbefore = q{} if $norenewalbefore =~ /^\s*$/;
271
    $norenewalbefore = q{} if $norenewalbefore =~ /^\s*$/;
272
    my $noautorenewalbefore = $input->param('noautorenewalbefore');
272
    my $noautorenewalbefore = $input->param('noautorenewalbefore');
273
    $noautorenewalbefore = q{} if $noautorenewalbefore =~ /^\s*$/;
273
    $noautorenewalbefore = q{} if $noautorenewalbefore =~ /^\s*$/;
Lines 300-344 elsif ($op eq 'add') { Link Here
300
    my $recall_shelf_time = $input->param('recall_shelf_time');
300
    my $recall_shelf_time = $input->param('recall_shelf_time');
301
301
302
    my $rules = {
302
    my $rules = {
303
        maxissueqty                   => $maxissueqty,
303
        maxissueqty                      => $maxissueqty,
304
        maxonsiteissueqty             => $maxonsiteissueqty,
304
        maxonsiteissueqty                => $maxonsiteissueqty,
305
        rentaldiscount                => $rentaldiscount,
305
        rentaldiscount                   => $rentaldiscount,
306
        fine                          => $fine,
306
        fine                             => $fine,
307
        finedays                      => $finedays,
307
        finedays                         => $finedays,
308
        maxsuspensiondays             => $maxsuspensiondays,
308
        maxsuspensiondays                => $maxsuspensiondays,
309
        suspension_chargeperiod       => $suspension_chargeperiod,
309
        suspension_chargeperiod          => $suspension_chargeperiod,
310
        firstremind                   => $firstremind,
310
        firstremind                      => $firstremind,
311
        chargeperiod                  => $chargeperiod,
311
        chargeperiod                     => $chargeperiod,
312
        chargeperiod_charge_at        => $chargeperiod_charge_at,
312
        chargeperiod_charge_at           => $chargeperiod_charge_at,
313
        issuelength                   => $issuelength,
313
        issuelength                      => $issuelength,
314
        daysmode                      => $daysmode,
314
        daysmode                         => $daysmode,
315
        lengthunit                    => $lengthunit,
315
        lengthunit                       => $lengthunit,
316
        hardduedate                   => $hardduedate,
316
        hardduedate                      => $hardduedate,
317
        hardduedatecompare            => $hardduedatecompare,
317
        hardduedatecompare               => $hardduedatecompare,
318
        renewalsallowed               => $renewalsallowed,
318
        renewalsallowed                  => $renewalsallowed,
319
        unseen_renewals_allowed       => $unseen_renewals_allowed,
319
        unseen_renewals_allowed          => $unseen_renewals_allowed,
320
        renewalperiod                 => $renewalperiod,
320
        renewalperiod                    => $renewalperiod,
321
        norenewalbefore               => $norenewalbefore,
321
        norenewalbefore                  => $norenewalbefore,
322
        noautorenewalbefore           => $noautorenewalbefore,
322
        noautorenewalbefore              => $noautorenewalbefore,
323
        auto_renew                    => $auto_renew,
323
        auto_renew                       => $auto_renew,
324
        no_auto_renewal_after         => $no_auto_renewal_after,
324
        no_auto_renewal_after            => $no_auto_renewal_after,
325
        no_auto_renewal_after_hard_limit => $no_auto_renewal_after_hard_limit,
325
        no_auto_renewal_after_hard_limit => $no_auto_renewal_after_hard_limit,
326
        reservesallowed               => $reservesallowed,
326
        reservesallowed                  => $reservesallowed,
327
        holds_per_record              => $holds_per_record,
327
        holds_per_record                 => $holds_per_record,
328
        holds_per_day                 => $holds_per_day,
328
        holds_per_day                    => $holds_per_day,
329
        onshelfholds                  => $onshelfholds,
329
        onshelfholds                     => $onshelfholds,
330
        opacitemholds                 => $opacitemholds,
330
        opacitemholds                    => $opacitemholds,
331
        overduefinescap               => $overduefinescap,
331
        overduefinescap                  => $overduefinescap,
332
        cap_fine_to_replacement_price => $cap_fine_to_replacement_price,
332
        cap_fine_to_replacement_price    => $cap_fine_to_replacement_price,
333
        article_requests              => $article_requests,
333
        article_requests                 => $article_requests,
334
        note                          => $note,
334
        note                             => $note,
335
        decreaseloanholds             => $decreaseloanholds,
335
        decreaseloanholds                => $decreaseloanholds,
336
        recalls_allowed               => $recalls_allowed,
336
        recalls_allowed                  => $recalls_allowed,
337
        recalls_per_record            => $recalls_per_record,
337
        recalls_per_record               => $recalls_per_record,
338
        on_shelf_recalls              => $on_shelf_recalls,
338
        on_shelf_recalls                 => $on_shelf_recalls,
339
        recall_due_date_interval      => $recall_due_date_interval,
339
        recall_due_date_interval         => $recall_due_date_interval,
340
        recall_overdue_fine           => $recall_overdue_fine,
340
        recall_overdue_fine              => $recall_overdue_fine,
341
        recall_shelf_time             => $recall_shelf_time,
341
        recall_shelf_time                => $recall_shelf_time,
342
    };
342
    };
343
343
344
    Koha::CirculationRules->set_rules(
344
    Koha::CirculationRules->set_rules(
(-)a/installer/data/mysql/atomicupdate/bug_25393.pl (-5 / +6 lines)
Lines 3-9 use Modern::Perl; Link Here
3
return {
3
return {
4
    bug_number  => "25393",
4
    bug_number  => "25393",
5
    description => "Create separate 'no automatic renewal before' rule",
5
    description => "Create separate 'no automatic renewal before' rule",
6
    up => sub {
6
    up          => sub {
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
9
Lines 12-18 return { Link Here
12
            { Slice => {} }
12
            { Slice => {} }
13
        );
13
        );
14
14
15
        if(!scalar @{$rules}){
15
        if ( !scalar @{$rules} ) {
16
            my $existing_rules = $dbh->selectall_arrayref(
16
            my $existing_rules = $dbh->selectall_arrayref(
17
                q|SELECT * FROM circulation_rules WHERE rule_name = "norenewalbefore"|,
17
                q|SELECT * FROM circulation_rules WHERE rule_name = "norenewalbefore"|,
18
                { Slice => {} }
18
                { Slice => {} }
Lines 31-40 return { Link Here
31
                    $existing_rule->{rule_value}
31
                    $existing_rule->{rule_value}
32
                );
32
                );
33
            }
33
            }
34
            say $out "Bug 25939: New circulation rule 'noautorenewalbefore' has been added. Defaulting value to 'norenewalbefore'.";
34
            say $out
35
        }else{
35
                "Bug 25939: New circulation rule 'noautorenewalbefore' has been added. Defaulting value to 'norenewalbefore'.";
36
        } else {
36
            say $out "Bug 25939: Circulation rule 'noautorenewalbefore' found. Skipping update.";
37
            say $out "Bug 25939: Circulation rule 'noautorenewalbefore' found. Skipping update.";
37
        }
38
        }
38
39
39
        },
40
    },
40
};
41
};
(-)a/misc/cronjobs/automatic_renewals.pl (-27 / +28 lines)
Lines 178-223 while ( my $auto_renew = $auto_renews->next ) { Link Here
178
        $updated = 1;
178
        $updated = 1;
179
        if ($verbose) {
179
        if ($verbose) {
180
            say sprintf "Issue id: %s for borrower: %s and item: %s %s be renewed.",
180
            say sprintf "Issue id: %s for borrower: %s and item: %s %s be renewed.",
181
              $auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, $confirm ? 'will' : 'would';
181
                $auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber,
182
                $confirm ? 'will' : 'would';
182
        }
183
        }
183
        if ($confirm){
184
        if ($confirm) {
184
            my $date_due = AddRenewal(
185
            my $date_due = AddRenewal(
185
                {
186
                {
186
                    borrowernumber    => $auto_renew->borrowernumber,
187
                    borrowernumber => $auto_renew->borrowernumber,
187
                    itemnumber        => $auto_renew->itemnumber,
188
                    itemnumber     => $auto_renew->itemnumber,
188
                    branch            => $auto_renew->branchcode,
189
                    branch         => $auto_renew->branchcode,
189
                    seen              => 0,
190
                    seen           => 0,
190
                    automatic         => 1,
191
                    automatic      => 1,
191
                }
192
                }
192
            );
193
            );
193
            push @item_renewal_ids, $auto_renew->itemnumber;
194
            push @item_renewal_ids, $auto_renew->itemnumber;
194
            $auto_renew->auto_renew_error(undef)->store;
195
            $auto_renew->auto_renew_error(undef)->store;
195
        }
196
        }
196
        push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
197
        push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
197
            if ( $wants_messages ) && !$wants_digest;
198
            if ($wants_messages) && !$wants_digest;
198
    } elsif (
199
    } elsif ( $error eq 'too_many'
199
        $error eq 'too_many' ||
200
        || $error eq 'on_reserve'
200
        $error eq 'on_reserve' ||
201
        || $error eq 'restriction'
201
        $error eq 'restriction' ||
202
        || $error eq 'overdue'
202
        $error eq 'overdue' ||
203
        || $error eq 'too_unseen'
203
        $error eq 'too_unseen' ||
204
        || $error eq 'auto_account_expired'
204
        $error eq 'auto_account_expired' ||
205
        || $error eq 'auto_too_late'
205
        $error eq 'auto_too_late' ||
206
        || $error eq 'auto_too_much_oweing'
206
        $error eq 'auto_too_much_oweing' ||
207
        || $error eq 'auto_too_soon'
207
        $error eq 'auto_too_soon' ||
208
        || $error eq 'too_soon'
208
        $error eq 'too_soon' ||
209
        || $error eq 'item_denied_renewal'
209
        $error eq 'item_denied_renewal' ||
210
        || $error eq 'item_issued_to_other_patron' )
210
        $error eq 'item_issued_to_other_patron'
211
    {
211
    ) {
212
        if ($verbose) {
212
        if ( $verbose ) {
213
            say sprintf "Issue id: %s for borrower: %s and item: %s %s not be renewed. (%s)",
213
            say sprintf "Issue id: %s for borrower: %s and item: %s %s not be renewed. (%s)",
214
              $auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, $confirm ? 'will' : 'would', $error;
214
                $auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber,
215
                $confirm ? 'will' : 'would', $error;
215
        }
216
        }
216
        $updated = 1 if (!$auto_renew->auto_renew_error || $error ne $auto_renew->auto_renew_error);
217
        $updated = 1 if ( !$auto_renew->auto_renew_error || $error ne $auto_renew->auto_renew_error );
217
        if ( $updated ) {
218
        if ($updated) {
218
            $auto_renew->auto_renew_error($error)->store if $confirm;
219
            $auto_renew->auto_renew_error($error)->store if $confirm;
219
            push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
220
            push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
220
              if $error ne 'auto_too_soon' && ( $wants_messages  && !$wants_digest );    # Do not notify if it's too soon
221
                if $error ne 'auto_too_soon' && ( $wants_messages && !$wants_digest );  # Do not notify if it's too soon
221
        }
222
        }
222
    }
223
    }
223
224
(-)a/svc/checkouts (-52 / +56 lines)
Lines 240-306 while ( my $c = $sth->fetchrow_hashref() ) { Link Here
240
    }
240
    }
241
241
242
    my $checkout = {
242
    my $checkout = {
243
        DT_RowId             => $c->{itemnumber} . '-' . $c->{borrowernumber},
243
        DT_RowId               => $c->{itemnumber} . '-' . $c->{borrowernumber},
244
        title                => $c->{title},
244
        title                  => $c->{title},
245
        subtitle             => \@subtitles,
245
        subtitle               => \@subtitles,
246
        medium               => $c->{medium} // '',
246
        medium                 => $c->{medium} // '',
247
        part_number          => $c->{part_number} // '',
247
        part_number            => $c->{part_number} // '',
248
        part_name            => $c->{part_name} // '',
248
        part_name              => $c->{part_name} // '',
249
        author               => $c->{author},
249
        author                 => $c->{author},
250
        barcode              => $c->{barcode},
250
        barcode                => $c->{barcode},
251
        type_for_stat          => $type_for_stat || q{},
251
        type_for_stat          => $type_for_stat || q{},
252
        itemtype_description   => $itemtype || q{},
252
        itemtype_description   => $itemtype || q{},
253
        recordtype_description => $recordtype || q{},
253
        recordtype_description => $recordtype || q{},
254
        collection           => $collection,
254
        collection             => $collection,
255
        location             => $location,
255
        location               => $location,
256
        homebranch           => $c->{homebranch},
256
        homebranch             => $c->{homebranch},
257
        itemnotes            => $c->{itemnotes},
257
        itemnotes              => $c->{itemnotes},
258
        itemnotes_nonpublic  => $c->{itemnotes_nonpublic},
258
        itemnotes_nonpublic    => $c->{itemnotes_nonpublic},
259
        branchcode           => $c->{branchcode},
259
        branchcode             => $c->{branchcode},
260
        branchname           => $c->{branchname},
260
        branchname             => $c->{branchname},
261
        itemcallnumber       => $c->{itemcallnumber} || q{},
261
        itemcallnumber         => $c->{itemcallnumber} || q{},
262
        copynumber           => $c->{copynumber} || q{},
262
        copynumber             => $c->{copynumber} || q{},
263
        charge         => $charge,
263
        charge                 => $charge,
264
        fine           => $fine,
264
        fine                   => $fine,
265
        price          => $c->{replacementprice} || q{},
265
        price                  => $c->{replacementprice} || q{},
266
        can_renew      => $can_renew,
266
        can_renew              => $can_renew,
267
        can_renew_error     => $can_renew_error,
267
        can_renew_error        => $can_renew_error,
268
        can_renew_date      => $can_renew_date,
268
        can_renew_date         => $can_renew_date,
269
        itemnumber          => $c->{itemnumber},
269
        itemnumber             => $c->{itemnumber},
270
        borrowernumber      => $c->{borrowernumber},
270
        borrowernumber         => $c->{borrowernumber},
271
        biblionumber        => $c->{biblionumber},
271
        biblionumber           => $c->{biblionumber},
272
        issuedate           => $c->{issuedate},
272
        issuedate              => $c->{issuedate},
273
        date_due            => $c->{date_due},
273
        date_due               => $c->{date_due},
274
        date_due_overdue    => $c->{date_due_overdue} ? JSON::true : JSON::false,
274
        date_due_overdue       => $c->{date_due_overdue} ? JSON::true : JSON::false,
275
        timestamp           => $c->{timestamp},
275
        timestamp              => $c->{timestamp},
276
        auto_renew          => $c->{auto_renew},
276
        auto_renew             => $c->{auto_renew},
277
        onsite_checkout     => $c->{onsite_checkout},
277
        onsite_checkout        => $c->{onsite_checkout},
278
        enumchron           => $c->{enumchron},
278
        enumchron              => $c->{enumchron},
279
        renewals_count      => $renewals_count,
279
        renewals_count         => $renewals_count,
280
        renewals_allowed    => $renewals_allowed || 0,
280
        renewals_allowed       => $renewals_allowed || 0,
281
        renewals_remaining  => $renewals_remaining,
281
        renewals_remaining     => $renewals_remaining,
282
        unseen_count        => $unseen_count,
282
        unseen_count           => $unseen_count,
283
        unseen_allowed      => $unseen_allowed,
283
        unseen_allowed         => $unseen_allowed,
284
        unseen_remaining    => $unseen_remaining,
284
        unseen_remaining       => $unseen_remaining,
285
285
286
        return_claim_id         => $c->{return_claim_id},
286
        return_claim_id                   => $c->{return_claim_id},
287
        return_claim_notes      => $c->{return_claim_notes},
287
        return_claim_notes                => $c->{return_claim_notes},
288
        return_claim_created_on => $c->{return_claim_created_on},
288
        return_claim_created_on           => $c->{return_claim_created_on},
289
        return_claim_updated_on => $c->{return_claim_updated_on},
289
        return_claim_updated_on           => $c->{return_claim_updated_on},
290
        return_claim_created_on_formatted => $c->{return_claim_created_on} ? output_pref({ dt => dt_from_string( $c->{return_claim_created_on} ) }) : undef,
290
        return_claim_created_on_formatted => $c->{return_claim_created_on}
291
        return_claim_updated_on_formatted => $c->{return_claim_updated_on} ? output_pref({ dt => dt_from_string( $c->{return_claim_updated_on} ) }) : undef,
291
        ? output_pref( { dt => dt_from_string( $c->{return_claim_created_on} ) } )
292
292
        : undef,
293
        lost    => $lost,
293
        return_claim_updated_on_formatted => $c->{return_claim_updated_on}
294
        ? output_pref( { dt => dt_from_string( $c->{return_claim_updated_on} ) } )
295
        : undef,
296
297
        lost            => $lost,
294
        claims_returned => $claims_returned,
298
        claims_returned => $claims_returned,
295
        damaged => $damaged,
299
        damaged         => $damaged,
296
        materials => $materials,
300
        materials       => $materials,
297
        borrower => {
301
        borrower        => {
298
            surname    => $c->{surname},
302
            surname    => $c->{surname},
299
            firstname  => $c->{firstname},
303
            firstname  => $c->{firstname},
300
            cardnumber => $c->{cardnumber},
304
            cardnumber => $c->{cardnumber},
301
        },
305
        },
302
        issued_today => !$c->{not_issued_today},
306
        issued_today => !$c->{not_issued_today},
303
        recalled => $recalled,
307
        recalled     => $recalled,
304
    };
308
    };
305
309
306
    if ( $c->{not_issued_today} ) {
310
    if ( $c->{not_issued_today} ) {
(-)a/t/db_dependent/Circulation.t (-13 / +15 lines)
Lines 278-293 Koha::CirculationRules->set_rules( Link Here
278
        branchcode   => undef,
278
        branchcode   => undef,
279
        itemtype     => undef,
279
        itemtype     => undef,
280
        rules        => {
280
        rules        => {
281
            reservesallowed => 25,
281
            reservesallowed     => 25,
282
            issuelength     => 14,
282
            issuelength         => 14,
283
            lengthunit      => 'days',
283
            lengthunit          => 'days',
284
            renewalsallowed => 1,
284
            renewalsallowed     => 1,
285
            renewalperiod   => 7,
285
            renewalperiod       => 7,
286
            norenewalbefore     => undef,
286
            norenewalbefore     => undef,
287
            noautorenewalbefore => undef,
287
            noautorenewalbefore => undef,
288
            auto_renew      => 0,
288
            auto_renew          => 0,
289
            fine            => .10,
289
            fine                => .10,
290
            chargeperiod    => 1,
290
            chargeperiod        => 1,
291
        }
291
        }
292
    }
292
    }
293
);
293
);
Lines 845-854 subtest "CanBookBeRenewed tests" => sub { Link Here
845
        }
845
        }
846
    );
846
    );
847
847
848
    my $auto_renew_issue = AddIssue( $renewing_borrower_obj, $item_4->barcode, undef, undef, undef, undef, { auto_renew => 1 } );
848
    my $auto_renew_issue =
849
        AddIssue( $renewing_borrower_obj, $item_4->barcode, undef, undef, undef, undef, { auto_renew => 1 } );
849
    my $info;
850
    my $info;
850
    ( $renewokay, $error, $info ) =
851
    ( $renewokay, $error, $info ) = CanBookBeRenewed( $renewing_borrower_obj, $auto_renew_issue );
851
      CanBookBeRenewed( $renewing_borrower_obj, $auto_renew_issue );
852
    is( $info->{soonest_renew_date}, undef, "soonest_renew_date is not returned because this issue can be renewed" );
852
    is( $info->{soonest_renew_date}, undef, "soonest_renew_date is not returned because this issue can be renewed" );
853
    is( $renewokay, 1, 'Bug 25393: Can do a manual renew, even if renewal is automatic and premature' );
853
    is( $renewokay, 1, 'Bug 25393: Can do a manual renew, even if renewal is automatic and premature' );
854
    is(
854
    is(
Lines 939-945 subtest "CanBookBeRenewed tests" => sub { Link Here
939
    is( $error, 'too_soon',
939
    is( $error, 'too_soon',
940
        'Bug 25393: Cannot renew, renewal is premature (returned code is too_soon)'
940
        'Bug 25393: Cannot renew, renewal is premature (returned code is too_soon)'
941
    );
941
    );
942
    is( $info->{soonest_renew_date}, dt_from_string($auto_renew_issue->date_due)->subtract( days => 7 ), "Soonest renew date returned when error is 'auto_too_soon'");
942
    is(
943
        $info->{soonest_renew_date}, dt_from_string( $auto_renew_issue->date_due )->subtract( days => 7 ),
944
        "Soonest renew date returned when error is 'auto_too_soon'"
945
    );
943
946
944
    ( $renewokay_cron, $error_cron, $info_cron ) =
947
    ( $renewokay_cron, $error_cron, $info_cron ) =
945
        CanBookBeRenewed( $renewing_borrower_obj, $auto_renew_issue, undef, 1 );
948
        CanBookBeRenewed( $renewing_borrower_obj, $auto_renew_issue, undef, 1 );
946
- 

Return to bug 25393