ciclos

commit d9e9b1292373b6255904887de8ad961bd425ae5f

Author: Pedro Lucas Porcellis <pedrolucasporcellis@gmail.com>

Introduce reports

 core/app.py | 2 
 core/blueprints/reports.py | 44 ++++++++++++++
 core/templates/report_by_user.html | 100 ++++++++++++++++++++++++++++++++
 core/templates/reports.html | 15 ++++


diff --git a/core/app.py b/core/app.py
index 35e2afab601f35e7a96e36821d9c91a9a4f784ba..ed828f0386eab33a665011e25b051b2fdd117828 100644
--- a/core/app.py
+++ b/core/app.py
@@ -35,6 +35,7 @@ from core.blueprints.product_categories import product_categories
 from core.blueprints.products import pro as products
 from core.blueprints.cycles import cycles
 from core.blueprints.orders import orders
+from core.blueprints.reports import reports
 
 app.register_blueprint(basic)
 app.register_blueprint(auth)
@@ -43,6 +44,7 @@ app.register_blueprint(product_categories)
 app.register_blueprint(products)
 app.register_blueprint(cycles)
 app.register_blueprint(orders)
+app.register_blueprint(reports)
 
 @app.errorhandler(404)
 def handle_404(e):




diff --git a/core/blueprints/reports.py b/core/blueprints/reports.py
new file mode 100644
index 0000000000000000000000000000000000000000..75ea1e950dc6f6f5f2ccecb5932e6d3c5a091126
--- /dev/null
+++ b/core/blueprints/reports.py
@@ -0,0 +1,44 @@
+from flask import Blueprint, request, render_template
+from core.config import title
+
+from functools import reduce
+
+import pdb
+
+from core.types.order import Order
+from core.types.order_product import OrderProduct
+from core.types.product import Product
+from core.types.group import Group
+from core.types.cycle import Cycle
+import random
+
+reports = Blueprint("reports", __name__, url_prefix = "/reports")
+
+@reports.route("/")
+def index():
+    return render_template("reports.html", title = f"Relatórios - {title}")
+
+@reports.route("/user")
+def user():
+    current_cycle = Cycle.query.filter_by(status = 'published').first()
+    orders = current_cycle.orders
+    groups = Group.query.filter(Group.id == Product.group_id).filter(OrderProduct.product_id == Product.id).filter(Order.id == OrderProduct.order_id).filter(Order.cycle_id == current_cycle.id).all()
+
+    total = sum(list(map(lambda order: order.total(), orders)))
+    total_orders = len(orders)
+    total_groups = len(groups)
+
+    return render_template("report_by_user.html",
+            total = total,
+            groups = groups,
+            orders = orders,
+            total_orders = total_orders,
+            total_groups = total_groups,
+            current_cycle = current_cycle,
+            random = random,
+            title = f"Relatório por Consumidor - {title}"
+    )
+
+@reports.route("/group")
+def group():
+    return render_template("report_by_group.html", title = f"Relatório por Fornecedor - {title}")




diff --git a/core/templates/report_by_user.html b/core/templates/report_by_user.html
new file mode 100644
index 0000000000000000000000000000000000000000..707e51fef3b5d79958d82ea9894d549ff1525ce1
--- /dev/null
+++ b/core/templates/report_by_user.html
@@ -0,0 +1,100 @@
+{% extends "layout.html" %}
+{% block body %}
+	<section class="row">
+		<div class="col-xs">
+			<h1> Relatórios por Consumidor </h1>
+		</div>
+	</section>
+
+	<section class="row">
+		<div class="col-xs">
+			<h2> Resumo desse ciclo </h2>
+		</div>
+	</section>
+
+	<section class="row">
+		<div class="col-xs-4 col-md-3">
+			<div class="box br-5 pt-5 pb-5">
+				<h2 class="center-xs"> {{ total_orders  }} </h2>
+				<small class="center-xs d-block">Pedidos</small>
+			</div>
+		</div>
+
+		<div class="col-xs-4 col-md-3">
+			<div class="box br-5 pt-5 pb-5">
+				<h2 class="center-xs"> {{ total | as_currency }} </h2>
+				<small class="center-xs d-block">Total Líquido</small>
+			</div>
+		</div>
+		<div class="col-xs-4 col-md-3">
+			<div class="box br-5 pt-5 pb-5">
+				<h2 class="center-xs"> {{ total_groups }} </h2>
+				<small class="center-xs d-block">Fornecedores</small>
+			</div>
+		</div>
+	</section>
+
+	<section class="row">
+		<div class="col-xs">
+			<h2> Pedidos por Consumidor </h2>
+		</div>
+	</section>
+
+	<section class="row pb-5" style="background-color: white; padding: 3px;">
+		<div class="col-xs">
+			{% for item in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] %}
+
+			<div class="wrap-details">
+				<input id="collapsible-{{item}}" class="toggle" type="checkbox">
+				<label class="lbl-toggle" for="collapsible-{{item}}">
+					<div class="row">
+						<div class="col-xs">
+							#312
+						</div>
+						<div class="col-xs">
+							Pedro Lucas Porcellis
+						</div>
+						<div class="col-xs">
+							$123,12
+						</div>
+						<div class="col-xs">
+							15 itens
+						</div>
+						<div class="col-xs">
+							?
+						</div>
+					</div>
+				</label>
+				<div class="wrap-details-content">
+					<div class="content-inner">
+						<table class="umbo-table">
+							<thead>
+								<tr>
+									<th class="umbo-table-header">Codigo</th>
+									<th class="umbo-table-header">Item</th>
+									<th class="umbo-table-header">Grupo</th>
+									<th class="umbo-table-header">Quantidade</th>
+									<th class="umbo-table-header umbo-table-header-numeric">Valor</th>
+								</tr>
+								<tbody>
+									{% for sub_item in [1, 2, 3, 4, 5, 6] %}
+									<tr>
+										<td class="umbo-table-cell">#31{{sub_item}}</td>
+										<td class="umbo-table-cell">Pão de Forma</td>
+										<td class="umbo-table-cell">Germinari</td>
+										<td class="umbo-table-cell">{{ random.randrange(1, 5) }}</td>
+										<td class="umbo-table-cell umbo-table-cell-numeric">$12,11</td>
+									</tr>
+									{% endfor %}
+								</tbody>
+							</thead>
+						</table>
+					</div>
+				</div>
+			</div>
+
+
+			{% endfor %}
+		</div>
+	</section>
+{% endblock %}




diff --git a/core/templates/reports.html b/core/templates/reports.html
new file mode 100644
index 0000000000000000000000000000000000000000..c09cc0019ca30b8866f7ee5b06870bc465eea909
--- /dev/null
+++ b/core/templates/reports.html
@@ -0,0 +1,15 @@
+{% extends "layout.html" %}
+{% block body %}
+<section>
+	<h1> Relatorios </h1>
+
+	<ul>
+		<li>
+			<a href="{{ url_for('reports.user') }}">Por consumidor</a>
+		</li>
+		<li>
+			<a href="#">Por fornecedor</a>
+		</li>
+	</ul>
+</section>
+{% endblock %}