Get tax rate for customized sales invoice print format

Hello everyone,

it’s me again with another challenge that I can’t figure out on my own…

Due to the charakteristics of my invoices it appears that there are different types values for the VAT.
Unfortunately in Germany we have to write the exact percentage VAT value on every invoice.
To not have hundreds of different invoice templates I wanted a nice and clean solution where I take the tax rate right out of the invoice form.

Unfortunately the “tax_rate” is inside of the taxes table and I can’t figure out how to get the value that is entered into the (first line of the) tax table.

I already tried the following unsuccessfully:

{% set inv_taxes = frappe.get_doc("Sales Taxes and Charges", doc.taxes) %}

{{ inv_taxes.get_formatted('tax_rate') }}

But this throws me an error…

Maybe someone of you can help me?
Thank you already in advance!

If someone knows the “secret knowledge base” of all the possible commands that can be used for the customization of print formats - please feel free to share it with me, I’m willing to go on the search on my own, I just don’t know where to look after a solution/command if it’s not inside this forum…

After some more research and some reengineering of existing templates I could figure out the solution on my own.
But to share this information for others that might have the same or atleast a similar problem - this simple code snippet solved the issue for me:


I still don’t understand why it is “rate” instead of “tax_rate” (atleast that’s what it is called inside the doctype…
But the more important part is that taxes as a table can just be accessed like any other table and cause I only have one tax row at the same time I can just refere to the first row [0].