From ec5db19e2013c48a44b6279fe8710582cc1f3fc3 Mon Sep 17 00:00:00 2001 From: VivianDee <115420678+VivianDee@users.noreply.github.com> Date: Wed, 28 May 2025 20:19:50 +0100 Subject: [PATCH] [add]: loan max amount --- app/api/services/provide_loan.py | 3 +++ app/models/customer.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/app/api/services/provide_loan.py b/app/api/services/provide_loan.py index 61b2a16..f09cd31 100644 --- a/app/api/services/provide_loan.py +++ b/app/api/services/provide_loan.py @@ -64,6 +64,9 @@ class ProvideLoanService(BaseService): if(amount < transaction_offer.min_amount): return ResponseHelper.error(result_description="The amount is less than the minimum allowed transaction amount.") + elif amount > transaction_offer.max_amount: + return ResponseHelper.error(result_description="The amount is greater than the maximum allowed transaction amount.") + # transaction_offer_id = int(offer_id[5:]) # The last part is int diff --git a/app/models/customer.py b/app/models/customer.py index 883d34f..1469dad 100644 --- a/app/models/customer.py +++ b/app/models/customer.py @@ -50,6 +50,8 @@ class Customer(db.Model): raise ValueError("Customer already exists") elif Account.query.filter_by(id=account_id).first(): raise ValueError("Account already exists") + elif cls.query.filter_by(msisdn=msisdn).first(): + raise ValueError("msisdn already exists") # Create the customer customer = cls( -- 2.34.1