Skip to content

Commit

Permalink
Merge pull request #2642 from Sanket322/validate_doc_name_for_gstr1_beta
Browse files Browse the repository at this point in the history
fix: validate doc name for GSTR1
  • Loading branch information
mergify[bot] authored Oct 18, 2024
2 parents 4bb9af2 + bb33cc0 commit 5d73560
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion india_compliance/gst_india/overrides/purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -47,6 +47,9 @@ def validate(doc, method=None):
return

validate_hsn_codes(doc)
if doc.is_reverse_charge and not doc.supplier_gstin:
validate_invoice_number(doc)

set_ineligibility_reason(doc)
update_itc_totals(doc)
validate_supplier_invoice_number(doc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -168,6 +171,9 @@ def validate(doc, method=None):
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

Expand Down
26 changes: 26 additions & 0 deletions india_compliance/gst_india/overrides/test_purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

0 comments on commit 5d73560

Please sign in to comment.