fix: StopIteration error when e-invoice not enabled (#24548)

* fix: StopIteration error when e-invoice not enabled

* chore: update message

Co-authored-by: Saqib <nextchamp.saqib@gmail.com>
This commit is contained in:
Afshan 2021-02-08 12:32:42 +05:30 committed by Nabin Hait
parent d60a40ae82
commit 33f4419a78

View File

@ -446,6 +446,8 @@ class GSPConnector():
def get_credentials(self):
if self.invoice:
gstin = self.get_seller_gstin()
if not self.e_invoice_settings.enable:
frappe.throw(_("E-Invoicing is disabled. Please enable it from {} to generate e-invoices.").format(get_link_to_form("E Invoice Settings", "E Invoice Settings")))
credentials = next(d for d in self.e_invoice_settings.credentials if d.gstin == gstin)
else:
credentials = self.e_invoice_settings.credentials[0] if self.e_invoice_settings.credentials else None
@ -816,4 +818,4 @@ def generate_eway_bill(doctype, docname, **kwargs):
@frappe.whitelist()
def cancel_eway_bill(doctype, docname, eway_bill, reason, remark):
gsp_connector = GSPConnector(doctype, docname)
gsp_connector.cancel_eway_bill(eway_bill, reason, remark)
gsp_connector.cancel_eway_bill(eway_bill, reason, remark)