Updates for templates to check for valid data prior to iterating

This commit is contained in:
David Bomba 2024-10-13 08:10:05 +11:00
parent 2837c008ab
commit 12775c1efe
12 changed files with 113 additions and 88 deletions

View File

@ -180,7 +180,9 @@
</tr>
</table>
<!-- If you are using this template for other entities such as quotes, you'll want to ensure that you change the variable from invoices => quotes here -->
<ninja>
{% if invoices is defined and invoices is not empty %}
{% set invoice = invoices|first %}
<table width="100%" cellspacing="0" cellpadding="0" class="">
<thead class="table-header">
@ -204,6 +206,7 @@
{% endfor %}
</tbody>
</table>
{% endif %}
</ninja>
<table width="100%" cellspacing="0" cellpadding="0" class="">

View File

@ -170,7 +170,9 @@
</tr>
</table>
<!-- If you are using this template for other entities such as quotes, you'll want to ensure that you change the variable from invoices => quotes here -->
<ninja>
{% if invoices is defined and invoices is not empty %}
{% set invoice = invoices|first %}
<table width="100%" cellspacing="0" cellpadding="0" class="">
<thead class="table-header">
@ -190,6 +192,7 @@
{% endfor %}
</tbody>
</table>
{% endif %}
</ninja>
<table width="100%" cellspacing="0" cellpadding="0" class="">

View File

@ -204,7 +204,10 @@
</tr>
</table>
<!-- If you are using this template for other entities such as quotes, you'll want to ensure that you change the variable from invoices => quotes here -->
<ninja>
{% if invoices is defined and invoices is not empty %}
{% set invoice = invoices|first %}
<table width="100%" cellspacing="0" cellpadding="0" class="">
<thead class="table-header">
@ -228,6 +231,8 @@
{% endfor %}
</tbody>
</table>
{% endif %}
</ninja>
<table width="100%" cellspacing="0" cellpadding="0" class="">

View File

@ -206,7 +206,10 @@
</tr>
</table>
<!-- If you are using this template for other entities such as quotes, you'll want to ensure that you change the variable from invoices => quotes here -->
<ninja>
{% if invoices is defined and invoices is not empty %}
{% set invoice = invoices|first %}
<table width="100%" cellspacing="0" cellpadding="0" class="">
<thead class="table-header">
@ -230,6 +233,8 @@
{% endfor %}
</tbody>
</table>
{% endif %}
</ninja>
<table width="100%" cellspacing="0" cellpadding="0" class="">

View File

@ -208,8 +208,8 @@
style="border:0;border-collapse:collapse;margin:0;padding:0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;vertical-align:middle;color:#525f7f;font-size:15px;line-height:24px;white-space:nowrap">
<span>
<ninja>
{% if payments is defined and payments is not empty %}
{% set payment = payments|first %}
{% if payment %}
{{ payment.method }}
{% endif %}
</ninja>
@ -303,9 +303,9 @@
</tr>
<ninja>
{% set totalPrice = 0 %}
{% if payments is defined and payments is not empty %}
{% for payment in payments %}
{% for pivot in payment.paymentables|filter(pivot =>
pivot.is_credit == '0') %}
{% for pivot in payment.paymentables|filter(pivot => pivot.is_credit == '0') %}
<tr>
<td
style="border:0;border-collapse:collapse;margin:0;padding:0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;vertical-align:middle;color:#8898aa;font-size:12px;line-height:16px;font-weight:bold;text-transform:uppercase">
@ -396,6 +396,8 @@
style="border:0;border-collapse:collapse;margin:0;padding:0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;vertical-align:middle;color:#525f7f;font-size:15px;line-height:24px;font-weight:bold">
${{ totalPrice|format_currency(currency_code) }}
<td>
{% endif %}
</ninja>
</tr>
<tr>

View File

@ -108,10 +108,12 @@
<h4 class="italic" style="margin-bottom:0.5rem;">$to_label</h3>
<p style="margin-bottom:0.5rem;">$client.name</p>
<ninja>
{% if payments is defined and payments is not empty %}
{% set payment = payments|first %}
{% if payment.client.vat_number %}
<p>$vat_number_label: $vat_number</p>
{% endif %}
{% endif %}
</ninja>
</div>
<div class="pull-right">
@ -129,7 +131,7 @@
</div>
<ninja>
{% if payments|e %}
{% if payments is defined and payments is not empty %}
{% for payment in payments %}
<div class="four-col-grid bottom-border" style="padding:2px;">
<div>

