Merge pull request #17035 from gaurav-naik/issue-17033
fix(regional,italy): autoset tax id, cf from customer before validating
This commit is contained in:
commit
1271dea39b
@ -207,19 +207,25 @@ def sales_invoice_validate(doc):
|
|||||||
else:
|
else:
|
||||||
doc.company_fiscal_regime = company_fiscal_regime
|
doc.company_fiscal_regime = company_fiscal_regime
|
||||||
|
|
||||||
|
doc.company_tax_id = frappe.get_cached_value("Company", doc.company, 'tax_id')
|
||||||
|
doc.company_fiscal_code = frappe.get_cached_value("Company", doc.company, 'fiscal_code')
|
||||||
if not doc.company_tax_id and not doc.company_fiscal_code:
|
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"))
|
frappe.throw(_("Please set either the Tax ID or Fiscal Code on Company '%s'" % doc.company), title=_("E-Invoicing Information Missing"))
|
||||||
|
|
||||||
#Validate customer details
|
#Validate customer details
|
||||||
customer_type, is_public_administration = frappe.db.get_value("Customer", doc.customer, ["customer_type", "is_public_administration"])
|
customer = frappe.get_doc("Customer", doc.customer)
|
||||||
if customer_type == _("Individual"):
|
|
||||||
|
if customer.customer_type == _("Individual"):
|
||||||
|
doc.customer_fiscal_code = customer.fiscal_code
|
||||||
if not doc.customer_fiscal_code:
|
if not doc.customer_fiscal_code:
|
||||||
frappe.throw(_("Please set Fiscal Code for the customer '%s'" % doc.customer), title=_("E-Invoicing Information Missing"))
|
frappe.throw(_("Please set Fiscal Code for the customer '%s'" % doc.customer), title=_("E-Invoicing Information Missing"))
|
||||||
else:
|
else:
|
||||||
if is_public_administration:
|
if customer.is_public_administration:
|
||||||
|
doc.customer_fiscal_code = customer.fiscal_code
|
||||||
if not doc.customer_fiscal_code:
|
if not doc.customer_fiscal_code:
|
||||||
frappe.throw(_("Please set Fiscal Code for the public administration '%s'" % doc.customer), title=_("E-Invoicing Information Missing"))
|
frappe.throw(_("Please set Fiscal Code for the public administration '%s'" % doc.customer), title=_("E-Invoicing Information Missing"))
|
||||||
else:
|
else:
|
||||||
|
doc.tax_id = customer.tax_id
|
||||||
if not doc.tax_id:
|
if not doc.tax_id:
|
||||||
frappe.throw(_("Please set Tax ID for the customer '%s'" % doc.customer), title=_("E-Invoicing Information Missing"))
|
frappe.throw(_("Please set Tax ID for the customer '%s'" % doc.customer), title=_("E-Invoicing Information Missing"))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user