[% USE Price %]
[% USE KohaDates %]
[% PROCESS "accounts.inc" %]
<table>
    [% IF ( LibraryName ) %]
    <tr>
      <th colspan="3" class="centerednames">
        <h3>[% LibraryName | html %]</h3>
      </th>
    </tr>
    [% END %]
    [% IF debit.library %]
    <tr>
      <th colspan="3" class="centerednames">
        <h2>[% debit.library.branchname | html %]</h2>
      </th>
    </tr>
    [% END %]
    <tr>
      <td colspan="2" style="text-align:right;">ID del cargo: </td>
      <td>[% debit.accountlines_id %]</td>
    </tr>
    [% IF credit.manager_id %]
    <tr>
      <td colspan="2" style="text-align:right;">ID de operador: </td>
      <td>[% credit.manager_id %]</td>
    </tr>
    [% END %]
    <tr>
      <th colspan="3" class="centerednames">
        <h2><u>Recibo</u></h2>
      </th>
    </tr>
    <tr>
      <th colspan="3" >
        Facturar a: [% debit.patron.firstname | html %] [% debit.patron.surname | html %] <br />
        Número de carné: [% debit.patron.cardnumber | html %]<br />
      </th>
    </tr>
    [% IF debit.amountoutstanding != 0 %]
    <tr>
      <th>Fecha</th>
      <th>Descripción de los cargos</th>
      <th>Cantidad</th>
    </tr>
    <tr>
      <td>[% debit.date | $KohaDates %]</td>
      <td>[% PROCESS account_type_description account=debit %]</td>
      <td>[% debit.amount | $Price %]</td>
    </tr>
    <tr>
      <td colspan="2" style="text-align:right;">Total adeudado:</td>
      <td>[% debit.amount | $Price %]</td>
    </tr>
    [% END %]
    [% IF debit.amount != debit.amountoutstanding %]
    <tr>
      <th>Fecha</th>
      <th>Descripción de los pagos</th>
      <th>Cantidad</th>
    </tr>
    [% FOREACH offset IN debit.debit_offsets %]
    <tr>
      <td>[% offset.credit.date | $KohaDates %]</td>
      <td>[% PROCESS account_type_description account=offset.credit %]</td>
      <td>[% offset.amount * -1 | $Price %]</td>
    </tr>
    [% END %]
    <tr class="highlight">
      <td colspan="2" style="text-align:right;">Total pagado:</td>
      <td>[% debit.amount - debit.amountoutstanding | $Price %]</td>
    </tr>
    [% END %]
    </tr>
      <td colspan="3"></td>
    <tr>
  <tfoot>
    <tr>
      <th colspan="2" style="text-align:right;">Total demanente:</th>
      <td>[% debit.amountoutstanding | $Price %]</td>
    </tr>
  </tfoot>
</table>