Skip to content

Commit

Permalink
fix: validate original references on before_submit hook
Browse files Browse the repository at this point in the history
(cherry picked from commit 2a6beab)
  • Loading branch information
Ninad1306 authored and mergify[bot] committed Aug 29, 2024
1 parent a7c223b commit fada0e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 17 additions & 11 deletions india_compliance/gst_india/overrides/subcontracting_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,6 @@ def validate(doc, method=None):
if ignore_gst_validation_for_subcontracting(doc):
return

if (doc.doctype == "Stock Entry" and doc.purpose == "Material Transfer") or (
doc.doctype == "Subcontracting Receipt" and not doc.is_return
):
if not doc.doc_references:
frappe.throw(
_("Please Select Original Document Reference for ITC-04 Reporting"),
title=_("Mandatory Field"),
)
else:
remove_duplicates(doc)

field_map = (
STOCK_ENTRY_FIELD_MAP
if doc.doctype == "Stock Entry"
Expand All @@ -194,6 +183,23 @@ def validate(doc, method=None):
update_gst_details(doc)


def before_submit(doc, method=None):
# Stock Entries with Subcontracting Order should only be considered
if ignore_gst_validation_for_subcontracting(doc):
return

if (doc.doctype == "Stock Entry" and doc.purpose == "Material Transfer") or (
doc.doctype == "Subcontracting Receipt" and not doc.is_return
):
if not doc.doc_references:
frappe.throw(
_("Please Select Original Document Reference for ITC-04 Reporting"),
title=_("Mandatory Field"),
)
else:
remove_duplicates(doc)


def validate_transaction(doc, method=None):
if doc.doctype == "Stock Entry":
company_gstin_field = "bill_from_gstin"
Expand Down
2 changes: 2 additions & 0 deletions india_compliance/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
"Stock Entry": {
"onload": "india_compliance.gst_india.overrides.subcontracting_transaction.onload",
"validate": "india_compliance.gst_india.overrides.subcontracting_transaction.validate",
"before_submit": "india_compliance.gst_india.overrides.subcontracting_transaction.before_submit",
"after_mapping": "india_compliance.gst_india.overrides.subcontracting_transaction.after_mapping_stock_entry",
},
"Subcontracting Order": {
Expand All @@ -243,6 +244,7 @@
"Subcontracting Receipt": {
"onload": "india_compliance.gst_india.overrides.subcontracting_transaction.onload",
"validate": "india_compliance.gst_india.overrides.subcontracting_transaction.validate",
"before_submit": "india_compliance.gst_india.overrides.subcontracting_transaction.before_submit",
"before_mapping": "india_compliance.gst_india.overrides.subcontracting_transaction.before_mapping_subcontracting_receipt",
},
"Supplier": {
Expand Down

0 comments on commit fada0e5

Please sign in to comment.