#!/usr/bin/env python3 """ Data models for ACH file processing. Represents database records and transactions. """ from dataclasses import dataclass, asdict from datetime import date, datetime from decimal import Decimal from typing import Optional @dataclass class TransactionRecord: """Represents a transaction record for ach_api_log table.""" narration: str status: str bankcode: str jrnl_id: str tran_date: str # DDMMYYYY format cbs_acct: str tran_amt: Decimal txnind: str def to_dict(self): """Convert to dictionary for database insertion.""" return { 'narration': self.narration, 'status': self.status, 'bankcode': self.bankcode, 'jrnl_id': self.jrnl_id, 'tran_date': self.tran_date, 'cbs_acct': self.cbs_acct, 'tran_amt': self.tran_amt, 'TXNIND': self.txnind, } @dataclass class ProcessedFile: """Represents a processed file record for ach_processed_files table.""" 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): """Convert to dictionary for database insertion.""" 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(), }