Skip to content

Commit

Permalink
fix: gst invoice warning based on gst_tax_type
Browse files Browse the repository at this point in the history
  • Loading branch information
ljain112 committed Jul 30, 2024
1 parent 7ac0410 commit f6ed785
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions india_compliance/gst_india/client_scripts/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="/app/gst-settings">
Expand Down Expand Up @@ -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];
}

0 comments on commit f6ed785

Please sign in to comment.