Getting incorrect TAX_ID bug


I have created a custom print format for quotation. I have this in the template:

<td class="text-center">
                {% if doc.quotation_to=="Customer" %}
                    {{ frappe.db.get_value("Customer", doc.customer, "tax_id") or "" }}
                {% endif %}
        <td class="text-center"><small>{{ doc.customer_name }}</small></td>

{{ doc.customer_name }} shows the correct customer name, but {{ frappe.db.get_value(“Customer”, doc.customer, “tax_id”) or “” }} shows a TAX_ID of other customer.

What is it going on? I think I am using the right function call, that is why I send this as a bug.

Is there a workaround?

Also, when displaying the quotation as PDF, tax id appears empty.

These are my versions:

Installed Apps

ERPNext: v11.1.56 (version-11)

Frappe Framework: v11.1.52 (version-11)