From bc59c2e94dfdb8306c5cc86ef8f13ec8bf7a5f99 Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Sun, 30 Jul 2023 19:02:06 +0530 Subject: [PATCH] fix: improve implementation for sandbox desc --- .../gst_india/client_scripts/e_invoice_actions.js | 12 +++--------- .../gst_india/client_scripts/e_waybill_actions.js | 13 +++---------- 2 files changed, 6 insertions(+), 19 deletions(-) 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 16330660e..e3789b295 100644 --- a/india_compliance/gst_india/client_scripts/e_invoice_actions.js +++ b/india_compliance/gst_india/client_scripts/e_invoice_actions.js @@ -1,5 +1,8 @@ frappe.ui.form.on("Sales Invoice", { refresh(frm) { + if (frm.doc.__onload?.e_invoice_info?.is_generated_in_sandbox_mode) + frm.get_field("irn").set_description("Generated in Sandbox Mode"); + if (!is_e_invoice_applicable(frm)) return; if ( @@ -13,7 +16,6 @@ frappe.ui.form.on("Sales Invoice", { method: "india_compliance.gst_india.utils.e_invoice.generate_e_invoice", args: { docname: frm.doc.name }, callback: () => { - show_e_invoice_sandbox_mode_desc(frm, (force = true)); return frm.refresh(); }, }); @@ -32,7 +34,6 @@ frappe.ui.form.on("Sales Invoice", { "e-Invoice" ); } - show_e_invoice_sandbox_mode_desc(frm); }, async on_submit(frm) { if ( @@ -51,7 +52,6 @@ frappe.ui.form.on("Sales Invoice", { throw: false, } ); - show_e_invoice_sandbox_mode_desc(frm, (force = true)); }, before_cancel(frm) { if (!frm.doc.irn) return; @@ -88,12 +88,6 @@ frappe.ui.form.on("Sales Invoice", { }, }); -function show_e_invoice_sandbox_mode_desc(frm, force = false) { - const is_generated_in_sandbox_mode = frm.doc.__onload?.e_invoice_info?.is_generated_in_sandbox_mode; - - if ((gst_settings.sandbox_mode && force) || is_generated_in_sandbox_mode) - frm.get_field("irn").set_description("Generated in Sandbox Mode"); -} function is_irn_cancellable(frm) { const e_invoice_info = frm.doc.__onload && frm.doc.__onload.e_invoice_info; diff --git a/india_compliance/gst_india/client_scripts/e_waybill_actions.js b/india_compliance/gst_india/client_scripts/e_waybill_actions.js index d1995cf70..f91f1e488 100644 --- a/india_compliance/gst_india/client_scripts/e_waybill_actions.js +++ b/india_compliance/gst_india/client_scripts/e_waybill_actions.js @@ -25,6 +25,9 @@ function setup_e_waybill_actions(doctype) { }); }, refresh(frm) { + if (frm.doc.__onload?.e_waybill_info?.is_generated_in_sandbox_mode) + frm.get_field("ewaybill").set_description("Generated in Sandbox Mode"); + if ( frm.doc.docstatus != 1 || frm.is_dirty() || @@ -119,7 +122,6 @@ function setup_e_waybill_actions(doctype) { "e-Waybill" ); } - show_e_waybill_sandbox_mode_desc(frm); }, async on_submit(frm) { if ( @@ -141,7 +143,6 @@ function setup_e_waybill_actions(doctype) { "india_compliance.gst_india.utils.e_waybill.generate_e_waybill", { doctype: frm.doctype, docname: frm.doc.name } ); - show_e_waybill_sandbox_mode_desc(frm, (force = true)); }, before_cancel(frm) { // if IRN is present, e-Waybill gets cancelled in e-Invoice action @@ -199,7 +200,6 @@ function show_generate_e_waybill_dialog(frm) { values, }, callback: () => { - show_e_waybill_sandbox_mode_desc(frm, (force = true)); return frm.refresh(); }, }); @@ -813,10 +813,3 @@ function set_primary_action_label(dialog, primary_action_label) { dialog.get_primary_btn().removeClass("hide").html(primary_action_label); } -function show_e_waybill_sandbox_mode_desc(frm, force = false) { - const is_generated_in_sandbox_mode = - frm.doc.__onload?.e_waybill_info?.is_generated_in_sandbox_mode; - - if ((gst_settings.sandbox_mode && force) || is_generated_in_sandbox_mode) - frm.get_field("ewaybill").set_description("Generated in Sandbox Mode"); -}