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>
diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py
index 4b6bc25..410c093 100644
--- a/erpnext/regional/india/e_invoice/utils.py
+++ b/erpnext/regional/india/e_invoice/utils.py
@@ -446,6 +446,8 @@
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 @@
@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)
\ No newline at end of file
+ gsp_connector.cancel_eway_bill(eway_bill, reason, remark)