fixed vat allocation report not being in formula editor
This commit is contained in:
parent
24740d0b44
commit
0991ecadee
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in New Issue