Added Transaction Offer #17
@@ -80,7 +80,7 @@ class TransactionOfferService:
|
||||
'max_amount': offer.max_amount,
|
||||
'eligible_amount': offer.eligible_amount,
|
||||
'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
|
||||
})
|
||||
|
||||
@@ -106,4 +106,4 @@ class TransactionOfferService:
|
||||
logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
||||
return jsonify({
|
||||
"message": "Internal Server Error"
|
||||
}), 500
|
||||
}), 500
|
||||
|
||||
@@ -22,14 +22,20 @@ class TransactionOffer(db.Model):
|
||||
eligible_amount = db.Column(db.Float, nullable=True)
|
||||
tenor = db.Column(db.Integer, nullable=True) # tenor in months, typically
|
||||
|
||||
created_at = db.Column(db.DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now())
|
||||
customer = relationship(
|
||||
"Customer",
|
||||
primaryjoin="Customer.id == TransactionOffer.customer_id",
|
||||
foreign_keys=[customer_id],
|
||||
back_populates="transaction_offers",
|
||||
)
|
||||
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))
|
||||
# created_at = db.Column(db.DateTime(timezone=True), server_default=func.now())
|
||||
# updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
def __repr__(self):
|
||||
return f'<TransactionOffer {self.id}>'
|
||||
|
||||
# customer = relationship(
|
||||
# "Customer",
|
||||
# primaryjoin="Customer.id == TransactionOffer.customer_id",
|
||||
# foreign_keys=[customer_id],
|
||||
# back_populates="transaction_offers",
|
||||
# )
|
||||
|
||||
@classmethod
|
||||
def is_valid_transaction_offer(cls, transaction_offer, customer_id, product_id):
|
||||
@@ -114,7 +120,4 @@ class TransactionOffer(db.Model):
|
||||
# 'tenor': self.tenor,
|
||||
# 'createdAt': self.created_at.isoformat() if self.created_at else None,
|
||||
# 'updatedAt': self.updated_at.isoformat() if self.updated_at else None,
|
||||
# }
|
||||
|
||||
def __repr__(self):
|
||||
return f'<TransactionOffer {self.id}>'
|
||||
# }
|
||||
Reference in New Issue
Block a user