Skip to content

Commit

Permalink
fix: minor changes as per review
Browse files Browse the repository at this point in the history
  • Loading branch information
vorasmit committed Dec 12, 2024
1 parent 7a5b7cc commit 07d24bb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 52 deletions.
32 changes: 10 additions & 22 deletions india_compliance/gst_india/client_scripts/e_invoice_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ frappe.ui.form.on("Sales Invoice", {
)
return;

if(frm.doc.docstatus === 2) return;
if (frm.doc.docstatus === 2) return;

const is_einv_generatable = is_e_invoice_generatable(frm, true);

Expand Down Expand Up @@ -144,14 +144,11 @@ frappe.ui.form.on("Sales Invoice", {
return;
}

(async () => {
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);
})();
if (gst_settings.auto_cancel_e_invoice === 1) {
continueCancellation();
return;
}
return show_cancel_e_invoice_dialog(frm, continueCancellation);
});
},
});
Expand Down Expand Up @@ -195,8 +192,6 @@ async function show_cancel_e_invoice_dialog(frm, callback) {
india_compliance.primary_to_danger_btn(d);
d.show();

update_reason_for_e_invoice_cancellation(d);

$(`
<div class="alert alert-warning" role="alert">
Sales invoice will be cancelled along with the IRN.
Expand Down Expand Up @@ -274,16 +269,6 @@ 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");
d.get_field("reason").set_value(reason);
}
}

function get_cancel_e_invoice_dialog_fields(frm, manual_cancel = false) {
Expand All @@ -300,7 +285,10 @@ function get_cancel_e_invoice_dialog_fields(frm, manual_cancel = false) {
fieldname: "reason",
fieldtype: "Select",
reqd: 1,
default: manual_cancel ? "Others" : "Data Entry Mistake",
default: manual_cancel
? "Others"
: gst_settings.reason_for_e_invoice_cancellation ||
"Data Entry Mistake",
options: ["Duplicate", "Data Entry Mistake", "Order Cancelled", "Others"],
},
{
Expand Down
27 changes: 8 additions & 19 deletions india_compliance/gst_india/client_scripts/e_waybill_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,12 @@ function setup_e_waybill_actions(doctype) {
return;
}

(async () => {
const auto_cancel_e_waybill = await frappe.db.get_single_value("GST Settings", "auto_cancel_e_waybill");
if (auto_cancel_e_waybill === 1) {
continueCancellation()
return
}
return show_cancel_e_waybill_dialog(frm, continueCancellation);
})();
if (gst_settings.auto_cancel_e_waybill === 1) {
continueCancellation();
return;
}

return show_cancel_e_waybill_dialog(frm, continueCancellation);
});
},
});
Expand Down Expand Up @@ -716,7 +714,6 @@ function show_cancel_e_waybill_dialog(frm, callback) {

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

function show_mark_e_waybill_as_cancelled_dialog(frm) {
Expand Down Expand Up @@ -750,15 +747,6 @@ 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");
d.get_field("reason").set_value(reason);
}
}

function get_cancel_e_waybill_dialog_fields(frm) {
Expand All @@ -775,7 +763,8 @@ function get_cancel_e_waybill_dialog_fields(frm) {
fieldname: "reason",
fieldtype: "Select",
reqd: 1,
default: "Data Entry Mistake",
default:
gst_settings.reason_for_e_waybill_cancellation || "Data Entry Mistake",
options: ["Duplicate", "Order Cancelled", "Data Entry Mistake", "Others"],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,8 @@
"fieldtype": "Select",
"label": "Default Reason for e-Waybill Cancellation",
"mandatory_depends_on": "eval: doc.auto_cancel_e_waybill",
"options": "Duplicate\nOrder Cancelled\nData Entry Mistake"
"options": "Duplicate\nOrder Cancelled\nData Entry Mistake",
"read_only_depends_on": "eval: doc.enable_e_invoice"
},
{
"default": "Data Entry Mistake",
Expand All @@ -672,7 +673,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2024-12-06 12:43:06.963007",
"modified": "2024-12-12 19:09:07.185191",
"modified_by": "Administrator",
"module": "GST India",
"name": "GST Settings",
Expand Down
11 changes: 2 additions & 9 deletions india_compliance/gst_india/overrides/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def on_submit(doc, method=None):


def before_cancel(doc, method=None):
cancel_e_documents(doc)
cancel_e_waybill_e_invoice(doc)
if ignore_gst_validations(doc):
return

Expand All @@ -212,14 +212,7 @@ def before_cancel(doc, method=None):
)


def cancel_e_documents(doc, method=None):
if (
not frappe.form_dict
or frappe.form_dict.cmd.endswith("cancel_e_invoice")
or frappe.form_dict.cmd.endswith("cancel_e_waybill")
):
return

def cancel_e_waybill_e_invoice(doc, method=None):
gst_settings = frappe.get_cached_doc("GST Settings")

if not is_api_enabled(gst_settings):
Expand Down

0 comments on commit 07d24bb

Please sign in to comment.