Hello everyone…
I’m editing a budget template, and the main table needs to perform the following calculation:
“Assinatura Anual” field: Finds the “Quantity” field of the line items, adds them (if there’s more than one), and multiplies them by 12 (to represent per year);
“Valor por Assinatura” field: Pulls and adds the “Net Price” field of the line items;
“Investimento Anual” field: Finds the “Net Price” field of the line items, adds them (if there’s more than one), and multiplies them by 12.
I tried to configure something like the following:
"<!-- Tabela de valores -->
<div class=“container–content”>
<table class=“tabela”>
<thead>
<tr style=“background-color: #f9b915;”>
<th>Assinaturas Anual</th>
<th>Valor por Assinatura</th>
<th>Investimento Mensal</th>
<th>Investimento Anual</th>
<th>Setup</th>
</tr>
</thead>
<tbody>
{% for item in line_items %}
<tr>
<td>{{ item.quantity * 12 }}</td>
<td>
{% set valor = item.price|float %}
R$ {{ “{:,.2f}”.format(valor)|replace(“,”, “X”)|replace(“.”, “,”)|replace(“X”, “.”) }}
</td>
<td>
{% if item.hs_post_tax_amount %}
{% set mensal = item.hs_post_tax_amount|float %}
R$ {{ “{:,.2f}”.format(mensal)|replace(“,”, “X”)|replace(“.”, “,”)|replace(“X”, “.”) }}
{% else %}
R$ 0,00
{% endif %}
</td>
<td>
{% if item.hs_post_tax_amount %}
{% set anual = (item.hs_post_tax_amount|float * 12)|round(2) %}
R$ {{ “{:,.2f}”.format(anual)|replace(“,”, “X”)|replace(“.”, “,”)|replace(“X”, “.”) }}
{% else %}
R$ 0,00
{% endif %}
</td>
<td>-</td>
</tr>
{% endfor %}
</tbody>
</table>"
It worked initially, but I can’t get it to format to the Brazilian real (R$). It always ends up with a comma at the beginning, or it ignores a trailing 0 or doesn’t set the value when it goes over a thousand
My guess is that the code is generating the gross value, but I can’t find how to make this adjustment.
I really need help
