Files
upi_inward_file_based/db/models.py
T
2026-06-14 16:49:20 +05:30

50 lines
1.3 KiB
Python

from dataclasses import dataclass
from datetime import datetime
from decimal import Decimal
from typing import Optional
@dataclass
class UPIInwardRecord:
rrn: str
txn_date: str
txn_amt: Optional[Decimal]
credit_account: str
status: str
note: str
bank_code: str
txn_type: str # will be CREDIT / DEBIT from parser
def to_dict(self):
return {
"BANKCODE": self.bank_code,
"RRN": self.rrn,
"TXN_DATE": self.txn_date,
"TXN_AMT": self.txn_amt,
"TXN_TYPE": self.txn_type, # converted to CR before insert
"BENEFICIARY_ACCOUNT": self.credit_account,
"STATUS": self.status,
"NARRATION": self.note,
}
@dataclass
class ProcessedFile:
filename: str
bankcode: str
file_path: str
transaction_count: int
status: str = 'SUCCESS'
error_message: Optional[str] = None
processed_at: Optional[datetime] = None
def to_dict(self):
return {
'filename': self.filename,
'bankcode': self.bankcode,
'file_path': self.file_path,
'transaction_count': self.transaction_count,
'status': self.status,
'error_message': self.error_message,
'processed_at': self.processed_at or datetime.now(),
}