|
Lines 4263-4268
sub _CanBookBeAutoRenewed {
Link Here
|
| 4263 |
my $branchcode = $params->{branchcode}; |
4263 |
my $branchcode = $params->{branchcode}; |
| 4264 |
my $issue = $params->{issue}; |
4264 |
my $issue = $params->{issue}; |
| 4265 |
|
4265 |
|
|
|
4266 |
return "no" unless $issue->auto_renew && $patron->autorenew_checkouts; |
| 4267 |
|
| 4266 |
my $issuing_rule = Koha::CirculationRules->get_effective_rules( |
4268 |
my $issuing_rule = Koha::CirculationRules->get_effective_rules( |
| 4267 |
{ |
4269 |
{ |
| 4268 |
categorycode => $patron->categorycode, |
4270 |
categorycode => $patron->categorycode, |
|
Lines 4277-4339
sub _CanBookBeAutoRenewed {
Link Here
|
| 4277 |
} |
4279 |
} |
| 4278 |
); |
4280 |
); |
| 4279 |
|
4281 |
|
| 4280 |
if ( $issue->auto_renew && $patron->autorenew_checkouts ) { |
4282 |
if ( $patron->category->effective_BlockExpiredPatronOpacActions and $patron->is_expired ) { |
| 4281 |
|
4283 |
return 'auto_account_expired'; |
| 4282 |
if ( $patron->category->effective_BlockExpiredPatronOpacActions and $patron->is_expired ) { |
4284 |
} |
| 4283 |
return 'auto_account_expired'; |
|
|
| 4284 |
} |
| 4285 |
|
4285 |
|
| 4286 |
if ( defined $issuing_rule->{no_auto_renewal_after} |
4286 |
if ( defined $issuing_rule->{no_auto_renewal_after} |
| 4287 |
and $issuing_rule->{no_auto_renewal_after} ne "" ) { |
4287 |
and $issuing_rule->{no_auto_renewal_after} ne "" ) { |
| 4288 |
# Get issue_date and add no_auto_renewal_after |
4288 |
# Get issue_date and add no_auto_renewal_after |
| 4289 |
# If this is greater than today, it's too late for renewal. |
4289 |
# If this is greater than today, it's too late for renewal. |
| 4290 |
my $maximum_renewal_date = dt_from_string($issue->issuedate, 'sql'); |
4290 |
my $maximum_renewal_date = dt_from_string($issue->issuedate, 'sql'); |
| 4291 |
$maximum_renewal_date->add( |
4291 |
$maximum_renewal_date->add( |
| 4292 |
$issuing_rule->{lengthunit} => $issuing_rule->{no_auto_renewal_after} |
4292 |
$issuing_rule->{lengthunit} => $issuing_rule->{no_auto_renewal_after} |
| 4293 |
); |
4293 |
); |
| 4294 |
my $now = dt_from_string; |
4294 |
my $now = dt_from_string; |
| 4295 |
if ( $now >= $maximum_renewal_date ) { |
4295 |
if ( $now >= $maximum_renewal_date ) { |
| 4296 |
return "auto_too_late"; |
4296 |
return "auto_too_late"; |
| 4297 |
} |
|
|
| 4298 |
} |
| 4299 |
if ( defined $issuing_rule->{no_auto_renewal_after_hard_limit} |
| 4300 |
and $issuing_rule->{no_auto_renewal_after_hard_limit} ne "" ) { |
| 4301 |
# If no_auto_renewal_after_hard_limit is >= today, it's also too late for renewal |
| 4302 |
if ( dt_from_string >= dt_from_string( $issuing_rule->{no_auto_renewal_after_hard_limit} ) ) { |
| 4303 |
return "auto_too_late"; |
| 4304 |
} |
| 4305 |
} |
4297 |
} |
| 4306 |
|
4298 |
} |
| 4307 |
if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) { |
4299 |
if ( defined $issuing_rule->{no_auto_renewal_after_hard_limit} |
| 4308 |
my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals"); |
4300 |
and $issuing_rule->{no_auto_renewal_after_hard_limit} ne "" ) { |
| 4309 |
my $amountoutstanding = |
4301 |
# If no_auto_renewal_after_hard_limit is >= today, it's also too late for renewal |
| 4310 |
C4::Context->preference("OPACFineNoRenewalsIncludeCredit") |
4302 |
if ( dt_from_string >= dt_from_string( $issuing_rule->{no_auto_renewal_after_hard_limit} ) ) { |
| 4311 |
? $patron->account->balance |
4303 |
return "auto_too_late"; |
| 4312 |
: $patron->account->outstanding_debits->total_outstanding; |
|
|
| 4313 |
if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) { |
| 4314 |
return "auto_too_much_oweing"; |
| 4315 |
} |
| 4316 |
} |
4304 |
} |
|
|
4305 |
} |
| 4317 |
|
4306 |
|
| 4318 |
if ( defined $issuing_rule->{norenewalbefore} |
4307 |
if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) { |
| 4319 |
and $issuing_rule->{norenewalbefore} ne "" ) { |
4308 |
my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals"); |
| 4320 |
if ( GetSoonestRenewDate($patron->id, $item->id) > dt_from_string()) { |
4309 |
my $amountoutstanding = |
| 4321 |
return "auto_too_soon"; |
4310 |
C4::Context->preference("OPACFineNoRenewalsIncludeCredit") |
| 4322 |
} else { |
4311 |
? $patron->account->balance |
| 4323 |
return "ok"; |
4312 |
: $patron->account->outstanding_debits->total_outstanding; |
| 4324 |
} |
4313 |
if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) { |
|
|
4314 |
return "auto_too_much_oweing"; |
| 4325 |
} |
4315 |
} |
|
|
4316 |
} |
| 4326 |
|
4317 |
|
| 4327 |
# Fallback for automatic renewals: |
4318 |
if ( defined $issuing_rule->{norenewalbefore} |
| 4328 |
# If norenewalbefore is undef, don't renew before due date. |
4319 |
and $issuing_rule->{norenewalbefore} ne "" ) { |
| 4329 |
my $now = dt_from_string; |
4320 |
if ( GetSoonestRenewDate($patron->id, $item->id) > dt_from_string()) { |
| 4330 |
if ( $now >= dt_from_string( $issue->date_due, 'sql' ) ){ |
|
|
| 4331 |
return "ok"; |
| 4332 |
} else { |
| 4333 |
return "auto_too_soon"; |
4321 |
return "auto_too_soon"; |
|
|
4322 |
} else { |
| 4323 |
return "ok"; |
| 4334 |
} |
4324 |
} |
| 4335 |
} |
4325 |
} |
| 4336 |
return "no"; |
4326 |
|
|
|
4327 |
# Fallback for automatic renewals: |
| 4328 |
# If norenewalbefore is undef, don't renew before due date. |
| 4329 |
my $now = dt_from_string; |
| 4330 |
if ( $now >= dt_from_string( $issue->date_due, 'sql' ) ){ |
| 4331 |
return "ok"; |
| 4332 |
} else { |
| 4333 |
return "auto_too_soon"; |
| 4334 |
} |
| 4337 |
} |
4335 |
} |
| 4338 |
|
4336 |
|
| 4339 |
sub _item_denied_renewal { |
4337 |
sub _item_denied_renewal { |
| 4340 |
- |
|
|