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

(-)a/C4/Circulation.pm (-12 / +22 lines)
Lines 2829-2842 sub CanBookBeRenewed { Link Here
2829
        and $issuingrule->{norenewalbefore} ne "" )
2829
        and $issuingrule->{norenewalbefore} ne "" )
2830
    {
2830
    {
2831
2831
2832
        # Get current time and add norenewalbefore.
2832
        # Calculate soonest renewal by subtracting 'No renewal before' from due date
2833
        # If this is smaller than date_due, it's too soon for renewal.
2833
        my $soonestrenewal =
2834
        my $now = dt_from_string;
2834
          $itemissue->{date_due}->clone()
2835
        if (
2835
          ->subtract(
2836
            $now->add(
2836
            $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} );
2837
                $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore}
2837
2838
            ) < $itemissue->{date_due}
2838
        # Depending on syspref reset the exact time, only check the date
2839
          )
2839
        if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date'
2840
            and $issuingrule->{lengthunit} eq 'days' )
2841
        {
2842
            $soonestrenewal->truncate( to => 'day' );
2843
        }
2844
2845
        if ( $soonestrenewal > DateTime->now( time_zone => C4::Context->tz() ) )
2840
        {
2846
        {
2841
            return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew};
2847
            return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew};
2842
            return ( 0, "too_soon" );
2848
            return ( 0, "too_soon" );
Lines 3072-3082 sub GetSoonestRenewDate { Link Here
3072
        and $issuingrule->{norenewalbefore} ne "" )
3078
        and $issuingrule->{norenewalbefore} ne "" )
3073
    {
3079
    {
3074
        my $soonestrenewal =
3080
        my $soonestrenewal =
3075
          $itemissue->{date_due}->subtract(
3081
          $itemissue->{date_due}->clone()
3082
          ->subtract(
3076
            $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} );
3083
            $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} );
3077
3084
3078
        $soonestrenewal = $now > $soonestrenewal ? $now : $soonestrenewal;
3085
        if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date'
3079
        return $soonestrenewal;
3086
            and $issuingrule->{lengthunit} eq 'days' )
3087
        {
3088
            $soonestrenewal->truncate( to => 'day' );
3089
        }
3090
        return $soonestrenewal if $now < $soonestrenewal;
3080
    }
3091
    }
3081
    return $now;
3092
    return $now;
3082
}
3093
}
3083
- 

Return to bug 14395