You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the sales_invoice_validate() method, an error is thrown only if both company_tax_id and company_fiscal_code are missing. This allows invoices to proceed if at least one of these fields is set. and in the get_progressive_name_and_number() method, the company_tax_id is accessed without a fallback mechanism, leading to runtime errors if it is not set.
if not doc.company_tax_id and not doc.company_fiscal_code:
frappe.throw(
_("Please set either the Tax ID or Fiscal Code on Company '%s'" % doc.company),
title=_("E-Invoicing Information Missing"),
)
company_tax_id = doc.company_tax_id if doc.company_tax_id.startswith("IT") else "IT" + doc.company_tax_id
Steps to Reproduce:
Create a company in the Italian regional setup without setting a tax_id but with a fiscal_code.
Create a sales invoice for this company.
Validation does not raise any error in sales_invoice_validate() since the fiscal_code is set.
During submission of the sales invoice it triggers get_progressive_name_and_number() method.
A runtime error occurs because company_tax_id is accessed directly without checking its existence.
Suggested Solution
Throw an error if company_tax_id is not present during validation.
Handle get_progressive_name_and_number() method by including either company_fiscal_code or tax_id
company_tax_id = doc.company_tax_id if doc.company_tax_id and doc.company_tax_id.startswith("IT") else "IT" + (doc.company_tax_id or doc.tax_id)
if not company_tax_id:
frappe.throw(
_("Company Tax ID is required to generate the progressive name."),
title=_("Missing Information")
)
Module
regional
Version
Frappe Version - Version-15
ERPNext Version - Version-15
Installation method
None
Relevant log output / Stack trace / Full Error Message.
The text was updated successfully, but these errors were encountered:
Information about bug
Adding an Issue and not a PR since I am unsure about the legal side.
Issue
In the current implementation of e-invoicing for Italy, the company_tax_id is not being handled properly.
https://github.com/frappe/erpnext/blob/43ce185429ad125d76379e5a98179181627e2d8e/erpnext/regional/italy/utils.py#L264
In the sales_invoice_validate() method, an error is thrown only if both company_tax_id and company_fiscal_code are missing. This allows invoices to proceed if at least one of these fields is set. and in the get_progressive_name_and_number() method, the company_tax_id is accessed without a fallback mechanism, leading to runtime errors if it is not set.
https://github.com/frappe/erpnext/blob/43ce185429ad125d76379e5a98179181627e2d8e/erpnext/regional/italy/utils.py#L469
company_tax_id = doc.company_tax_id if doc.company_tax_id.startswith("IT") else "IT" + doc.company_tax_id
Steps to Reproduce:
Suggested Solution
Module
regional
Version
Frappe Version - Version-15
ERPNext Version - Version-15
Installation method
None
Relevant log output / Stack trace / Full Error Message.
The text was updated successfully, but these errors were encountered: