Skip to content

Commit ba768c5

Browse files
committed
Fixes #933
1 parent de11c57 commit ba768c5

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/folio_migration_tools/migration_tasks/loans_migrator.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def checkout_single_loan(self, legacy_loan: LegacyLoan):
234234
legacy_loan (LegacyLoan): The Legacy loan
235235
"""
236236
res_checkout = self.circulation_helper.check_out_by_barcode(legacy_loan)
237-
237+
238238
if res_checkout.was_successful:
239239
self.migration_report.add("Details", i18n.t("Checked out on first try"))
240240
self.migration_report.add_general_statistics(i18n.t("Successfully checked out"))
@@ -463,7 +463,7 @@ def handle_checkout_failure(
463463
elif folio_checkout.error_message == "Declared lost":
464464
return folio_checkout
465465
elif folio_checkout.error_message.startswith("Cannot check out to inactive user"):
466-
return self.checkout_to_inactice_user(legacy_loan)
466+
return self.checkout_to_inactive_user(legacy_loan)
467467
else:
468468
self.migration_report.add(
469469
"Details",
@@ -493,14 +493,16 @@ def handle_checkout_failure(
493493
del self.failed[legacy_loan.item_barcode]
494494
return TransactionResult(False, False, "", "", "")
495495

496-
def checkout_to_inactice_user(self, legacy_loan) -> TransactionResult:
496+
def checkout_to_inactive_user(self, legacy_loan) -> TransactionResult:
497497
logging.info("Cannot check out to inactive user. Activating and trying again")
498498
user = self.get_user_by_barcode(legacy_loan.patron_barcode)
499499
expiration_date = user.get("expirationDate", datetime.isoformat(datetime.now()))
500500
user["expirationDate"] = datetime.isoformat(datetime.now() + timedelta(days=1))
501501
self.activate_user(user)
502502
logging.debug("Successfully Activated user")
503503
res = self.circulation_helper.check_out_by_barcode(legacy_loan) # checkout_and_update
504+
if res.should_be_retried:
505+
res = self.handle_checkout_failure(legacy_loan, res)
504506
self.migration_report.add("Details", res.migration_report_message)
505507
self.deactivate_user(user, expiration_date)
506508
logging.debug("Successfully Deactivated user again")

0 commit comments

Comments
 (0)