added repayment data

This commit was merged in pull request #23.
This commit is contained in:
Chinenye Nmoh
2025-06-16 19:50:24 +01:00
parent e0ca6f0e1c
commit 87a876252d
7 changed files with 54 additions and 9 deletions
+16 -1
View File
@@ -10,6 +10,11 @@ class RepaymentsData(db.Model):
added_date = db.Column(db.DateTime(timezone=True), default=datetime.now(timezone.utc), nullable=False)
response_code = db.Column(db.String(10), nullable=True)
response_descr = db.Column(db.String(255), nullable=True)
fbn_transaction_id = db.Column(db.String(255),nullable=True)
account_id = db.Column(db.String(50), nullable=True)
customer_id = db.Column(db.String(50), nullable=True)
repayment_amount = db.Column(db.Float, nullable=True)
amount_collected = db.Column(db.Float, nullable=True)
def to_dict(self):
return {
@@ -18,6 +23,11 @@ class RepaymentsData(db.Model):
"added_date": self.added_date.isoformat() if self.added_date else None,
"response_code": self.response_code,
"response_descr": self.response_descr,
"customerId": self.customer_id,
"accountId": self.customer_id,
"fbnTransactionId": self.fbn_transaction_id,
"repaymentAmount": self.repayment_amount,
"amountCollected": self.amount_collected
}
@@ -33,7 +43,12 @@ class RepaymentsData(db.Model):
new_data = cls(
transaction_id=data.get('transactionId'),
response_code=data.get('responseCode'),
response_descr=data.get('responseMessage')
response_descr=data.get('responseDescr'),
fbn_transaction_id=data.get('fbnTransactionId'),
account_id=data.get('accountId'),
customer_id=data.get('customerId'),
amount_collected=data.get('amountCollected'),
repayment_amount=data.get('repaymentAmount'),
)
db.session.add(new_data)
db.session.commit()