Lines 171-222
while ( my $auto_renew = $auto_renews->next ) {
Link Here
|
171 |
$wants_digest = 0; |
171 |
$wants_digest = 0; |
172 |
} |
172 |
} |
173 |
|
173 |
|
174 |
# CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script |
174 |
my ( $success, $error, $updated ) = $auto_renew->attempt_auto_renew({ confirm => $confirm }); |
175 |
my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->patron, $auto_renew, undef, 1 ); |
175 |
if ( $success ) { |
176 |
my $updated; |
|
|
177 |
if ( $error eq 'auto_renew' ) { |
178 |
$updated = 1; |
179 |
if ($verbose) { |
176 |
if ($verbose) { |
180 |
say sprintf "Issue id: %s for borrower: %s and item: %s %s be renewed.", |
177 |
say sprintf "Issue id: %s for borrower: %s and item: %s %s be renewed.", |
181 |
$auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, |
178 |
$auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, |
182 |
$confirm ? 'will' : 'would'; |
179 |
$confirm ? 'will' : 'would'; |
183 |
} |
180 |
} |
184 |
if ($confirm) { |
181 |
if ($confirm) { |
185 |
my $date_due = AddRenewal( |
|
|
186 |
{ |
187 |
borrowernumber => $auto_renew->borrowernumber, |
188 |
itemnumber => $auto_renew->itemnumber, |
189 |
branch => $auto_renew->branchcode, |
190 |
seen => 0, |
191 |
automatic => 1, |
192 |
} |
193 |
); |
194 |
push @item_renewal_ids, $auto_renew->itemnumber; |
182 |
push @item_renewal_ids, $auto_renew->itemnumber; |
195 |
$auto_renew->auto_renew_error(undef)->store; |
|
|
196 |
} |
183 |
} |
197 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
184 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
198 |
if ($wants_messages) && !$wants_digest; |
185 |
if ( $wants_messages ) && !$wants_digest; |
199 |
} elsif ( $error eq 'too_many' |
186 |
} elsif ( |
200 |
|| $error eq 'on_reserve' |
187 |
# FIXME Do we need to list every status? Why not simply else? |
201 |
|| $error eq 'restriction' |
188 |
$error eq 'too_many' || |
202 |
|| $error eq 'overdue' |
189 |
$error eq 'on_reserve' || |
203 |
|| $error eq 'too_unseen' |
190 |
$error eq 'restriction' || |
204 |
|| $error eq 'auto_account_expired' |
191 |
$error eq 'overdue' || |
205 |
|| $error eq 'auto_too_late' |
192 |
$error eq 'too_unseen' || |
206 |
|| $error eq 'auto_too_much_oweing' |
193 |
$error eq 'auto_account_expired' || |
207 |
|| $error eq 'auto_too_soon' |
194 |
$error eq 'auto_too_late' || |
208 |
|| $error eq 'too_soon' |
195 |
$error eq 'auto_too_much_oweing' || |
209 |
|| $error eq 'item_denied_renewal' |
196 |
$error eq 'auto_too_soon' || |
210 |
|| $error eq 'item_issued_to_other_patron' ) |
197 |
$error eq 'item_denied_renewal' || |
211 |
{ |
198 |
$error eq 'item_issued_to_other_patron' |
212 |
if ($verbose) { |
199 |
) { |
|
|
200 |
if ( $verbose ) { |
213 |
say sprintf "Issue id: %s for borrower: %s and item: %s %s not be renewed. (%s)", |
201 |
say sprintf "Issue id: %s for borrower: %s and item: %s %s not be renewed. (%s)", |
214 |
$auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, |
202 |
$auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, |
215 |
$confirm ? 'will' : 'would', $error; |
203 |
$confirm ? 'will' : 'would', $error; |
216 |
} |
204 |
} |
217 |
$updated = 1 if ( !$auto_renew->auto_renew_error || $error ne $auto_renew->auto_renew_error ); |
205 |
if ( $updated ) { |
218 |
if ($updated) { |
|
|
219 |
$auto_renew->auto_renew_error($error)->store if $confirm; |
220 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
206 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
221 |
if $error ne 'auto_too_soon' && ( $wants_messages && !$wants_digest ); # Do not notify if it's too soon |
207 |
if $error ne 'auto_too_soon' && ( $wants_messages && !$wants_digest ); # Do not notify if it's too soon |
222 |
} |
208 |
} |