mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 05:25:40 +00:00
fiz um monte de coisa e criei um bug
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -5,6 +5,7 @@ from django.db.models import Count, F
|
||||
|
||||
|
||||
from comandas.models import Comanda, ProductComanda
|
||||
from mesas.models import Mesa
|
||||
from products.models import Product
|
||||
from payments.models import Payments
|
||||
from typePay.models import TypePay
|
||||
@@ -66,7 +67,12 @@ def removeProductBalcao(request, productComanda_id):
|
||||
def paymentBalcao(request, comanda_id):
|
||||
typePayment = TypePay.objects.get(id=1)
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||
vendasBalcao = Comanda.objects.get(name='VENDAS BALCAO')
|
||||
try:
|
||||
vendasBalcao = Comanda.objects.get(name='VENDAS BALCAO')
|
||||
except:
|
||||
mesa = Mesa.objects.get(id=1)
|
||||
vendasBalcao = Comanda(name='VENDAS BALCAO', mesa=mesa, user=request.user, status='CLOSED')
|
||||
vendasBalcao.save()
|
||||
comanda = Comanda.objects.get(name='VENDA BALCÃO')
|
||||
total = 0
|
||||
for produto in consumo:
|
||||
@@ -77,3 +83,7 @@ def paymentBalcao(request, comanda_id):
|
||||
pagamento.save()
|
||||
return redirect('viewBalcao')
|
||||
|
||||
|
||||
|
||||
#"GET /balcao/addProductBalcaoTeclado83/1/1/ HTTP/1.1" 200 747
|
||||
#"GET /balcao/addProductBalcaoTeclado83/13/1/ HTTP/1.1" 500 133103
|
||||
@@ -71,8 +71,11 @@
|
||||
{% for product in products %}
|
||||
{% if forloop.counter0 == 0 %}
|
||||
|
||||
<article name="productBox" id="productId-{{ product.id }}"
|
||||
onclick="addProductClick({{product.id}} , {{comanda.id}})" style="background-color: #293552;">
|
||||
<article
|
||||
name="productBox"
|
||||
id="productId-{{ product.id }}"
|
||||
onclick="addProductClick({{product.id}} , {{comanda.id}})"
|
||||
style="background-color: #293552;">
|
||||
<p hidden id="{{forloop.counter0}}">{{product.id}}</p>
|
||||
<p hidden id="comanda{{forloop.counter0}}">{{comanda.id}}</p>
|
||||
{{product.name}} <br>
|
||||
@@ -82,8 +85,11 @@
|
||||
|
||||
{% else %}
|
||||
|
||||
<article name="productBox" id="productId-{{ product.id }}"
|
||||
onclick="addProductClick({{product.id}} , {{comanda.id}})" style="background-color: #293552;">
|
||||
<article
|
||||
name="productBox"
|
||||
id="productId-{{ product.id }}"
|
||||
onclick="addProductClick({{product.id}} , {{comanda.id}})"
|
||||
style="background-color: #293552;">
|
||||
{{product.name}} <br>
|
||||
R$ {{product.price}}
|
||||
</article>
|
||||
|
||||
@@ -2,13 +2,22 @@ from django.shortcuts import render
|
||||
|
||||
from comandas.models import Comanda, ProductComanda
|
||||
from products.models import Product
|
||||
from mesas.models import Mesa
|
||||
from django.db.models import Count, F
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
|
||||
|
||||
def viewBalcao(request):
|
||||
try:
|
||||
comanda = Comanda.objects.get(name='VENDA BALCÃO')
|
||||
except:
|
||||
user = User.objects.get(id=request.user.id)
|
||||
mesa = Mesa.objects.get(id=1)
|
||||
comanda = Comanda(name='VENDA BALCÃO', mesa=mesa, user=user,status='CLOSED')
|
||||
comanda.save()
|
||||
|
||||
comanda = Comanda.objects.get(name='VENDA BALCÃO')
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda.id)
|
||||
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
|
||||
quantidade=Count('product'),
|
||||
|
||||
Binary file not shown.
Binary file not shown.
22
gestaoRaul/comandas/migrations/0004_comanda_user.py
Normal file
22
gestaoRaul/comandas/migrations/0004_comanda_user.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 5.1.4 on 2025-01-15 12:43
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('comandas', '0003_comanda_status_alter_productcomanda_product'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='comanda',
|
||||
name='user',
|
||||
field=models.ForeignKey(blank=True, default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
Binary file not shown.
@@ -1,4 +1,6 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
from clients.models import Client
|
||||
from products.models import Product
|
||||
@@ -8,6 +10,7 @@ from typePay.models import TypePay
|
||||
class Comanda(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
mesa = models.ForeignKey(Mesa, on_delete=models.CASCADE)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, null=False, blank=True)
|
||||
type_pay = models.ForeignKey(TypePay, on_delete=models.SET_NULL, null=True)
|
||||
dt_open = models.DateTimeField(auto_now_add=True)
|
||||
dt_close = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
@@ -40,7 +40,7 @@ def createComanda(request):
|
||||
name = request.POST.get('name-comanda')
|
||||
mesa_id = int(request.POST.get('select-mesa')[0])
|
||||
mesa = Mesa.objects.get(id=mesa_id)
|
||||
comanda = Comanda(name=name, mesa=mesa)
|
||||
comanda = Comanda(name=name, mesa=mesa, user=request.user)
|
||||
comanda.save()
|
||||
return redirect('comandas')
|
||||
|
||||
|
||||
BIN
gestaoRaul/db - Copia (2).sqlite3
Normal file
BIN
gestaoRaul/db - Copia (2).sqlite3
Normal file
Binary file not shown.
BIN
gestaoRaul/db - Copia.sqlite3
Normal file
BIN
gestaoRaul/db - Copia.sqlite3
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -14,15 +14,19 @@ from gestaoRaul.decorators import group_required
|
||||
|
||||
@group_required(groupName='Gerente')
|
||||
def home(request):
|
||||
total_pagamentos = Payments.objects.aggregate(total=Sum('value'))['total']
|
||||
qdt_pagamentos = Payments.objects.aggregate(total=Count('value'))['total']
|
||||
pagamentos = Payments.objects.all()
|
||||
ticekMedio = total_pagamentos / qdt_pagamentos
|
||||
try:
|
||||
total_pagamentos = Payments.objects.aggregate(total=Sum('value'))['total']
|
||||
qdt_pagamentos = Payments.objects.aggregate(total=Count('value'))['total']
|
||||
pagamentos = Payments.objects.all()
|
||||
ticekMedio = total_pagamentos / qdt_pagamentos
|
||||
|
||||
produtos_mais_vendidos = ProductComanda.objects.values('product').annotate(
|
||||
quantidade=Count('product'),
|
||||
nome=F('product__name') ).order_by('-quantidade')[:5]
|
||||
return render(request, 'home.html', {'total_pagamentos': total_pagamentos, 'pagamentos': pagamentos, 'qdt_pagamentos': qdt_pagamentos, 'produtos_mais_vendidos': produtos_mais_vendidos, 'ticekMedio': ticekMedio, })
|
||||
except:
|
||||
return render(request, 'home.html')
|
||||
|
||||
produtos_mais_vendidos = ProductComanda.objects.values('product').annotate(
|
||||
quantidade=Count('product'),
|
||||
nome=F('product__name') ).order_by('-quantidade')[:5]
|
||||
return render(request, 'home.html', {'total_pagamentos': total_pagamentos, 'pagamentos': pagamentos, 'qdt_pagamentos': qdt_pagamentos, 'produtos_mais_vendidos': produtos_mais_vendidos, 'ticekMedio': ticekMedio, })
|
||||
|
||||
@group_required(groupName='Gerente')
|
||||
def chartCuisine(request):
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
<h4>{{order.id_product.name}}</h4>
|
||||
<h4>{{order.obs}} </h4>
|
||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </h4>
|
||||
<h4> Atendente: {{order.id_comanda.user.first_name}} </h4>
|
||||
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||
<button
|
||||
hx-get="{% url 'preparing' order.id %} " hx-trigger="click" hx-target="#list-orders"
|
||||
@@ -72,6 +73,7 @@
|
||||
<h4>{{order.id_product.name}}</h4>
|
||||
<h4>{{order.obs}} </h4>
|
||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </h4>
|
||||
<h4> Atendente: {{order.id_comanda.user.first_name}} </h4>
|
||||
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||
<button
|
||||
hx-get="{% url 'finished' order.id %} " hx-trigger="click" hx-target="#list-orders"
|
||||
@@ -95,6 +97,7 @@
|
||||
<h4>{{order.id_product.name}}</h4>
|
||||
<h4>{{order.obs}} </h4>
|
||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </h4>
|
||||
<h4> Atendente: {{order.id_comanda.user.first_name}} </h4>
|
||||
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||
<button
|
||||
hx-get="{% url 'delivered' order.id %} " hx-trigger="click" hx-target="#list-orders"
|
||||
@@ -118,6 +121,7 @@
|
||||
<h4>{{order.id_product.name}}</h4>
|
||||
<h4>{{order.obs}} </h4>
|
||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </h4>
|
||||
<h4> Atendente: {{order.id_comanda.user.first_name}} </h4>
|
||||
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||
<!-- <button>Preparar</button> -->
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
{% for product in products %}
|
||||
|
||||
{% if forloop.counter0 == 0 %}
|
||||
{% if forloop.counter0 == 0 %}
|
||||
<input hidden type="text" id="idComanda0" value="{{comanda_id}}">
|
||||
|
||||
<article
|
||||
name="productBox"
|
||||
@@ -11,7 +12,7 @@
|
||||
onclick="addProductClick({{product.id}} , {{comanda_id}})"
|
||||
>
|
||||
<p hidden id="{{forloop.counter0}}" >{{product.id}}</p>
|
||||
<p hidden id="comanda{{forloop.counter0}}" >{{comanda_id}}</p>
|
||||
<p hidden id="comanda{{forloop.counter0}}" >{{comanda.id}}</p>
|
||||
{{product.name}} <br> <p id="{{product.id}}"></p>
|
||||
R$ {{product.price}}
|
||||
</article >
|
||||
@@ -22,7 +23,7 @@
|
||||
name="productBox"
|
||||
id="productId-{{ product.id }}"
|
||||
style="background-color: #293552;"
|
||||
onclick="addProductClick({{product.id}} , {{comanda_id}})"
|
||||
onclick="addProductClick({{product.id}} , {{comanda.id}})"
|
||||
>
|
||||
{{product.name}} <br>
|
||||
R$ {{product.price}}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<h4>{{order.id_product.name}}</h4>
|
||||
<h4>{{order.obs}} </h4>
|
||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </h4>
|
||||
<h4> Atendente: {{order.id_comanda.user.first_name}} </h4>
|
||||
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||
<button
|
||||
hx-get="{% url 'preparing' order.id %} " hx-trigger="click" hx-target="#list-orders"
|
||||
@@ -45,6 +46,7 @@
|
||||
<h4>{{order.id_product.name}}</h4>
|
||||
<h4>{{order.obs}} </h4>
|
||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </h4>
|
||||
<h4> Atendente: {{order.id_comanda.user.first_name}} </h4>
|
||||
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||
<button
|
||||
hx-get="{% url 'finished' order.id %} " hx-trigger="click" hx-target="#list-orders"
|
||||
@@ -68,6 +70,7 @@
|
||||
<h4>{{order.id_product.name}}</h4>
|
||||
<h4>{{order.obs}} </h4>
|
||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </h4>
|
||||
<h4> Atendente: {{order.id_comanda.user.first_name}} </h4>
|
||||
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||
<button
|
||||
hx-get="{% url 'delivered' order.id %} " hx-trigger="click" hx-target="#list-orders"
|
||||
@@ -91,6 +94,7 @@
|
||||
<h4>{{order.id_product.name}}</h4>
|
||||
<h4>{{order.obs}} </h4>
|
||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </h4>
|
||||
<h4> Atendente: {{order.id_comanda.user.first_name}} </h4>
|
||||
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||
<!-- <button>Preparar</button> -->
|
||||
</div>
|
||||
|
||||
@@ -150,8 +150,9 @@ function searchProduct() {
|
||||
function time(){
|
||||
var search_product = document.getElementById('search-product').value.trim()
|
||||
var productListElement = document.getElementById("product-list");
|
||||
var comanda_id = document.getElementById("idComanda0").value;
|
||||
if(search_product.length == 0 ){search_product ='*';}
|
||||
fetch(`/balcao/listProductBalcao/13/${search_product}`, {
|
||||
fetch(`/balcao/listProductBalcao/${comanda_id}/${search_product}`, {
|
||||
method: 'GET',}
|
||||
).then(function(response) {
|
||||
return response.text();
|
||||
|
||||
Reference in New Issue
Block a user