Skip to content

Commit

Permalink
Merge pull request #1197 from resilient-tech/mergify/bp/version-14-ho…
Browse files Browse the repository at this point in the history
…tfix/pr-1194

fix: throw if default gst expense account is missing (backport #1194)
  • Loading branch information
vorasmit authored Oct 27, 2023
2 parents 4439dbd + 2c5319c commit c8d4b4c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions india_compliance/gst_india/overrides/ineligible_itc.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 <strong>Default GST Expense Account</strong> 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"

Expand All @@ -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()

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit c8d4b4c

Please sign in to comment.