{% set voucher = voucher|default(null) %} {% set pago = pago|default(null) %} {% set mode = mode|default('compact') %} {% set voucherJobs = voucherJobs|default({}) %} {% set cheque = cheque|default(null) %} {% set transferencia = transferencia|default(null) %} {% set voucherId = voucher.id|default(null) %} {% set voucherNumber = voucher.numeroVoucher|default(voucher.numero|default(null)) %} {% set voucherEstado = voucher.estado|default(null) %} {% set pagoId = pago.id|default(pagoId|default(voucher.pago.id|default(null))) %} {% set pagoEstado = pago.estado|default(null) %} {% set canGenerate = voucher is empty and pagoId and pagoEstado != 'Anulado' %} {% set statusClass = { 'generado': 'status-pill-success', 'sincronizado': 'status-pill-success', 'pendiente': 'status-pill-warning', 'procesando': 'status-pill-warning', 'error': 'status-pill-warning', 'anulado': 'status-pill-muted' } %} {% macro job_badge(job) %} {% if job %} {% if job.estado in ['pendiente', 'procesando'] %} {{ job.estado|capitalize }}{% if job.progreso %} {{ job.progreso }}%{% endif %} {% elseif job.estado == 'error' %} Error {% elseif job.estado == 'completado' %} Completado {% else %} {{ job.estado|capitalize }} {% endif %} {% endif %} {% endmacro %} {% import _self as voucherUi %} {% if mode == 'compact' %}
{% if voucher %} Voucher {% if voucherNumber %}{{ voucherNumber }}{% endif %} {% if voucherEstado %} {{ voucherEstado|capitalize }} {% endif %} {% elseif canGenerate %}
{% else %} Sin voucher {% endif %}
{% else %} {% set pdfJob = voucherJobs.pdf|default(null) %} {% set xlsxJob = voucherJobs.xlsx|default(null) %} {% set syncJob = voucherJobs.sync|default(null) %} {% set voucherHistory = voucherJobs.history|default([]) %} {% set isVoided = voucherEstado == 'anulado' %}

Voucher de pago

Estado, archivos y acciones del comprobante operativo.

{% if voucher %} {{ voucherEstado|capitalize }} {% else %} Sin voucher {% endif %}
{% if voucher %}

Numero

{{ voucherNumber ?: '-' }}

Pago

PAY-{{ '%05d'|format(voucher.pago.id) }}

Total

{{ voucher.moneda }} {{ voucher.total|number_format(2, '.', ',') }}

Generado

{{ voucher.fechaGeneracion|date('d/m/Y H:i') }}

{% if isVoided %}

Voucher anulado. Se conservan los archivos existentes para consulta, pero no se permiten regeneraciones ni sincronizaciones.

{% endif %}

Archivos

PDF y XLSX generados por job.

{% for format, label in {'pdf': 'PDF', 'xlsx': 'XLSX'} %} {% set filePath = format == 'pdf' ? voucher.archivoPdf : voucher.archivoExcel %} {% set fileJob = format == 'pdf' ? pdfJob : xlsxJob %}

{{ label }}

{{ voucherUi.job_badge(fileJob) }}
{% if fileJob and fileJob.estado == 'error' and fileJob.error %}

{{ fileJob.error }}

{% endif %}
{% if filePath %} Descargar {% elseif not isVoided and (fileJob is empty or fileJob.estado in ['error', 'completado']) %}
{% if fileJob and fileJob.estado == 'error' %}{% endif %}
{% endif %}
{% endfor %}

Acciones

Solo se muestran las acciones aplicables.

Imprimir CSV {% if not isVoided %}
{% if syncJob and syncJob.estado == 'error' %}{% endif %}
{% endif %}
{% if syncJob %}
Sincronizacion nube {{ voucherUi.job_badge(syncJob) }}
{% if syncJob.estado == 'error' and syncJob.error %}

{{ syncJob.error }}

{% endif %}
{% endif %}

Medio de pago

Cheque o transferencia relacionada.

{% if voucher.formaPago == 1 %} {% if cheque %} Ver cheque {{ cheque.numeroCheque }} {% if cheque.estado == 'entregado' %}

Cheque entregado. No se debe regenerar el flujo operativo.

{% endif %} {% elseif not isVoided %} Crear cheque {% else %}

Voucher anulado.

{% endif %} {% elseif voucher.formaPago in [2, 3, 4] %} {% if transferencia %} Ver transferencia {% if transferencia.estado == 'sincronizada' %}

Transferencia sincronizada.

{% endif %} {% elseif not isVoided %} Registrar transferencia {% else %}

Voucher anulado.

{% endif %} {% else %}

No aplica cheque o transferencia.

{% endif %}

Historial de jobs

Ultimos procesos relacionados con archivos y sincronizacion.

{% for job in voucherHistory|slice(0, 8) %} {% else %} {% endfor %}
Fecha Tipo Estado Detalle
{{ job.createdAt|date('d/m/Y H:i') }} {{ job.tipo }} {{ voucherUi.job_badge(job) }} {{ job.error ?: (job.archivoResultado ?: '-') }}
Sin jobs registrados para este voucher.
{% else %}
Este pago todavia no tiene voucher.
{% if canGenerate %}
{% endif %} {% endif %}
{% endif %}