Added Transaction offer

This commit was merged in pull request #17.
This commit is contained in:
Azeez Muibi
2025-05-19 13:43:49 +01:00
parent 3ae29b69b5
commit 26868c0043
2 changed files with 17 additions and 14 deletions
@@ -80,7 +80,7 @@ class TransactionOfferService:
'max_amount': offer.max_amount, 'max_amount': offer.max_amount,
'eligible_amount': offer.eligible_amount, 'eligible_amount': offer.eligible_amount,
'tenor': offer.tenor, 'tenor': offer.tenor,
'created_at': offer.created_at.isoformat(), 'created_at': offer.created_at.isoformat() if offer.created_at else None,
'updated_at': offer.updated_at.isoformat() if offer.updated_at else None 'updated_at': offer.updated_at.isoformat() if offer.updated_at else None
}) })
+14 -11
View File
@@ -22,14 +22,20 @@ class TransactionOffer(db.Model):
eligible_amount = db.Column(db.Float, nullable=True) eligible_amount = db.Column(db.Float, nullable=True)
tenor = db.Column(db.Integer, nullable=True) # tenor in months, typically tenor = db.Column(db.Integer, nullable=True) # tenor in months, typically
created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) created_at = db.Column(db.DateTime, default=datetime.now(timezone.utc))
updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) updated_at = db.Column(db.DateTime, default=datetime.now(timezone.utc), onupdate=datetime.now(timezone.utc))
customer = relationship( # created_at = db.Column(db.DateTime(timezone=True), server_default=func.now())
"Customer", # updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now())
primaryjoin="Customer.id == TransactionOffer.customer_id",
foreign_keys=[customer_id], def __repr__(self):
back_populates="transaction_offers", return f'<TransactionOffer {self.id}>'
)
# customer = relationship(
# "Customer",
# primaryjoin="Customer.id == TransactionOffer.customer_id",
# foreign_keys=[customer_id],
# back_populates="transaction_offers",
# )
@classmethod @classmethod
def is_valid_transaction_offer(cls, transaction_offer, customer_id, product_id): def is_valid_transaction_offer(cls, transaction_offer, customer_id, product_id):
@@ -115,6 +121,3 @@ class TransactionOffer(db.Model):
# 'createdAt': self.created_at.isoformat() if self.created_at else None, # 'createdAt': self.created_at.isoformat() if self.created_at else None,
# 'updatedAt': self.updated_at.isoformat() if self.updated_at else None, # 'updatedAt': self.updated_at.isoformat() if self.updated_at else None,
# } # }
def __repr__(self):
return f'<TransactionOffer {self.id}>'