From 1100bf4def033f87b5d70a1dd3a901f4848660dd Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Fri, 27 Sep 2024 13:19:31 +0530 Subject: [PATCH 1/4] fix: validate doc name which are required in doc issue summary --- india_compliance/gst_india/overrides/purchase_invoice.py | 3 ++- .../gst_india/overrides/subcontracting_transaction.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/india_compliance/gst_india/overrides/purchase_invoice.py b/india_compliance/gst_india/overrides/purchase_invoice.py index 2572d5436..0b9f14ead 100644 --- a/india_compliance/gst_india/overrides/purchase_invoice.py +++ b/india_compliance/gst_india/overrides/purchase_invoice.py @@ -9,7 +9,7 @@ validate_hsn_codes as _validate_hsn_codes, ) from india_compliance.gst_india.overrides.transaction import validate_transaction -from india_compliance.gst_india.utils import is_api_enabled +from india_compliance.gst_india.utils import is_api_enabled, validate_invoice_number from india_compliance.gst_india.utils.e_waybill import get_e_waybill_info @@ -47,6 +47,7 @@ def validate(doc, method=None): return validate_hsn_codes(doc) + validate_invoice_number(doc) set_ineligibility_reason(doc) update_itc_totals(doc) validate_supplier_invoice_number(doc) diff --git a/india_compliance/gst_india/overrides/subcontracting_transaction.py b/india_compliance/gst_india/overrides/subcontracting_transaction.py index 200a0dc36..e4dfb444c 100644 --- a/india_compliance/gst_india/overrides/subcontracting_transaction.py +++ b/india_compliance/gst_india/overrides/subcontracting_transaction.py @@ -24,6 +24,9 @@ validate_place_of_supply, ) from india_compliance.gst_india.utils import get_gst_accounts_by_type, is_api_enabled +from india_compliance.gst_india.utils import ( + validate_invoice_number as validate_transaction_name, +) from india_compliance.gst_india.utils.e_waybill import get_e_waybill_info from india_compliance.gst_india.utils.taxes_controller import ( CustomTaxController, @@ -165,6 +168,8 @@ def onload(doc, method=None): def validate(doc, method=None): + validate_transaction_name(doc) + if ignore_gst_validation_for_subcontracting(doc): return From 7ed0d1c30fb702b3f98e514238a3b7ad9ca4a944 Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Mon, 30 Sep 2024 10:50:36 +0530 Subject: [PATCH 2/4] fix: validate name only for stock entry and subcontracting receipt --- .../gst_india/overrides/subcontracting_transaction.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/india_compliance/gst_india/overrides/subcontracting_transaction.py b/india_compliance/gst_india/overrides/subcontracting_transaction.py index e4dfb444c..b676b35fa 100644 --- a/india_compliance/gst_india/overrides/subcontracting_transaction.py +++ b/india_compliance/gst_india/overrides/subcontracting_transaction.py @@ -168,7 +168,8 @@ def onload(doc, method=None): def validate(doc, method=None): - validate_transaction_name(doc) + if doc.doctype in ("Stock Entry", "Subcontracting Receipt"): + validate_transaction_name(doc) if ignore_gst_validation_for_subcontracting(doc): return From 2eb1628b49f319af36f09e0a50c28dadaff5f825 Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Thu, 10 Oct 2024 17:13:03 +0530 Subject: [PATCH 3/4] fix: changes as per review --- india_compliance/gst_india/overrides/purchase_invoice.py | 4 +++- .../gst_india/overrides/subcontracting_transaction.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/india_compliance/gst_india/overrides/purchase_invoice.py b/india_compliance/gst_india/overrides/purchase_invoice.py index 0b9f14ead..44e2d0a98 100644 --- a/india_compliance/gst_india/overrides/purchase_invoice.py +++ b/india_compliance/gst_india/overrides/purchase_invoice.py @@ -47,7 +47,9 @@ def validate(doc, method=None): return validate_hsn_codes(doc) - validate_invoice_number(doc) + if doc.is_reverse_charge: + validate_invoice_number(doc) + set_ineligibility_reason(doc) update_itc_totals(doc) validate_supplier_invoice_number(doc) diff --git a/india_compliance/gst_india/overrides/subcontracting_transaction.py b/india_compliance/gst_india/overrides/subcontracting_transaction.py index b676b35fa..f976c1d5b 100644 --- a/india_compliance/gst_india/overrides/subcontracting_transaction.py +++ b/india_compliance/gst_india/overrides/subcontracting_transaction.py @@ -168,12 +168,12 @@ def onload(doc, method=None): def validate(doc, method=None): - if doc.doctype in ("Stock Entry", "Subcontracting Receipt"): - validate_transaction_name(doc) - if ignore_gst_validation_for_subcontracting(doc): return + if doc.doctype in ("Stock Entry", "Subcontracting Receipt"): + validate_transaction_name(doc) + if doc.doctype == "Stock Entry" and doc.purpose != "Send to Subcontractor": return From bb33cc0d2a786c215df723d7d63c8075407d4327 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Fri, 18 Oct 2024 16:14:25 +0530 Subject: [PATCH 4/4] test: validate purchase invoice length --- .../gst_india/overrides/purchase_invoice.py | 2 +- .../overrides/test_purchase_invoice.py | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/india_compliance/gst_india/overrides/purchase_invoice.py b/india_compliance/gst_india/overrides/purchase_invoice.py index 44e2d0a98..de2c4e72d 100644 --- a/india_compliance/gst_india/overrides/purchase_invoice.py +++ b/india_compliance/gst_india/overrides/purchase_invoice.py @@ -47,7 +47,7 @@ def validate(doc, method=None): return validate_hsn_codes(doc) - if doc.is_reverse_charge: + if doc.is_reverse_charge and not doc.supplier_gstin: validate_invoice_number(doc) set_ineligibility_reason(doc) diff --git a/india_compliance/gst_india/overrides/test_purchase_invoice.py b/india_compliance/gst_india/overrides/test_purchase_invoice.py index 702c21155..9d149fe0f 100644 --- a/india_compliance/gst_india/overrides/test_purchase_invoice.py +++ b/india_compliance/gst_india/overrides/test_purchase_invoice.py @@ -58,3 +58,29 @@ def test_itc_classification(self): "Reverse Charge is not applicable on Import of Goods", pinv.save, ) + + def test_validate_invoice_length(self): + # No error for registered supplier + pinv = create_purchase_invoice( + supplier="_Test Registered Supplier", + is_reverse_charge=True, + do_not_save=True, + ) + setattr(pinv, "__newname", "INV/2022/00001/asdfsadf") # NOQA + pinv.meta.autoname = "prompt" + pinv.save() + + # Error for unregistered supplier + pinv = create_purchase_invoice( + supplier="_Test Unregistered Supplier", + is_reverse_charge=True, + do_not_save=True, + ) + setattr(pinv, "__newname", "INV/2022/00001/asdfsadg") # NOQA + pinv.meta.autoname = "prompt" + + self.assertRaisesRegex( + frappe.exceptions.ValidationError, + "GST Invoice Number cannot exceed 16 characters", + pinv.save, + )