{% macro invoice_detail_table(rows, caption, total, showTotal, continued, hasMore, role, key) %} {% for detalle in rows %} {% endfor %} {% if showTotal and total %} {% endif %}
{{ caption }}{{ continued ? ' - Continuacion' : '' }}
Fecha Serie No. factura Nombre de la empresa Cantidad
{{ detalle.fecha|default('') }} {{ detalle.serie|default('') }} {{ detalle.numero|default('') }} {{ detalle.proveedor|default('') }} {{ detalle.monto_formateado|default(detalle.monto|default('')) }}
Total aplicado {{ total }}
{% if role == 'main' %}

Detalle completo en la pagina siguiente

{% endif %} {% endmacro %} {% macro centro_costo_table(rows, caption, continued, hasMore, role, key) %} {% for fila in rows %} {% endfor %}
{{ caption }}{{ continued ? ' - Continuacion' : '' }}
Centro de costo Monto
{{ fila.nombre }}{{ fila.monto }}
{% if role == 'main' %}

Detalle completo en la pagina siguiente

{% endif %} {% endmacro %} {% import _self as voucher %} {# El @page y cada campo siempre se imprimen en milimetros, sin importar en que unidad se edito el formato: mm/cm son fiables para el tamano fisico de pagina en los motores de impresion de los navegadores, pero px no siempre se respeta igual (a veces el navegador ignora el tamano de papel personalizado). #} {% set unitFactors = {'mm': 1, 'cm': 10, 'px': (25.4 / 96)} %} {% set unitFactor = unitFactors[formato.unidad] ?? 1 %} {% set papelAnchoMm = (formato.papelAncho * unitFactor)|number_format(2, '.', '') %} {% set papelAltoMm = (formato.papelAlto * unitFactor)|number_format(2, '.', '') %} Prueba {{ formato.nombre }}
{% set invoiceTableFields = formato.campos|filter(campo => campo.visible and (campo.campo == 'detalle_facturas_tabla' or campo.campo == 'centro_costo_tabla')) %}
{% for campo in formato.campos %} {% if campo.visible %} {% set fieldValue = campo.campo == 'centro_costo_tabla' ? values.centro_costo_detalle|default(null) : values[campo.campo]|default(null) %} {% set invoiceKey = 'invoice-' ~ campo.orden|default(loop.index0) %} {% set fieldXMm = campo.x * unitFactor %} {% set fieldYMm = campo.y * unitFactor %} {% set fieldWidthMm = campo.width * unitFactor %} {% set fieldHeightMm = campo.height * unitFactor %}
{% if campo.campo == 'detalle_facturas_tabla' %} {% if fieldValue is iterable and fieldValue|length > 0 %} {% set firstPageLimit = ((fieldHeightMm - 20) / 10)|round(0, 'floor') %} {% set firstPageLimit = firstPageLimit < 1 ? 1 : firstPageLimit %} {{ voucher.invoice_detail_table( fieldValue|slice(0, firstPageLimit), campo.etiqueta, values.detalle_facturas_total_formateado|default(''), fieldValue|length <= firstPageLimit, false, fieldValue|length > firstPageLimit, 'main', invoiceKey ) }} {% else %} {{ values.detalle_facturas_texto|default(campo.etiqueta) }} {% endif %} {% elseif campo.campo == 'centro_costo_tabla' %} {% if fieldValue is iterable and fieldValue|length > 0 %} {% set firstPageLimit = ((fieldHeightMm - 20) / 10)|round(0, 'floor') %} {% set firstPageLimit = firstPageLimit < 1 ? 1 : firstPageLimit %} {{ voucher.centro_costo_table( fieldValue|slice(0, firstPageLimit), campo.etiqueta, false, fieldValue|length > firstPageLimit, 'main', invoiceKey ) }} {% endif %} {% elseif campo.campo == 'texto' %} {{ campo.etiqueta }} {% elseif fieldValue is not null and '{valor}' in campo.etiqueta %} {{ campo.etiqueta|replace({'{valor}': fieldValue}) }} {% else %} {{ fieldValue ?? campo.etiqueta }} {% endif %}
{% endif %} {% endfor %}
{% for campo in invoiceTableFields %} {% set fieldValue = campo.campo == 'centro_costo_tabla' ? values.centro_costo_detalle|default([]) : values[campo.campo]|default([]) %} {% if fieldValue is iterable and fieldValue|length > 0 %} {% set invoiceKey = 'invoice-' ~ campo.orden|default(loop.index0) %} {% set fieldHeightMm = campo.height * unitFactor %} {% set firstPageLimit = ((fieldHeightMm - 20) / 10)|round(0, 'floor') %} {% set firstPageLimit = firstPageLimit < 1 ? 1 : firstPageLimit %} {% set remainingRows = fieldValue|slice(firstPageLimit) %}
0 ? '' : 'hidden' }}> {% if campo.campo == 'centro_costo_tabla' %} {{ voucher.centro_costo_table( remainingRows, campo.etiqueta, true, false, 'continuation', invoiceKey ) }} {% else %} {{ voucher.invoice_detail_table( remainingRows, campo.etiqueta, values.detalle_facturas_total_formateado|default(''), remainingRows|length > 0, true, false, 'continuation', invoiceKey ) }} {% endif %}
{% endif %} {% endfor %}