ermover turno, añadir horas, mover gastos y hacer q no afecten total

This commit is contained in:
2026-03-21 21:20:49 -03:00
parent 82ccfa6940
commit 72b81b26b8
5 changed files with 143 additions and 93 deletions

View File

@@ -25,23 +25,22 @@
<th>Fecha</th>
<th>Trabajador</th>
<th>Módulo</th>
<th>Turno</th>
<th>Total Declarado</th>
<th>Gastos</th>
<th class="text-end">Acciones</th>
</tr>
</thead>
<tbody>
<tbody>
{% for r in rendiciones %}
<tr>
<td class="align-middle">{{ r[1] }}</td>
<td class="align-middle">{{ r[2] }}</td>
<td class="align-middle"><span class="badge bg-info text-dark">{{ r[3] }}</span></td>
<td class="align-middle">{{ r[4] }}</td>
<td class="align-middle">
${{ "{:,.0f}".format((r[5] or 0) + (r[6] or 0) + (r[7] or 0) + (r[8] or 0)).replace(',', '.') }}
${{ "{:,.0f}".format((r[4] or 0) + (r[5] or 0) + (r[6] or 0) + (r[7] or 0)).replace(',', '.') }}
</td>
<td class="align-middle text-danger">${{ "{:,.0f}".format(r[9] or 0).replace(',', '.') }}</td>
<td class="align-middle text-danger">${{ "{:,.0f}".format(r[8] or 0).replace(',', '.') }}</td>
<td class="text-end">
<div class="btn-group" role="group">
<button type="button" class="btn btn-sm btn-info text-white" data-bs-toggle="modal" data-bs-target="#viewRendicion{{ r[0] }}" title="Ver Detalle"><i class="bi bi-eye"></i></button>
@@ -49,7 +48,7 @@
<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[15], r[16], r[17]) }}
{{ rendicion_detail_modal(r, r[14], r[15], r[16]) }}
{{ edit_rendicion_modal(r, workers, modulos) }}
{{ confirm_modal(
@@ -64,7 +63,7 @@
</tr>
{% else %}
<tr>
<td colspan="7" class="text-center py-4 text-muted">Aún no hay rendiciones enviadas.</td>
<td colspan="6" class="text-center py-4 text-muted">Aún no hay rendiciones enviadas.</td>
</tr>
{% endfor %}
</tbody>

View File

@@ -121,7 +121,7 @@
<button type="button" class="btn btn-outline-warning btn-sm w-100"
data-bs-toggle="modal"
data-bs-target="#confirmResetPass"
data-bs-dismiss="modal"> {# Esto cierra el de edición al abrir el de confirmación #}
data-bs-dismiss="modal">
<i class="bi bi-key me-1"></i> Restablecer Contraseña
</button>
<small class="text-muted text-center mt-1">Generará una nueva clave aleatoria.</small>
@@ -201,8 +201,8 @@
<dt class="col-sm-5 text-muted">Acompañante</dt>
<dd class="col-sm-7">
{% if rendicion[11] %}
{{ rendicion[11] }}
{% if rendicion[10] %}
{{ rendicion[10] }}
{% else %}
<span class="text-muted italic small">Sin acompañante</span>
{% endif %}
@@ -210,29 +210,26 @@
<dt class="col-sm-5 text-muted">Módulo</dt>
<dd class="col-sm-7"><span class="badge bg-secondary">{{ rendicion[3] }}</span></dd>
<dt class="col-sm-5 text-muted">Turno</dt>
<dd class="col-sm-7">{{ rendicion[4] }}</dd>
</dl>
<hr>
<div class="d-flex justify-content-between mb-2">
<span class="text-muted">Débito:</span>
<span>${{ "{:,.0f}".format(rendicion[5] or 0).replace(',', '.') }}</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:</span>
<span>${{ "{:,.0f}".format(rendicion[6] or 0).replace(',', '.') }}</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:</span>
<span>${{ "{:,.0f}".format(rendicion[7] or 0).replace(',', '.') }}</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:</span>
<span>${{ "{:,.0f}".format(rendicion[8] or 0).replace(',', '.') }}</span>
<span>${{ "{:,.0f}".format(rendicion[7] or 0).replace(',', '.') }}</span>
</div>
{% set total_declarado = (rendicion[5] or 0) + (rendicion[6] or 0) + (rendicion[7] or 0) + (rendicion[8] or 0) %}
{% set total_declarado = (rendicion[4] or 0) + (rendicion[5] or 0) + (rendicion[6] or 0) + (rendicion[7] or 0) %}
<div class="d-flex justify-content-between mt-3 pt-2 border-top">
<strong class="fs-5">Total Declarado:</strong>
<strong class="fs-5">${{ "{:,.0f}".format(total_declarado).replace(',', '.') }}</strong>
@@ -251,12 +248,12 @@
<div class="card-body">
<div class="d-flex justify-content-between mb-3">
<strong class="text-danger">Monto Gastos:</strong>
<strong class="text-danger">-${{ "{:,.0f}".format(rendicion[9] or 0).replace(',', '.') }}</strong>
<strong class="text-danger">-${{ "{:,.0f}".format(rendicion[8] or 0).replace(',', '.') }}</strong>
</div>
<div>
<span class="text-muted d-block mb-1">Observaciones:</span>
<p class="mb-0 bg-dark p-2 rounded border border-secondary" style="font-size: 0.9em;">
{{ rendicion[10] if rendicion[10] else "Sin observaciones." }}
{{ rendicion[9] if rendicion[9] else "Sin observaciones." }}
</p>
</div>
</div>
@@ -284,23 +281,15 @@
<div class="modal-body text-start">
<h6 class="border-bottom pb-2 text-primary">Datos Generales</h6>
<div class="row g-3 mb-4">
<div class="col-md-4">
<div class="col-md-6">
<label class="form-label">Fecha</label>
<input type="date" class="form-control" name="fecha" value="{{ rendicion[1] }}" required>
</div>
<div class="col-md-4">
<label class="form-label">Turno</label>
<select class="form-select" name="turno" required>
<option value="Primer Turno" {% if rendicion[4] == 'Primer Turno' %}selected{% endif %}>Primer Turno</option>
<option value="Segundo Turno" {% if rendicion[4] == 'Segundo Turno' %}selected{% endif %}>Segundo Turno</option>
<option value="Part Time" {% if rendicion[4] == 'Part Time' %}selected{% endif %}>Part Time</option>
</select>
</div>
<div class="col-md-4">
<div class="col-md-6">
<label class="form-label">Módulo</label>
<select class="form-select" name="modulo_id" required>
{% for mod in modulos %}
<option value="{{ mod[0] }}" {% if mod[0] == rendicion[14] %}selected{% endif %}>{{ mod[1] }}</option>
<option value="{{ mod[0] }}" {% if mod[0] == rendicion[13] %}selected{% endif %}>{{ mod[1] }}</option>
{% endfor %}
</select>
</div>
@@ -308,7 +297,7 @@
<label class="form-label">Trabajador</label>
<select class="form-select" name="worker_id" required>
{% for w in workers %}
<option value="{{ w[0] }}" {% if w[0] == rendicion[12] %}selected{% endif %}>{{ w[1] }}</option>
<option value="{{ w[0] }}" {% if w[0] == rendicion[11] %}selected{% endif %}>{{ w[1] }}</option>
{% endfor %}
</select>
</div>
@@ -317,7 +306,7 @@
<select class="form-select" name="companion_id">
<option value="">Sin acompañante</option>
{% for w in workers %}
<option value="{{ w[0] }}" {% if w[0] == rendicion[13] %}selected{% endif %}>{{ w[1] }}</option>
<option value="{{ w[0] }}" {% if w[0] == rendicion[12] %}selected{% endif %}>{{ w[1] }}</option>
{% endfor %}
</select>
</div>
@@ -329,32 +318,32 @@
<label class="form-label">Débito</label>
<div class="input-group">
<span class="input-group-text">$</span>
<input type="text" class="form-control" id="edit_debito_{{ rendicion[0] }}" name="venta_debito" value="{{ '{:,.0f}'.format(rendicion[5] or 0).replace(',', '.') }}" oninput="calcTotalEdit({{ rendicion[0] }})">
<input type="text" class="form-control" id="edit_debito_{{ rendicion[0] }}" name="venta_debito" value="{{ '{:,.0f}'.format(rendicion[4] or 0).replace(',', '.') }}" oninput="calcTotalEdit({{ rendicion[0] }})">
</div>
</div>
<div class="col-md-3">
<label class="form-label">Crédito</label>
<div class="input-group">
<span class="input-group-text">$</span>
<input type="text" class="form-control" id="edit_credito_{{ rendicion[0] }}" name="venta_credito" value="{{ '{:,.0f}'.format(rendicion[6] or 0).replace(',', '.') }}" oninput="calcTotalEdit({{ rendicion[0] }})">
<input type="text" class="form-control" id="edit_credito_{{ rendicion[0] }}" name="venta_credito" value="{{ '{:,.0f}'.format(rendicion[5] or 0).replace(',', '.') }}" oninput="calcTotalEdit({{ rendicion[0] }})">
</div>
</div>
<div class="col-md-3">
<label class="form-label">Mercado Pago</label>
<div class="input-group">
<span class="input-group-text">$</span>
<input type="text" class="form-control money-input" id="edit_mp_{{ rendicion[0] }}" name="venta_mp" value="{{ '{:,.0f}'.format(rendicion[7] or 0).replace(',', '.') }}" oninput="calcTotalEdit({{ rendicion[0] }})" required>
<input type="text" class="form-control money-input" id="edit_mp_{{ rendicion[0] }}" name="venta_mp" value="{{ '{:,.0f}'.format(rendicion[6] or 0).replace(',', '.') }}" oninput="calcTotalEdit({{ rendicion[0] }})" required>
</div>
</div>
<div class="col-md-3">
<label class="form-label">Efectivo</label>
<div class="input-group">
<span class="input-group-text">$</span>
<input type="text" class="form-control money-input" id="edit_efectivo_{{ rendicion[0] }}" name="venta_efectivo" value="{{ '{:,.0f}'.format(rendicion[8] or 0).replace(',', '.') }}" oninput="calcTotalEdit({{ rendicion[0] }})" required>
<input type="text" class="form-control money-input" id="edit_efectivo_{{ rendicion[0] }}" name="venta_efectivo" value="{{ '{:,.0f}'.format(rendicion[7] or 0).replace(',', '.') }}" oninput="calcTotalEdit({{ rendicion[0] }})" required>
</div>
</div>
{% set total_declarado_actual = (rendicion[5] or 0) + (rendicion[6] or 0) + (rendicion[7] or 0) + (rendicion[8] or 0) %}
{% set total_declarado_actual = (rendicion[4] or 0) + (rendicion[5] or 0) + (rendicion[6] or 0) + (rendicion[7] or 0) %}
<div class="col-12 mt-3 bg-body-secondary p-3 rounded border border-secondary-subtle">
<div class="d-flex justify-content-between pb-2">
<span class="text-body-secondary">Total Declarado (Original):</span>
@@ -370,12 +359,12 @@
<label class="form-label text-danger">Gastos</label>
<div class="input-group">
<span class="input-group-text">$</span>
<input type="text" class="form-control money-input border-danger" name="gastos" value="{{ '{:,.0f}'.format(rendicion[9] or 0).replace(',', '.') }}" required>
<input type="text" class="form-control money-input border-danger" name="gastos" value="{{ '{:,.0f}'.format(rendicion[8] or 0).replace(',', '.') }}" required>
</div>
</div>
<div class="col-md-8 mt-4">
<label class="form-label">Observaciones</label>
<textarea class="form-control" name="observaciones" rows="1">{{ rendicion[10] }}</textarea>
<textarea class="form-control" name="observaciones" rows="1">{{ rendicion[9] }}</textarea>
</div>
</div>
</div>

View File

@@ -30,28 +30,39 @@
<div class="card-header bg-primary text-white">Datos del Turno</div>
<div class="card-body">
<div class="row g-3">
<div class="col-md-6">
<div class="col-md-4">
<label class="form-label">Fecha de Venta</label>
<input type="date" class="form-control" name="fecha" value="{{ today }}" required>
</div>
<div class="col-md-6">
<label class="form-label">Turno</label>
<select class="form-select" name="turno" required>
<option value="" disabled selected>Seleccionar...</option>
<option value="Primer Turno">Primer Turno</option>
<option value="Segundo Turno">Segundo Turno</option>
<option value="Part Time">Part Time</option>
</select>
<div class="col-md-4">
<label class="form-label">Entrada</label>
<input type="time" class="form-control" name="hora_entrada" required>
</div>
<div class="col-md-12">
<div class="col-md-4">
<label class="form-label">Salida</label>
<input type="time" class="form-control" name="hora_salida" required>
</div>
<div class="col-md-6">
<label class="form-label">Acompañante (Opcional)</label>
<select class="form-select" name="companion_id">
<select class="form-select" name="companion_id" id="companion_select">
<option value="">Trabajando solo / Sin acompañante</option>
{% for worker in otros_trabajadores %}
<option value="{{ worker[0] }}">{{ worker[1] }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-6" id="companion_times_div" style="display: none;">
<div class="row">
<div class="col-6">
<label class="form-label">Entrada Acompañante</label>
<input type="time" class="form-control" name="companion_hora_entrada" id="comp_in">
</div>
<div class="col-6">
<label class="form-label">Salida Acompañante</label>
<input type="time" class="form-control" name="companion_hora_salida" id="comp_out">
</div>
</div>
</div>
</div>
</div>
</div>
@@ -110,7 +121,7 @@
</div>
</div>
<div class="card mb-4 shadow-sm border-info">
<div class="card mb-4 shadow-sm border-info">
<div class="card-header bg-info text-dark">Resumen Financiero</div>
<div class="card-body">
<div class="row g-3 mb-4">
@@ -143,32 +154,41 @@
</div>
</div>
</div>
<div class="row g-3 mb-4 p-3 bg-body-secondary rounded shadow-sm">
<div class="col-md-4">
<label class="form-label text-info fw-bold">Total Digital (Tarjeta + MP)</label>
<div class="row g-3 p-3 bg-body-secondary rounded shadow-sm">
<div class="col-md-6">
<label class="form-label text-info fw-bold">Total Digital (Tarjetas + MP)</label>
<div class="input-group">
<span class="input-group-text bg-info text-white border-info">$</span>
<input type="text" class="form-control bg-dark-subtle fw-bold" placeholder="0" id="total_digital" readonly>
</div>
</div>
<div class="col-md-4">
<label class="form-label text-danger fw-bold">Gastos del Módulo</label>
<div class="input-group">
<span class="input-group-text bg-danger text-white border-danger">-$</span>
<input type="text" class="form-control money-input sale-input" name="gastos" id="gastos" placeholder="0">
</div>
</div>
<div class="col-md-4">
<label class="form-label text-success fw-bold">Total Ventas (Neto)</label>
<div class="col-md-6">
<label class="form-label text-success fw-bold">Total Ventas Declaradas</label>
<div class="input-group">
<span class="input-group-text bg-success text-white border-success">$</span>
<input type="text" class="form-control bg-dark-subtle fw-bold" placeholder="0" id="total_general" readonly>
</div>
</div>
</div>
<div class="mt-3">
<label class="form-label">Observaciones / Concepto de Gastos</label>
<textarea class="form-control" name="observaciones" rows="2" placeholder="Si hubo gastos, anota el motivo aquí..."></textarea>
</div>
</div>
<div class="card mb-4 shadow-sm border-danger">
<div class="card-header bg-danger text-white">Gastos y Observaciones</div>
<div class="card-body">
<div class="row g-3">
<div class="col-md-4">
<label class="form-label text-danger fw-bold">Monto de Gastos</label>
<div class="input-group">
<span class="input-group-text bg-danger text-white border-danger">$</span>
<input type="text" class="form-control money-input" name="gastos" id="gastos" placeholder="0">
</div>
</div>
<div class="col-md-8">
<label class="form-label">Observaciones / Motivo</label>
<textarea class="form-control" name="observaciones" rows="2" placeholder="Si hubo gastos o necesitas reportar algo, anótalo aquí..."></textarea>
</div>
</div>
</div>
</div>
@@ -196,6 +216,25 @@
{% endblock %}
{% block scripts %}
<script>
document.getElementById('companion_select').addEventListener('change', function() {
const timeDiv = document.getElementById('companion_times_div');
const compIn = document.getElementById('comp_in');
const compOut = document.getElementById('comp_out');
if (this.value) {
timeDiv.style.display = 'block';
compIn.required = true;
compOut.required = true;
} else {
timeDiv.style.display = 'none';
compIn.required = false;
compOut.required = false;
compIn.value = '';
compOut.value = '';
}
});
</script>
<script>
const inputsCantidad = document.querySelectorAll('input[name^="qty_"]');
const displayTotalProductos = document.getElementById('total_productos_calc');
@@ -295,13 +334,12 @@ document.addEventListener('DOMContentLoaded', function() {
const credito = getVal('venta_credito');
const mp = getVal('venta_mp');
const efectivo = getVal('venta_efectivo');
const gastos = getVal('gastos');
const totalDigital = debito + credito + mp;
const totalGeneral = (totalDigital + efectivo) - gastos;
const totalGeneral = totalDigital + efectivo; // Ya no restamos los gastos aquí
displayDigital.value = totalDigital.toLocaleString('es-CL');
displayGeneral.value = totalGeneral.toLocaleString('es-CL');
document.getElementById('total_digital').value = totalDigital.toLocaleString('es-CL');
document.getElementById('total_general').value = totalGeneral.toLocaleString('es-CL');
}
inputsVenta.forEach(input => {