fiz um monte de coisa e criei um bug

This commit is contained in:
2025-01-15 11:04:27 -03:00
parent a2fd5d12e3
commit 43d9cd9c5b
20 changed files with 83 additions and 19 deletions

View File

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

View File

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

View File

@@ -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()
consumo = ProductComanda.objects.filter(comanda=comanda.id)
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
quantidade=Count('product'),

View 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,
),
]

View File

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

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -14,6 +14,7 @@ from gestaoRaul.decorators import group_required
@group_required(groupName='Gerente')
def home(request):
try:
total_pagamentos = Payments.objects.aggregate(total=Sum('value'))['total']
qdt_pagamentos = Payments.objects.aggregate(total=Count('value'))['total']
pagamentos = Payments.objects.all()
@@ -23,6 +24,9 @@ def home(request):
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')
@group_required(groupName='Gerente')
def chartCuisine(request):

View File

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

View File

@@ -3,6 +3,7 @@
{% for product in products %}
{% 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}}

View File

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

View File

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