Tax ID shown in print format is incorrect


in invoice print format I have this:

{{ frappe.db.get_value("Customer", doc.customer, "tax_id") or "" }}

That is to display the tax id number.

I have realized today that this does not work when a customer does not have a Tax ID.

For example, these are the steps to reproduce the problem:

  1. Create a customer and assign a Tax ID

  2. Create a Lead not assigned to any customer nor company. Just enter a person name.

  3. Create a quotation from that Lead

  4. Print the quotation. The Tax ID that will appear will be the Tax ID entered earlier. In that case, since the quotation comes from the lead, the tax ID should be empty.

Please solve this. At the moment, I will have to remove that tag in the print format.

I have create a quotation from a customer which has the Tax ID set, it is shown correctly.

Kind regards,

Add an if statement:

{% if doc.quotation_to=="Customer" %}
    <b>TAX ID:</b> {{ frappe.db.get_value("Customer", doc.customer, 
    "tax_id") or "" }}
{% endif %}   

The tax ID field is only visible if the Quotation To field is set to Customer. Else the field/tag will not appear in the quotation.

1 Like

Hello, I have just realized that the TAX_ID shown in quotation still belongs to other customer. Not the customer of the quotation.

On the other hand, the instruction:

{{ doc.customer_name }}

displays the customer name correctly.

Furthermore, when displaying the PDF equivalent, tax id appears empty.