Skip to content

Commit

Permalink
Changed set_renewal_count() for returning int
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrineyev committed Feb 13, 2025
1 parent bb67ece commit dbd2c7a
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ def __init__(
self.out_date: datetime = temp_date_out
self.correct_for_1_day_loans()
self.make_utc()
self.renewal_count = 0
self.set_renewal_count(legacy_loan_dict)
self.renewal_count = self.set_renewal_count(legacy_loan_dict)
self.next_item_status = legacy_loan_dict.get("next_item_status", "").strip()
if self.next_item_status not in legal_statuses:
self.errors.append(("Not an allowed status", self.next_item_status))
Expand All @@ -102,16 +101,17 @@ def __init__(
else fallback_service_point_id
)

def set_renewal_count(self, loan: dict):
def set_renewal_count(self, loan: dict) -> int:
if "renewal_count" in loan:
renewal_count = loan["renewal_count"]
try:
self.renewal_count = int(renewal_count)
return int(renewal_count)
except ValueError:
self.report(
f"Unresolvable {renewal_count=} was replaced with 0.")
else:
self.report(f"Missing renewal count was replaced with 0.")
return 0

def correct_for_1_day_loans(self):
try:
Expand Down

0 comments on commit dbd2c7a

Please sign in to comment.