Skip to content

Commit 07d24bb

Browse files
committed
fix: minor changes as per review
1 parent 7a5b7cc commit 07d24bb

File tree

4 files changed

+23
-52
lines changed

4 files changed

+23
-52
lines changed

india_compliance/gst_india/client_scripts/e_invoice_actions.js

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ frappe.ui.form.on("Sales Invoice", {
2121
)
2222
return;
2323

24-
if(frm.doc.docstatus === 2) return;
24+
if (frm.doc.docstatus === 2) return;
2525

2626
const is_einv_generatable = is_e_invoice_generatable(frm, true);
2727

@@ -144,14 +144,11 @@ frappe.ui.form.on("Sales Invoice", {
144144
return;
145145
}
146146

147-
(async () => {
148-
const auto_cancel_e_invoice = await frappe.db.get_single_value("GST Settings", "auto_cancel_e_invoice");
149-
if (auto_cancel_e_invoice === 1) {
150-
continueCancellation()
151-
return
152-
}
153-
return show_cancel_e_invoice_dialog(frm, continueCancellation);
154-
})();
147+
if (gst_settings.auto_cancel_e_invoice === 1) {
148+
continueCancellation();
149+
return;
150+
}
151+
return show_cancel_e_invoice_dialog(frm, continueCancellation);
155152
});
156153
},
157154
});
@@ -195,8 +192,6 @@ async function show_cancel_e_invoice_dialog(frm, callback) {
195192
india_compliance.primary_to_danger_btn(d);
196193
d.show();
197194

198-
update_reason_for_e_invoice_cancellation(d);
199-
200195
$(`
201196
<div class="alert alert-warning" role="alert">
202197
Sales invoice will be cancelled along with the IRN.
@@ -274,16 +269,6 @@ async function show_mark_e_invoice_as_cancelled_dialog(frm) {
274269
});
275270

276271
d.show();
277-
278-
update_reason_for_e_invoice_cancellation(d);
279-
}
280-
281-
async function update_reason_for_e_invoice_cancellation(d) {
282-
const auto_cancel_e_invoice = await frappe.db.get_single_value("GST Settings", "auto_cancel_e_invoice");
283-
if (auto_cancel_e_invoice) {
284-
const reason = await frappe.db.get_single_value("GST Settings", "reason_for_e_invoice_cancellation");
285-
d.get_field("reason").set_value(reason);
286-
}
287272
}
288273

289274
function get_cancel_e_invoice_dialog_fields(frm, manual_cancel = false) {
@@ -300,7 +285,10 @@ function get_cancel_e_invoice_dialog_fields(frm, manual_cancel = false) {
300285
fieldname: "reason",
301286
fieldtype: "Select",
302287
reqd: 1,
303-
default: manual_cancel ? "Others" : "Data Entry Mistake",
288+
default: manual_cancel
289+
? "Others"
290+
: gst_settings.reason_for_e_invoice_cancellation ||
291+
"Data Entry Mistake",
304292
options: ["Duplicate", "Data Entry Mistake", "Order Cancelled", "Others"],
305293
},
306294
{

india_compliance/gst_india/client_scripts/e_waybill_actions.js

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,12 @@ function setup_e_waybill_actions(doctype) {
221221
return;
222222
}
223223

224-
(async () => {
225-
const auto_cancel_e_waybill = await frappe.db.get_single_value("GST Settings", "auto_cancel_e_waybill");
226-
if (auto_cancel_e_waybill === 1) {
227-
continueCancellation()
228-
return
229-
}
230-
return show_cancel_e_waybill_dialog(frm, continueCancellation);
231-
})();
224+
if (gst_settings.auto_cancel_e_waybill === 1) {
225+
continueCancellation();
226+
return;
227+
}
228+
229+
return show_cancel_e_waybill_dialog(frm, continueCancellation);
232230
});
233231
},
234232
});
@@ -716,7 +714,6 @@ function show_cancel_e_waybill_dialog(frm, callback) {
716714

717715
india_compliance.primary_to_danger_btn(d);
718716
d.show();
719-
update_reason_for_e_invoice_cancellation(d);
720717
}
721718

722719
function show_mark_e_waybill_as_cancelled_dialog(frm) {
@@ -750,15 +747,6 @@ function show_mark_e_waybill_as_cancelled_dialog(frm) {
750747
});
751748

752749
d.show();
753-
update_reason_for_e_invoice_cancellation(d);
754-
}
755-
756-
async function update_reason_for_e_invoice_cancellation(d){
757-
const auto_cancel_e_waybill = await frappe.db.get_single_value("GST Settings", "auto_cancel_e_waybill");
758-
if (auto_cancel_e_waybill) {
759-
const reason = await frappe.db.get_single_value("GST Settings", "reason_for_e_waybill_cancellation");
760-
d.get_field("reason").set_value(reason);
761-
}
762750
}
763751

764752
function get_cancel_e_waybill_dialog_fields(frm) {
@@ -775,7 +763,8 @@ function get_cancel_e_waybill_dialog_fields(frm) {
775763
fieldname: "reason",
776764
fieldtype: "Select",
777765
reqd: 1,
778-
default: "Data Entry Mistake",
766+
default:
767+
gst_settings.reason_for_e_waybill_cancellation || "Data Entry Mistake",
779768
options: ["Duplicate", "Order Cancelled", "Data Entry Mistake", "Others"],
780769
},
781770
{

india_compliance/gst_india/doctype/gst_settings/gst_settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@
657657
"fieldtype": "Select",
658658
"label": "Default Reason for e-Waybill Cancellation",
659659
"mandatory_depends_on": "eval: doc.auto_cancel_e_waybill",
660-
"options": "Duplicate\nOrder Cancelled\nData Entry Mistake"
660+
"options": "Duplicate\nOrder Cancelled\nData Entry Mistake",
661+
"read_only_depends_on": "eval: doc.enable_e_invoice"
661662
},
662663
{
663664
"default": "Data Entry Mistake",
@@ -672,7 +673,7 @@
672673
"index_web_pages_for_search": 1,
673674
"issingle": 1,
674675
"links": [],
675-
"modified": "2024-12-06 12:43:06.963007",
676+
"modified": "2024-12-12 19:09:07.185191",
676677
"modified_by": "Administrator",
677678
"module": "GST India",
678679
"name": "GST Settings",

india_compliance/gst_india/overrides/sales_invoice.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def on_submit(doc, method=None):
187187

188188

189189
def before_cancel(doc, method=None):
190-
cancel_e_documents(doc)
190+
cancel_e_waybill_e_invoice(doc)
191191
if ignore_gst_validations(doc):
192192
return
193193

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

214214

215-
def cancel_e_documents(doc, method=None):
216-
if (
217-
not frappe.form_dict
218-
or frappe.form_dict.cmd.endswith("cancel_e_invoice")
219-
or frappe.form_dict.cmd.endswith("cancel_e_waybill")
220-
):
221-
return
222-
215+
def cancel_e_waybill_e_invoice(doc, method=None):
223216
gst_settings = frappe.get_cached_doc("GST Settings")
224217

225218
if not is_api_enabled(gst_settings):

0 commit comments

Comments
 (0)