From eccd596dc01e519e341094903c20b22dba118239 Mon Sep 17 00:00:00 2001 From: Bishwajeet Kumar Rajak Date: Sun, 15 Mar 2026 16:24:12 +0530 Subject: [PATCH] config updation --- processors/data_mapper.py | 40 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/processors/data_mapper.py b/processors/data_mapper.py index 38ea66d..4cac430 100644 --- a/processors/data_mapper.py +++ b/processors/data_mapper.py @@ -10,7 +10,7 @@ from decimal import Decimal from typing import Dict, Any, List from logging_config import get_logger -from db.models import RTGSInwardRecord +from db.models import RTGSInwardRecord # Note: You use NEFTInwardRecord below logger = get_logger(__name__) @@ -41,24 +41,23 @@ class RTGSDataMapper: logger.error(f"Error converting date '{date_str}': {e}") return datetime.now().strftime("%d%m%Y") - - @staticmethod def process_status(status: str) -> str: - - try: - if not status: - return '' - s = status.strip() - if s == 'PROS': - return 'PROCESSED' - if s == 'SUSP': - return 'SUSPENDED' - if s == 'FAIL': - return 'FAILED' - if s == 'RVRS': - return 'REVERSED' - return s + """ + Normalize status codes. + """ + if not status: + return '' + s = status.strip() + if s == 'PROS': + return 'PROCESSED' + if s == 'SUSP': + return 'SUSPENDED' + if s == 'FAIL': + return 'FAILED' + if s == 'RVRS': + return 'REVERSED' + return s @staticmethod def convert_amount(amount_in: Any) -> Decimal: @@ -95,7 +94,7 @@ class RTGSDataMapper: amount_in = parsed_txn.get('amount', '0') txn_amt = cls.convert_amount(amount_in) txnind = "CR" - creditor_amt=parsed_txn.get('amount', '0') + creditor_amt = parsed_txn.get('amount', '0') # Date handling txn_date_raw = parsed_txn.get('tran_date', '') or '' @@ -112,7 +111,6 @@ class RTGSDataMapper: recvr_acct_name = (parsed_txn.get('beneficiary_details') or '').strip() record = NEFTInwardRecord( - bank_code=bankcode, txnind=txnind, jrnl_id=(parsed_txn.get('journal_no') or '').strip(), @@ -128,7 +126,7 @@ class RTGSDataMapper: recvr_acct_no=recvr_acct, recvr_acct_name=recvr_acct_name, status=status_norm, - reject_code=(parsed_txn.get('reject_code') or '').strip(), + reject_code=(parsed_txn.get('reject_code') or '').strip(), benef_address=(parsed_txn.get('benef_address') or '').strip(), msg_type=(parsed_txn.get('sub_msg_type') or '').strip(), creditor_amt=creditor_amt, @@ -157,4 +155,4 @@ class RTGSDataMapper: except Exception as e: logger.warning(f"Skipping transaction due to error: {e}") logger.info(f"Mapped {len(records)} NEFT transactions for bank {bankcode}") - return records + return records \ No newline at end of file