Skip to content

Commit

Permalink
fix: ignore mandatory fields for onload of purchase receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
vorasmit committed Feb 28, 2024
1 parent de65699 commit fefb55d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 17 additions & 2 deletions india_compliance/gst_india/overrides/purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from india_compliance.gst_india.overrides.sales_invoice import (
update_dashboard_with_gst_logs,
)
from india_compliance.gst_india.overrides.transaction import validate_transaction
from india_compliance.gst_india.overrides.transaction import (
ignore_gst_validations,
validate_mandatory_fields,
validate_transaction,
)


def get_dashboard_data(data):
Expand All @@ -17,9 +21,20 @@ def get_dashboard_data(data):


def onload(doc, method=None):
if validate_transaction(doc) is False:
if ignore_gst_validations(doc):
return

doc.flags.ignore_mandatory = True
if (
validate_mandatory_fields(
doc, ("company_gstin", "place_of_supply", "gst_category")
)
is False
):
return

doc.flags.ignore_mandatory = False

set_ineligibility_reason(doc, show_alert=False)


Expand Down
4 changes: 1 addition & 3 deletions india_compliance/gst_india/overrides/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ def is_indian_registered_company(doc):


def validate_mandatory_fields(doc, fields, error_message=None):
ignore_mandatory = not doc.docstatus and doc.flags.ignore_mandatory

if isinstance(fields, str):
fields = (fields,)

Expand All @@ -157,7 +155,7 @@ def validate_mandatory_fields(doc, fields, error_message=None):
if doc.get(field):
continue

if ignore_mandatory:
if doc.flags.ignore_mandatory:
return False

frappe.throw(
Expand Down

0 comments on commit fefb55d

Please sign in to comment.