fixed report vat allocation
This commit is contained in:
parent
b848bbd1d0
commit
4d778cf8f1
|
|
@ -168,7 +168,7 @@
|
|||
"fieldname": "sales_invoice_previous_table",
|
||||
"fieldtype": "Table",
|
||||
"label": "Sales Invoice Previous Months",
|
||||
"options": "VAT allocation sales invoice previous months"
|
||||
"options": "VAT allocation sales invoice"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_lpuu",
|
||||
|
|
|
|||
|
|
@ -91,8 +91,9 @@ def calculate_row_data(vat_allocation_name):
|
|||
item_tax_template,
|
||||
SUM(amount) as total_amount,
|
||||
SUM(allocated_amount) as total_allocated
|
||||
FROM `tabVAT allocation sales invoice previous months`
|
||||
FROM `tabVAT allocation sales invoice`
|
||||
WHERE parent = %(parent)s
|
||||
AND parentfield = 'sales_invoice_previous_table'
|
||||
GROUP BY item_tax_template
|
||||
""", {"parent": vat_allocation_name}, as_dict=1)
|
||||
|
||||
|
|
@ -103,9 +104,15 @@ def calculate_row_data(vat_allocation_name):
|
|||
SUM(unallocated_amount) as total_unallocated
|
||||
FROM `tabVAT allocation sales invoice`
|
||||
WHERE parent = %(parent)s
|
||||
AND parentfield = 'sales_invoice_table'
|
||||
GROUP BY item_tax_template
|
||||
""", {"parent": vat_allocation_name}, as_dict=1)
|
||||
|
||||
# Debug: log the raw data
|
||||
frappe.logger().debug(f"VAT Allocation: {vat_allocation_name}")
|
||||
frappe.logger().debug(f"Previous month data: {prev_month_data}")
|
||||
frappe.logger().debug(f"Current month data: {current_month_data}")
|
||||
|
||||
# Initialize row
|
||||
row = {
|
||||
'vat_allocation': vat_allocation_name,
|
||||
|
|
@ -122,30 +129,32 @@ def calculate_row_data(vat_allocation_name):
|
|||
|
||||
# Process previous month data
|
||||
for item in prev_month_data:
|
||||
template = (item.item_tax_template or '').strip()
|
||||
template = (item.item_tax_template or '').strip().lower()
|
||||
amount = flt(item.total_amount)
|
||||
allocated = flt(item.total_allocated)
|
||||
|
||||
if template in ['ƏDV 18%', 'ƏDV daxil 18%']:
|
||||
# Match templates (case-insensitive)
|
||||
if 'ədv 18%' in template or 'ədv daxil 18%' in template:
|
||||
row['prev_month_18'] += amount
|
||||
row['allocated_18'] += allocated
|
||||
elif template == 'ƏDV 0%':
|
||||
elif 'ədv 0%' in template:
|
||||
row['prev_month_0'] += amount
|
||||
row['allocated_0'] += allocated
|
||||
elif template == 'ƏDV-dən azadolma':
|
||||
elif 'azadolma' in template:
|
||||
row['prev_month_azad'] += amount
|
||||
row['allocated_azad'] += allocated
|
||||
|
||||
# Process current month data
|
||||
for item in current_month_data:
|
||||
template = (item.item_tax_template or '').strip()
|
||||
template = (item.item_tax_template or '').strip().lower()
|
||||
unallocated = flt(item.total_unallocated)
|
||||
|
||||
if template in ['ƏDV 18%', 'ƏDV daxil 18%']:
|
||||
# Match templates (case-insensitive)
|
||||
if 'ədv 18%' in template or 'ədv daxil 18%' in template:
|
||||
row['unallocated_18'] += unallocated
|
||||
elif template == 'ƏDV 0%':
|
||||
elif 'ədv 0%' in template:
|
||||
row['unallocated_0'] += unallocated
|
||||
elif template == 'ƏDV-dən azadolma':
|
||||
elif 'azadolma' in template:
|
||||
row['unallocated_azad'] += unallocated
|
||||
|
||||
# Calculate balances
|
||||
|
|
|
|||
Loading…
Reference in New Issue