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

(-)a/C4/Circulation.pm (-11 / +22 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
            and $issuingrule->{lengthunit} eq 'days' )
2772
        {
2773
            $soonestrenewal->truncate( to => 'day' );
2774
        }
2775
2776
        if ( $soonestrenewal > DateTime->now( time_zone => C4::Context->tz() ) )
2770
        {
2777
        {
2771
            return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew};
2778
            return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew};
2772
            return ( 0, "too_soon" );
2779
            return ( 0, "too_soon" );
Lines 3001-3011 sub GetSoonestRenewDate { Link Here
3001
3008
3002
    if ( defined $issuingrule->{norenewalbefore} ) {
3009
    if ( defined $issuingrule->{norenewalbefore} ) {
3003
        my $soonestrenewal =
3010
        my $soonestrenewal =
3004
          $itemissue->{date_due}->subtract(
3011
          $itemissue->{date_due}->clone()
3012
          ->subtract(
3005
            $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} );
3013
            $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} );
3006
3014
3007
        $soonestrenewal = $now > $soonestrenewal ? $now : $soonestrenewal;
3015
        if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date'
3008
        return $soonestrenewal;
3016
            and $issuingrule->{lengthunit} eq 'days' )
3017
        {
3018
            $soonestrenewal->truncate( to => 'day' );
3019
        }
3020
        return $soonestrenewal if $now < $soonestrenewal;
3009
    }
3021
    }
3010
    return $now;
3022
    return $now;
3011
}
3023
}
3012
- 

Return to bug 14395