updated vat allocation previous month work

This commit is contained in:
Ali 2026-01-15 15:29:21 +04:00
parent 9b8f9abf66
commit 7097d61c6e
3 changed files with 1176 additions and 4 deletions

View File

@ -163,7 +163,7 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2025-10-07 14:10:17.385408", "modified": "2026-01-15 15:22:24.103624",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Taxes Az", "module": "Taxes Az",
"name": "VAT allocation", "name": "VAT allocation",
@ -171,6 +171,7 @@
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
"cancel": 1,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
@ -180,9 +181,11 @@
"report": 1, "report": 1,
"role": "System Manager", "role": "System Manager",
"share": 1, "share": 1,
"submit": 1,
"write": 1 "write": 1
} }
], ],
"row_format": "Dynamic",
"sort_field": "creation", "sort_field": "creation",
"sort_order": "DESC", "sort_order": "DESC",
"states": [] "states": []

View File

@ -407,8 +407,13 @@ def get_sales_invoice_items_previous_months(year, month, customers=None, min_amo
if customers and len(customers) > 0: if customers and len(customers) > 0:
customer_list = [c.get('customer') for c in customers if c.get('customer')] customer_list = [c.get('customer') for c in customers if c.get('customer')]
# Find all previous VAT Allocation documents # Chain Logic Implementation:
# We need to find documents where (year < current_year) OR (year == current_year AND month < current_month) # Get ONLY the immediately previous VAT Allocation document (LIMIT 1).
# The query below (lines 434-445) fetches from BOTH child tables:
# - sales_invoice_table (last month's current items, if unpaid)
# - sales_invoice_previous_table (older months' items, if unpaid)
# This creates a "chain" where each month inherits the complete unpaid state
# from the previous month, preventing double-counting.
vat_allocations = frappe.db.sql(""" vat_allocations = frappe.db.sql("""
SELECT name, year, month SELECT name, year, month
FROM `tabVAT allocation` FROM `tabVAT allocation`
@ -418,6 +423,7 @@ def get_sales_invoice_items_previous_months(year, month, customers=None, min_amo
OR (year = %(year)s AND month < %(month)s) OR (year = %(year)s AND month < %(month)s)
) )
ORDER BY year DESC, month DESC ORDER BY year DESC, month DESC
LIMIT 1
""", { """, {
'year': year, 'year': year,
'month': month_number 'month': month_number

File diff suppressed because it is too large Load Diff