[add]: loan charges and offers. Fix RACCheck

This commit is contained in:
VivianDee
2025-04-16 21:36:26 +01:00
parent 359621dc9d
commit 93ed8b3d17
12 changed files with 161 additions and 71 deletions
+20
View File
@@ -12,6 +12,26 @@ class Offer(db.Model):
created_at = db.Column(db.DateTime, default=datetime.now(timezone.utc))
updated_at = db.Column(db.DateTime, default=datetime.now(timezone.utc), onupdate=datetime.now(timezone.utc))
@classmethod
def get_all_offers(cls):
"""
Return all offers in dictionary format.
"""
offers = cls.query.all()
if not offers:
raise ValueError(f"No available offers")
return offers
@classmethod
def is_valid_offer(cls, offer_id):
offer = cls.query.filter_by(id=str(offer_id)).first()
if not offer:
return False
return offer
def to_dict(self):
return {
"offerId": self.id,