Add transaction_time field to DCA payments: Updated the database schema to include a new transaction_time column in the dca_payments table, modified the CreateDcaPaymentData model to accept transaction_time, and adjusted the create_dca_payment function to store the original ATM transaction time. Updated transaction processing to capture this new field.
This commit is contained in:
parent
18323dc0c8
commit
3a2f10f949
4 changed files with 20 additions and 4 deletions
7
crud.py
7
crud.py
|
|
@ -160,9 +160,9 @@ async def create_dca_payment(data: CreateDcaPaymentData) -> DcaPayment:
|
||||||
"""
|
"""
|
||||||
INSERT INTO satmachineadmin.dca_payments
|
INSERT INTO satmachineadmin.dca_payments
|
||||||
(id, client_id, amount_sats, amount_fiat, exchange_rate, transaction_type,
|
(id, client_id, amount_sats, amount_fiat, exchange_rate, transaction_type,
|
||||||
lamassu_transaction_id, payment_hash, status, created_at)
|
lamassu_transaction_id, payment_hash, status, created_at, transaction_time)
|
||||||
VALUES (:id, :client_id, :amount_sats, :amount_fiat, :exchange_rate, :transaction_type,
|
VALUES (:id, :client_id, :amount_sats, :amount_fiat, :exchange_rate, :transaction_type,
|
||||||
:lamassu_transaction_id, :payment_hash, :status, :created_at)
|
:lamassu_transaction_id, :payment_hash, :status, :created_at, :transaction_time)
|
||||||
""",
|
""",
|
||||||
{
|
{
|
||||||
"id": payment_id,
|
"id": payment_id,
|
||||||
|
|
@ -174,7 +174,8 @@ async def create_dca_payment(data: CreateDcaPaymentData) -> DcaPayment:
|
||||||
"lamassu_transaction_id": data.lamassu_transaction_id,
|
"lamassu_transaction_id": data.lamassu_transaction_id,
|
||||||
"payment_hash": data.payment_hash,
|
"payment_hash": data.payment_hash,
|
||||||
"status": "pending",
|
"status": "pending",
|
||||||
"created_at": datetime.now()
|
"created_at": datetime.now(),
|
||||||
|
"transaction_time": data.transaction_time
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return await get_dca_payment(payment_id)
|
return await get_dca_payment(payment_id)
|
||||||
|
|
|
||||||
|
|
@ -111,3 +111,15 @@ async def m001_initial_dca_schema(db):
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def m002_add_transaction_time_to_dca_payments(db):
|
||||||
|
"""
|
||||||
|
Add transaction_time field to dca_payments table to store original ATM transaction time
|
||||||
|
"""
|
||||||
|
await db.execute(
|
||||||
|
"""
|
||||||
|
ALTER TABLE satmachineadmin.dca_payments
|
||||||
|
ADD COLUMN transaction_time TIMESTAMP
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
@ -67,6 +67,7 @@ class CreateDcaPaymentData(BaseModel):
|
||||||
transaction_type: str # 'flow', 'fixed', 'manual', 'commission'
|
transaction_type: str # 'flow', 'fixed', 'manual', 'commission'
|
||||||
lamassu_transaction_id: Optional[str] = None
|
lamassu_transaction_id: Optional[str] = None
|
||||||
payment_hash: Optional[str] = None
|
payment_hash: Optional[str] = None
|
||||||
|
transaction_time: Optional[datetime] = None # Original ATM transaction time
|
||||||
|
|
||||||
|
|
||||||
class DcaPayment(BaseModel):
|
class DcaPayment(BaseModel):
|
||||||
|
|
@ -80,6 +81,7 @@ class DcaPayment(BaseModel):
|
||||||
payment_hash: Optional[str]
|
payment_hash: Optional[str]
|
||||||
status: str # 'pending', 'confirmed', 'failed'
|
status: str # 'pending', 'confirmed', 'failed'
|
||||||
created_at: datetime
|
created_at: datetime
|
||||||
|
transaction_time: Optional[datetime] = None # Original ATM transaction time
|
||||||
|
|
||||||
|
|
||||||
# Client Balance Summary
|
# Client Balance Summary
|
||||||
|
|
|
||||||
|
|
@ -609,7 +609,8 @@ class LamassuTransactionProcessor:
|
||||||
amount_fiat=distribution["fiat_amount"],
|
amount_fiat=distribution["fiat_amount"],
|
||||||
exchange_rate=distribution["exchange_rate"],
|
exchange_rate=distribution["exchange_rate"],
|
||||||
transaction_type="flow",
|
transaction_type="flow",
|
||||||
lamassu_transaction_id=transaction_id
|
lamassu_transaction_id=transaction_id,
|
||||||
|
transaction_time=transaction.get("transaction_time") # Original ATM transaction time
|
||||||
)
|
)
|
||||||
|
|
||||||
# Record the payment in our database
|
# Record the payment in our database
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue