mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 07:29:22 +00:00
chore: group e-invoicing actions
This commit is contained in:
@@ -464,7 +464,7 @@ def make_e_invoice(doctype, name):
|
|||||||
else:
|
else:
|
||||||
frappe.throw(_("{}").format(error_msgs[0]), title=_("E Invoice Validation Failed"))
|
frappe.throw(_("{}").format(error_msgs[0]), title=_("E Invoice Validation Failed"))
|
||||||
|
|
||||||
return {'einvoice': json.dumps(e_invoice)}
|
return {'einvoice': json.dumps([e_invoice])}
|
||||||
|
|
||||||
def validate_einvoice(validations, e_invoice, error_msgs=[]):
|
def validate_einvoice(validations, e_invoice, error_msgs=[]):
|
||||||
type_map = {
|
type_map = {
|
||||||
@@ -549,9 +549,18 @@ def download_cancel_einvoice():
|
|||||||
reason = data['reason']
|
reason = data['reason']
|
||||||
remark = data['remark']
|
remark = data['remark']
|
||||||
|
|
||||||
cancel_einvoice = json.dumps(dict(Irn=irn, CnlRsn=reason, CnlRem=remark))
|
cancel_einvoice = json.dumps([dict(Irn=irn, CnlRsn=reason, CnlRem=remark)])
|
||||||
|
|
||||||
frappe.response['filename'] = "Cancel E-Invoice " + name + ".json"
|
frappe.response['filename'] = "Cancel E-Invoice " + name + ".json"
|
||||||
frappe.response['filecontent'] = cancel_einvoice
|
frappe.response['filecontent'] = cancel_einvoice
|
||||||
frappe.response['content_type'] = 'application/json'
|
frappe.response['content_type'] = 'application/json'
|
||||||
frappe.response['type'] = 'download'
|
frappe.response['type'] = 'download'
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def download_cancel_ack():
|
||||||
|
cancel_ack = json.loads(frappe.local.uploaded_file)
|
||||||
|
data = frappe._dict(frappe.local.form_dict)
|
||||||
|
doctype = data['doctype']
|
||||||
|
name = data['docname']
|
||||||
|
|
||||||
|
frappe.db.set_value(doctype, name, "irn_cancelled", 1)
|
||||||
@@ -112,10 +112,7 @@ erpnext.setup_einvoice_actions = (doctype) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}, "E-Invoicing");
|
||||||
);
|
|
||||||
}
|
|
||||||
if (frm.doc.docstatus == 0 && !frm.doc.irn && !frm.doc.__unsaved) {
|
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
"Upload Signed E-Invoice",
|
"Upload Signed E-Invoice",
|
||||||
() => {
|
() => {
|
||||||
@@ -130,8 +127,7 @@ erpnext.setup_einvoice_actions = (doctype) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}, "E-Invoicing");
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (frm.doc.docstatus == 1 && frm.doc.irn && !frm.doc.irn_cancelled) {
|
if (frm.doc.docstatus == 1 && frm.doc.irn && !frm.doc.irn_cancelled) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
@@ -161,8 +157,22 @@ erpnext.setup_einvoice_actions = (doctype) => {
|
|||||||
primary_action_label: __('Download JSON')
|
primary_action_label: __('Download JSON')
|
||||||
});
|
});
|
||||||
d.show();
|
d.show();
|
||||||
}
|
}, "E-Invoicing");
|
||||||
);
|
frm.add_custom_button(
|
||||||
|
"Upload Cancel JSON",
|
||||||
|
() => {
|
||||||
|
new frappe.ui.FileUploader({
|
||||||
|
method: 'erpnext.regional.india.e_invoice_utils.download_cancel_ack',
|
||||||
|
allow_multiple: 0,
|
||||||
|
doctype: frm.doc.doctype,
|
||||||
|
docname: frm.doc.name,
|
||||||
|
on_success: (attachment, r) => {
|
||||||
|
if (!r.exc) {
|
||||||
|
frm.reload_doc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, "E-Invoicing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user