This commit is contained in:
2026-06-11 02:22:51 +05:30
parent c3d43e5493
commit 9c718e81eb
1704 changed files with 321358 additions and 9 deletions
Binary file not shown.
+51 -8
View File
@@ -45,43 +45,86 @@ class Processor:
response = self.api.fetch(payload)
# ✅ Business-level failure logging
if response.get("status") != "SUCCESS":
logger.error("API error for bank %s", bank_code)
logger.warning(
"API business failure | bank=%s | status=%s | message=%s | response=%s",
bank_code,
response.get("status"),
response.get("message"),
response.get("response")
)
continue
items = response.get("response", {}).get("VwQueueItems", [])
if not items:
logger.info("No VwQueueItems found for bank %s", bank_code)
continue
# build lookup map
api_map = {
(int(x["queueItemId"]), float(x["txnAmt"])): x
for x in items
if x.get("queueItemId") and x.get("txnAmt") is not None
}
for r in records:
key = (int(r["CBS_QUEUE_NO2"]), float(r["TXN_AMT"]))
try:
key = (int(r["CBS_QUEUE_NO2"]), float(r["TXN_AMT"]))
except Exception:
logger.error("Invalid record data %s", r, exc_info=True)
continue
item = api_map.get(key)
if not item:
continue
if item.get("status") != "Processed":
logger.info(
"Skipping non-processed item id=%s status=%s",
item.get("queueItemId"),
item.get("status")
)
continue
ref = item.get("remarks")
if not ref:
logger.warning("Missing remarks for item %s", item)
continue
if self.repo.exists_by_ref(ref):
logger.info("Duplicate ref %s", ref)
# duplicate check
try:
if self.repo.exists_by_ref(ref):
logger.info("Duplicate ref %s", ref)
continue
except Exception:
logger.exception("Duplicate check failed for ref %s", ref)
continue
model = OutwardLogModel(bank_code, r, item)
# build model
try:
model = OutwardLogModel(bank_code, r, item)
data = model.to_dict()
except Exception:
logger.exception("Model building failed for record %s", r)
continue
self.repo.insert_outward_log(model.to_dict())
total_inserted += 1
# insert
try:
self.repo.insert_outward_log(data)
total_inserted += 1
logger.info("Inserted ref %s", ref)
logger.info(
"Inserted record ref=%s journalId=%s",
ref,
item.get("journalId")
)
except Exception:
logger.exception("Insert failed for ref %s", ref)
except Exception:
logger.exception("Error processing bank %s", bank_code)