Fix bank analyzer Excel export for current pandas

This commit is contained in:
A R R R Associates
2026-07-13 10:38:25 +05:30
parent 5225d11d3a
commit c0c02cedfb
+11 -11
View File
@@ -3,7 +3,7 @@ from pathlib import Path
import re import re
import pandas as pd import pandas as pd
from .parsers import parse_pdf from .parsers import parse_pdf
from .parsers.common import infer_mode from parsers.common import infer_mode
def clean_key(s): def clean_key(s):
@@ -80,22 +80,22 @@ def export_excel(output,metas,all_df,unique_df):
['Total Credit (Unique)',float(unique_df.credit.sum()) if not unique_df.empty else 0], ['Total Credit (Unique)',float(unique_df.credit.sum()) if not unique_df.empty else 0],
],columns=['Metric','Value']) ],columns=['Metric','Value'])
with pd.ExcelWriter(output,engine='xlsxwriter',datetime_format='dd-mmm-yyyy') as w: with pd.ExcelWriter(output,engine='xlsxwriter',datetime_format='dd-mmm-yyyy') as w:
dashboard.to_excel(w,'Dashboard',index=False) dashboard.to_excel(w, sheet_name='Dashboard', index=False)
recon.to_excel(w,'Statement Reconciliation',index=False) recon.to_excel(w, sheet_name='Statement Reconciliation', index=False)
all_df.to_excel(w,'All Extracted Rows',index=False) all_df.to_excel(w, sheet_name='All Extracted Rows', index=False)
unique_df.to_excel(w,'Unique Transactions',index=False) unique_df.to_excel(w, sheet_name='Unique Transactions', index=False)
all_df[all_df.exact_duplicate].to_excel(w,'Exact Duplicates',index=False) all_df[all_df.exact_duplicate].to_excel(w, sheet_name='Exact Duplicates', index=False)
all_df[all_df.possible_duplicate].to_excel(w,'Possible Duplicates',index=False) all_df[all_df.possible_duplicate].to_excel(w, sheet_name='Possible Duplicates', index=False)
monthly_summary(unique_df).to_excel(w,'Monthly Summary',index=False) monthly_summary(unique_df).to_excel(w, sheet_name='Monthly Summary', index=False)
mode_summary(unique_df).to_excel(w,'Mode Summary',index=False) mode_summary(unique_df).to_excel(w, sheet_name='Mode Summary', index=False)
duplicate_summary(all_df).to_excel(w,'Duplicate Summary',index=False) duplicate_summary(all_df).to_excel(w, sheet_name='Duplicate Summary', index=False)
notes=pd.DataFrame({'Notes':[ notes=pd.DataFrame({'Notes':[
'Exact duplicates use transaction date, value date, debit, credit, balance and normalized narration.', 'Exact duplicates use transaction date, value date, debit, credit, balance and normalized narration.',
'Possible duplicates use same date, direction, amount and normalized narration; review before deletion.', 'Possible duplicates use same date, direction, amount and normalized narration; review before deletion.',
'Bank-specific parsers are selected automatically. Customer name/account number can be manually overridden in the app.', 'Bank-specific parsers are selected automatically. Customer name/account number can be manually overridden in the app.',
'The workbook is a bank-statement analysis aid, not a substitute for ledger, GST, inventory, receivable/payable and cash-book records.' 'The workbook is a bank-statement analysis aid, not a substitute for ledger, GST, inventory, receivable/payable and cash-book records.'
]}) ]})
notes.to_excel(w,'Notes',index=False) notes.to_excel(w, sheet_name='Notes', index=False)
wb=w.book wb=w.book
head=wb.add_format({'bold':True,'bg_color':'#1F4E78','font_color':'white','border':1}) head=wb.add_format({'bold':True,'bg_color':'#1F4E78','font_color':'white','border':1})
money=wb.add_format({'num_format':'#,##0.00'}) money=wb.add_format({'num_format':'#,##0.00'})