[add]: transaction fix
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from datetime import datetime, timezone
|
||||
from app.extensions import db
|
||||
from app.models import account
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy import and_, or_, not_
|
||||
|
||||
@@ -11,8 +12,7 @@ class Transaction(db.Model):
|
||||
autoincrement=True,
|
||||
)
|
||||
transaction_id = db.Column(db.String(50), nullable=False)
|
||||
ref_id = db.Column(db.String(50), nullable=False)
|
||||
ref_model = db.Column(db.String(50), nullable=True, default='account')
|
||||
account_id = db.Column(db.String(50), nullable=True)
|
||||
type = db.Column(db.String(50), nullable=False)
|
||||
channel = db.Column(db.String(50), nullable=False)
|
||||
created_at = db.Column(db.DateTime, default=datetime.now(timezone.utc))
|
||||
@@ -22,7 +22,7 @@ class Transaction(db.Model):
|
||||
return f'<Transaction {self.id}>'
|
||||
|
||||
@classmethod
|
||||
def create_transaction(cls, transaction_id, ref_id, ref_model, type, channel):
|
||||
def create_transaction(cls, transaction_id, account_id, type, channel):
|
||||
|
||||
# if cls.query.filter_by(transaction_id=transaction_id).first():
|
||||
# raise ValueError("Duplicate Transaction")
|
||||
@@ -34,8 +34,7 @@ class Transaction(db.Model):
|
||||
|
||||
transaction = cls(
|
||||
transaction_id = transaction_id,
|
||||
ref_id = ref_id,
|
||||
ref_model = ref_model,
|
||||
account_id = account_id,
|
||||
type = type,
|
||||
channel = channel
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user