From fefb55db4106a60589d650aa27b70ce7cfca0337 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Wed, 28 Feb 2024 15:38:20 +0530 Subject: [PATCH] fix: ignore mandatory fields for onload of purchase receipt --- .../gst_india/overrides/purchase_receipt.py | 19 +++++++++++++++++-- .../gst_india/overrides/transaction.py | 4 +--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/india_compliance/gst_india/overrides/purchase_receipt.py b/india_compliance/gst_india/overrides/purchase_receipt.py index 41226ca6a..3cedd46bb 100644 --- a/india_compliance/gst_india/overrides/purchase_receipt.py +++ b/india_compliance/gst_india/overrides/purchase_receipt.py @@ -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): @@ -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) diff --git a/india_compliance/gst_india/overrides/transaction.py b/india_compliance/gst_india/overrides/transaction.py index 028e87730..8d8d49a60 100644 --- a/india_compliance/gst_india/overrides/transaction.py +++ b/india_compliance/gst_india/overrides/transaction.py @@ -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,) @@ -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(