Fix multi-account bank reconciliation and output filename
This commit is contained in:
@@ -210,6 +210,15 @@ def _claim_jobs() -> list[str]:
|
||||
db.close()
|
||||
|
||||
|
||||
|
||||
def _workbook_filename(metas) -> str:
|
||||
"""Return BankName_ClientName.xlsx using filesystem-safe segments."""
|
||||
banks = sorted({_segment(getattr(meta, "bank_name", ""), "Bank") for meta in metas if str(getattr(meta, "bank_name", "") or "").strip()})
|
||||
customers = sorted({_segment(getattr(meta, "customer_name", ""), "Client") for meta in metas if str(getattr(meta, "customer_name", "") or "").strip()})
|
||||
bank_label = banks[0] if len(banks) == 1 else ("Multi_Bank" if banks else "Bank")
|
||||
client_label = customers[0] if len(customers) == 1 else ("Multiple_Clients" if customers else "Client")
|
||||
return f"{bank_label}_{client_label}.xlsx"
|
||||
|
||||
def _process_job(job_id: str) -> None:
|
||||
db = CommonSessionLocal()
|
||||
try:
|
||||
@@ -229,7 +238,7 @@ def _process_job(job_id: str) -> None:
|
||||
)
|
||||
job.progress_percent = 75
|
||||
db.commit()
|
||||
output = output_dir / "Bank_Statement_Analysis.xlsx"
|
||||
output = output_dir / _workbook_filename(metas)
|
||||
export_excel(
|
||||
output,
|
||||
metas,
|
||||
|
||||
Reference in New Issue
Block a user