|
Lines 2737-2743
sub CanBookBeRenewed {
Link Here
|
| 2737 |
return ( 0, "too_many" ) |
2737 |
return ( 0, "too_many" ) |
| 2738 |
if $issuingrule->{renewalsallowed} <= $itemissue->{renewals}; |
2738 |
if $issuingrule->{renewalsallowed} <= $itemissue->{renewals}; |
| 2739 |
|
2739 |
|
| 2740 |
if ( $issuingrule->{norenewalbefore} ) { |
2740 |
if ( defined $issuingrule->{norenewalbefore} ) { |
| 2741 |
|
2741 |
|
| 2742 |
# Get current time and add norenewalbefore. |
2742 |
# Get current time and add norenewalbefore. |
| 2743 |
# If this is smaller than date_due, it's too soon for renewal. |
2743 |
# If this is smaller than date_due, it's too soon for renewal. |
|
Lines 2750-2758
sub CanBookBeRenewed {
Link Here
|
| 2750 |
return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew}; |
2750 |
return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew}; |
| 2751 |
return ( 0, "too_soon" ); |
2751 |
return ( 0, "too_soon" ); |
| 2752 |
} |
2752 |
} |
|
|
2753 |
else { |
| 2754 |
return ( 0, "auto_renew" ) if $itemissue->{auto_renew}; |
| 2755 |
return ( 1, undef ); |
| 2756 |
} |
| 2757 |
} |
| 2758 |
|
| 2759 |
# Fallback for automatic renewals: |
| 2760 |
# If norenewalbefore is undef, don't renew before due date. |
| 2761 |
elsif ( $itemissue->{auto_renew} ) { |
| 2762 |
return ( 0, "auto_renew" ) |
| 2763 |
if DateTime->now( time_zone => C4::Context->tz() ) >= |
| 2764 |
$itemissue->{date_due}; |
| 2765 |
return ( 0, "auto_too_soon" ); |
| 2753 |
} |
2766 |
} |
| 2754 |
|
2767 |
|
| 2755 |
return ( 0, "auto_renew" ) if $itemissue->{auto_renew}; |
|
|
| 2756 |
return ( 1, undef ); |
2768 |
return ( 1, undef ); |
| 2757 |
} |
2769 |
} |
| 2758 |
|
2770 |
|
|
Lines 2966-2972
sub GetSoonestRenewDate {
Link Here
|
| 2966 |
|
2978 |
|
| 2967 |
my $now = DateTime->now( time_zone => C4::Context->tz() ); |
2979 |
my $now = DateTime->now( time_zone => C4::Context->tz() ); |
| 2968 |
|
2980 |
|
| 2969 |
if ( $issuingrule->{norenewalbefore} ) { |
2981 |
if ( defined $issuingrule->{norenewalbefore} ) { |
| 2970 |
my $soonestrenewal = |
2982 |
my $soonestrenewal = |
| 2971 |
$itemissue->{date_due}->subtract( |
2983 |
$itemissue->{date_due}->subtract( |
| 2972 |
$issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} ); |
2984 |
$issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} ); |