diff --git a/erpnext/regional/doctype/e_invoice_settings/e_invoice_settings.json b/erpnext/regional/doctype/e_invoice_settings/e_invoice_settings.json
index 68ed3391d04..16b29633010 100644
--- a/erpnext/regional/doctype/e_invoice_settings/e_invoice_settings.json
+++ b/erpnext/regional/doctype/e_invoice_settings/e_invoice_settings.json
@@ -10,6 +10,10 @@
"sandbox_mode",
"applicable_from",
"credentials",
+ "advanced_settings_section",
+ "client_id",
+ "column_break_8",
+ "client_secret",
"auth_token",
"token_expiry"
],
@@ -56,12 +60,32 @@
"in_list_view": 1,
"label": "Applicable From",
"reqd": 1
+ },
+ {
+ "collapsible": 1,
+ "fieldname": "advanced_settings_section",
+ "fieldtype": "Section Break",
+ "label": "Advanced Settings"
+ },
+ {
+ "fieldname": "client_id",
+ "fieldtype": "Data",
+ "label": "Client ID"
+ },
+ {
+ "fieldname": "client_secret",
+ "fieldtype": "Password",
+ "label": "Client Secret"
+ },
+ {
+ "fieldname": "column_break_8",
+ "fieldtype": "Column Break"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
- "modified": "2021-03-30 12:26:25.538294",
+ "modified": "2021-11-16 19:50:28.029517",
"modified_by": "Administrator",
"module": "Regional",
"name": "E Invoice Settings",
diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py
index b0b40758ab0..1e329d41702 100644
--- a/erpnext/regional/india/e_invoice/utils.py
+++ b/erpnext/regional/india/e_invoice/utils.py
@@ -151,6 +151,10 @@ def validate_address_fields(address, skip_gstin_validation):
title=_('Missing Address Fields')
)
+ if address.address_line2 and len(address.address_line2) < 2:
+ # to prevent "The field Address 2 must be a string with a minimum length of 3 and a maximum length of 100"
+ address.address_line2 = ""
+
def get_party_details(address_name, skip_gstin_validation=False):
addr = frappe.get_doc('Address', address_name)
@@ -402,6 +406,12 @@ def validate_totals(einvoice):
if abs(flt(value_details['AssVal']) - total_item_ass_value) > 1:
frappe.throw(_('Total Taxable Value of the items is not equal to the Invoice Net Total. Please check item taxes / discounts for any correction.'))
+ if abs(flt(value_details['CgstVal']) + flt(value_details['SgstVal']) - total_item_cgst_value - total_item_sgst_value) > 1:
+ frappe.throw(_('CGST + SGST value of the items is not equal to total CGST + SGST value. Please review taxes for any correction.'))
+
+ if abs(flt(value_details['IgstVal']) - total_item_igst_value) > 1:
+ frappe.throw(_('IGST value of all items is not equal to total IGST value. Please review taxes for any correction.'))
+
if abs(flt(value_details['TotInvVal']) + flt(value_details['Discount']) - flt(value_details['OthChrg']) - total_item_value) > 1:
frappe.throw(_('Total Value of the items is not equal to the Invoice Grand Total. Please check item taxes / discounts for any correction.'))
@@ -475,7 +485,11 @@ def make_einvoice(invoice):
except Exception:
show_link_to_error_log(invoice, einvoice)
- validate_totals(einvoice)
+ try:
+ validate_totals(einvoice)
+ except Exception:
+ log_error(einvoice)
+ raise
return einvoice
@@ -629,9 +643,11 @@ class GSPConnector():
frappe.db.commit()
def fetch_auth_token(self):
+ client_id = self.e_invoice_settings.client_id or frappe.conf.einvoice_client_id
+ client_secret = self.e_invoice_settings.get_password('client_secret') or frappe.conf.einvoice_client_secret
headers = {
- 'gspappid': frappe.conf.einvoice_client_id,
- 'gspappsecret': frappe.conf.einvoice_client_secret
+ 'gspappid': client_id,
+ 'gspappsecret': client_secret
}
res = {}
try:
@@ -936,7 +952,7 @@ class GSPConnector():
if errors:
frappe.throw(errors, title=title, as_list=1)
else:
- link_to_error_list = 'Error Log'
+ link_to_error_list = 'Error Log'
frappe.msgprint(
_('An error occurred while making e-invoicing request. Please check {} for more information.').format(link_to_error_list),
title=title,