feat(india): cancel e-way bill is enabled with e-invoicing APIs. (#30924)
This commit is contained in:
@@ -149,27 +149,58 @@ erpnext.setup_einvoice_actions = (doctype) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (irn && ewaybill && !irn_cancelled && !eway_bill_cancelled) {
|
if (irn && ewaybill && !irn_cancelled && !eway_bill_cancelled) {
|
||||||
|
const fields = [
|
||||||
|
{
|
||||||
|
"label": "Reason",
|
||||||
|
"fieldname": "reason",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"reqd": 1,
|
||||||
|
"default": "1-Duplicate",
|
||||||
|
"options": ["1-Duplicate", "2-Data Entry Error", "3-Order Cancelled", "4-Other"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Remark",
|
||||||
|
"fieldname": "remark",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"reqd": 1
|
||||||
|
}
|
||||||
|
];
|
||||||
const action = () => {
|
const action = () => {
|
||||||
let message = __('Cancellation of e-way bill is currently not supported.') + ' ';
|
const d = new frappe.ui.Dialog({
|
||||||
message += '<br><br>';
|
title: __('Cancel E-Way Bill'),
|
||||||
message += __('You must first use the portal to cancel the e-way bill and then update the cancelled status in the ERPNext system.');
|
fields: fields,
|
||||||
|
primary_action: function() {
|
||||||
const dialog = frappe.msgprint({
|
const data = d.get_values();
|
||||||
title: __('Update E-Way Bill Cancelled Status?'),
|
|
||||||
message: message,
|
|
||||||
indicator: 'orange',
|
|
||||||
primary_action: {
|
|
||||||
action: function() {
|
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: 'erpnext.regional.india.e_invoice.utils.cancel_eway_bill',
|
method: 'erpnext.regional.india.e_invoice.utils.cancel_eway_bill',
|
||||||
args: { doctype, docname: name },
|
args: {
|
||||||
freeze: true,
|
doctype,
|
||||||
callback: () => frm.reload_doc() || dialog.hide()
|
docname: name,
|
||||||
});
|
eway_bill: ewaybill,
|
||||||
}
|
reason: data.reason.split('-')[0],
|
||||||
|
remark: data.remark
|
||||||
},
|
},
|
||||||
primary_action_label: __('Yes')
|
freeze: true,
|
||||||
|
callback: () => {
|
||||||
|
frappe.show_alert({
|
||||||
|
message: __('E-Way Bill Cancelled successfully'),
|
||||||
|
indicator: 'green'
|
||||||
|
}, 7);
|
||||||
|
frm.reload_doc();
|
||||||
|
d.hide();
|
||||||
|
},
|
||||||
|
error: () => {
|
||||||
|
frappe.show_alert({
|
||||||
|
message: __('E-Way Bill was not Cancelled'),
|
||||||
|
indicator: 'red'
|
||||||
|
}, 7);
|
||||||
|
d.hide();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
primary_action_label: __('Submit')
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
};
|
};
|
||||||
add_custom_button(__("Cancel E-Way Bill"), action);
|
add_custom_button(__("Cancel E-Way Bill"), action);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -791,7 +791,7 @@ class GSPConnector:
|
|||||||
self.irn_details_url = self.base_url + "/enriched/ei/api/invoice/irn"
|
self.irn_details_url = self.base_url + "/enriched/ei/api/invoice/irn"
|
||||||
self.generate_irn_url = self.base_url + "/enriched/ei/api/invoice"
|
self.generate_irn_url = self.base_url + "/enriched/ei/api/invoice"
|
||||||
self.gstin_details_url = self.base_url + "/enriched/ei/api/master/gstin"
|
self.gstin_details_url = self.base_url + "/enriched/ei/api/master/gstin"
|
||||||
self.cancel_ewaybill_url = self.base_url + "/enriched/ewb/ewayapi?action=CANEWB"
|
self.cancel_ewaybill_url = self.base_url + "/enriched/ei/api/ewayapi"
|
||||||
self.generate_ewaybill_url = self.base_url + "/enriched/ei/api/ewaybill"
|
self.generate_ewaybill_url = self.base_url + "/enriched/ei/api/ewaybill"
|
||||||
|
|
||||||
def set_invoice(self):
|
def set_invoice(self):
|
||||||
@@ -1147,7 +1147,6 @@ class GSPConnector:
|
|||||||
headers = self.get_headers()
|
headers = self.get_headers()
|
||||||
data = json.dumps({"ewbNo": eway_bill, "cancelRsnCode": reason, "cancelRmrk": remark}, indent=4)
|
data = json.dumps({"ewbNo": eway_bill, "cancelRsnCode": reason, "cancelRmrk": remark}, indent=4)
|
||||||
headers["username"] = headers["user_name"]
|
headers["username"] = headers["user_name"]
|
||||||
del headers["user_name"]
|
|
||||||
try:
|
try:
|
||||||
res = self.make_request("post", self.cancel_ewaybill_url, headers, data)
|
res = self.make_request("post", self.cancel_ewaybill_url, headers, data)
|
||||||
if res.get("success"):
|
if res.get("success"):
|
||||||
@@ -1310,13 +1309,9 @@ def generate_eway_bill(doctype, docname, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def cancel_eway_bill(doctype, docname):
|
def cancel_eway_bill(doctype, docname, eway_bill, reason, remark):
|
||||||
# TODO: uncomment when eway_bill api from Adequare is enabled
|
gsp_connector = GSPConnector(doctype, docname)
|
||||||
# gsp_connector = GSPConnector(doctype, docname)
|
gsp_connector.cancel_eway_bill(eway_bill, reason, remark)
|
||||||
# gsp_connector.cancel_eway_bill(eway_bill, reason, remark)
|
|
||||||
|
|
||||||
frappe.db.set_value(doctype, docname, "ewaybill", "")
|
|
||||||
frappe.db.set_value(doctype, docname, "eway_bill_cancelled", 1)
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
|||||||
Reference in New Issue
Block a user