No GSTIN Validation for Purchase Invoice and Purchase Order

Hi,

In the validation override done for Purchase order and Purchase Invoice, there is no validation if Company GSTIN is there on billing address and thereby document.
This fails the item valuation reposting as during reposting GL_Entry validate override checks if the account is part of GST accounts and if yes, there must be Company GSTIN present on the document.

I feel its important check to have on Purcahse Order and Purchase Invoice:

  1. If there is a GST account used for taxes and charges, check if company GSTIN is not null or blank on the document.

Must add check for company GSTIN in the following function:
india_compliance/gst_india/overrides/transaction.py/before_validate_transaction

Solution: Please add the following code in overrides/transaction.py

def before_validate_transaction(doc, method=None):
    if ignore_gst_validations(doc, throw=False):
        return False

    if not doc.place_of_supply:
        doc.place_of_supply = get_place_of_supply(doc, doc.doctype)

    set_reverse_charge_as_per_gst_settings(doc)

    # Check if Company GSTIN is set on the document if GST account is used for taxes
    validate_gstin(doc)

def validate_gstin(doc, method=None):
    # Check if Company GSTIN is set on the document if GST account is used for taxes
    doc_accounts = [tax.account_head for tax in doc.taxes if tax.tax_amount != 0]
    gst_accounts = get_all_gst_accounts(doc.company)
    if any(account in gst_accounts for account in doc_accounts) and doc.company_gstin == "":
        frappe.throw(
            _(
                "Company GSTIN is a mandatory field for accounting of GST Accounts. "
                "Please add GSTIN to Company Billing address."
            )
        )

This is already validated and hence its raising error.

With this, you will not be able to create any new entry without company GSTIN.

In order to assist updation of gstins in docs where its missing, we have a manual patch using button Update GSTINs in GST Balance Report.

Somehow, this code is not invoked when submitting a Pur Inv. I created an address without GSTIN and added that as the billing address (same as the shipping address too). I could submit the purchase invoice with GST applied (when Company GSTIN is blank).

Only in two cases, this validation is skipped.

  1. GST Accounts were not specified originally in the GST Settings
  2. It’s not an Indian Registered Company (GSTIN is not specified in company doc) at the time of creation of Purchase Invoice.