mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-28 09:24:45 +00:00
feat: add client id & client secret fields in e invoice settings
This commit is contained in:
@@ -9,6 +9,10 @@
|
|||||||
"section_break_2",
|
"section_break_2",
|
||||||
"sandbox_mode",
|
"sandbox_mode",
|
||||||
"credentials",
|
"credentials",
|
||||||
|
"advanced_settings_section",
|
||||||
|
"client_id",
|
||||||
|
"column_break_8",
|
||||||
|
"client_secret",
|
||||||
"auth_token",
|
"auth_token",
|
||||||
"token_expiry"
|
"token_expiry"
|
||||||
],
|
],
|
||||||
@@ -48,12 +52,32 @@
|
|||||||
"fieldname": "sandbox_mode",
|
"fieldname": "sandbox_mode",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Sandbox Mode"
|
"label": "Sandbox Mode"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-01-13 12:04:49.449199",
|
"modified": "2021-11-16 19:50:28.029517",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Regional",
|
"module": "Regional",
|
||||||
"name": "E Invoice Settings",
|
"name": "E Invoice Settings",
|
||||||
|
|||||||
@@ -460,7 +460,11 @@ def make_einvoice(invoice):
|
|||||||
except Exception:
|
except Exception:
|
||||||
show_link_to_error_log(invoice, einvoice)
|
show_link_to_error_log(invoice, einvoice)
|
||||||
|
|
||||||
validate_totals(einvoice)
|
try:
|
||||||
|
validate_totals(einvoice)
|
||||||
|
except Exception:
|
||||||
|
log_error(einvoice)
|
||||||
|
raise
|
||||||
|
|
||||||
return einvoice
|
return einvoice
|
||||||
|
|
||||||
@@ -609,10 +613,17 @@ class GSPConnector():
|
|||||||
request_log.save(ignore_permissions=True)
|
request_log.save(ignore_permissions=True)
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
|
def get_client_credentials(self):
|
||||||
|
if self.e_invoice_settings.client_id and self.e_invoice_settings.client_secret:
|
||||||
|
return self.e_invoice_settings.client_id, self.e_invoice_settings.get_password('client_secret')
|
||||||
|
|
||||||
|
return frappe.conf.einvoice_client_id, frappe.conf.einvoice_client_secret
|
||||||
|
|
||||||
def fetch_auth_token(self):
|
def fetch_auth_token(self):
|
||||||
|
client_id, client_secret = self.get_client_credentials()
|
||||||
headers = {
|
headers = {
|
||||||
'gspappid': frappe.conf.einvoice_client_id,
|
'gspappid': client_id,
|
||||||
'gspappsecret': frappe.conf.einvoice_client_secret
|
'gspappsecret': client_secret
|
||||||
}
|
}
|
||||||
res = {}
|
res = {}
|
||||||
try:
|
try:
|
||||||
@@ -852,7 +863,7 @@ class GSPConnector():
|
|||||||
if errors:
|
if errors:
|
||||||
throw_error_list(errors, title)
|
throw_error_list(errors, title)
|
||||||
else:
|
else:
|
||||||
link_to_error_list = '<a href="desk#List/Error Log/List?method=E Invoice Request Failed">Error Log</a>'
|
link_to_error_list = '<a href="desk#List/Error Log/List?method=E Invoice Request Failed" target="_blank">Error Log</a>'
|
||||||
frappe.msgprint(
|
frappe.msgprint(
|
||||||
_('An error occurred while making e-invoicing request. Please check {} for more information.').format(link_to_error_list),
|
_('An error occurred while making e-invoicing request. Please check {} for more information.').format(link_to_error_list),
|
||||||
title=title,
|
title=title,
|
||||||
|
|||||||
Reference in New Issue
Block a user