Addition to the reconciliation template 'Fleet' - load from account failing

I would like to extend the template ‘Fleet’ with data coming directly from the accounts, instead of adding the amounts manually. For this we will add the car plate to the reference during the booking and I want to group the value based on the reference and add the value to the correct line.

So I add in the fleet template the different cars with their car plate and adjusted the code below. However I am not able to make {% if name == plate_name %} to work. What is wrong in the code?

{% for car in var2 %}{% capture car_key %}car_{{ car.key }}{% endcapture %}
  |{{ car.beneficiary }}|{% capture carlink %}license_plate{{ forloop.index0 }}{% endcapture %}{{ car.license_plate | upcase }}
  |
  {% assign name = car.license_plate | upcase %}
    {% for account in accounts_totaal1 %}
    {% comment %}take current account to display for each account, and use it to call on transactions-drop of that account{% endcomment %}
      {% assign current_acc = account.number %}
      {% assign transactions = period.accounts[current_acc].first.transactions %}
        {% comment %}loop over all transactions for each account{% endcomment %}
          {% for tr in transactions %}
            {% assign plate_name = tr.Ref_ | upcase %}
            {% if name == plate_name %}
              {% assign $1 = $1+tr.value %}
            {% endif %}
          {% endfor %}
    {% endfor %}
    
  {% ifi car_insurance %}|{% =$2+input car.insurance placeholder:pl_holder_c2 as:currency %}{% endifi %}
  {% ifi car_tax %}|{% =$3+input car.tax placeholder:pl_holder_c3 as:currency %}{% endifi %}
  {% ifi car_parking %}|{% =$4+input car.parking placeholder:pl_holder_c4 as:currency %}{% endifi %}
  {% ifi car_depreciation %}|{% =$5+input car.depreciation placeholder:pl_holder_c5 as:currency %}{% endifi %}
  {% ifi car_leasing %}|{% =$6+input car.leasing placeholder:pl_holder_c6 as:currency %}{% endifi %}
  {% fori cat in custom.categories %}{% if cat.name == blank %}{% capture pl_holder %}{% t "Kost" %}{% endcapture %}{% else %}{% assign pl_holder = cat.name %}{% endif %}|
  {% capture total %}total_{{ cat.key }}{% endcapture %}
  {% capture celid %}{{ car_key }}_{{ cat.key }}{% endcapture %}
  {% input cat.[celid] placeholder:pl_holder as:currency %}
  {% assign [total] = [total]+cat.[celid] %}
  {% endfori %}{% newline %}
{% endfor %}

Hi @tver

I had a look at our code for the template ‘Fleet’ and just replaced this specific part of our code with your adjusted code.

My guess is that the problem is that accounts_totaal1 is not defined yet at this part of the code, but only later on. Unless of course you moved this higher up in the code, but I can not check that.

Can you let us know if this was the issue?

Kind regards,
Kimberly

Hi @Kimberly

The problem was the comparison of the car license plate with the reference in the accountancy system. But the license plate was containing dashes (-) and after removing them, it was working fine.

Anyway, thanks for the help.

T.

Hi @tver

Thanks for letting us know what the issue was.

Kind regards,
Kimberly