chore: clean up einvoice actions

This commit is contained in:
Saqib Ansari
2020-11-04 11:54:01 +05:30
parent 778141c569
commit 63bfa30bc1

View File

@@ -10,24 +10,19 @@ erpnext.setup_einvoice_actions = (doctype) => {
const { docstatus, irn, irn_cancelled, ewaybill, eway_bill_cancelled, doctype, name, __unsaved } = frm.doc;
if (docstatus == 0 && !irn && !__unsaved) {
frm.add_custom_button(
__("Generate IRN"),
() => {
const action = () => {
frappe.call({
method: 'erpnext.regional.india.e_invoice.utils.generate_irn',
args: { doctype: doctype, name: name },
freeze: true,
callback: () => frm.reload_doc()
})
},
__("E Invoicing")
);
};
frm.add_custom_button(__("Generate IRN"), action, __('E Invoicing'));
}
if (docstatus == 1 && irn && !irn_cancelled) {
frm.add_custom_button(
__("Cancel IRN"),
() => {
const fields = [
{
"label" : "Reason",
@@ -44,6 +39,7 @@ erpnext.setup_einvoice_actions = (doctype) => {
"reqd": 1
}
];
const action = () => {
const d = new frappe.ui.Dialog({
title: __("Cancel IRN"),
fields: fields,
@@ -66,15 +62,11 @@ erpnext.setup_einvoice_actions = (doctype) => {
primary_action_label: __('Submit')
});
d.show();
},
__("E Invoicing")
)
};
frm.add_custom_button(__("Cancel IRN"), action, __("E Invoicing"));
}
if (docstatus == 1 && irn && !irn_cancelled && !eway_bill_cancelled) {
frm.add_custom_button(
__("Cancel E-Way Bill"),
() => {
const fields = [
{
"label" : "Reason",
@@ -90,7 +82,8 @@ erpnext.setup_einvoice_actions = (doctype) => {
"fieldtype": "Data",
"reqd": 1
}
]
];
const action = () => {
const d = new frappe.ui.Dialog({
title: __('Cancel E-Way Bill'),
fields: fields,
@@ -113,9 +106,8 @@ erpnext.setup_einvoice_actions = (doctype) => {
primary_action_label: __('Submit')
});
d.show();
},
__("E Invoicing")
);
};
frm.add_custom_button(__("Cancel E-Way Bill"), action, __("E Invoicing"));
}
}
})