From 2c5319c8eb1885a4631d3e441a09633908e950e1 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Fri, 27 Oct 2023 15:21:15 +0530 Subject: [PATCH] fix: throw if default gst expense account is missing, pre-validations (cherry picked from commit 4fb5fb7172ad6e016e9ce8427df981a585b9a5b6) --- .../gst_india/overrides/ineligible_itc.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/india_compliance/gst_india/overrides/ineligible_itc.py b/india_compliance/gst_india/overrides/ineligible_itc.py index 5528438bd..8978c57d5 100644 --- a/india_compliance/gst_india/overrides/ineligible_itc.py +++ b/india_compliance/gst_india/overrides/ineligible_itc.py @@ -1,5 +1,6 @@ import frappe -from frappe.utils import flt, rounded +from frappe import _ +from frappe.utils import flt, get_link_to_form, rounded from erpnext.assets.doctype.asset.asset import ( get_asset_account, is_cwip_accounting_enabled, @@ -19,6 +20,13 @@ def __init__(self, doc): self.is_perpetual = self.company.enable_perpetual_inventory self.cost_center = doc.cost_center or self.company.cost_center + if not self.company.default_gst_expense_account: + frappe.throw( + _( + "Please set Default GST Expense Account in Company {0}" + ).format(get_link_to_form("Company", self.company.name)) + ) + self.dr_or_cr = "credit" if doc.get("is_return") else "debit" self.cr_or_dr = "debit" if doc.get("is_return") else "credit" @@ -29,11 +37,6 @@ def update_valuation_rate(self): - Only updates if its a stock item or fixed asset - No updates for expense items """ - if self.doc.get("is_opening") == "Yes" or not is_indian_registered_company( - self.doc - ): - return - self.doc._has_ineligible_itc_items = False stock_items = self.doc.get_stock_items() @@ -357,11 +360,17 @@ def update_landed_cost_voucher(self, landed_cost_voucher): def update_valuation_rate(doc, method=None): + if doc.get("is_opening") == "Yes" or not is_indian_registered_company(doc): + return + if doc.doctype in DOCTYPE_MAPPING: DOCTYPE_MAPPING[doc.doctype](doc).update_valuation_rate() def update_regional_gl_entries(gl_entries, doc): + if doc.get("is_opening") == "Yes" or not is_indian_registered_company(doc): + return gl_entries + if doc.doctype in DOCTYPE_MAPPING: DOCTYPE_MAPPING[doc.doctype](doc).update_gl_entries(gl_entries)