mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-07 07:20:26 +00:00
Merge pull request #30401 from nextchamp-saqib/add-client-cred-fields-einvoicing
feat: add client id & client secret fields in e invoice settings
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
"section_break_2",
|
||||
"sandbox_mode",
|
||||
"credentials",
|
||||
"advanced_settings_section",
|
||||
"client_id",
|
||||
"column_break_8",
|
||||
"client_secret",
|
||||
"auth_token",
|
||||
"token_expiry"
|
||||
],
|
||||
@@ -48,12 +52,32 @@
|
||||
"fieldname": "sandbox_mode",
|
||||
"fieldtype": "Check",
|
||||
"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,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2021-01-13 12:04:49.449199",
|
||||
"modified": "2021-11-16 19:50:28.029517",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Regional",
|
||||
"name": "E Invoice Settings",
|
||||
|
||||
@@ -460,7 +460,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
|
||||
|
||||
@@ -609,10 +613,17 @@ class GSPConnector():
|
||||
request_log.save(ignore_permissions=True)
|
||||
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):
|
||||
client_id, client_secret = self.get_client_credentials()
|
||||
headers = {
|
||||
'gspappid': frappe.conf.einvoice_client_id,
|
||||
'gspappsecret': frappe.conf.einvoice_client_secret
|
||||
'gspappid': client_id,
|
||||
'gspappsecret': client_secret
|
||||
}
|
||||
res = {}
|
||||
try:
|
||||
@@ -852,7 +863,7 @@ class GSPConnector():
|
||||
if errors:
|
||||
throw_error_list(errors, title)
|
||||
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(
|
||||
_('An error occurred while making e-invoicing request. Please check {} for more information.').format(link_to_error_list),
|
||||
title=title,
|
||||
|
||||
Reference in New Issue
Block a user