diff --git a/RepostajesPy/servicios/instance/uploads/born.jpeg b/RepostajesPy/servicios/instance/uploads/born.jpeg new file mode 100644 index 0000000..9074f89 Binary files /dev/null and b/RepostajesPy/servicios/instance/uploads/born.jpeg differ diff --git a/RepostajesPy/servicios/instance/uploads/therising.jpeg b/RepostajesPy/servicios/instance/uploads/therising.jpeg new file mode 100644 index 0000000..22be7d4 Binary files /dev/null and b/RepostajesPy/servicios/instance/uploads/therising.jpeg differ diff --git a/RepostajesPy/servicios/repostajes/models.py b/RepostajesPy/servicios/repostajes/models.py index 3d76497..6191e63 100644 --- a/RepostajesPy/servicios/repostajes/models.py +++ b/RepostajesPy/servicios/repostajes/models.py @@ -17,6 +17,9 @@ class Vehiculos(db.Model): repostajes = db.relationship('Repostajes', backref='vehiculos', lazy=True) foto = db.Column(db.String(100), nullable=True) + def __repr__(self): + return f'' + class Repostajes(db.Model): id = db.Column(db.Integer, primary_key=True) fecha = db.Column(db.Date, nullable=False) @@ -29,4 +32,4 @@ class Repostajes(db.Model): def __repr__(self): - return f'' + return f'' diff --git a/RepostajesPy/servicios/repostajes/paginas.py b/RepostajesPy/servicios/repostajes/paginas.py index 802030f..7d2a6b6 100644 --- a/RepostajesPy/servicios/repostajes/paginas.py +++ b/RepostajesPy/servicios/repostajes/paginas.py @@ -11,8 +11,11 @@ bp = Blueprint("paginas", __name__) @bp.route('/') def index(): + vehiculos = Vehiculos.query.all() + repostajes = Repostajes.query.all() - return render_template('index.html') + + return render_template('index.html', vehiculos=vehiculos, repostajes=repostajes) @bp.route('/repostajes') def repostajes(): @@ -56,22 +59,24 @@ def add_repostaje(): kms = request.form['kms'] litros = request.form['litros'] importe = request.form['importe'] - dtoing = request.form['dtoing'] - precioxlitro = int(importe) / int(litros) + dtoing = request.form.get('dtoing') - descuento = 0 + if dtoing: + descuento = int(importe) * 0.03 # Aplico el descuento de ING + else : + descuento = 0 # no se marcó la casilla de descuento ING - print("add_repostaje: dtoing ",dtoing) + totalcondto = int(importe) - descuento + precioxlitro = totalcondto / int(litros) - new_repostaje = Repostajes(fecha=fecha, vehiculo_id=vehiculo_id, kms=kms, litros=litros, importe=importe, descuento=descuento, precioxlitro=precioxlitro) + new_repostaje = Repostajes(fecha=fecha, vehiculo_id=vehiculo_id, kms=kms, litros=litros, importe=totalcondto, descuento=descuento, precioxlitro=precioxlitro) db.session.add(new_repostaje) db.session.commit() return redirect(url_for('paginas.vehiculo', vehiculo_id=vehiculo_id)) vehiculos = Vehiculos.query.all() - for coche in vehiculos: - print("add_repostaje: ", coche.matricula) + return render_template('add_repostaje.html', vehiculos=vehiculos) diff --git a/RepostajesPy/servicios/repostajes/templates/index.html b/RepostajesPy/servicios/repostajes/templates/index.html index 4ffca92..b968ab9 100644 --- a/RepostajesPy/servicios/repostajes/templates/index.html +++ b/RepostajesPy/servicios/repostajes/templates/index.html @@ -4,23 +4,147 @@
-

Introducción

+

Resumen

+ + - +
+
+
+
+
+ + + + + + + + + + + + + + + {% for repostaje in repostajes %} + + + + + + + + + + + {% endfor %} + +
#FechaVehículoKilómetrosLitrosDescuentoPrecio/litroImporte
{{ repostaje.id }}{{ repostaje.fecha }}{{ repostaje.vehiculos.matricula }}{{ "%.0f"|format(repostaje.kms) }}{{ "%.2f €"|format(repostaje.litros) }}{{ "%.2f €"|format(repostaje.descuento) }}{{ "%.2f €"|format(repostaje.precioxlitro) }}{{ "%.2f €"|format(repostaje.importe) }}
+
+ +
+
+
+ + {% for micoche in vehiculos %} + +
+
+
+
+ + + + + + + + + + + + + + + + + + + {% for repostaje in repostajes %} + + + + + + + + + + + + + + + + + + + {% endfor %} + + +
Matrícula#FechaVehículoKilómetrosLitrosDescuentoPrecio/litroImporteRecorridosConsumo/100kms
{{ micoche.matricula }} {{ repostaje.id }}{{ repostaje.fecha }}{{ repostaje.vehiculo }}{{ repostaje.kms }}{{ repostaje.litros }}{{ repostaje.descuento }}{{ repostaje.precioxlitro }}{{ repostaje.importe }}{{ repostaje.kmsrecorridos }} 0
+
+
+
+
+ {% endfor %} + + +
+
+
+
+ + + + + + + + + + + {% for row in vehiculos %} + + + + + + + {% endfor %} + + +
#MarcaModeloMatricula
{{ row.id }}{{ row.marca }}{{ row.modelo }}{{ row.matricula }}
+
+
+
+
+
+ + +
{% endblock %} diff --git a/RepostajesPy/servicios/repostajes/templates/repostajes.html b/RepostajesPy/servicios/repostajes/templates/repostajes.html index 87a1d88..a590acd 100644 --- a/RepostajesPy/servicios/repostajes/templates/repostajes.html +++ b/RepostajesPy/servicios/repostajes/templates/repostajes.html @@ -26,11 +26,11 @@ # Fecha Vehículo - Kilómetros - Litros - Descuento - Precio por litro - Importe + Kilómetros + Litros + Descuento + Precio por litro + Importe @@ -38,12 +38,12 @@ {{ repostaje.id }} {{ repostaje.fecha }} - {{ repostaje.vehiculo }} - {{ repostaje.kms }} - {{ repostaje.litros }} - {{ repostaje.descuento }} - {{ repostaje.precioxlitro }} - {{ repostaje.importe }} + {{ repostaje.vehiculos.matricula }} + {{ "%.0f"|format(repostaje.kms) }} + {{ "%.2f €"|format(repostaje.litros) }} + {{ "%.2f €"|format(repostaje.descuento) }} + {{ "%.2f €"|format(repostaje.precioxlitro) }} + {{ "%.2f €"|format(repostaje.importe) }} {% endfor %} diff --git a/RepostajesPy/servicios/repostajes/templates/vehiculo.html b/RepostajesPy/servicios/repostajes/templates/vehiculo.html index bcb17a8..687ffd6 100644 --- a/RepostajesPy/servicios/repostajes/templates/vehiculo.html +++ b/RepostajesPy/servicios/repostajes/templates/vehiculo.html @@ -45,11 +45,11 @@ {{ repostaje.id }} {{ repostaje.fecha }} {{ repostaje.vehiculo }} - {{ repostaje.kms }} - {{ repostaje.litros }} - {{ repostaje.descuento }} - {{ repostaje.precioxlitro }} - {{ repostaje.importe }} + {{ repostaje.kms }} + {{ repostaje.litros }} + {{ "%.2f €"|format(repostaje.descuento) }} + {{ "%.2f €"|format(repostaje.precioxlitro) }} + {{ "%.2f €"|format(repostaje.importe) }} {% endfor %}