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