diff --git a/app/api/services/repayment.py b/app/api/services/repayment.py index dac4fb0..6aa575b 100644 --- a/app/api/services/repayment.py +++ b/app/api/services/repayment.py @@ -33,7 +33,8 @@ class RepaymentService(BaseService): loan_id = validated_data.get('debtId') product_id = validated_data.get('productId') account_id = validated_data.get('accountId') - customer = Customer.get_customer(customer_id) + customer = Customer.get_customer(customer_id) + transaction_id = validated_data.get('transactionId') if(RepaymentService.validate_account_ownership(account_id = account_id, customer_id = customer_id)): @@ -41,7 +42,8 @@ class RepaymentService(BaseService): repayment = Repayment.create_repayment( customer_id = customer_id, loan_id = loan_id, - product_id = product_id + product_id = product_id, + transaction_id=transaction_id ) diff --git a/app/models/repayment.py b/app/models/repayment.py index c313131..3cc8451 100644 --- a/app/models/repayment.py +++ b/app/models/repayment.py @@ -19,9 +19,10 @@ class Repayment(db.Model): product_id = db.Column(db.String(20), nullable=True) 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)) + transaction_id = db.Column(db.String(50), nullable=True) @classmethod - def create_repayment(cls, customer_id, loan_id, product_id): + def create_repayment(cls, customer_id, loan_id, product_id, transaction_id): # Check customer exists @@ -40,6 +41,7 @@ class Repayment(db.Model): customer_id=customer_id, loan_id=loan_id, product_id=product_id, + transaction_id = transaction_id ) try: