added new totals to vat allocation

This commit is contained in:
Ali 2026-02-09 15:14:03 +04:00
parent c5fe07a20d
commit 9815fbee02
2 changed files with 21 additions and 2 deletions

View File

@ -1,6 +1,5 @@
{
"actions": [],
"autoname": "format:VAT-{year}-{month}",
"creation": "2025-09-29 19:03:22.767217",
"doctype": "DocType",
"engine": "InnoDB",
@ -240,7 +239,6 @@
"modified_by": "Administrator",
"module": "Taxes Az",
"name": "VAT allocation",
"naming_rule": "Expression",
"owner": "Administrator",
"permissions": [
{

View File

@ -8,6 +8,27 @@ import json
ROUNDING_TOLERANCE = Decimal('0.01')
class VATallocation(Document):
def autoname(self):
"""
Generate unique name for the document
- For submitted documents or first draft: VAT-{year}-{month}
- For additional drafts: VAT-{year}-{month}-{counter}
"""
if not self.year or not self.month:
frappe.throw(_("Year and Month are required"))
base_name = f"VAT-{self.year}-{self.month}"
# Check if base name already exists
if frappe.db.exists('VAT allocation', base_name):
# Add counter for additional drafts
counter = 1
while frappe.db.exists('VAT allocation', f"{base_name}-{counter}"):
counter += 1
self.name = f"{base_name}-{counter}"
else:
self.name = base_name
def validate(self):
# Check if document with same year and month already exists
self.validate_unique_year_month()