From 0991ecadee21ff9577bfe0c325383c5cbeb4b5f7 Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Wed, 11 Feb 2026 21:26:23 +0400 Subject: [PATCH] fixed vat allocation report not being in formula editor --- .../vat_allocation_report.py | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/taxes_az/taxes_az/report/vat_allocation_report/vat_allocation_report.py b/taxes_az/taxes_az/report/vat_allocation_report/vat_allocation_report.py index e462d09..9ab9499 100644 --- a/taxes_az/taxes_az/report/vat_allocation_report/vat_allocation_report.py +++ b/taxes_az/taxes_az/report/vat_allocation_report/vat_allocation_report.py @@ -56,34 +56,53 @@ def get_columns(): return columns +def get_empty_row(vat_name=""): + """Return an empty row with zero values (needed for Formula Editor)""" + return { + 'vat_allocation': vat_name or "No Data", + 'prev_month_18': 0.0, + 'prev_month_0': 0.0, + 'prev_month_azad': 0.0, + 'unallocated_18': 0.0, + 'unallocated_0': 0.0, + 'unallocated_azad': 0.0, + 'allocated_18': 0.0, + 'allocated_0': 0.0, + 'allocated_azad': 0.0, + 'balance_18': 0.0, + 'balance_0': 0.0, + 'balance_azad': 0.0 + } + + def get_data(filters): """Get VAT allocation documents and calculate values""" - # Return empty data if filters are not provided (needed for Formula Editor) + # Return empty row if filters are not provided (needed for Formula Editor) if not filters: - return [] + return [get_empty_row()] - # Validate filters + # Validate filters - return empty row if incomplete if not filters.get('company'): - return [] + return [get_empty_row()] if not filters.get('year'): - return [] + return [get_empty_row()] if not filters.get('month'): - return [] + return [get_empty_row()] # Find VAT allocation document (max one result due to autoname format) vat_name = f"VAT-{filters.get('year')}-{filters.get('month')}" if not frappe.db.exists("VAT allocation", vat_name): - return [] + return [get_empty_row(vat_name)] # Check if submitted docstatus = frappe.db.get_value("VAT allocation", vat_name, "docstatus") if docstatus != 1: - return [] + return [get_empty_row(vat_name)] row = calculate_row_data(vat_name) - return [row] if row else [] + return [row] if row else [get_empty_row(vat_name)] def calculate_row_data(vat_allocation_name):