Browse Source

Con los cambios hechos fuera de casa

politica
Celestino Rey 1 year ago
parent
commit
4472e45afd
7 changed files with 172 additions and 40 deletions
  1. BIN
      RepostajesPy/servicios/instance/uploads/born.jpeg
  2. BIN
      RepostajesPy/servicios/instance/uploads/therising.jpeg
  3. +4
    -1
      RepostajesPy/servicios/repostajes/models.py
  4. +13
    -8
      RepostajesPy/servicios/repostajes/paginas.py
  5. +139
    -15
      RepostajesPy/servicios/repostajes/templates/index.html
  6. +11
    -11
      RepostajesPy/servicios/repostajes/templates/repostajes.html
  7. +5
    -5
      RepostajesPy/servicios/repostajes/templates/vehiculo.html

BIN
RepostajesPy/servicios/instance/uploads/born.jpeg View File

Before After
Width: 274  |  Height: 184  |  Size: 6.7 KiB

BIN
RepostajesPy/servicios/instance/uploads/therising.jpeg View File

Before After
Width: 225  |  Height: 225  |  Size: 7.3 KiB

+ 4
- 1
RepostajesPy/servicios/repostajes/models.py View File

@ -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'<Vehiculos {self.matricula}>'
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'<Vehiculos {self.matricula}>'
return f'<Repostajes {self.fecha}>'

+ 13
- 8
RepostajesPy/servicios/repostajes/paginas.py View File

@ -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)


+ 139
- 15
RepostajesPy/servicios/repostajes/templates/index.html View File

