Skip to content

Commit

Permalink
fix: using function for same task
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed Dec 10, 2024
1 parent bbcdc20 commit 7a5b7cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
10 changes: 5 additions & 5 deletions india_compliance/gst_india/client_scripts/e_invoice_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,7 @@ async 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);
}
update_reason_for_e_invoice_cancellation(d);

$(`
<div class="alert alert-warning" role="alert">
Expand Down Expand Up @@ -279,6 +275,10 @@ async function show_mark_e_invoice_as_cancelled_dialog(frm) {

d.show();

update_reason_for_e_invoice_cancellation(d);
}

async function update_reason_for_e_invoice_cancellation(d) {
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");
Expand Down
14 changes: 6 additions & 8 deletions india_compliance/gst_india/client_scripts/e_waybill_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ function show_mark_e_waybill_as_generated_dialog(frm) {
d.show();
}

async function show_cancel_e_waybill_dialog(frm, callback) {
function show_cancel_e_waybill_dialog(frm, callback) {
const d = new frappe.ui.Dialog({
title: __("Cancel e-Waybill"),
fields: get_cancel_e_waybill_dialog_fields(frm),
Expand All @@ -716,15 +716,10 @@ async function show_cancel_e_waybill_dialog(frm, callback) {

india_compliance.primary_to_danger_btn(d);
d.show();

const auto_cancel_e_waybill = await frappe.db.get_single_value("GST Settings", "auto_cancel_e_waybill");
if (auto_cancel_e_waybill) {
const reason = await frappe.db.get_single_value("GST Settings", "reason_for_e_waybill_cancellation");
d.get_field("reason").set_value(reason);
}
update_reason_for_e_invoice_cancellation(d);
}

async function show_mark_e_waybill_as_cancelled_dialog(frm) {
function show_mark_e_waybill_as_cancelled_dialog(frm) {
const fields = get_cancel_e_waybill_dialog_fields(frm);
fields.push({
label: "Cancelled On",
Expand Down Expand Up @@ -755,7 +750,10 @@ async function show_mark_e_waybill_as_cancelled_dialog(frm) {
});

d.show();
update_reason_for_e_invoice_cancellation(d);
}

async function update_reason_for_e_invoice_cancellation(d){
const auto_cancel_e_waybill = await frappe.db.get_single_value("GST Settings", "auto_cancel_e_waybill");
if (auto_cancel_e_waybill) {
const reason = await frappe.db.get_single_value("GST Settings", "reason_for_e_waybill_cancellation");
Expand Down

0 comments on commit 7a5b7cc

Please sign in to comment.