{#
The Mia! Accounting Project
detail-line-items-item: The line items in the journal entry detail

 Copyright (c) 2023 imacat.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

Author: imacat@mail.imacat.idv.tw (imacat)
First written: 2023/3/14
#}
{# <ul> For SonarQube not to complain about incorrect HTML #}
{% for line_item in line_items %}
  <li class="list-group-item accounting-journal-entry-line-item">
    <div class="d-flex justify-content-between">
      <div>
        <div class="small">{{ line_item.account }}</div>
        {% if line_item.description is not none %}
          <div>{{ line_item.description }}</div>
        {% endif %}
        {% if line_item.original_line_item %}
          <div class="fst-italic small accounting-original-line-item">
            <a href="{{ url_for("accounting.journal-entry.detail", journal_entry=line_item.original_line_item.journal_entry)|accounting_append_next }}">
              {{ A_("Offset %(item)s", item=line_item.original_line_item) }}
            </a>
          </div>
        {% endif %}
        {% if line_item.is_need_offset %}
          <div class="fst-italic small accounting-offset-line-items">
            {% if line_item.offsets %}
              <div class="d-flex justify-content-between">
                <div>{{ A_("Offsets") }}</div>
                <ul class="ms-2 ps-0">
                  {% for offset in line_item.offsets %}
                    <li>
                      <a href="{{ url_for("accounting.journal-entry.detail", journal_entry=offset.journal_entry)|accounting_append_next }}">
                        {{ offset.journal_entry.date|accounting_format_date }} {{ offset.amount|accounting_format_amount }}
                      </a>
                    </li>
                  {% endfor %}
                </ul>
              </div>
              {% if line_item.net_balance %}
                <div class="d-flex justify-content-between">
                  <div>{{ A_("Net balance") }}</div>
                  <div>{{ line_item.net_balance|accounting_format_amount }}</div>
                </div>
              {% else %}
                <div class="d-flex justify-content-between">
                  <div>{{ A_("Fully offset") }}</div>
                </div>
              {% endif %}
            {% else %}
              <div class="d-flex justify-content-between">
                {{ A_("Unmatched") }}
              </div>
            {% endif %}
          </div>
        {% endif %}
      </div>
      <div>{{ line_item.amount|accounting_format_amount }}</div>
    </div>
  </li>
{% endfor %}
{# </ul> For SonarQube not to complain about incorrect HTML #}