@ -4,23 +4,147 @@
<div class="container-xl">
<h1 class="app-page-title">Introducción</h1>
<h1 class="app-page-title">Resumen</h1>
<nav id="orders-table-tab" class="orders-table-tab app-nav-tabs nav shadow-sm flex-column flex-sm-row mb-4">
<a class="flex-sm-fill text-sm-center nav-link active" id="orders-all-tab" data-bs-toggle="tab" href="#orders-all" role="tab" aria-controls="orders-all" aria-selected="true">Todos</a>
{% for cadacoche in vehiculos %}
<a class="flex-sm-fill text-sm-center nav-link" id="orders-paid-tab" data-bs-toggle="tab" href="#{{ cadacoche.matricula }}" role="tab" aria-controls="orders-paid" aria-selected="false">{{ cadacoche.marca }}</a>
{% endfor %}
<a class="flex-sm-fill text-sm-center nav-link" id="orders-pending-tab" data-bs-toggle="tab" href="#vehiculos" role="tab" aria-controls="orders-pending" aria-selected="false">Vehículos</a>
</nav>
<div class="app-card alert alert-dismissible shadow-sm mb-4 border-left-decoration" role="alert">
<div class="inner">
<div class="app-card-body p-3 p-lg-4">
<h3 class="mb-3">¡Bienvenido al registro de repostajes de mis vehículos!</h3>
<div class="row gx-5 gy-3">
<div class="col-12 col-lg-9">
<div>Pensado para tener información del consumo de los coches.</div>
</div><!--//col-->
</div><!--//row-->
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div><!--//app-card-body-->
</div><!--//inner-->
</div><!--//app-card-->
<div class="tab-content" id="orders-table-tab-content">
<div class="tab-pane fade show active" id="orders-all" role="tabpanel" aria-labelledby="orders-all-tab">
<div class="app-card app-card-orders-table shadow-sm mb-5">
<div class="app-card-body">
<div class="table-responsive">
<table class="table app-table-hover mb-0 text-left">
<thead>
<tr>
<th class="cell">#</th>
<th class="cell">Fecha</th>
<th class="cell">Vehículo</th>
<th class="cell">Kilómetros</th>
<th class="cell">Litros</th>
<th class="cell">Descuento</th>
<th class="cell">Precio/litro</th>
<th class="cell">Importe</th>
</tr>
</thead>
<tbody>
{% for repostaje in repostajes %}
<tr>
<td class="cell">{{ repostaje.id }}</td>
<td class="cell">{{ repostaje.fecha }}</td>
<td class="cell">{{ repostaje.vehiculos.matricula }}</td>
<td style="text-align: right" class="cell">{{ "%.0f"|format(repostaje.kms) }}</td>
<td style="text-align: right" class="cell">{{ "%.2f €"|format(repostaje.litros) }}</td>
<td style="text-align: right" class="cell">{{ "%.2f €"|format(repostaje.descuento) }}</td>
<td style="text-align: right" class="cell">{{ "%.2f €"|format(repostaje.precioxlitro) }}</td>
<td style="text-align: right" class="cell">{{ "%.2f €"|format(repostaje.importe) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div><!--//table-responsive-->
</div><!--//app-card-body-->
</div><!--//app-card-->
</div><!--//tab-pane-->
{% for micoche in vehiculos %}
<div class="tab-pane fade" id="{{ micoche.matricula }}" role="tabpanel" aria-labelledby="orders-paid-tab">
<div class="app-card app-card-orders-table mb-5">
<div class="app-card-body">
<div class="table-responsive">
<table class="table mb-0 text-left">
<thead>
<tr>
<th class="cell">Matrícula</th>
<th class="cell">#</th>
<th class="cell">Fecha</th>
<th class="cell">Vehículo</th>
<th class="cell">Kilómetros</th>
<th class="cell">Litros</th>
<th class="cell">Descuento</th>
<th class="cell">Precio/litro</th>
<th class="cell">Importe</th>
<th class="cell">Recorridos</th>
<th class="cell">Consumo/100kms</th>
</tr>
</thead>
<tbody>
{% for repostaje in repostajes %}
<!-- {% if micoche.id == repostajes.vehiculo_id %}-->
<tr>
<td>{{ micoche.matricula }} </td>
<td class="cell">{{ repostaje.id }}</td>
<td class="cell">{{ repostaje.fecha }}</td>
<td class="cell">{{ repostaje.vehiculo }}</td>
<td style="text-align: right" class="cell">{{ repostaje.kms }}</td>
<td style="text-align: right" class="cell">{{ repostaje.litros }}</td>
<td style="text-align: right" class="cell">{{ repostaje.descuento }}</td>
<td style="text-align: right" class="cell">{{ repostaje.precioxlitro }}</td>
<td style="text-align: right" class="cell">{{ repostaje.importe }}</td>
<td style="text-align: right" class="cell">{{ repostaje.kmsrecorridos }} </td>
<td class="cell">0</td>
</tr>
<!--{% endif %} -->
{% endfor %}
</tbody>
</table>
</div><!--//table-responsive-->
</div><!--//app-card-body-->
</div><!--//app-card-->
</div><!--//tab-pane-->
{% endfor %}
<div class="tab-pane fade" id="vehiculos" role="tabpanel" aria-labelledby="orders-pending-tab">
<div class="app-card app-card-orders-table mb-5">
<div class="app-card-body">
<div class="table-responsive">
<table class="table mb-0 text-left">
<thead>
<tr>
<th class="cell">#</th>
<th class="cell">Marca</th>
<th class="cell">Modelo</th>
<th class="cell">Matricula</th>
</tr>
</thead>
<tbody>
{% for row in vehiculos %}
<tr>
<td class="cell">{{ row.id }}</td>
<td class="cell">{{ row.marca }}</td>
<td class="cell">{{ row.modelo }}</td>
<td class="cell">{{ row.matricula }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div><!--//table-responsive-->
</div><!--//app-card-body-->
</div><!--//app-card-->
</div><!--//tab-pane-->
</div><!--//tab-content-->
</div><!--//container-fluid-->
{% endblock %}

+ 11
- 11
RepostajesPy/servicios/repostajes/templates/repostajes.html View File

@ -26,11 +26,11 @@
<th class="cell">#</th>
<th class="cell">Fecha</th>
<th class="cell">Vehículo</th>
<th class="cell">Kilómetros</th>
<th class="cell">Litros</th>
<th class="cell">Descuento</th>
<th class="cell">Precio por litro</th>
<th class="cell">Importe</th>
<th style="text-align: right" class="cell">Kilómetros</th>
<th style="text-align: right" class="cell">Litros</th>
<th style="text-align: right" class="cell">Descuento</th>
<th style="text-align: right" class="cell">Precio por litro</th>
<th style="text-align: right" class="cell">Importe</th>
</tr>
</thead>
<tbody>
@ -38,12 +38,12 @@
<tr>
<td class="cell">{{ repostaje.id }}</td>
<td class="cell">{{ repostaje.fecha }}</td>
<td class="cell">{{ repostaje.vehiculo }}</td>
<td class="cell">{{ repostaje.kms }}</td>
<td class="cell">{{ repostaje.litros }}</td>
<td class="cell">{{ repostaje.descuento }}</td>
<td class="cell">{{ repostaje.precioxlitro }}</td>
<td class="cell">{{ repostaje.importe }}</td>
<td class="cell">{{ repostaje.vehiculos.matricula }}</td>
<td style="text-align: right" class="cell">{{ "%.0f"|format(repostaje.kms) }}</td>
<td style="text-align: right" class="cell">{{ "%.2f €"|format(repostaje.litros) }}</td>
<td style="text-align: right" class="cell">{{ "%.2f €"|format(repostaje.descuento) }}</td>
<td style="text-align: right" class="cell">{{ "%.2f €"|format(repostaje.precioxlitro) }}</td>
<td style="text-align: right" class="cell">{{ "%.2f €"|format(repostaje.importe) }}</td>
</tr>
{% endfor %}
</tbody>


+ 5
- 5
RepostajesPy/servicios/repostajes/templates/vehiculo.html View File

@ -45,11 +45,11 @@
<td class="cell">{{ repostaje.id }}</td>
<td class="cell">{{ repostaje.fecha }}</td>
<td class="cell">{{ repostaje.vehiculo }}</td>
<td class="cell">{{ repostaje.kms }}</td>
<td class="cell">{{ repostaje.litros }}</td>
<td class="cell">{{ repostaje.descuento }}</td>
<td class="cell">{{ repostaje.precioxlitro }}</td>
<td class="cell">{{ repostaje.importe }}</td>
<td style="text-align: right" class="cell">{{ repostaje.kms }}</td>
<td style="text-align: right" class="cell">{{ repostaje.litros }}</td>
<td style="text-align: right" class="cell">{{ "%.2f €"|format(repostaje.descuento) }}</td>
<td style="text-align: right" class="cell">{{ "%.2f €"|format(repostaje.precioxlitro) }} </td>
<td style="text-align: right" class="cell">{{ "%.2f €"|format(repostaje.importe) }}</td>
</tr>
{% endfor %}
</tbody>


Loading…
Cancel
Save