[add]: Loan charge

This commit is contained in:
VivianDee
2025-04-17 15:52:14 +01:00
parent 75f71a807d
commit 57fa4d72d9
6 changed files with 93 additions and 90 deletions
+5 -5
View File
@@ -45,9 +45,9 @@ class LoanCharge(db.Model):
now = datetime.now(timezone.utc)
for charge in charges:
due_days = charge.get("due", 0)
amount = charge.get("amount", 0.0)
percent = charge.get("percent", 0.0)
due_days = getattr(charge, "due", 0)
amount = getattr(charge, "amount", 0.0)
percent = getattr(charge, "percent", 0.0)
if amount == 0.0:
amount = (percent / 100.0) * referenced_amount
@@ -55,10 +55,10 @@ class LoanCharge(db.Model):
charge_obj = cls(
loan_id = loan_id,
transaction_id = transaction_id,
code = charge.get("code"),
code = getattr(charge, "code"),
amount = amount,
percent = percent,
description = charge.get("description", ""),
description = getattr(charge, "description", ""),
due = due_days,
due_date = now + timedelta(days=due_days)
)