ermover turno, añadir horas, mover gastos y hacer q no afecten total
This commit is contained in:
@@ -34,8 +34,11 @@ services:
|
|||||||
```
|
```
|
||||||
# TODO preguntas:
|
# TODO preguntas:
|
||||||
- ver si gastos debe o no restar del total
|
- ver si gastos debe o no restar del total
|
||||||
|
- ver si tienen como turnos fijos para setear un horario
|
||||||
|
- ver si trabajan mas de 2 personas maximo al dia
|
||||||
|
|
||||||
# TODO general:
|
# TODO general:
|
||||||
|
- añadir si es part time o full time en la tabla de trabajadores para ver si necesitan comisiones
|
||||||
- separar productos para tiendas
|
- separar productos para tiendas
|
||||||
- limpiar requirements.txt
|
- limpiar requirements.txt
|
||||||
- hacer placeholders funcionales (si dice 0 que el sistema lea 0 no null)
|
- hacer placeholders funcionales (si dice 0 que el sistema lea 0 no null)
|
||||||
|
|||||||
65
app.py
65
app.py
@@ -80,7 +80,28 @@ def populateDefaults():
|
|||||||
for name, price, commission in productos_data:
|
for name, price, commission in productos_data:
|
||||||
c.execute("INSERT INTO productos (zona_id, name, price, commission) VALUES (?, ?, ?, ?)",
|
c.execute("INSERT INTO productos (zona_id, name, price, commission) VALUES (?, ?, ?, ?)",
|
||||||
(zona_id, name, price, commission))
|
(zona_id, name, price, commission))
|
||||||
conn.commit()
|
|
||||||
|
c.execute("SELECT COUNT(*) FROM workers WHERE is_admin = 0")
|
||||||
|
if c.fetchone()[0] == 0:
|
||||||
|
c.execute("SELECT id FROM modulos LIMIT 2")
|
||||||
|
modulos_ids = c.fetchall()
|
||||||
|
|
||||||
|
if len(modulos_ids) >= 2:
|
||||||
|
mod_1 = modulos_ids[0][0]
|
||||||
|
mod_2 = modulos_ids[1][0]
|
||||||
|
|
||||||
|
default_pass = generate_password_hash("123456")
|
||||||
|
|
||||||
|
workers_data = [
|
||||||
|
("11.111.111-1", "Juan Perez", "+56 9 1111 1111", default_pass, 0, mod_1),
|
||||||
|
("22.222.222-2", "Maria Gonzalez", "+56 9 2222 2222", default_pass, 0, mod_1),
|
||||||
|
("33.333.333-3", "Pedro Soto", "+56 9 3333 3333", default_pass, 0, mod_2),
|
||||||
|
("44.444.444-4", "Ana Silva", "+56 9 4444 4444", default_pass, 0, mod_2)
|
||||||
|
]
|
||||||
|
|
||||||
|
for w in workers_data:
|
||||||
|
c.execute("INSERT OR IGNORE INTO workers (rut, name, phone, password_hash, is_admin, modulo_id) VALUES (?, ?, ?, ?, ?, ?)", w)
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
def init_db():
|
def init_db():
|
||||||
@@ -127,7 +148,10 @@ def init_db():
|
|||||||
companion_id INTEGER,
|
companion_id INTEGER,
|
||||||
modulo_id INTEGER NOT NULL,
|
modulo_id INTEGER NOT NULL,
|
||||||
fecha DATE NOT NULL,
|
fecha DATE NOT NULL,
|
||||||
turno TEXT NOT NULL,
|
hora_entrada TEXT NOT NULL,
|
||||||
|
hora_salida TEXT NOT NULL,
|
||||||
|
companion_hora_entrada TEXT,
|
||||||
|
companion_hora_salida TEXT,
|
||||||
venta_debito INTEGER DEFAULT 0,
|
venta_debito INTEGER DEFAULT 0,
|
||||||
venta_credito INTEGER DEFAULT 0,
|
venta_credito INTEGER DEFAULT 0,
|
||||||
venta_mp INTEGER DEFAULT 0,
|
venta_mp INTEGER DEFAULT 0,
|
||||||
@@ -285,18 +309,19 @@ def worker_dashboard():
|
|||||||
# 2. Manejo del envío del formulario
|
# 2. Manejo del envío del formulario
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
fecha = request.form.get('fecha')
|
fecha = request.form.get('fecha')
|
||||||
turno = request.form.get('turno')
|
hora_entrada = request.form.get('hora_entrada')
|
||||||
|
hora_salida = request.form.get('hora_salida')
|
||||||
|
companion_hora_entrada = request.form.get('companion_hora_entrada')
|
||||||
|
companion_hora_salida = request.form.get('companion_hora_salida')
|
||||||
|
|
||||||
# Función para limpiar puntos y validar presencia de datos
|
|
||||||
def clean_and_validate(val):
|
def clean_and_validate(val):
|
||||||
if val is None or val.strip() == "":
|
if val is None or val.strip() == "":
|
||||||
return 0 # <--- Cambiado de None a 0
|
return 0
|
||||||
try:
|
try:
|
||||||
return int(val.replace('.', ''))
|
return int(val.replace('.', ''))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return 0 # <--- Cambiado de None a 0
|
return 0
|
||||||
|
|
||||||
# Captura y validación de campos obligatorios
|
|
||||||
debito = clean_and_validate(request.form.get('venta_debito'))
|
debito = clean_and_validate(request.form.get('venta_debito'))
|
||||||
credito = clean_and_validate(request.form.get('venta_credito'))
|
credito = clean_and_validate(request.form.get('venta_credito'))
|
||||||
mp = clean_and_validate(request.form.get('venta_mp'))
|
mp = clean_and_validate(request.form.get('venta_mp'))
|
||||||
@@ -304,24 +329,24 @@ def worker_dashboard():
|
|||||||
gastos = clean_and_validate(request.form.get('gastos')) or 0
|
gastos = clean_and_validate(request.form.get('gastos')) or 0
|
||||||
obs = request.form.get('observaciones', '').strip()
|
obs = request.form.get('observaciones', '').strip()
|
||||||
companion_id = request.form.get('companion_id')
|
companion_id = request.form.get('companion_id')
|
||||||
|
|
||||||
if companion_id == "":
|
if companion_id == "":
|
||||||
companion_id = None
|
companion_id = None
|
||||||
|
companion_hora_entrada = None
|
||||||
|
companion_hora_salida = None
|
||||||
|
|
||||||
# VERIFICACIÓN: Todos los campos de venta deben estar rellenos
|
if debito is None or credito is None or mp is None or efectivo is None or not fecha or not hora_entrada or not hora_salida:
|
||||||
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 obligatorios deben estar rellenos.", "danger")
|
||||||
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'))
|
return redirect(url_for('worker_dashboard'))
|
||||||
|
|
||||||
# CÁLCULOS ADICIONALES (Para lógica de negocio o auditoría futura)
|
|
||||||
total_digital = debito + credito + mp
|
total_digital = debito + credito + mp
|
||||||
total_ventas_general = total_digital + efectivo
|
total_ventas_general = total_digital + efectivo
|
||||||
|
|
||||||
# Insertar Cabecera de Rendición
|
|
||||||
c.execute('''INSERT INTO rendiciones
|
c.execute('''INSERT INTO rendiciones
|
||||||
(worker_id, companion_id, modulo_id, fecha, turno,
|
(worker_id, companion_id, modulo_id, fecha, hora_entrada, hora_salida, companion_hora_entrada, companion_hora_salida,
|
||||||
venta_debito, venta_credito, venta_mp, venta_efectivo, gastos, observaciones)
|
venta_debito, venta_credito, venta_mp, venta_efectivo, gastos, observaciones)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
(session['user_id'], companion_id, modulo_id, fecha, turno,
|
(session['user_id'], companion_id, modulo_id, fecha, hora_entrada, hora_salida, companion_hora_entrada, companion_hora_salida,
|
||||||
debito, credito, mp, efectivo, gastos, obs))
|
debito, credito, mp, efectivo, gastos, obs))
|
||||||
rendicion_id = c.lastrowid
|
rendicion_id = c.lastrowid
|
||||||
|
|
||||||
@@ -672,7 +697,7 @@ def admin_rendiciones():
|
|||||||
|
|
||||||
# Añadimos worker_id (11), companion_id (12) y modulo_id (13) a la consulta
|
# Añadimos worker_id (11), companion_id (12) y modulo_id (13) a la consulta
|
||||||
c.execute('''
|
c.execute('''
|
||||||
SELECT r.id, r.fecha, w.name, m.name, r.turno,
|
SELECT r.id, r.fecha, w.name, m.name,
|
||||||
r.venta_debito, r.venta_credito, r.venta_mp, r.venta_efectivo, r.gastos, r.observaciones,
|
r.venta_debito, r.venta_credito, r.venta_mp, r.venta_efectivo, r.gastos, r.observaciones,
|
||||||
c_w.name, r.worker_id, r.companion_id, r.modulo_id
|
c_w.name, r.worker_id, r.companion_id, r.modulo_id
|
||||||
FROM rendiciones r
|
FROM rendiciones r
|
||||||
@@ -736,9 +761,7 @@ def delete_rendicion(id):
|
|||||||
@app.route('/admin/rendiciones/edit/<int:id>', methods=['POST'])
|
@app.route('/admin/rendiciones/edit/<int:id>', methods=['POST'])
|
||||||
@admin_required
|
@admin_required
|
||||||
def edit_rendicion(id):
|
def edit_rendicion(id):
|
||||||
# Campos de cabecera
|
|
||||||
fecha = request.form.get('fecha')
|
fecha = request.form.get('fecha')
|
||||||
turno = request.form.get('turno')
|
|
||||||
worker_id = request.form.get('worker_id')
|
worker_id = request.form.get('worker_id')
|
||||||
modulo_id = request.form.get('modulo_id')
|
modulo_id = request.form.get('modulo_id')
|
||||||
companion_id = request.form.get('companion_id')
|
companion_id = request.form.get('companion_id')
|
||||||
@@ -746,7 +769,6 @@ def edit_rendicion(id):
|
|||||||
if companion_id == "":
|
if companion_id == "":
|
||||||
companion_id = None
|
companion_id = None
|
||||||
|
|
||||||
# ¡ADIÓS venta_tarjeta! Capturamos débito y crédito separados
|
|
||||||
debito = request.form.get('venta_debito', '0').replace('.', '')
|
debito = request.form.get('venta_debito', '0').replace('.', '')
|
||||||
credito = request.form.get('venta_credito', '0').replace('.', '')
|
credito = request.form.get('venta_credito', '0').replace('.', '')
|
||||||
mp = request.form.get('venta_mp', '0').replace('.', '')
|
mp = request.form.get('venta_mp', '0').replace('.', '')
|
||||||
@@ -767,13 +789,12 @@ def edit_rendicion(id):
|
|||||||
conn = sqlite3.connect(DB_NAME)
|
conn = sqlite3.connect(DB_NAME)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
|
||||||
# Actualizamos los nombres de las columnas en el UPDATE
|
|
||||||
c.execute('''
|
c.execute('''
|
||||||
UPDATE rendiciones
|
UPDATE rendiciones
|
||||||
SET fecha=?, turno=?, worker_id=?, modulo_id=?, companion_id=?,
|
SET fecha=?, worker_id=?, modulo_id=?, companion_id=?,
|
||||||
venta_debito=?, venta_credito=?, venta_mp=?, venta_efectivo=?, gastos=?, observaciones=?
|
venta_debito=?, venta_credito=?, venta_mp=?, venta_efectivo=?, gastos=?, observaciones=?
|
||||||
WHERE id=?
|
WHERE id=?
|
||||||
''', (fecha, turno, worker_id, modulo_id, companion_id, debito, credito, mp, efectivo, gastos, observaciones, id))
|
''', (fecha, worker_id, modulo_id, companion_id, debito, credito, mp, efectivo, gastos, observaciones, id))
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|||||||
@@ -25,23 +25,22 @@
|
|||||||
<th>Fecha</th>
|
<th>Fecha</th>
|
||||||
<th>Trabajador</th>
|
<th>Trabajador</th>
|
||||||
<th>Módulo</th>
|
<th>Módulo</th>
|
||||||
<th>Turno</th>
|
|
||||||
<th>Total Declarado</th>
|
<th>Total Declarado</th>
|
||||||
<th>Gastos</th>
|
<th>Gastos</th>
|
||||||
<th class="text-end">Acciones</th>
|
<th class="text-end">Acciones</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for r in rendiciones %}
|
{% for r in rendiciones %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="align-middle">{{ r[1] }}</td>
|
<td class="align-middle">{{ r[1] }}</td>
|
||||||
<td class="align-middle">{{ r[2] }}</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"><span class="badge bg-info text-dark">{{ r[3] }}</span></td>
|
||||||
<td class="align-middle">{{ r[4] }}</td>
|
|
||||||
<td class="align-middle">
|
<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>
|
||||||
<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">
|
<td class="text-end">
|
||||||
<div class="btn-group" role="group">
|
<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-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>
|
<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>
|
</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) }}
|
{{ edit_rendicion_modal(r, workers, modulos) }}
|
||||||
|
|
||||||
{{ confirm_modal(
|
{{ confirm_modal(
|
||||||
@@ -64,7 +63,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% else %}
|
{% else %}
|
||||||
<tr>
|
<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>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -121,7 +121,7 @@
|
|||||||
<button type="button" class="btn btn-outline-warning btn-sm w-100"
|
<button type="button" class="btn btn-outline-warning btn-sm w-100"
|
||||||
data-bs-toggle="modal"
|
data-bs-toggle="modal"
|
||||||
data-bs-target="#confirmResetPass"
|
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
|
<i class="bi bi-key me-1"></i> Restablecer Contraseña
|
||||||
</button>
|
</button>
|
||||||
<small class="text-muted text-center mt-1">Generará una nueva clave aleatoria.</small>
|
<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>
|
<dt class="col-sm-5 text-muted">Acompañante</dt>
|
||||||
<dd class="col-sm-7">
|
<dd class="col-sm-7">
|
||||||
{% if rendicion[11] %}
|
{% if rendicion[10] %}
|
||||||
{{ rendicion[11] }}
|
{{ rendicion[10] }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="text-muted italic small">Sin acompañante</span>
|
<span class="text-muted italic small">Sin acompañante</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -210,29 +210,26 @@
|
|||||||
|
|
||||||
<dt class="col-sm-5 text-muted">Módulo</dt>
|
<dt class="col-sm-5 text-muted">Módulo</dt>
|
||||||
<dd class="col-sm-7"><span class="badge bg-secondary">{{ rendicion[3] }}</span></dd>
|
<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>
|
</dl>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="d-flex justify-content-between mb-2">
|
<div class="d-flex justify-content-between mb-2">
|
||||||
<span class="text-muted">Débito:</span>
|
<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>
|
||||||
<div class="d-flex justify-content-between mb-2">
|
<div class="d-flex justify-content-between mb-2">
|
||||||
<span class="text-muted">Crédito:</span>
|
<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>
|
||||||
<div class="d-flex justify-content-between mb-2">
|
<div class="d-flex justify-content-between mb-2">
|
||||||
<span class="text-muted">Mercado Pago:</span>
|
<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>
|
||||||
<div class="d-flex justify-content-between mb-2">
|
<div class="d-flex justify-content-between mb-2">
|
||||||
<span class="text-muted">Efectivo:</span>
|
<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>
|
</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">
|
<div class="d-flex justify-content-between mt-3 pt-2 border-top">
|
||||||
<strong class="fs-5">Total Declarado:</strong>
|
<strong class="fs-5">Total Declarado:</strong>
|
||||||
<strong class="fs-5">${{ "{:,.0f}".format(total_declarado).replace(',', '.') }}</strong>
|
<strong class="fs-5">${{ "{:,.0f}".format(total_declarado).replace(',', '.') }}</strong>
|
||||||
@@ -251,12 +248,12 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="d-flex justify-content-between mb-3">
|
<div class="d-flex justify-content-between mb-3">
|
||||||
<strong class="text-danger">Monto Gastos:</strong>
|
<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>
|
||||||
<div>
|
<div>
|
||||||
<span class="text-muted d-block mb-1">Observaciones:</span>
|
<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;">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -284,23 +281,15 @@
|
|||||||
<div class="modal-body text-start">
|
<div class="modal-body text-start">
|
||||||
<h6 class="border-bottom pb-2 text-primary">Datos Generales</h6>
|
<h6 class="border-bottom pb-2 text-primary">Datos Generales</h6>
|
||||||
<div class="row g-3 mb-4">
|
<div class="row g-3 mb-4">
|
||||||
<div class="col-md-4">
|
<div class="col-md-6">
|
||||||
<label class="form-label">Fecha</label>
|
<label class="form-label">Fecha</label>
|
||||||
<input type="date" class="form-control" name="fecha" value="{{ rendicion[1] }}" required>
|
<input type="date" class="form-control" name="fecha" value="{{ rendicion[1] }}" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-6">
|
||||||
<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">
|
|
||||||
<label class="form-label">Módulo</label>
|
<label class="form-label">Módulo</label>
|
||||||
<select class="form-select" name="modulo_id" required>
|
<select class="form-select" name="modulo_id" required>
|
||||||
{% for mod in modulos %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -308,7 +297,7 @@
|
|||||||
<label class="form-label">Trabajador</label>
|
<label class="form-label">Trabajador</label>
|
||||||
<select class="form-select" name="worker_id" required>
|
<select class="form-select" name="worker_id" required>
|
||||||
{% for w in workers %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -317,7 +306,7 @@
|
|||||||
<select class="form-select" name="companion_id">
|
<select class="form-select" name="companion_id">
|
||||||
<option value="">Sin acompañante</option>
|
<option value="">Sin acompañante</option>
|
||||||
{% for w in workers %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -329,32 +318,32 @@
|
|||||||
<label class="form-label">Débito</label>
|
<label class="form-label">Débito</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-text">$</span>
|
<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>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label class="form-label">Crédito</label>
|
<label class="form-label">Crédito</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-text">$</span>
|
<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>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label class="form-label">Mercado Pago</label>
|
<label class="form-label">Mercado Pago</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-text">$</span>
|
<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>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label class="form-label">Efectivo</label>
|
<label class="form-label">Efectivo</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-text">$</span>
|
<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>
|
||||||
</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="col-12 mt-3 bg-body-secondary p-3 rounded border border-secondary-subtle">
|
||||||
<div class="d-flex justify-content-between pb-2">
|
<div class="d-flex justify-content-between pb-2">
|
||||||
<span class="text-body-secondary">Total Declarado (Original):</span>
|
<span class="text-body-secondary">Total Declarado (Original):</span>
|
||||||
@@ -370,12 +359,12 @@
|
|||||||
<label class="form-label text-danger">Gastos</label>
|
<label class="form-label text-danger">Gastos</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-text">$</span>
|
<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>
|
</div>
|
||||||
<div class="col-md-8 mt-4">
|
<div class="col-md-8 mt-4">
|
||||||
<label class="form-label">Observaciones</label>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -30,28 +30,39 @@
|
|||||||
<div class="card-header bg-primary text-white">Datos del Turno</div>
|
<div class="card-header bg-primary text-white">Datos del Turno</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="col-md-6">
|
<div class="col-md-4">
|
||||||
<label class="form-label">Fecha de Venta</label>
|
<label class="form-label">Fecha de Venta</label>
|
||||||
<input type="date" class="form-control" name="fecha" value="{{ today }}" required>
|
<input type="date" class="form-control" name="fecha" value="{{ today }}" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-4">
|
||||||
<label class="form-label">Turno</label>
|
<label class="form-label">Entrada</label>
|
||||||
<select class="form-select" name="turno" required>
|
<input type="time" class="form-control" name="hora_entrada" 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>
|
</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>
|
<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>
|
<option value="">Trabajando solo / Sin acompañante</option>
|
||||||
{% for worker in otros_trabajadores %}
|
{% for worker in otros_trabajadores %}
|
||||||
<option value="{{ worker[0] }}">{{ worker[1] }}</option>
|
<option value="{{ worker[0] }}">{{ worker[1] }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -110,7 +121,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</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-header bg-info text-dark">Resumen Financiero</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row g-3 mb-4">
|
<div class="row g-3 mb-4">
|
||||||
@@ -143,32 +154,41 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row g-3 mb-4 p-3 bg-body-secondary rounded shadow-sm">
|
|
||||||
<div class="col-md-4">
|
<div class="row g-3 p-3 bg-body-secondary rounded shadow-sm">
|
||||||
<label class="form-label text-info fw-bold">Total Digital (Tarjeta + MP)</label>
|
<div class="col-md-6">
|
||||||
|
<label class="form-label text-info fw-bold">Total Digital (Tarjetas + MP)</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-text bg-info text-white border-info">$</span>
|
<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>
|
<input type="text" class="form-control bg-dark-subtle fw-bold" placeholder="0" id="total_digital" readonly>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-6">
|
||||||
<label class="form-label text-danger fw-bold">Gastos del Módulo</label>
|
<label class="form-label text-success fw-bold">Total Ventas Declaradas</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="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-text bg-success text-white border-success">$</span>
|
<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>
|
<input type="text" class="form-control bg-dark-subtle fw-bold" placeholder="0" id="total_general" readonly>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-3">
|
</div>
|
||||||
<label class="form-label">Observaciones / Concepto de Gastos</label>
|
</div>
|
||||||
<textarea class="form-control" name="observaciones" rows="2" placeholder="Si hubo gastos, anota el motivo aquí..."></textarea>
|
|
||||||
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -196,6 +216,25 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block scripts %}
|
{% 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>
|
<script>
|
||||||
const inputsCantidad = document.querySelectorAll('input[name^="qty_"]');
|
const inputsCantidad = document.querySelectorAll('input[name^="qty_"]');
|
||||||
const displayTotalProductos = document.getElementById('total_productos_calc');
|
const displayTotalProductos = document.getElementById('total_productos_calc');
|
||||||
@@ -295,13 +334,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
const credito = getVal('venta_credito');
|
const credito = getVal('venta_credito');
|
||||||
const mp = getVal('venta_mp');
|
const mp = getVal('venta_mp');
|
||||||
const efectivo = getVal('venta_efectivo');
|
const efectivo = getVal('venta_efectivo');
|
||||||
const gastos = getVal('gastos');
|
|
||||||
|
|
||||||
const totalDigital = debito + credito + mp;
|
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');
|
document.getElementById('total_digital').value = totalDigital.toLocaleString('es-CL');
|
||||||
displayGeneral.value = totalGeneral.toLocaleString('es-CL');
|
document.getElementById('total_general').value = totalGeneral.toLocaleString('es-CL');
|
||||||
}
|
}
|
||||||
|
|
||||||
inputsVenta.forEach(input => {
|
inputsVenta.forEach(input => {
|
||||||
|
|||||||
Reference in New Issue
Block a user