[%- USE AuthorisedValues -%]
[%- USE KohaDates -%]
[%- USE Price -%]
[%- PROCESS "accounts.inc" -%]
<table>
    [% IF ( LibraryName ) %]
    <tr>
      <th colspan="2" class="centerednames">
        <h3>[% LibraryName | html %]</h3>
      </th>
    </tr>
    [% END %]
    [% IF credit.library %]
    <tr>
      <th colspan="2" class="centerednames">
        <h2>[% credit.library.branchname | html %]</h2>
      </th>
    </tr>
    [% END %]
    <tr>
      <th colspan="2" class="centerednames">
        <h3>[% today | $KohaDates %]</h3>
      </th>
    </tr>
    <tr>
      <td>ID de transacción: </td>
      <td>[% credit.accountlines_id %]</td>
    </tr>
    <tr>
      <td>ID de operador: </td>
      <td>[% credit.manager_id %]</td>
    </tr>
    [% IF credit.payment_type %]
    <tr>
      <td>Tipo de pago: </td>
      <td>[% AuthorisedValues.GetByCode('PAYMENT_TYPE', credit.payment_type) %]</td>
    </tr>
    [% END %]
    <tr>
      <th colspan="2" class="centerednames">
        <h2><u>[%- PROCESS credit_type_description credit_type = credit.credit_type -%] recibo</u></h2>
      </th>
    </tr>
    [% IF ( credit.credit_type_code == 'PAYMENT' ) %]
    <tr>
      <th colspan="2">
        Recibido con agradecimientos de  [% credit.patron.firstname | html %] [% credit.patron.surname | html %] <br />
        Número de carné: [% credit.patron.cardnumber | html %]<br />
      </th>
    </tr>
    [% ELSIF ( credit.credit_type_code == 'CREDIT' ) %]
    <tr>
      <th colspan="2">
        Crédito agregado a la cuenta por [% credit.patron.firstname | html %] [% credit.patron.surname | html %] <br />
        Número de carné: [% credit.patron.cardnumber | html %]<br />
      </th>
    </tr>
    [% ELSIF ( credit.credit_type_code == 'WRITEOFF' ) %]
    <tr>
      <th colspan="2">
        Cancelación de deuda en la cuenta por [% credit.patron.firstname | html %] [% credit.patron.surname | html %] <br />
        Número de carné: [% credit.patron.cardnumber | html %]<br />
      </th>
    </tr>
    [% END %]
    [% IF credit.amountoutstanding + 0 != 0 %]
    <tr>
      <th>Descripción del crédito</th>
      <th>Cantidad</th>
    </tr>
    <tr>
      <td>[%- PROCESS credit_type_description credit_type = credit.credit_type -%]</td>
      <td>[% credit.amount * -1 | $Price %]</td>
    </tr>
    <tr>
      <th style="text-align:right;">Total disponible:</th>
      <td>[% credit.amountoutstanding * -1 | $Price %]</td>
    </tr>
    [% END %]
    [% IF credit.amount != credit.amountoutstanding %]
    <tr>
      <th>Descripción de los cargos</th>
      <th>Cantidad</th>
    </tr>
    [% FOREACH offset IN credit.credit_offsets %]
    <tr>
      <td>[% PROCESS account_type_description account=offset.debit %][% IF ( offset.debit.itemnumber ) %] - [% offset.debit.item.biblio.title %][% END %]</td>
      <td>[% offset.amount * -1 | $Price %]</td>
    </tr>
    [% END %]
    [% END %]
  <tfoot>
    <tr class="highlight">
      <td>Total:</td>
      <td>[% credit.amount * -1 | $Price %]</td>
    </tr>
    [% IF change.defined %]
    <tr>
      <td>Cambio entregado: </td>
      <td>[% change | $Price %]</td>
    </tr>
    [% END %]
    <tr>
      <td colspan="2"></td>
    </tr>
    <tr>
      <td>Balance de la cuenta a la fecha:</td>
      <td>[% credit.patron.account.balance * -1 | $Price %]</td>
    </tr>
  </tfoot>
</table>