mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +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 comandas.models import Comanda, ProductComanda
|
||||||
|
from mesas.models import Mesa
|
||||||
from products.models import Product
|
from products.models import Product
|
||||||
from payments.models import Payments
|
from payments.models import Payments
|
||||||
from typePay.models import TypePay
|
from typePay.models import TypePay
|
||||||
@@ -66,7 +67,12 @@ def removeProductBalcao(request, productComanda_id):
|
|||||||
def paymentBalcao(request, comanda_id):
|
def paymentBalcao(request, comanda_id):
|
||||||
typePayment = TypePay.objects.get(id=1)
|
typePayment = TypePay.objects.get(id=1)
|
||||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||||
|
try:
|
||||||
vendasBalcao = Comanda.objects.get(name='VENDAS BALCAO')
|
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')
|
comanda = Comanda.objects.get(name='VENDA BALCÃO')
|
||||||
total = 0
|
total = 0
|
||||||
for produto in consumo:
|
for produto in consumo:
|
||||||
@@ -77,3 +83,7 @@ def paymentBalcao(request, comanda_id):
|
|||||||
pagamento.save()
|
pagamento.save()
|
||||||
return redirect('viewBalcao')
|
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 %}
|
{% for product in products %}
|
||||||
{% if forloop.counter0 == 0 %}
|
{% if forloop.counter0 == 0 %}
|
||||||
|
|
||||||
<article name="productBox" id="productId-{{ product.id }}"
|
<article
|
||||||
onclick="addProductClick({{product.id}} , {{comanda.id}})" style="background-color: #293552;">
|
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="{{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>
|
{{product.name}} <br>
|
||||||
@@ -82,8 +85,11 @@
|
|||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
<article name="productBox" id="productId-{{ product.id }}"
|
<article
|
||||||
onclick="addProductClick({{product.id}} , {{comanda.id}})" style="background-color: #293552;">
|
name="productBox"
|
||||||
|
id="productId-{{ product.id }}"
|
||||||
|
onclick="addProductClick({{product.id}} , {{comanda.id}})"
|
||||||
|
style="background-color: #293552;">
|
||||||
{{product.name}} <br>
|
{{product.name}} <br>
|
||||||
R$ {{product.price}}
|
R$ {{product.price}}
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
@@ -2,13 +2,22 @@ from django.shortcuts import render
|
|||||||
|
|
||||||
from comandas.models import Comanda, ProductComanda
|
from comandas.models import Comanda, ProductComanda
|
||||||
from products.models import Product
|
from products.models import Product
|
||||||
|
from mesas.models import Mesa
|
||||||
from django.db.models import Count, F
|
from django.db.models import Count, F
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def viewBalcao(request):
|
def viewBalcao(request):
|
||||||
|
try:
|
||||||
comanda = Comanda.objects.get(name='VENDA BALCÃO')
|
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)
|
consumo = ProductComanda.objects.filter(comanda=comanda.id)
|
||||||
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
|
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
|
||||||
quantidade=Count('product'),
|
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.db import models
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
from clients.models import Client
|
from clients.models import Client
|
||||||
from products.models import Product
|
from products.models import Product
|
||||||
@@ -8,6 +10,7 @@ from typePay.models import TypePay
|
|||||||
class Comanda(models.Model):
|
class Comanda(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
mesa = models.ForeignKey(Mesa, on_delete=models.CASCADE)
|
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)
|
type_pay = models.ForeignKey(TypePay, on_delete=models.SET_NULL, null=True)
|
||||||
dt_open = models.DateTimeField(auto_now_add=True)
|
dt_open = models.DateTimeField(auto_now_add=True)
|
||||||
dt_close = models.DateTimeField(null=True, blank=True)
|
dt_close = models.DateTimeField(null=True, blank=True)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ def createComanda(request):
|
|||||||
name = request.POST.get('name-comanda')
|
name = request.POST.get('name-comanda')
|
||||||
mesa_id = int(request.POST.get('select-mesa')[0])
|
mesa_id = int(request.POST.get('select-mesa')[0])
|
||||||
mesa = Mesa.objects.get(id=mesa_id)
|
mesa = Mesa.objects.get(id=mesa_id)
|
||||||
comanda = Comanda(name=name, mesa=mesa)
|
comanda = Comanda(name=name, mesa=mesa, user=request.user)
|
||||||
comanda.save()
|
comanda.save()
|
||||||
return redirect('comandas')
|
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,6 +14,7 @@ from gestaoRaul.decorators import group_required
|
|||||||
|
|
||||||
@group_required(groupName='Gerente')
|
@group_required(groupName='Gerente')
|
||||||
def home(request):
|
def home(request):
|
||||||
|
try:
|
||||||
total_pagamentos = Payments.objects.aggregate(total=Sum('value'))['total']
|
total_pagamentos = Payments.objects.aggregate(total=Sum('value'))['total']
|
||||||
qdt_pagamentos = Payments.objects.aggregate(total=Count('value'))['total']
|
qdt_pagamentos = Payments.objects.aggregate(total=Count('value'))['total']
|
||||||
pagamentos = Payments.objects.all()
|
pagamentos = Payments.objects.all()
|
||||||
@@ -23,6 +24,9 @@ def home(request):
|
|||||||
quantidade=Count('product'),
|
quantidade=Count('product'),
|
||||||
nome=F('product__name') ).order_by('-quantidade')[:5]
|
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, })
|
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')
|
@group_required(groupName='Gerente')
|
||||||
def chartCuisine(request):
|
def chartCuisine(request):
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
<h4>{{order.id_product.name}}</h4>
|
<h4>{{order.id_product.name}}</h4>
|
||||||
<h4>{{order.obs}} </h4>
|
<h4>{{order.obs}} </h4>
|
||||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </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>
|
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||||
<button
|
<button
|
||||||
hx-get="{% url 'preparing' order.id %} " hx-trigger="click" hx-target="#list-orders"
|
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.id_product.name}}</h4>
|
||||||
<h4>{{order.obs}} </h4>
|
<h4>{{order.obs}} </h4>
|
||||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </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>
|
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||||
<button
|
<button
|
||||||
hx-get="{% url 'finished' order.id %} " hx-trigger="click" hx-target="#list-orders"
|
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.id_product.name}}</h4>
|
||||||
<h4>{{order.obs}} </h4>
|
<h4>{{order.obs}} </h4>
|
||||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </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>
|
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||||
<button
|
<button
|
||||||
hx-get="{% url 'delivered' order.id %} " hx-trigger="click" hx-target="#list-orders"
|
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.id_product.name}}</h4>
|
||||||
<h4>{{order.obs}} </h4>
|
<h4>{{order.obs}} </h4>
|
||||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </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>
|
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||||
<!-- <button>Preparar</button> -->
|
<!-- <button>Preparar</button> -->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
{% for product in products %}
|
{% for product in products %}
|
||||||
|
|
||||||
{% if forloop.counter0 == 0 %}
|
{% if forloop.counter0 == 0 %}
|
||||||
|
<input hidden type="text" id="idComanda0" value="{{comanda_id}}">
|
||||||
|
|
||||||
<article
|
<article
|
||||||
name="productBox"
|
name="productBox"
|
||||||
@@ -11,7 +12,7 @@
|
|||||||
onclick="addProductClick({{product.id}} , {{comanda_id}})"
|
onclick="addProductClick({{product.id}} , {{comanda_id}})"
|
||||||
>
|
>
|
||||||
<p hidden id="{{forloop.counter0}}" >{{product.id}}</p>
|
<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>
|
{{product.name}} <br> <p id="{{product.id}}"></p>
|
||||||
R$ {{product.price}}
|
R$ {{product.price}}
|
||||||
</article >
|
</article >
|
||||||
@@ -22,7 +23,7 @@
|
|||||||
name="productBox"
|
name="productBox"
|
||||||
id="productId-{{ product.id }}"
|
id="productId-{{ product.id }}"
|
||||||
style="background-color: #293552;"
|
style="background-color: #293552;"
|
||||||
onclick="addProductClick({{product.id}} , {{comanda_id}})"
|
onclick="addProductClick({{product.id}} , {{comanda.id}})"
|
||||||
>
|
>
|
||||||
{{product.name}} <br>
|
{{product.name}} <br>
|
||||||
R$ {{product.price}}
|
R$ {{product.price}}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
<h4>{{order.id_product.name}}</h4>
|
<h4>{{order.id_product.name}}</h4>
|
||||||
<h4>{{order.obs}} </h4>
|
<h4>{{order.obs}} </h4>
|
||||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </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>
|
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||||
<button
|
<button
|
||||||
hx-get="{% url 'preparing' order.id %} " hx-trigger="click" hx-target="#list-orders"
|
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.id_product.name}}</h4>
|
||||||
<h4>{{order.obs}} </h4>
|
<h4>{{order.obs}} </h4>
|
||||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </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>
|
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||||
<button
|
<button
|
||||||
hx-get="{% url 'finished' order.id %} " hx-trigger="click" hx-target="#list-orders"
|
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.id_product.name}}</h4>
|
||||||
<h4>{{order.obs}} </h4>
|
<h4>{{order.obs}} </h4>
|
||||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </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>
|
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||||
<button
|
<button
|
||||||
hx-get="{% url 'delivered' order.id %} " hx-trigger="click" hx-target="#list-orders"
|
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.id_product.name}}</h4>
|
||||||
<h4>{{order.obs}} </h4>
|
<h4>{{order.obs}} </h4>
|
||||||
<h4>{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}} </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>
|
<h4>{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}</h4>
|
||||||
<!-- <button>Preparar</button> -->
|
<!-- <button>Preparar</button> -->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -150,8 +150,9 @@ function searchProduct() {
|
|||||||
function time(){
|
function time(){
|
||||||
var search_product = document.getElementById('search-product').value.trim()
|
var search_product = document.getElementById('search-product').value.trim()
|
||||||
var productListElement = document.getElementById("product-list");
|
var productListElement = document.getElementById("product-list");
|
||||||
|
var comanda_id = document.getElementById("idComanda0").value;
|
||||||
if(search_product.length == 0 ){search_product ='*';}
|
if(search_product.length == 0 ){search_product ='*';}
|
||||||
fetch(`/balcao/listProductBalcao/13/${search_product}`, {
|
fetch(`/balcao/listProductBalcao/${comanda_id}/${search_product}`, {
|
||||||
method: 'GET',}
|
method: 'GET',}
|
||||||
).then(function(response) {
|
).then(function(response) {
|
||||||
return response.text();
|
return response.text();
|
||||||
|
|||||||
Reference in New Issue
Block a user