Skip to content

Commit

Permalink
fix: gst_hsn_code is mandatory if gst_category is overseas
Browse files Browse the repository at this point in the history
(cherry picked from commit 024e6f2)
  • Loading branch information
Ninad1306 authored and mergify[bot] committed Sep 12, 2024
1 parent f5ab72f commit cd4bef5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
20 changes: 18 additions & 2 deletions india_compliance/gst_india/client_scripts/purchase_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ frappe.ui.form.on(DOCTYPE, {

onload: toggle_reverse_charge,

gst_category: toggle_reverse_charge,
gst_category(frm) {
toggle_reverse_charge(frm);
validate_gst_hsn_code(frm);
},

after_save(frm) {
if (
Expand Down Expand Up @@ -90,9 +93,14 @@ frappe.ui.form.on(DOCTYPE, {
});

frappe.ui.form.on("Purchase Invoice Item", {
item_code: toggle_reverse_charge,
item_code(frm) {
toggle_reverse_charge(frm);
validate_gst_hsn_code(frm);
},

items_remove: toggle_reverse_charge,

gst_hsn_code: validate_gst_hsn_code,
});

function toggle_reverse_charge(frm) {
Expand All @@ -104,3 +112,11 @@ function toggle_reverse_charge(frm) {

frm.set_df_property("is_reverse_charge", "read_only", is_read_only);
}

function validate_gst_hsn_code(frm) {
if (frm.doc.gst_category !== "Overseas") return;

if (frm.doc.items.some(item => !item.gst_hsn_code)) {
frappe.throw(__("GST HSN Code is mandatory for Overseas Purchase Invoice."));
}
}
11 changes: 10 additions & 1 deletion india_compliance/gst_india/overrides/purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def validate(doc, method=None):
if validate_transaction(doc) is False:
return

validate_gst_hsn_code(doc)
set_ineligibility_reason(doc)
update_itc_totals(doc)
validate_supplier_invoice_number(doc)
Expand All @@ -51,7 +52,6 @@ def validate(doc, method=None):


def on_cancel(doc, method=None):

frappe.db.set_value(
"GST Inward Supply",
{"link_doctype": "Purchase Invoice", "link_name": doc.name},
Expand Down Expand Up @@ -263,3 +263,12 @@ def validate_reverse_charge(doc):
return

frappe.throw(_("Reverse Charge is not applicable on Import of Goods"))


def validate_gst_hsn_code(doc):
if doc.gst_category != "Overseas":
return

for item in doc.items:
if not item.get("gst_hsn_code"):
frappe.throw(_("GST HSN Code is mandatory for Overseas Purchase Invoice"))

0 comments on commit cd4bef5

Please sign in to comment.