""" Donor Revenue Report built from a GL Dump alone - for when a trial balance isn't available. Deliberately reuses donor_report's own project- parsing, donor-resolution, categorization, and workbook-writing logic (same donor_merge_map.csv and report_summary_template.xlsx it already has) rather than re-implementing any of it, so a donor's numbers here can never drift out of sync with what donor_report itself would show for the same GL Dump - only the input requirement differs. Necessarily Canada-only (Planeterra Foundation): a GL Dump has no visibility into the US entity's activity, which donor_report's trial- balance-based US-aggregate rows normally supply. That's surfaced to the caller as us_entity_included=False rather than silently omitted. """ import pandas as pd from tools.donor_report.logic import ( process_revenue_detail, process_expense_detail, build_donor_workbook, ) # Same columns process_revenue_detail/process_expense_detail produce (see # donor_report/logic.py's _process_side_detail) - build_donor_workbook's # detailed-mode writer expects revenue_us/expense_us to have this shape # even when there's no US-entity data to put in them. _EMPTY_US_COLUMNS = [ "donor", "slob", "category", "amount", "journal_memo", "line_memo", "line_description", "contingent_worker", "supplier_name", ] def build_gl_only_report(gl_df, output_path): """ Build the donor workbook straight from a GL Dump's revenue/expense line-item detail, with no US-entity supplementary rows (there's no trial balance to source them from). Returns (donor_count, total_revenue, total_expense), same shape as build_donor_workbook. """ revenue_detail = process_revenue_detail(gl_df) expense_detail = process_expense_detail(gl_df) empty_us = pd.DataFrame(columns=_EMPTY_US_COLUMNS) return build_donor_workbook( None, None, output_path, revenue_detail=revenue_detail, revenue_us=empty_us, expense_detail=expense_detail, expense_us=empty_us, )