From f6ed785ec96662620397ee54b374ef624dc63860 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Tue, 30 Jul 2024 12:26:43 +0530 Subject: [PATCH] fix: gst invoice warning based on gst_tax_type --- .../gst_india/client_scripts/sales_invoice.js | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/india_compliance/gst_india/client_scripts/sales_invoice.js b/india_compliance/gst_india/client_scripts/sales_invoice.js index 9711c6ae6f..2e341dcc00 100644 --- a/india_compliance/gst_india/client_scripts/sales_invoice.js +++ b/india_compliance/gst_india/client_scripts/sales_invoice.js @@ -57,7 +57,9 @@ frappe.ui.form.on(DOCTYPE, { }); async function gst_invoice_warning(frm) { - if (is_gst_invoice(frm) && !(await contains_gst_account(frm))) { + const contains_gst_account = frm.doc.taxes.some(row => row.gst_tax_type); + + if (is_gst_invoice(frm) && !contains_gst_account) { frm.dashboard.add_comment( __( `GST is applicable for this invoice but no tax accounts specified in @@ -92,23 +94,3 @@ function is_gst_invoice(frm) { else return gst_invoice_conditions; } -async function contains_gst_account(frm) { - const gst_accounts = await _get_account_options(frm.doc.company); - const accounts = frm.doc.taxes.map(taxes => taxes.account_head); - - return accounts.some(account => gst_accounts.includes(account)); -} - -async function _get_account_options(company) { - if (!frappe.flags.gst_accounts) { - frappe.flags.gst_accounts = {}; - } - - if (!frappe.flags.gst_accounts[company]) { - frappe.flags.gst_accounts[company] = await india_compliance.get_account_options( - company - ); - } - - return frappe.flags.gst_accounts[company]; -}