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

(-)a/C4/Circulation.pm (-28 / +13 lines)
Lines 2795-2801 sub CanBookBeRenewed { Link Here
2795
            branchcode => $branchcode,
2795
            branchcode => $branchcode,
2796
            issue      => $issue
2796
            issue      => $issue
2797
        });
2797
        });
2798
        return ( 0, $auto_renew  ) if $auto_renew =~ 'too_soon' && $cron;
2798
        return ( 0, $auto_renew  ) if $auto_renew =~ 'auto_too_soon' && $cron;
2799
        # cron wants 'too_soon' over 'on_reserve' for performance and to avoid
2799
        # cron wants 'too_soon' over 'on_reserve' for performance and to avoid
2800
        # extra notices being sent. Cron also implies no override
2800
        # extra notices being sent. Cron also implies no override
2801
        return ( 0, $auto_renew  ) if $auto_renew =~ 'auto_account_expired';
2801
        return ( 0, $auto_renew  ) if $auto_renew =~ 'auto_account_expired';
Lines 2864-2869 sub CanBookBeRenewed { Link Here
2864
2864
2865
    return ( 0, "on_reserve" ) if $resfound;    # '' when no hold was found
2865
    return ( 0, "on_reserve" ) if $resfound;    # '' when no hold was found
2866
    return ( 0, $auto_renew  ) if $auto_renew =~ 'too_soon';#$auto_renew ne "no" && $auto_renew ne "ok";
2866
    return ( 0, $auto_renew  ) if $auto_renew =~ 'too_soon';#$auto_renew ne "no" && $auto_renew ne "ok";
2867
    if ( GetSoonestRenewDate($borrowernumber, $itemnumber) > dt_from_string() ){
2868
        return (0, "too_soon") unless $override_limit;
2869
    }
2867
2870
2868
    return ( 0, "auto_renew" ) if $auto_renew eq "ok" && !$override_limit; # 0 if auto-renewal should not succeed
2871
    return ( 0, "auto_renew" ) if $auto_renew eq "ok" && !$override_limit; # 0 if auto-renewal should not succeed
2869
2872
Lines 4311-4345 sub _CanBookBeAutoRenewed { Link Here
4311
                return "auto_too_much_oweing";
4314
                return "auto_too_much_oweing";
4312
            }
4315
            }
4313
        }
4316
        }
4314
    }
4315
4316
    if ( defined $issuing_rule->{norenewalbefore}
4317
        and $issuing_rule->{norenewalbefore} ne "" )
4318
    {
4319
4317
4320
        # Calculate soonest renewal by subtracting 'No renewal before' from due date
4318
        if ( defined $issuing_rule->{norenewalbefore}
4321
        my $soonestrenewal = dt_from_string( $issue->date_due, 'sql' )->subtract(
4319
            and $issuing_rule->{norenewalbefore} ne "" ) {
4322
            $issuing_rule->{lengthunit} => $issuing_rule->{norenewalbefore} );
4320
            if ( GetSoonestRenewDate($patron->id, $item->id) > dt_from_string()) {
4323
4321
                return "auto_too_soon";
4324
        # Depending on syspref reset the exact time, only check the date
4322
            } else {
4325
        if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date'
4323
                return "ok";
4326
            and $issuing_rule->{lengthunit} eq 'days' )
4324
            }
4327
        {
4328
            $soonestrenewal->truncate( to => 'day' );
4329
        }
4330
4331
        if ( $soonestrenewal > dt_from_string() )
4332
        {
4333
            return ($issue->auto_renew && $patron->autorenew_checkouts) ? "auto_too_soon" : "too_soon";
4334
        }
4335
        elsif ( $issue->auto_renew && $patron->autorenew_checkouts ) {
4336
            return "ok";
4337
        }
4325
        }
4338
    }
4339
4326
4340
    # Fallback for automatic renewals:
4327
        # Fallback for automatic renewals:
4341
    # If norenewalbefore is undef, don't renew before due date.
4328
        # If norenewalbefore is undef, don't renew before due date.
4342
    if ( $issue->auto_renew && $patron->autorenew_checkouts ) {
4343
        my $now = dt_from_string;
4329
        my $now = dt_from_string;
4344
        if ( $now >= dt_from_string( $issue->date_due, 'sql' ) ){
4330
        if ( $now >= dt_from_string( $issue->date_due, 'sql' ) ){
4345
            return "ok";
4331
            return "ok";
4346
- 

Return to bug 29474