Calculating with amount of days

Hi,

Anybody who could help with with the code below? I’m trying to calculate the amount that needs to be transefered to next year.
E.g. cost of € 1.500
cost is over a period from 01/10/2018 - 30/09/2019. Bookyear ends 31/12/2018.
I need to calculate the cost for the period from 01/01/2019 - 30/09/2019.

{% stripnewlines %} |------12%------|----2%---|---10%-------|-------25%--------|----15%------:|--10%--:|--10%--:|--15%--:+{% newline %} |_factnr. _|_ _|_ rek. nr. _|_ omschrijving _|_totaal bedrag_|_beginsdatum_|_einddatum_|_bedrag over te dragen_|{% fori detail in current_account.details %} {% newline %} |{% input detail.custom.nr %} |{% input detail.custom.account_nr as:account_collection range:1,2,3,4,5,6,7 %}{% assign account = period.accounts | range:detail.custom.account_nr %} |{{ account.first.number }} |{{ account.first.name }} |{% input detail.value as:currency %} |{% input detail.custom.begindatum as:date%}{% assign start_date = detail.custom.begindatum+0 %}{% assign begin_volgend_boekjaar = periode.end_date+1 %} |{% input detail.custom.einddatum as:date%}{% assign end_date = detail.custom.einddatum+0 %} {% assign amount_of_days = end_date+1-start_date %} {% assign amount_of_days_transfered = end_date+1-begin_volgend_boekjaar %} |{% if forloop.last %}_{%endif %}{%=$0+ detail.value*(amount_of_days_transfered/amount_of_days) | currency %}{% if forloop.last %}_{%endif %}|{% endfori %} {% newline %} |||||||**Totaal**| {{ $0 | currency }}{% unexplained current_account.value-$0 %}| {% endstripnewlines %}

Never mind, found my mistake myself. :slight_smile:

Hi Cedric

nice that you found the solution yourself. Can you past it into the community, so others can learn from it?

Thanks in advance.

Sofie

Mistake was periode.year_end_date in stead op period.year_end_date…

Hereby the correct code:

´´{% stripnewlines %}
|------12%------|----2%—|---10%-------|-------25%--------|----15%------:|–10%–:|–10%–:|–15%–:+{% newline %}
|factnr. | | rek. nr. | omschrijving |totaal bedrag|beginsdatum|einddatum|bedrag over te dragen|{% fori detail in current_account.details %}
{% newline %}
|{% input detail.custom.nr %}
|{% input detail.custom.account_nr as:account_collection range:1,2,3,4,5,6,7 %}{% assign account = period.accounts | range:detail.custom.account_nr %}
|{{ account.first.number }}
|{{ account.first.name }}
|{% input detail.value as:currency %}
|{% input detail.custom.begindatum as:date%}{% assign start_date = detail.custom.begindatum+0 %}{% assign begin_volgend_boekjaar = period.year_end_date+1 %}
|{% input detail.custom.einddatum as:date%}{% assign end_date = detail.custom.einddatum+0 %}
{% assign amount_of_days = end_date+1-start_date %}
{% assign amount_of_days_transfered = end_date+1-begin_volgend_boekjaar %}
|{% if forloop.last %}
{%endif %}{%=$0+ detail.value*(amount_of_days_transfered/amount_of_days) | currency %}{% if forloop.last %}
{%endif %}|{% endfori %}
{% newline %}
|||||||Totaal| {{ $0 | currency }}{% unexplained current_account.value-$0 %}|
{% endstripnewlines %}``

Thanks for sharing the right code @Cedric! :slight_smile: