Adding and showing overdue amount to current invoice

Hello,

Please help me to show on current invoice if the client has an overdue invoice the overdue amount and to sum with current invoice.
I tried something to show the overdue amount but doesn’t work. Here is what I done until now:

{% for invoicemama in loader.getInvoices() %}
heuhio
{% if (date(date_till) < date()) and status == ‘not_paid’ %}
eeee
{% set sold_precendent = invoicemama.total %}
{{ sold_precedent }}
{% endif %}
{% endfor %}
But doesn’t enter even in for.

Thanks.

Does, but 1) you have to disable invoice cache -> Config / Finance / Settings (Invouice / Invoice cache set to false)
2) You have to delete existing invoice cache : Config / Tools / Invoice cache - Delete

  1. You have typo on code - {% set sold_precendent = invoicemama.total %} - sold_precendent != sold_precedent

  2. before for you need to inicialize sold_precendent : {% set sold_precendent = 0 %}

  3. you have bad IF statement (you use current invoice values, not loaded), it
    should be:

{% if (date(invoicemama.date_till) < date()) and invoicemama.status == 'not_paid' %}

  1. working example:

    {% set sold_precendent = 0 %}
    {% for invoicemama in loader.getInvoices() %}
    heuhio
    {% if (date(invoicemama.date_till) < date()) and invoicemama.status == ‘not_paid’ %}
    eeee
    {% set sold_precendent = invoicemama.total %}
    {{ sold_precendent }}
    {% endif %}
    {% endfor %}

result will be (like):

heuhio eeee 22.0000 heuhio eeee 22.0000 heuhio eeee 22.0000 heuhio eeee 22.0000 heuhio eeee 22.0000 heuhio eeee 33.0000 heuhio eeee 33.0000 heuhio eeee 222.0000 heuhio eeee 22.0000 heuhio eeee 222.0000