|
Lines 2818-2829
sub CanBookBeRenewed {
Link Here
|
| 2818 |
return ( 0, 'overdue'); |
2818 |
return ( 0, 'overdue'); |
| 2819 |
} |
2819 |
} |
| 2820 |
|
2820 |
|
| 2821 |
if ( $issuingrule->{norenewalbefore} ) { |
2821 |
if ( defined $issuingrule->{norenewalbefore} |
|
|
2822 |
and $issuingrule->{norenewalbefore} ne "" ) |
| 2823 |
{ |
| 2822 |
|
2824 |
|
| 2823 |
# Get current time and add norenewalbefore. |
2825 |
# Get current time and add norenewalbefore. |
| 2824 |
# If this is smaller than date_due, it's too soon for renewal. |
2826 |
# If this is smaller than date_due, it's too soon for renewal. |
|
|
2827 |
my $now = dt_from_string; |
| 2825 |
if ( |
2828 |
if ( |
| 2826 |
DateTime->now( time_zone => C4::Context->tz() )->add( |
2829 |
$now->add( |
| 2827 |
$issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} |
2830 |
$issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} |
| 2828 |
) < $itemissue->{date_due} |
2831 |
) < $itemissue->{date_due} |
| 2829 |
) |
2832 |
) |
|
Lines 2831-2839
sub CanBookBeRenewed {
Link Here
|
| 2831 |
return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew}; |
2834 |
return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew}; |
| 2832 |
return ( 0, "too_soon" ); |
2835 |
return ( 0, "too_soon" ); |
| 2833 |
} |
2836 |
} |
|
|
2837 |
elsif ( $itemissue->{auto_renew} ) { |
| 2838 |
return ( 0, "auto_renew" ); |
| 2839 |
} |
| 2840 |
} |
| 2841 |
|
| 2842 |
# Fallback for automatic renewals: |
| 2843 |
# If norenewalbefore is undef, don't renew before due date. |
| 2844 |
elsif ( $itemissue->{auto_renew} ) { |
| 2845 |
my $now = dt_from_string; |
| 2846 |
return ( 0, "auto_renew" ) |
| 2847 |
if $now >= $itemissue->{date_due}; |
| 2848 |
return ( 0, "auto_too_soon" ); |
| 2834 |
} |
2849 |
} |
| 2835 |
|
2850 |
|
| 2836 |
return ( 0, "auto_renew" ) if $itemissue->{auto_renew}; |
|
|
| 2837 |
return ( 1, undef ); |
2851 |
return ( 1, undef ); |
| 2838 |
} |
2852 |
} |
| 2839 |
|
2853 |
|
|
Lines 3045-3053
sub GetSoonestRenewDate {
Link Here
|
| 3045 |
my $issuingrule = |
3059 |
my $issuingrule = |
| 3046 |
GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode ); |
3060 |
GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode ); |
| 3047 |
|
3061 |
|
| 3048 |
my $now = DateTime->now( time_zone => C4::Context->tz() ); |
3062 |
my $now = dt_from_string; |
| 3049 |
|
3063 |
|
| 3050 |
if ( $issuingrule->{norenewalbefore} ) { |
3064 |
if ( defined $issuingrule->{norenewalbefore} |
|
|
3065 |
and $issuingrule->{norenewalbefore} ne "" ) |
| 3066 |
{ |
| 3051 |
my $soonestrenewal = |
3067 |
my $soonestrenewal = |
| 3052 |
$itemissue->{date_due}->subtract( |
3068 |
$itemissue->{date_due}->subtract( |
| 3053 |
$issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} ); |
3069 |
$issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} ); |