feat: add companion2 support, fix UI rendering, and update test data generator

This commit is contained in:
2026-06-22 02:31:08 -04:00
parent 81251fb869
commit ac0dd65efa
10 changed files with 268 additions and 27 deletions

View File

@@ -80,8 +80,8 @@
<button type="button" class="btn btn-sm btn-danger" data-bs-toggle="modal" data-bs-target="#deleteRendicion{{ r[0] }}" title="Eliminar Rendición"><i class="bi bi-trash"></i></button>
</div>
{{ rendicion_detail_modal(r, r[20], r[21], r[22]) }}
{{ edit_rendicion_modal(r, r[20], workers, modulos) }}
{{ rendicion_detail_modal(r, r[23], r[24], r[25]) }}
{{ edit_rendicion_modal(r, r[23], workers, modulos) }}
{{ confirm_modal(
id='deleteRendicion' ~ r[0],

View File

@@ -42,10 +42,10 @@
</div>
</div>
<div class="col-md-3">
<div class="card bg-warning text-dark shadow-sm h-100 border-0">
<div class="card bg-primary text-white shadow-sm h-100 border-0">
<div class="card-body">
<div class="text-uppercase small mb-1 opacity-75">Días Trabajados</div>
<h3 class="card-title mb-0">{{ dias_activos }} <span class="fs-6 fw-normal">/ 31</span></h3>
<div class="text-uppercase small mb-1 opacity-75">Venta Total Neto</div>
<h3 class="card-title mb-0">${{ "{:,.0f}".format(totales_mes.credito * 0.97620 + totales_mes.debito * 0.98453 + totales_mes.mp * 0.98691 + totales_mes.efectivo - totales_mes.gastos).replace(',', '.') }}</h3>
</div>
</div>
</div>
@@ -63,9 +63,9 @@
<div class="card-header border-0 bg-transparent d-flex justify-content-between align-items-center pb-0">
<span class="fw-bold text-muted text-uppercase"><i class="bi bi-calendar3 me-1"></i> Desglose Diario</span>
<button class="btn btn-success btn-sm shadow-sm" onclick="alert('Próximamente: Esto descargará un Excel con el detalle de todos los productos vendidos por día.')">
<a class="btn btn-success btn-sm shadow-sm" href="{{ url_for('admin.report_modulo_exportar_excel', modulo_id=modulo_id, fecha_inicio=fecha_inicio, fecha_fin=fecha_fin, worker_id=worker_actual) }}">
<i class="bi bi-file-earmark-excel-fill me-1"></i> Exportar Detalle Completo (.xlsx)
</button>
</a>
</div>
<div class="card-body">
<div class="table-responsive">
@@ -77,12 +77,20 @@
<th class="py-2 text-info" rowspan="2">COMISIÓN</th>
<th class="py-2 text-danger" rowspan="2">GASTOS</th>
<th class="py-1 border-bottom-0" colspan="4">MEDIOS DE PAGO</th>
<th class="py-1 border-bottom-0" colspan="3">COMISIÓN REDELCOM</th>
<th class="py-1 border-bottom-0" colspan="3">TOTALES NETOS</th>
</tr>
<tr>
<th class="py-1 text-muted">Crédito</th>
<th class="py-1 text-muted">Débito</th>
<th class="py-1 text-muted">Mercado Pago</th>
<th class="py-1 text-muted">Efectivo/Dep.</th>
<th class="py-1" style="color:#e5904d">Crédito (-2.38%)</th>
<th class="py-1" style="color:#e5904d">Débito (-1.547%)</th>
<th class="py-1" style="color:#e5904d">MP (-1.309%)</th>
<th class="py-1" style="color:#20c997">REDELCOM Neto</th>
<th class="py-1 text-warning">Efectivo - Gastos</th>
<th class="py-1 text-primary fw-bold">Venta Total Neto</th>
</tr>
</thead>
<tbody>
@@ -105,6 +113,17 @@
<td class="align-middle numeric-cell text-muted">{{ ("$" ~ "{:,.0f}".format(d.debito).replace(',', '.')) if d.debito > 0 else "-" }}</td>
<td class="align-middle numeric-cell text-muted">{{ ("$" ~ "{:,.0f}".format(d.mp).replace(',', '.')) if d.mp > 0 else "-" }}</td>
<td class="align-middle numeric-cell text-muted">{{ ("$" ~ "{:,.0f}".format(d.efectivo).replace(',', '.')) if d.efectivo > 0 else "-" }}</td>
{% set red_credito = d.credito * 0.97620 %}
{% set red_debito = d.debito * 0.98453 %}
{% set red_mp = d.mp * 0.98691 %}
{% set redelcom_neto = red_credito + red_debito + red_mp %}
{% set efectivo_menos_gastos = d.efectivo - d.gastos %}
<td class="align-middle numeric-cell" style="color:#e5904d">{{ ("$" ~ "{:,.0f}".format(red_credito).replace(',', '.')) if red_credito > 0 else "-" }}</td>
<td class="align-middle numeric-cell" style="color:#e5904d">{{ ("$" ~ "{:,.0f}".format(red_debito).replace(',', '.')) if red_debito > 0 else "-" }}</td>
<td class="align-middle numeric-cell" style="color:#e5904d">{{ ("$" ~ "{:,.0f}".format(red_mp).replace(',', '.')) if red_mp > 0 else "-" }}</td>
<td class="align-middle numeric-cell" style="color:#20c997">{{ ("$" ~ "{:,.0f}".format(redelcom_neto).replace(',', '.')) if redelcom_neto > 0 else "-" }}</td>
<td class="align-middle numeric-cell text-warning fw-bold">{{ ("$" ~ "{:,.0f}".format(efectivo_menos_gastos).replace(',', '.')) if efectivo_menos_gastos != 0 else "-" }}</td>
<td class="align-middle numeric-cell text-primary fw-bold">{{ ("$" ~ "{:,.0f}".format(redelcom_neto + efectivo_menos_gastos).replace(',', '.')) if (redelcom_neto + efectivo_menos_gastos) != 0 else "-" }}</td>
</tr>
{% endfor %}
</tbody>
@@ -125,6 +144,14 @@
<td class="align-middle numeric-cell py-2">${{ "{:,.0f}".format(totales_mes.debito).replace(',', '.') }}</td>
<td class="align-middle numeric-cell py-2">${{ "{:,.0f}".format(totales_mes.mp).replace(',', '.') }}</td>
<td class="align-middle numeric-cell py-2">${{ "{:,.0f}".format(totales_mes.efectivo).replace(',', '.') }}</td>
<td class="align-middle numeric-cell py-2" style="color:#e5904d">${{ "{:,.0f}".format(totales_mes.credito * 0.97620).replace(',', '.') }}</td>
<td class="align-middle numeric-cell py-2" style="color:#e5904d">${{ "{:,.0f}".format(totales_mes.debito * 0.98453).replace(',', '.') }}</td>
<td class="align-middle numeric-cell py-2" style="color:#e5904d">${{ "{:,.0f}".format(totales_mes.mp * 0.98691).replace(',', '.') }}</td>
{% set t_redelcom = totales_mes.credito * 0.97620 + totales_mes.debito * 0.98453 + totales_mes.mp * 0.98691 %}
{% set t_efectivo_menos = totales_mes.efectivo - totales_mes.gastos %}
<td class="align-middle numeric-cell py-2" style="color:#20c997">${{ "{:,.0f}".format(t_redelcom).replace(',', '.') }}</td>
<td class="align-middle numeric-cell py-2 text-warning">${{ "{:,.0f}".format(t_efectivo_menos).replace(',', '.') }}</td>
<td class="align-middle numeric-cell py-2 text-primary fw-bold">${{ "{:,.0f}".format(t_redelcom + t_efectivo_menos).replace(',', '.') }}</td>
</tr>
</tfoot>
</table>

View File

@@ -328,7 +328,7 @@
<dd class="col-sm-7">{{ rendicion[2] }}
{% if session.get('is_admin') %}
<span class="badge {% if rendicion[14] %}bg-success{% else %}bg-secondary{% endif %} ms-1" style="font-size: 0.65em;">
{% if rendicion[14] %}$ Si Recibe Comision{% else %}$ No Recibe Comision{% endif %}
{% if rendicion[14] %}Si Recibe Comision{% else %}No Recibe Comision{% endif %}
</span>
{% endif %}
</dd>
@@ -339,7 +339,21 @@
{{ rendicion[10] }}
{% if session.get('is_admin') %}
<span class="badge {% if rendicion[15] %}bg-success{% else %}bg-secondary{% endif %} ms-1" style="font-size: 0.65em;">
{% if rendicion[15] %}$ Si Recibe Comision{% else %}$ No Recibe Comision{% endif %}
{% if rendicion[15] %}Si Recibe Comision{% else %}No Recibe Comision{% endif %}
</span>
{% endif %}
{% else %}
<span class="text-muted italic small">Sin acompañante</span>
{% endif %}
</dd>
<dt class="col-sm-5 text-muted">Acompañante 2</dt>
<dd class="col-sm-7">
{% if rendicion[16] %}
{{ rendicion[16] }}
{% if session.get('is_admin') %}
<span class="badge {% if rendicion[18] %}bg-success{% else %}bg-secondary{% endif %} ms-1" style="font-size: 0.65em;">
{% if rendicion[18] %}Si Recibe Comision{% else %}No Recibe Comision{% endif %}
</span>
{% endif %}
{% else %}
@@ -352,19 +366,19 @@
</dl>
<hr>
<div class="d-flex justify-content-between mb-2">
<span class="text-muted">Débito <small>(x{{ rendicion[16] }})</small>:</span>
<span class="text-muted">Débito <small>(x{{ rendicion[19] or 0 }})</small>:</span>
<span>${{ "{:,.0f}".format(rendicion[4] or 0).replace(',', '.') }}</span>
</div>
<div class="d-flex justify-content-between mb-2">
<span class="text-muted">Crédito <small>(x{{ rendicion[17] }})</small>:</span>
<span class="text-muted">Crédito <small>(x{{ rendicion[20] or 0 }})</small>:</span>
<span>${{ "{:,.0f}".format(rendicion[5] or 0).replace(',', '.') }}</span>
</div>
<div class="d-flex justify-content-between mb-2">
<span class="text-muted">Mercado Pago <small>(x{{ rendicion[18] }})</small>:</span>
<span class="text-muted">Mercado Pago <small>(x{{ rendicion[21] or 0 }})</small>:</span>
<span>${{ "{:,.0f}".format(rendicion[6] or 0).replace(',', '.') }}</span>
</div>
<div class="d-flex justify-content-between mb-2">
<span class="text-muted">Efectivo <small>(x{{ rendicion[19] }})</small>:</span>
<span class="text-muted">Efectivo <small>(x{{ rendicion[22] or 0 }})</small>:</span>
<span>${{ "{:,.0f}".format(rendicion[7] or 0).replace(',', '.') }}</span>
</div>
@@ -451,7 +465,7 @@
<tr>
<td colspan="3" class="text-end fw-bold">Total Calculado por Sistema:</td>
<td class="text-end fw-bold fs-6 text-primary" id="sys_total_{{ rendicion[0] }}">
${{ "{:,.0f}".format(rendicion[21] or 0).replace(',', '.') }}
${{ "{:,.0f}".format(rendicion[24] or 0).replace(',', '.') }}
</td>
</tr>
</tfoot>
@@ -484,7 +498,7 @@
<div id="badge_worker_{{ rendicion[0] }}"></div>
<div class="form-check m-0">
<input class="form-check-input" type="checkbox" name="worker_comision" id="wc_{{ rendicion[0] }}" {% if rendicion[14] %}checked{% endif %}>
<label class="form-check-label text-warning small fw-bold" for="wc_{{ rendicion[0] }}">Recibe Comisión</label>
<label class="form-check-label text-success small fw-bold" for="wc_{{ rendicion[0] }}">Recibe Comisión</label>
</div>
</div>
</div>
@@ -503,7 +517,26 @@
<div id="badge_comp_{{ rendicion[0] }}"></div>
<div class="form-check m-0">
<input class="form-check-input" type="checkbox" name="companion_comision" id="cc_{{ rendicion[0] }}" {% if rendicion[15] %}checked{% endif %}>
<label class="form-check-label text-warning small fw-bold" for="cc_{{ rendicion[0] }}">Recibe Comisión</label>
<label class="form-check-label text-success small fw-bold" for="cc_{{ rendicion[0] }}">Recibe Comisión</label>
</div>
</div>
</div>
<div class="mb-2 border-top pt-2">
<label class="small text-muted mb-0">Acompañante 2</label>
<select class="form-select form-select-sm" name="companion2_id" onchange="toggleComp2Div({{ rendicion[0] }}, this)">
<option value="" data-tipo="">Sin acompañante</option>
{% for w in workers %}
{% if w[3] == rendicion[13] %}
<option value="{{ w[0] }}" data-tipo="{{ w[2] }}" {% if w[0] == rendicion[17] %}selected{% endif %}>{{ w[1] }}</option>
{% endif %}
{% endfor %}
</select>
<div class="d-flex justify-content-between align-items-center mt-1" id="comp2_com_div_{{ rendicion[0] }}" {% if not rendicion[17] %}style="display:none;"{% endif %}>
<div id="badge_comp2_{{ rendicion[0] }}"></div>
<div class="form-check m-0">
<input class="form-check-input" type="checkbox" name="companion2_comision" id="cc2_{{ rendicion[0] }}" {% if rendicion[18] %}checked{% endif %}>
<label class="form-check-label text-success small fw-bold" for="cc2_{{ rendicion[0] }}">Recibe Comisión</label>
</div>
</div>
</div>
@@ -514,7 +547,7 @@
<input type="text" class="form-control form-control-sm text-end money-input mb-1" id="edit_debito_{{ rendicion[0] }}" name="venta_debito" value="{{ '{:,.0f}'.format(rendicion[4] or 0).replace(',', '.') }}" oninput="calcTotalEdit({{ rendicion[0] }})">
<div class="input-group input-group-sm">
<span class="input-group-text bg-body-tertiary text-muted" style="font-size: 0.7em;">Boletas</span>
<input type="number" class="form-control text-center bg-body text-body border-secondary" name="boletas_debito" value="{{ rendicion[16] or 0 }}">
<input type="number" class="form-control text-center bg-body text-body border-secondary" name="boletas_debito" value="{{ rendicion[19] or 0 }}">
</div>
</div>
<div class="col-6">
@@ -522,7 +555,7 @@
<input type="text" class="form-control form-control-sm text-end money-input mb-1" id="edit_credito_{{ rendicion[0] }}" name="venta_credito" value="{{ '{:,.0f}'.format(rendicion[5] or 0).replace(',', '.') }}" oninput="calcTotalEdit({{ rendicion[0] }})">
<div class="input-group input-group-sm">
<span class="input-group-text bg-body-tertiary text-muted" style="font-size: 0.7em;">Boletas</span>
<input type="number" class="form-control text-center bg-body text-body border-secondary" name="boletas_credito" value="{{ rendicion[17] or 0 }}">
<input type="number" class="form-control text-center bg-body text-body border-secondary" name="boletas_credito" value="{{ rendicion[20] or 0 }}">
</div>
</div>
<div class="col-6">
@@ -530,7 +563,7 @@
<input type="text" class="form-control form-control-sm text-end money-input mb-1" id="edit_mp_{{ rendicion[0] }}" name="venta_mp" value="{{ '{:,.0f}'.format(rendicion[6] or 0).replace(',', '.') }}" oninput="calcTotalEdit({{ rendicion[0] }})">
<div class="input-group input-group-sm">
<span class="input-group-text bg-body-tertiary text-muted" style="font-size: 0.7em;">Boletas</span>
<input type="number" class="form-control text-center bg-body text-body border-secondary" name="boletas_mp" value="{{ rendicion[18] or 0 }}">
<input type="number" class="form-control text-center bg-body text-body border-secondary" name="boletas_mp" value="{{ rendicion[21] or 0 }}">
</div>
</div>
<div class="col-6">
@@ -538,7 +571,7 @@
<input type="text" class="form-control form-control-sm text-end money-input mb-1" id="edit_efectivo_{{ rendicion[0] }}" name="venta_efectivo" value="{{ '{:,.0f}'.format(rendicion[7] or 0).replace(',', '.') }}" oninput="calcTotalEdit({{ rendicion[0] }})">
<div class="input-group input-group-sm">
<span class="input-group-text bg-body-tertiary text-muted" style="font-size: 0.7em;">Boletas</span>
<input type="number" class="form-control text-center bg-body text-body border-secondary" name="boletas_efectivo" value="{{ rendicion[19] or 0 }}">
<input type="number" class="form-control text-center bg-body text-body border-secondary" name="boletas_efectivo" value="{{ rendicion[22] or 0 }}">
</div>
</div>
</div>