[update]: Eligibility check request
This commit is contained in:
@@ -1,16 +1,41 @@
|
||||
from datetime import datetime, timezone
|
||||
from app import db
|
||||
from app.extensions import db
|
||||
from app.models import Customer
|
||||
|
||||
class Transaction(db.Model):
|
||||
__tablename__ = 'transactions'
|
||||
|
||||
id = db.Column(db.String(50), primary_key=True)
|
||||
account_id = db.Column(db.String(50), nullable=False)
|
||||
customer_id = db.Column(db.String(50), nullable=False)
|
||||
type = db.Column(db.String(50), nullable=False)
|
||||
amount = db.Column(db.Float, nullable=False)
|
||||
status = db.Column(db.String(20), default='pending')
|
||||
channel = db.Column(db.String(50), nullable=False)
|
||||
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))
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Transaction {self.id}>'
|
||||
return f'<Transaction {self.id}>'
|
||||
|
||||
@classmethod
|
||||
def create_transaction(cls, id, account_id, customer_id, type, channel, msisdn, country_code,):
|
||||
transaction = cls(
|
||||
id=id,
|
||||
customer_id=customer_id,
|
||||
type=type,
|
||||
channel=channel
|
||||
|
||||
)
|
||||
|
||||
customer = Customer.create_customer(
|
||||
id=customer_id,
|
||||
msisdn= msisdn,
|
||||
country_code= country_code,
|
||||
account_id= account_id,
|
||||
)
|
||||
|
||||
db.session.add(transaction)
|
||||
db.session.commit()
|
||||
return transaction
|
||||
|
||||
@classmethod
|
||||
def get_transaction_by_id(cls, transaction_id):
|
||||
return cls.query.get(transaction_id)
|
||||
Reference in New Issue
Block a user