From 821674d9f5b5f5a671f86a7382961dfc6d6a89cf Mon Sep 17 00:00:00 2001 From: Shiro-Nek0 Date: Sat, 21 Mar 2026 00:01:47 -0300 Subject: [PATCH] =?UTF-8?q?acompa=C3=B1ante=20agregado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 43 ++++++++++++++++----------- templates/admin_rendicion_detail.html | 33 ++++++++++++-------- templates/worker_dashboard.html | 20 +++++++++---- 3 files changed, 61 insertions(+), 35 deletions(-) diff --git a/app.py b/app.py index 27f788b..e1e5fe9 100644 --- a/app.py +++ b/app.py @@ -52,18 +52,20 @@ def init_db(): # 5. Rendiciones (The main form headers) c.execute('''CREATE TABLE IF NOT EXISTS rendiciones - (id INTEGER PRIMARY KEY AUTOINCREMENT, - worker_id INTEGER NOT NULL, - modulo_id INTEGER NOT NULL, - fecha DATE NOT NULL, - turno TEXT NOT NULL, - venta_tarjeta INTEGER DEFAULT 0, - venta_mp INTEGER DEFAULT 0, - venta_efectivo INTEGER DEFAULT 0, - gastos INTEGER DEFAULT 0, - observaciones TEXT, - FOREIGN KEY (worker_id) REFERENCES workers(id), - FOREIGN KEY (modulo_id) REFERENCES modulos(id))''') + (id INTEGER PRIMARY KEY AUTOINCREMENT, + worker_id INTEGER NOT NULL, + companion_id INTEGER, -- Nueva columna + modulo_id INTEGER NOT NULL, + fecha DATE NOT NULL, + turno TEXT NOT NULL, + venta_tarjeta INTEGER DEFAULT 0, + venta_mp INTEGER DEFAULT 0, + venta_efectivo INTEGER DEFAULT 0, + gastos INTEGER DEFAULT 0, + observaciones TEXT, + FOREIGN KEY (worker_id) REFERENCES workers(id), + FOREIGN KEY (companion_id) REFERENCES workers(id), + FOREIGN KEY (modulo_id) REFERENCES modulos(id))''') # 6. Rendicion Items (The individual product quantities sold) c.execute('''CREATE TABLE IF NOT EXISTS rendicion_items @@ -228,6 +230,9 @@ def worker_dashboard(): efectivo = clean_and_validate(request.form.get('venta_efectivo')) gastos = clean_and_validate(request.form.get('gastos')) or 0 obs = request.form.get('observaciones', '').strip() + companion_id = request.form.get('companion_id') + if companion_id == "": + 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: @@ -239,10 +244,7 @@ def worker_dashboard(): total_ventas_general = total_digital + efectivo # Insertar Cabecera de Rendición - c.execute('''INSERT INTO rendiciones - (worker_id, modulo_id, fecha, turno, venta_tarjeta, venta_mp, venta_efectivo, gastos, observaciones) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)''', - (session['user_id'], modulo_id, fecha, turno, tarjeta, mp, efectivo, gastos, obs)) + c.execute('''INSERT INTO rendiciones (worker_id, companion_id, modulo_id, fecha, turno, venta_tarjeta, venta_mp, venta_efectivo, gastos, observaciones) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''', (session['user_id'], companion_id, modulo_id, fecha, turno, tarjeta, mp, efectivo, gastos, obs)) rendicion_id = c.lastrowid # Insertar Productos (Solo aquellos con cantidad > 0) @@ -265,6 +267,10 @@ def worker_dashboard(): return redirect(url_for('worker_dashboard')) # 3. Cargar Productos para la solicitud GET + c.execute("SELECT id, name FROM workers WHERE id != ? AND is_admin = 0 ORDER BY name", (session['user_id'],)) + otros_trabajadores = c.fetchall() + + # Cargar Productos (código existente) c.execute("SELECT id, name, price, commission FROM productos WHERE zona_id = ? ORDER BY name", (zona_id,)) productos = c.fetchall() conn.close() @@ -276,6 +282,7 @@ def worker_dashboard(): zona_name=zona_name, productos=productos, has_commission=has_commission, + otros_trabajadores=otros_trabajadores, today=date.today().strftime('%Y-%m-%d')) @app.route('/admin/workers', methods=['GET', 'POST']) @@ -605,10 +612,12 @@ def view_rendicion(id): # Get Header Info c.execute(''' SELECT r.id, r.fecha, w.name, m.name, r.turno, - r.venta_tarjeta, r.venta_mp, r.venta_efectivo, r.gastos, r.observaciones + r.venta_tarjeta, r.venta_mp, r.venta_efectivo, r.gastos, r.observaciones, + c_w.name -- Nombre del acompañante (índice 10) FROM rendiciones r JOIN workers w ON r.worker_id = w.id JOIN modulos m ON r.modulo_id = m.id + LEFT JOIN workers c_w ON r.companion_id = c_w.id -- Join para el acompañante WHERE r.id = ? ''', (id,)) rendicion = c.fetchone() diff --git a/templates/admin_rendicion_detail.html b/templates/admin_rendicion_detail.html index b7dbe4d..fc89171 100644 --- a/templates/admin_rendicion_detail.html +++ b/templates/admin_rendicion_detail.html @@ -58,20 +58,29 @@
Declaración del Trabajador
-
-
-
Fecha
-
{{ rendicion[1] }}
- -
Trabajador
-
{{ rendicion[2] }}
+
+
+
Fecha
+
{{ rendicion[1] }}
+ +
Trabajador
+
{{ rendicion[2] }}
-
Módulo
-
{{ rendicion[3] }}
+
Acompañante
+
+ {% if rendicion[10] %} + {{ rendicion[10] }} + {% else %} + Sin acompañante + {% endif %} +
-
Turno
-
{{ rendicion[4] }}
-
+
Módulo
+
{{ rendicion[3] }}
+ +
Turno
+
{{ rendicion[4] }}
+

diff --git a/templates/worker_dashboard.html b/templates/worker_dashboard.html index 61a58b4..491965a 100644 --- a/templates/worker_dashboard.html +++ b/templates/worker_dashboard.html @@ -43,10 +43,18 @@
+
+ + +
-
Detalle de Productos Vendidos
@@ -110,21 +118,21 @@
$ - +
$ - +
$ - +
@@ -134,14 +142,14 @@
$ - +
$ - +