[add]: Database connection and migrations

This commit is contained in:
VivianDee
2025-03-28 08:38:32 +01:00
parent 3054b7240e
commit 65efe0573a
21 changed files with 431 additions and 19 deletions
+15
View File
@@ -0,0 +1,15 @@
from app.models import Account
def check_account_settings(account_id, customer_id):
"""
Checks if the account belongs to the customer and if it has existing liens.
"""
account = Account.query.filter_by(id=account_id, customer_id=customer_id).first()
if not account:
return False, "Account not found or doesn't belong to customer"
if account.lien_amount > 0:
return False, "Account has an existing lien"
return True, "Account is valid"
+7
View File
@@ -0,0 +1,7 @@
from app.models import Customer
def check_customer_eligibility(data):
# Verify customer exists
customer = Customer.query.filter_by(id=data['customerId']).first()
if not customer:
return False, "Customer not found"
+10
View File
@@ -0,0 +1,10 @@
from app.models import Loan
def check_active_loans(data):
active_loans = Loan.query.filter_by(
customer_id=data['customerId'],
status='active'
).count()
if active_loans > 0:
return False, "Customer has active loans"