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

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

Return to bug 14395