fixed vat allocation report not being in formula editor
This commit is contained in:
parent
0991ecadee
commit
d998dbf47f
|
|
@ -85,13 +85,27 @@ def get_data(filters):
|
||||||
# Validate filters - return empty row if incomplete
|
# Validate filters - return empty row if incomplete
|
||||||
if not filters.get('company'):
|
if not filters.get('company'):
|
||||||
return [get_empty_row()]
|
return [get_empty_row()]
|
||||||
if not filters.get('year'):
|
|
||||||
return [get_empty_row()]
|
# Support both direct year/month filters AND from_date/to_date (for Formula Editor)
|
||||||
if not filters.get('month'):
|
year = filters.get('year')
|
||||||
|
month = filters.get('month')
|
||||||
|
|
||||||
|
# If year/month not provided, try to extract from from_date or to_date
|
||||||
|
if not year or not month:
|
||||||
|
date_to_use = filters.get('to_date') or filters.get('from_date')
|
||||||
|
if date_to_use:
|
||||||
|
from frappe.utils import getdate
|
||||||
|
date_obj = getdate(date_to_use)
|
||||||
|
year = date_obj.year
|
||||||
|
# Convert month number to month name
|
||||||
|
month_names = ['January', 'February', 'March', 'April', 'May', 'June',
|
||||||
|
'July', 'August', 'September', 'October', 'November', 'December']
|
||||||
|
month = month_names[date_obj.month - 1]
|
||||||
|
else:
|
||||||
return [get_empty_row()]
|
return [get_empty_row()]
|
||||||
|
|
||||||
# Find VAT allocation document (max one result due to autoname format)
|
# Find VAT allocation document (max one result due to autoname format)
|
||||||
vat_name = f"VAT-{filters.get('year')}-{filters.get('month')}"
|
vat_name = f"VAT-{year}-{month}"
|
||||||
|
|
||||||
if not frappe.db.exists("VAT allocation", vat_name):
|
if not frappe.db.exists("VAT allocation", vat_name):
|
||||||
return [get_empty_row(vat_name)]
|
return [get_empty_row(vat_name)]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue