E-Invoicing in ERPNext v13 - Setup Queries & Errors

Hello Guys,

I have an immediate requirement from my client to use the E-Invoicing feature in ERPNext.

The application is a self-hosted on Linux Server, Ubuntu v20.04 with the following below version:

ERPNext: v13.40.3 (version-13)

Frappe Framework: v13.42.0 (version-13)

I have followed the official documentation and have setup accordingly.

Documentation Link: E-Invoicing under GST

But after the setup, when I tried to generate the IRN, the system is giving me 3 different errors.

E-Invoice error message

I addition to this when I searched through forum, I found something from the below links that we need to signup in Adaequare, wherein we will be provided with the information on how to setup an app and get the Client ID and Client Secret.
How to setup E-Invoicing
[E-Invoicing][India][Guide] Setup Adequare GSP’s E-Invoicing Services in ERPNext

Can anyone please let me know the link to the Adaequare site, and also would like to know if there is any charges related to their services.

If anyone has setup E-Invoicing successfully on v13, please help me with this issue. Also the steps which you have followed to achieve it.

Below are the errors that I got from the Error Log.

Error 1:

Error
'NoneType' object has no attribute 'get'
----------------------------------------------------------------------------------------------------
Data:
null
----------------------------------------------------------------------------------------------------
Exception:
Traceback (most recent call last):
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 900, in make_request
    res = make_post_request(url, headers=headers, data=data)
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/integrations/utils.py", line 42, in make_post_request
    return make_request("POST", url, **kwargs)
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/integrations/utils.py", line 34, in make_request
    raise exc
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/integrations/utils.py", line 26, in make_request
    frappe.flags.integration_request.raise_for_status()
  File "/home/medtrix-frappe/frappe-bench/env/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error:  for url: https://gsp.adaequare.com/gsp/authenticate?grant_type=token

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 946, in fetch_auth_token
    res.get("token_type"), res.get("access_token")
AttributeError: 'NoneType' object has no attribute 'get'

Error 2:

Error
An error occurred while making e-invoicing request. Please check <a href="/app/error-log" target="_blank">Error Log</a> for more information.
----------------------------------------------------------------------------------------------------
Data:
{}
----------------------------------------------------------------------------------------------------
Exception:
Traceback (most recent call last):
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 900, in make_request
    res = make_post_request(url, headers=headers, data=data)
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/integrations/utils.py", line 42, in make_post_request
    return make_request("POST", url, **kwargs)
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/integrations/utils.py", line 34, in make_request
    raise exc
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/integrations/utils.py", line 26, in make_request
    frappe.flags.integration_request.raise_for_status()
  File "/home/medtrix-frappe/frappe-bench/env/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error:  for url: https://gsp.adaequare.com/gsp/authenticate?grant_type=token

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 946, in fetch_auth_token
    res.get("token_type"), res.get("access_token")
AttributeError: 'NoneType' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 944, in fetch_auth_token
    res = self.make_request("post", self.authenticate_url, headers)
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 906, in make_request
    self.auto_refresh_token()
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 915, in auto_refresh_token
    self.fetch_auth_token()
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 954, in fetch_auth_token
    self.raise_error(True)
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 1366, in raise_error
    frappe.msgprint(
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 479, in msgprint
    _raise_exception()
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 436, in _raise_exception
    raise ValidationError(msg)
frappe.exceptions.ValidationError: An error occurred while making e-invoicing request. Please check <a href="/app/error-log" target="_blank">Error Log</a> for more information.

Error 3:

Error
An error occurred while making e-invoicing request. Please check <a href="/app/error-log" target="_blank">Error Log</a> for more information.
----------------------------------------------------------------------------------------------------
Data:
{}
----------------------------------------------------------------------------------------------------
Exception:
Traceback (most recent call last):
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 900, in make_request
    res = make_post_request(url, headers=headers, data=data)
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/integrations/utils.py", line 42, in make_post_request
    return make_request("POST", url, **kwargs)
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/integrations/utils.py", line 34, in make_request
    raise exc
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/integrations/utils.py", line 26, in make_request
    frappe.flags.integration_request.raise_for_status()
  File "/home/medtrix-frappe/frappe-bench/env/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error:  for url: https://gsp.adaequare.com/gsp/authenticate?grant_type=token

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 946, in fetch_auth_token
    res.get("token_type"), res.get("access_token")
AttributeError: 'NoneType' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 944, in fetch_auth_token
    res = self.make_request("post", self.authenticate_url, headers)
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 906, in make_request
    self.auto_refresh_token()
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 915, in auto_refresh_token
    self.fetch_auth_token()
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 954, in fetch_auth_token
    self.raise_error(True)
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 1366, in raise_error
    frappe.msgprint(
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 479, in msgprint
    _raise_exception()
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 436, in _raise_exception
    raise ValidationError(msg)
frappe.exceptions.ValidationError: An error occurred while making e-invoicing request. Please check <a href="/app/error-log" target="_blank">Error Log</a> for more information.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 1002, in generate_irn
    headers = self.get_headers()
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 962, in get_headers
    "authorization": self.get_auth_token(),
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 892, in get_auth_token
    self.fetch_auth_token()
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 954, in fetch_auth_token
    self.raise_error(True)
  File "/home/medtrix-frappe/frappe-bench/apps/erpnext/erpnext/regional/india/e_invoice/utils.py", line 1366, in raise_error
    frappe.msgprint(
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 479, in msgprint
    _raise_exception()
  File "/home/medtrix-frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 436, in _raise_exception
    raise ValidationError(msg)
frappe.exceptions.ValidationError: An error occurred while making e-invoicing request. Please check <a href="/app/error-log" target="_blank">Error Log</a> for more information.

Thanks & Regards,
Sujay

Hello guys,

Any update on this??

Hello guys,

I have purchased an API subscription from Adaequare.

I have created an App in the Adaequare portal and got the Client ID & Client Secret.

In the E-Invoice Settings, I have made the following below setup:

  1. Sandbox: Enabled
  2. Credentials Table:
  • Company: Selected from Company master
  • GSTIN: Provided by Adaquare for testing purpose
  • Username: Provided by Adaquare for testing purpose
  • Password: Provided by Adaquare for testing purpose
  1. Advanced Settings:
  • Client ID: From the app created in Adaquare portal
  • Client Secret: From the app created in Adaquare portal

After this I tried to generate IRN , it is giving me the below error:

E-invoice credentials error

From this link: [E-Invoicing][India][Guide] Setup Adequare GSP’s E-Invoicing Services in ERPNext it says - The sandbox GSTIN used in the E-Invoice Settings (eg. 01AMBPXXXXXXXXX) needs to be saved into the company address GSTIN field as well. But if we try to edit the GSTIN in the company master address, it gives the invalid GST error.

Can anyone please help me to solve this issue. Has anyone successfully used the Sandbox mode in ERPNext??

Thanks & Regards,
Sujay

Hi,

Remove the username and password added in GST settings at ERPNext. Now make sure that u have API user name which may start from API_xxxx and credentials given to API user.

Add these details again on GST setting and make sure to add correct GSTN, API user name and API user name password.

This should be working.

Hi @Rakesh_Chougule,

I tried as follows:

In the E-invoice settings:

  • Company: Selected company from the company master
  • GSTIN: Entered the actual company GSTIN
  • Username: API_username (username provided by Adaequare sandbox testing)
  • Password: password provided by Adaequare sandbox testing

After this I tried to generate IRN, and it gave me an error as mentioned below;

Error Message: * Incorrect user id/User does not exists