ahora si funcan las tarjetas lol
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Rendiciones-App
|
||||
# KSNE-Rendiciones-App
|
||||
|
||||
## 🐳 Docker Deployment (Server)
|
||||
|
||||
|
||||
17
app.py
17
app.py
@@ -237,12 +237,12 @@ def worker_dashboard():
|
||||
companion_id = None
|
||||
|
||||
# VERIFICACIÓN: Todos los campos de venta deben estar rellenos
|
||||
if tarjeta is None or mp is None or efectivo is None or not fecha or not turno:
|
||||
if debito is None or credito is None or mp is None or efectivo is None or not fecha or not turno:
|
||||
flash("Error: Todos los campos (Fecha, Turno, Tarjeta, MP y Efectivo) son obligatorios. Use 0 si no hubo ventas.", "danger")
|
||||
return redirect(url_for('worker_dashboard'))
|
||||
|
||||
# CÁLCULOS ADICIONALES (Para lógica de negocio o auditoría futura)
|
||||
total_digital = tarjeta + mp
|
||||
total_digital = debito + credito + mp
|
||||
total_ventas_general = total_digital + efectivo
|
||||
|
||||
# Insertar Cabecera de Rendición
|
||||
@@ -671,15 +671,17 @@ def edit_rendicion(id):
|
||||
if companion_id == "":
|
||||
companion_id = None
|
||||
|
||||
# Campos de dinero
|
||||
tarjeta = request.form.get('venta_tarjeta', '0').replace('.', '')
|
||||
# ¡ADIÓS venta_tarjeta! Capturamos débito y crédito separados
|
||||
debito = request.form.get('venta_debito', '0').replace('.', '')
|
||||
credito = request.form.get('venta_credito', '0').replace('.', '')
|
||||
mp = request.form.get('venta_mp', '0').replace('.', '')
|
||||
efectivo = request.form.get('venta_efectivo', '0').replace('.', '')
|
||||
gastos = request.form.get('gastos', '0').replace('.', '')
|
||||
observaciones = request.form.get('observaciones', '').strip()
|
||||
|
||||
try:
|
||||
tarjeta = int(tarjeta) if tarjeta else 0
|
||||
debito = int(debito) if debito else 0
|
||||
credito = int(credito) if credito else 0
|
||||
mp = int(mp) if mp else 0
|
||||
efectivo = int(efectivo) if efectivo else 0
|
||||
gastos = int(gastos) if gastos else 0
|
||||
@@ -690,12 +692,13 @@ def edit_rendicion(id):
|
||||
conn = sqlite3.connect(DB_NAME)
|
||||
c = conn.cursor()
|
||||
|
||||
# Actualizamos los nombres de las columnas en el UPDATE
|
||||
c.execute('''
|
||||
UPDATE rendiciones
|
||||
SET fecha=?, turno=?, worker_id=?, modulo_id=?, companion_id=?,
|
||||
venta_tarjeta=?, venta_mp=?, venta_efectivo=?, gastos=?, observaciones=?
|
||||
venta_debito=?, venta_credito=?, venta_mp=?, venta_efectivo=?, gastos=?, observaciones=?
|
||||
WHERE id=?
|
||||
''', (fecha, turno, worker_id, modulo_id, companion_id, tarjeta, mp, efectivo, gastos, observaciones, id))
|
||||
''', (fecha, turno, worker_id, modulo_id, companion_id, debito, credito, mp, efectivo, gastos, observaciones, id))
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<th class="text-end">Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody>
|
||||
{% for r in rendiciones %}
|
||||
<tr>
|
||||
<td class="align-middle">{{ r[1] }}</td>
|
||||
@@ -39,37 +39,17 @@
|
||||
<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[17] or 0) + (r[6] or 0) + (r[7] or 0)).replace(',', '.') }}
|
||||
${{ "{:,.0f}".format((r[5] or 0) + (r[6] or 0) + (r[7] or 0) + (r[8] or 0)).replace(',', '.') }}
|
||||
</td>
|
||||
<td class="align-middle text-danger">${{ "{:,.0f}".format(r[8] or 0).replace(',', '.') }}</td>
|
||||
<td class="align-middle text-danger">${{ "{:,.0f}".format(r[9] 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>
|
||||
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-primary"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#editRendicion{{ r[0] }}"
|
||||
title="Editar Valores Declarados">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
<button type="button" class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#editRendicion{{ r[0] }}" title="Editar Valores Declarados"><i class="bi bi-pencil"></i></button>
|
||||
<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[14], r[15], r[16]) }}
|
||||
{{ rendicion_detail_modal(r, r[15], r[16], r[17]) }}
|
||||
{{ edit_rendicion_modal(r, workers, modulos) }}
|
||||
|
||||
{{ confirm_modal(
|
||||
@@ -98,11 +78,12 @@
|
||||
function calcTotalEdit(id) {
|
||||
const getVal = (inputId) => parseInt(document.getElementById(inputId).value.replace(/\D/g, '')) || 0;
|
||||
|
||||
const tarjeta = getVal(`edit_tarjeta_${id}`);
|
||||
const debito = getVal(`edit_debito_${id}`);
|
||||
const credito = getVal(`edit_credito_${id}`);
|
||||
const mp = getVal(`edit_mp_${id}`);
|
||||
const efectivo = getVal(`edit_efectivo_${id}`);
|
||||
|
||||
const total = tarjeta + mp + efectivo;
|
||||
const total = debito + credito + mp + efectivo;
|
||||
|
||||
document.getElementById(`display_nuevo_total_${id}`).innerText = '$' + total.toLocaleString('es-CL');
|
||||
}
|
||||
|
||||
@@ -201,8 +201,8 @@
|
||||
|
||||
<dt class="col-sm-5 text-muted">Acompañante</dt>
|
||||
<dd class="col-sm-7">
|
||||
{% if rendicion[10] %}
|
||||
{{ rendicion[10] }}
|
||||
{% if rendicion[11] %}
|
||||
{{ rendicion[11] }}
|
||||
{% else %}
|
||||
<span class="text-muted italic small">Sin acompañante</span>
|
||||
{% endif %}
|
||||
@@ -216,19 +216,23 @@
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<span class="text-muted">Tarjetas:</span>
|
||||
<span class="text-muted">Débito:</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 class="text-muted">Crédito:</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 class="text-muted">Mercado Pago:</span>
|
||||
<span>${{ "{:,.0f}".format(rendicion[7] 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>
|
||||
</div>
|
||||
|
||||
{% set total_declarado = rendicion[5] + rendicion[6] + rendicion[7] %}
|
||||
{% set total_declarado = (rendicion[5] or 0) + (rendicion[6] or 0) + (rendicion[7] or 0) + (rendicion[8] 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>
|
||||
@@ -247,12 +251,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[8] or 0).replace(',', '.') }}</strong>
|
||||
<strong class="text-danger">-${{ "{:,.0f}".format(rendicion[9] 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[9] if rendicion[9] else "Sin observaciones." }}
|
||||
{{ rendicion[10] if rendicion[10] else "Sin observaciones." }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -321,11 +325,18 @@
|
||||
|
||||
<h6 class="border-bottom pb-2 text-success">Declaración de Dinero</h6>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Tarjetas</label>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Débito</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">$</span>
|
||||
<input type="text" class="form-control money-input" id="edit_tarjeta_{{ rendicion[0] }}" name="venta_tarjeta" value="{{ rendicion[5] }}" oninput="calcTotalEdit({{ rendicion[0] }})" required>
|
||||
<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] }})">
|
||||
</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] }})">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
|
||||
@@ -128,14 +128,14 @@
|
||||
<input type="text" class="form-control money-input sale-input" name="venta_credito" id="venta_credito" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Venta Mercado Pago</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">$</span>
|
||||
<input type="text" class="form-control money-input sale-input" placeholder="0" name="venta_mp" id="venta_mp" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Venta Efectivo</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">$</span>
|
||||
@@ -143,7 +143,6 @@
|
||||
</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>
|
||||
|
||||
Reference in New Issue
Block a user