Skip to content

Commit

Permalink
Merge pull request #908 from sagarvora/fix-desc-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarvora authored Jul 30, 2023
2 parents bbc8aba + bc59c2e commit e0aba2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
12 changes: 3 additions & 9 deletions india_compliance/gst_india/client_scripts/e_invoice_actions.js
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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();
},
});
Expand All @@ -32,7 +34,6 @@ frappe.ui.form.on("Sales Invoice", {
"e-Invoice"
);
}
show_e_invoice_sandbox_mode_desc(frm);
},
async on_submit(frm) {
if (
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 3 additions & 10 deletions india_compliance/gst_india/client_scripts/e_waybill_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() ||
Expand Down Expand Up @@ -119,7 +122,6 @@ function setup_e_waybill_actions(doctype) {
"e-Waybill"
);
}
show_e_waybill_sandbox_mode_desc(frm);
},
async on_submit(frm) {
if (
Expand All @@ -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
Expand Down Expand Up @@ -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();
},
});
Expand Down Expand Up @@ -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");
}

0 comments on commit e0aba2c

Please sign in to comment.