diff --git a/india_compliance/gst_india/client_scripts/e_invoice_actions.js b/india_compliance/gst_india/client_scripts/e_invoice_actions.js index aff1439769..2f915278be 100644 --- a/india_compliance/gst_india/client_scripts/e_invoice_actions.js +++ b/india_compliance/gst_india/client_scripts/e_invoice_actions.js @@ -107,7 +107,7 @@ frappe.ui.form.on("Sales Invoice", { frappe.validated = false; - return new Promise(resolve => { + return new Promise(async (resolve) => { const continueCancellation = () => { frappe.validated = true; resolve(); @@ -144,6 +144,11 @@ frappe.ui.form.on("Sales Invoice", { return; } + const auto_cancel_e_invoice = await frappe.db.get_single_value("GST Settings", "auto_cancel_e_invoice"); + if(auto_cancel_e_invoice === 1){ + continueCancellation() + return + } return show_cancel_e_invoice_dialog(frm, continueCancellation); }); }, @@ -160,7 +165,7 @@ function is_irn_cancellable(frm) { ); } -function show_cancel_e_invoice_dialog(frm, callback) { +async function show_cancel_e_invoice_dialog(frm, callback) { const d = new frappe.ui.Dialog({ title: frm.doc.ewaybill ? __("Cancel e-Invoice and e-Waybill") @@ -188,6 +193,12 @@ function show_cancel_e_invoice_dialog(frm, callback) { india_compliance.primary_to_danger_btn(d); d.show(); + const auto_cancel_e_invoice = await frappe.db.get_single_value("GST Settings", "auto_cancel_e_invoice"); + if (auto_cancel_e_invoice) { + const reason = await frappe.db.get_single_value("GST Settings", "reason_for_e_invoice_cancellation"); + d.get_field("reason").set_value(reason); + } + $(`