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

(-)a/C4/Circulation.pm (-11 / +18 lines)
Lines 2760-2772 sub CanBookBeRenewed { Link Here
2760
2760
2761
    if ( defined $issuingrule->{norenewalbefore} ) {
2761
    if ( defined $issuingrule->{norenewalbefore} ) {
2762
2762
2763
        # Get current time and add norenewalbefore.
2763
    # Calculate soonest renewal by subtracting 'No renewal before' from due date
2764
        # If this is smaller than date_due, it's too soon for renewal.
2764
        my $soonestrenewal =
2765
        if (
2765
          $itemissue->{date_due}->clone()
2766
            DateTime->now( time_zone => C4::Context->tz() )->add(
2766
          ->subtract(
2767
                $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore}
2767
            $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} );
2768
            ) < $itemissue->{date_due}
2768
2769
          )
2769
        # Depending on syspref reset the exact time, only check the date
2770
        if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' ) {
2771
            $soonestrenewal->truncate( to => 'day' );
2772
        }
2773
2774
        if ( $soonestrenewal > DateTime->now( time_zone => C4::Context->tz() ) )
2770
        {
2775
        {
2771
            return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew};
2776
            return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew};
2772
            return ( 0, "too_soon" );
2777
            return ( 0, "too_soon" );
Lines 3001-3011 sub GetSoonestRenewDate { Link Here
3001
3006
3002
    if ( defined $issuingrule->{norenewalbefore} ) {
3007
    if ( defined $issuingrule->{norenewalbefore} ) {
3003
        my $soonestrenewal =
3008
        my $soonestrenewal =
3004
          $itemissue->{date_due}->subtract(
3009
          $itemissue->{date_due}->clone()
3010
          ->subtract(
3005
            $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} );
3011
            $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} );
3006
3012
3007
        $soonestrenewal = $now > $soonestrenewal ? $now : $soonestrenewal;
3013
        if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' ) {
3008
        return $soonestrenewal;
3014
            $soonestrenewal->truncate( to => 'day' );
3015
        }
3016
        return $soonestrenewal if $now < $soonestrenewal;
3009
    }
3017
    }
3010
    return $now;
3018
    return $now;
3011
}
3019
}
3012
- 

Return to bug 14395