View File

@ -96,8 +96,9 @@
<div class="two-col-grid" style="">
<div class="pull-left">
<ninja>
<h1 class="primary-color-highlight" style="margin-top:0; margin-bottom:0rem;">$refund_label {% if
payments|length == 1%}#$number {% endif %}</h2>
{% if payments is defined and payments is not empty %}
<h1 class="primary-color-highlight" style="margin-top:0; margin-bottom:0rem;">$refund_label {% if payments|length == 1%}#$number {% endif %}</h2>
{% endif %}
</ninja>
</div>
<div class="pull-right"><img src="$company.logo" class="company-logo"></div>
@ -108,10 +109,12 @@
<h4 class="italic" style="margin-bottom:0.5rem;">$to_label</h3>
<p style="margin-bottom:0.5rem;">$client.name</p>
<ninja>
{% if payments is defined and payments is not empty %}
{% set payment = payments|first %}
{% if payment.client.vat_number %}
<p>$vat_number_label: $vat_number</p>
{% endif %}
{% endif %}
</ninja>
</div>
<div class="pull-right">
@ -123,7 +126,7 @@
<div class="" style="margin-top:20px;">
<ninja>
{% if payments|e %}
{% if payments is defined and payments is not empty %}
{% set totalInvoices = 0 %}
{% set totalRefunds = 0 %}
{% for payment in payments %}

View File

@ -8,6 +8,7 @@
<body>
<ninja>
{% if payments is defined and payments is not empty %}
{%set payment = payments|first %}
{%set pivot = payment.paymentables|filter(pivot => pivot.refunded_raw > 0)|first %}
<table align="center" bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="600"
@ -522,6 +523,7 @@
</tr>
</tbody>
</table>
{% endif %}
</ninja>
</body>

View File

@ -52,7 +52,7 @@
</head>
<body>
<ninja>
{% if projects|e %}
{% if projects is defined and projects is not empty %}
{% for project in projects %}
<h1>{{ project.name }}</h1>

View File

@ -132,7 +132,7 @@
</div>
</div>
<ninja>
{% if invoices|e %}
{% if invoices is defined and invoices is not empty %}
<div class="entity-container">
<h2>Invoices<h2>
<table width="100%" cellspacing="0" cellpadding="0" class="">
@ -162,7 +162,7 @@
</ninja>
<ninja>
{% if payments|e %}
{% if payments is defined and payments is not empty %}
<div class="entity-container">
<h2>Payments<h2>
<table width="100%" cellspacing="0" cellpadding="0" class="">
@ -194,7 +194,7 @@
</ninja>
<ninja>
{% if credits|e %}
{% if credits is defined and credits is not empty %}
<div class="entity-container">
<h2>Credits<h2>
<table width="100%" cellspacing="0" cellpadding="0" class="">
@ -222,7 +222,7 @@
</ninja>
<ninja>
{% if aging %}
{% if aging is defined %}
<div class="entity-container">
<h2>Aging<h2>
<table width="100%" cellspacing="0" cellpadding="0" class="">

View File

@ -148,7 +148,7 @@
</div>
<ninja>
{% if invoices|e %}
{% if invoices is defined and invoices is not empty %}
<div id="entity-container">
<h2>{{ t('invoices') }}<h2>
<table width="100%" cellspacing="0" cellpadding="0" class="">
@ -189,7 +189,7 @@
</ninja>
<ninja>
{% if invoices|e and show_payments %}
{% if invoices is defined and invoices is not empty and show_payments %}
<div id="entity-container">
<h2>{{ t('payments') }}<h2>
<table width="100%" cellspacing="0" cellpadding="0" class="">
@ -270,7 +270,7 @@
</ninja>
<ninja>
{% if credits|e and show_credits %}
{% if credits is defined and credits is not empty and show_credits %}
<div id="entity-container">
<h2>{{ t('credits') }}<h2>
<table width="100%" cellspacing="0" cellpadding="0" class="">

View File

@ -43,7 +43,7 @@
<body>
<ninja>
{% if tasks %}
{% if tasks is defined and tasks is not empty %}
<table>
<thead>
<tr>