From 10be61958c449128969790af87dfbbe805116042 Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Wed, 1 Apr 2026 14:34:11 +0400 Subject: [PATCH] fix: vat18 should be item amount subject to VAT, make objectName optional Co-Authored-By: Claude Opus 4.6 (1M context) --- invoice_az/send_sales_api.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/invoice_az/send_sales_api.py b/invoice_az/send_sales_api.py index f28bfbb..4cce2ba 100644 --- a/invoice_az/send_sales_api.py +++ b/invoice_az/send_sales_api.py @@ -179,13 +179,6 @@ def validate_invoice_for_sending(doc): "message": f"Customer '{doc.customer}' does not have a TIN (tax_id). Please update customer details." } - # Check customer object name - if not doc.customer_object_name: - return { - "valid": False, - "message": "Customer's legal company name is required. Please fill the 'Customer Object Name' field in the Sales Invoice." - } - # Validate items if not doc.items: return { @@ -478,7 +471,7 @@ def build_invoice_payload(doc, serial_number): receiver = { "name": etaxes_customer_name, "tin": customer.tax_id, - "objectName": doc.customer_object_name + "objectName": doc.customer_object_name or "" } # Build items array @@ -487,8 +480,8 @@ def build_invoice_payload(doc, serial_number): item_master = frappe.get_doc("Item", item.item_code) # Map VAT fields to E-Taxes format - # vat18 = pure VAT tax amount (vat_amount), NOT total with VAT (vat_18_percent_with_amount) - vat18 = item.vat_amount if hasattr(item, 'vat_amount') and item.vat_amount else None + # vat18 = the amount subject to 18% VAT (i.e. item.amount), not the tax itself + vat18 = item.amount if hasattr(item, 'vat_18_percent_with_amount') and item.vat_18_percent_with_amount else None vat0 = item.vat_0_percent_with_amount if hasattr(item, 'vat_0_percent_with_amount') and item.vat_0_percent_with_amount else None vat_free = item.vat_free_amount if hasattr(item, 'vat_free_amount') and item.vat_free_amount else None exempt = item.amount_without_vat if hasattr(item, 'amount_without_vat') and item.amount_without_vat else None