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

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

Return to bug 14395