diff --git a/erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html b/erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html
index 15ea1c21744..a900711af1b 100644
--- a/erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html
+++ b/erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html
@@ -92,8 +92,8 @@
-
- {% for item in einvoice.ItemList %}
+ {% for item in einvoice.ItemList %}
+
| {{ item.SlNo }} |
{{ item.PrdDesc }} |
{{ item.HsnCd }} |
@@ -105,8 +105,8 @@
{{ item.GstRt + item.CesRt }} % |
{{ frappe.utils.fmt_money(0, None, "INR") }} |
{{ frappe.utils.fmt_money(item.TotItemVal, None, "INR") }} |
- {% endfor %}
-
+
+ {% endfor %}
diff --git a/erpnext/regional/india/e_invoice/e_invoice_utils.py b/erpnext/regional/india/e_invoice/e_invoice_utils.py
index fe48bbe0af4..649f5eb9f3e 100644
--- a/erpnext/regional/india/e_invoice/e_invoice_utils.py
+++ b/erpnext/regional/india/e_invoice/e_invoice_utils.py
@@ -473,7 +473,7 @@ def make_einvoice(doctype, name):
else:
frappe.throw(error_msgs[0], title=_('E Invoice Validation Failed'))
- return json.dumps(einvoice)
+ return {'einvoice': json.dumps([einvoice])}
def validate_einvoice(validations, einvoice, error_msgs=[]):
type_map = { 'string': 'str', 'number': 'int', 'object': 'dict', 'array': 'list' }
@@ -503,8 +503,10 @@ def validate_einvoice(validations, einvoice, error_msgs=[]):
continue
# convert to int or str
- function = eval('c' + should_be_of_type)
- einvoice[field] = function(invoice_value)
+ if should_be_of_type == 'str':
+ einvoice[field] = str(invoice_value)
+ elif should_be_of_type == 'int':
+ einvoice[field] = flt(invoice_value, 3)
max_length = validation.get('maxLength')
minimum = flt(validation.get('minimum'))
@@ -527,6 +529,12 @@ def update_einvoice_fields(doctype, name, signed_einvoice):
enc_signed_invoice = signed_einvoice.get('SignedInvoice')
decrypted_signed_invoice = jwt_decrypt(enc_signed_invoice)['data']
+ if json.loads(decrypted_signed_invoice)['DocDtls']['No'] != name:
+ frappe.throw(
+ _("Document number of uploaded Signed E-Invoice doesn't matches with Sales Invoice"),
+ title=_("Inappropriate E-Invoice")
+ )
+
frappe.db.set_value(doctype, name, 'irn', signed_einvoice.get('Irn'))
frappe.db.set_value(doctype, name, 'ewaybill', signed_einvoice.get('EwbNo'))
frappe.db.set_value(doctype, name, 'signed_qr_code', signed_einvoice.get('SignedQRCode').split('.')[1])
@@ -551,6 +559,7 @@ def upload_einvoice():
name = data['docname']
update_einvoice_fields(doctype, name, signed_einvoice)
+ attach_qrcode_image(doctype, name)
@frappe.whitelist()
def download_cancel_einvoice():
diff --git a/erpnext/regional/india/e_invoice/einvoice.js b/erpnext/regional/india/e_invoice/einvoice.js
index bcdd6ef02ff..7373e831b0c 100644
--- a/erpnext/regional/india/e_invoice/einvoice.js
+++ b/erpnext/regional/india/e_invoice/einvoice.js
@@ -9,197 +9,197 @@ 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"),
- () => {
- frappe.call({
- method: 'erpnext.regional.india.e_invoice.e_invoice_utils.generate_irn',
- args: { doctype: doctype, name: name },
- freeze: true,
- callback: () => frm.reload_doc()
- })
- },
- __("E Invoicing")
- );
- }
-
- if (docstatus == 1 && irn && !irn_cancelled) {
- frm.add_custom_button(
- __("Cancel IRN"),
- () => {
- 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 d = new frappe.ui.Dialog({
- title: __("Cancel IRN"),
- fields: fields,
- primary_action: function() {
- const data = d.get_values();
- frappe.call({
- method: 'erpnext.regional.india.e_invoice.e_invoice_utils.cancel_irn',
- args: {
- doctype: doctype,
- name: name,
- irn: irn,
- reason: data.reason.split('-')[0],
- remark: data.remark
- },
- freeze: true,
- callback: () => frm.reload_doc() || d.hide(),
- error: () => d.hide()
- });
- },
- primary_action_label: __('Submit')
- });
- d.show();
- },
- __("E Invoicing")
- )
- }
-
- if (docstatus == 1 && irn && !irn_cancelled && !eway_bill_cancelled) {
- frm.add_custom_button(
- __("Cancel E-Way Bill"),
- () => {
- 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 d = new frappe.ui.Dialog({
- title: __('Cancel E-Way Bill'),
- fields: fields,
- primary_action: function() {
- const data = d.get_values();
- frappe.call({
- method: 'erpnext.regional.india.e_invoice.e_invoice_utils.cancel_eway_bill',
- args: {
- doctype: doctype,
- name: name,
- eway_bill: ewaybill,
- reason: data.reason.split('-')[0],
- remark: data.remark
- },
- freeze: true,
- callback: () => frm.reload_doc() || d.hide(),
- error: () => d.hide()
- })
- },
- primary_action_label: __('Submit')
- });
- d.show();
- },
- __("E Invoicing")
- );
- }
-
- // if (frm.doc.docstatus == 0 && !frm.doc.irn && !frm.doc.__unsaved) {
+ // if (docstatus == 0 && !irn && !__unsaved) {
// frm.add_custom_button(
- // "Download E-Invoice",
+ // _("Generate IRN"),
// () => {
// frappe.call({
- // method: 'erpnext.regional.india.e_invoice.e_invoice_utils.make_einvoice',
- // args: { doctype: frm.doc.doctype, name: frm.doc.name },
+ // method: 'erpnext.regional.india.e_invoice.e_invoice_utils.generate_irn',
+ // args: { doctype: doctype, name: name },
// freeze: true,
- // callback: (res) => {
- // if (!res.exc) {
- // const args = {
- // cmd: 'erpnext.regional.india.e_invoice.e_invoice_utils.download_einvoice',
- // einvoice: res.message.einvoice,
- // name: frm.doc.name
- // };
- // open_url_post(frappe.request.url, args);
- // }
- // }
+ // callback: () => frm.reload_doc()
// })
- // }, "E-Invoicing");
- // frm.add_custom_button(
- // "Upload Signed E-Invoice",
- // () => {
- // new frappe.ui.FileUploader({
- // method: 'erpnext.regional.india.e_invoice.e_invoice_utils.upload_einvoice',
- // allow_multiple: 0,
- // doctype: frm.doc.doctype,
- // docname: frm.doc.name,
- // on_success: (attachment, r) => {
- // if (!r.exc) {
- // frm.reload_doc();
- // }
- // }
- // });
- // }, "E-Invoicing");
+ // },
+ // __("E Invoicing")
+ // );
// }
- // if (frm.doc.docstatus == 1 && frm.doc.irn && !frm.doc.irn_cancelled) {
+
+ // if (docstatus == 1 && irn && !irn_cancelled) {
// frm.add_custom_button(
- // "Cancel IRN",
+ // __("Cancel IRN"),
// () => {
+ // 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 d = new frappe.ui.Dialog({
- // title: __('Cancel IRN'),
- // 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
- // }
- // ],
+ // title: __("Cancel IRN"),
+ // fields: fields,
// primary_action: function() {
// const data = d.get_values();
- // const args = {
- // cmd: 'erpnext.regional.india.e_invoice.e_invoice_utils.download_cancel_einvoice',
- // irn: frm.doc.irn, reason: data.reason.split('-')[0], remark: data.remark, name: frm.doc.name
- // };
- // open_url_post(frappe.request.url, args);
- // d.hide();
+ // frappe.call({
+ // method: 'erpnext.regional.india.e_invoice.e_invoice_utils.cancel_irn',
+ // args: {
+ // doctype: doctype,
+ // name: name,
+ // irn: irn,
+ // reason: data.reason.split('-')[0],
+ // remark: data.remark
+ // },
+ // freeze: true,
+ // callback: () => frm.reload_doc() || d.hide(),
+ // error: () => d.hide()
+ // });
// },
- // primary_action_label: __('Download JSON')
+ // primary_action_label: __('Submit')
// });
// d.show();
- // }, "E-Invoicing");
-
- // frm.add_custom_button(
- // "Upload Cancel JSON",
- // () => {
- // new frappe.ui.FileUploader({
- // method: 'erpnext.regional.india.e_invoice.e_invoice_utils.upload_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");
+ // },
+ // __("E Invoicing")
+ // )
// }
+
+ // if (docstatus == 1 && irn && !irn_cancelled && !eway_bill_cancelled) {
+ // frm.add_custom_button(
+ // __("Cancel E-Way Bill"),
+ // () => {
+ // 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 d = new frappe.ui.Dialog({
+ // title: __('Cancel E-Way Bill'),
+ // fields: fields,
+ // primary_action: function() {
+ // const data = d.get_values();
+ // frappe.call({
+ // method: 'erpnext.regional.india.e_invoice.e_invoice_utils.cancel_eway_bill',
+ // args: {
+ // doctype: doctype,
+ // name: name,
+ // eway_bill: ewaybill,
+ // reason: data.reason.split('-')[0],
+ // remark: data.remark
+ // },
+ // freeze: true,
+ // callback: () => frm.reload_doc() || d.hide(),
+ // error: () => d.hide()
+ // })
+ // },
+ // primary_action_label: __('Submit')
+ // });
+ // d.show();
+ // },
+ // __("E Invoicing")
+ // );
+ // }
+
+ if (docstatus == 0 && !irn && !__unsaved) {
+ frm.add_custom_button(
+ "Download E-Invoice",
+ () => {
+ frappe.call({
+ method: 'erpnext.regional.india.e_invoice.e_invoice_utils.make_einvoice',
+ args: { doctype, name },
+ freeze: true,
+ callback: (res) => {
+ if (!res.exc) {
+ const args = {
+ cmd: 'erpnext.regional.india.e_invoice.e_invoice_utils.download_einvoice',
+ einvoice: res.message.einvoice,
+ name: name
+ };
+ open_url_post(frappe.request.url, args);
+ }
+ }
+ })
+ }, "E-Invoicing");
+ frm.add_custom_button(
+ "Upload Signed E-Invoice",
+ () => {
+ new frappe.ui.FileUploader({
+ method: 'erpnext.regional.india.e_invoice.e_invoice_utils.upload_einvoice',
+ allow_multiple: 0,
+ doctype: doctype,
+ docname: name,
+ on_success: (attachment, r) => {
+ if (!r.exc) {
+ frm.reload_doc();
+ }
+ }
+ });
+ }, "E-Invoicing");
+ }
+ if (docstatus == 1 && irn && !irn_cancelled) {
+ frm.add_custom_button(
+ "Cancel IRN",
+ () => {
+ const d = new frappe.ui.Dialog({
+ title: __('Cancel IRN'),
+ 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
+ }
+ ],
+ primary_action: function() {
+ const data = d.get_values();
+ const args = {
+ cmd: 'erpnext.regional.india.e_invoice.e_invoice_utils.download_cancel_einvoice',
+ irn: irn, reason: data.reason.split('-')[0], remark: data.remark, name: name
+ };
+ open_url_post(frappe.request.url, args);
+ d.hide();
+ },
+ primary_action_label: __('Download JSON')
+ });
+ d.show();
+ }, "E-Invoicing");
+
+ frm.add_custom_button(
+ "Upload Cancel JSON",
+ () => {
+ new frappe.ui.FileUploader({
+ method: 'erpnext.regional.india.e_invoice.e_invoice_utils.upload_cancel_ack',
+ allow_multiple: 0,
+ doctype: doctype,
+ docname: name,
+ on_success: (attachment, r) => {
+ if (!r.exc) {
+ frm.reload_doc();
+ }
+ }
+ });
+ }, "E-Invoicing");
+ }
}
})
}
\ No newline at end of file