diff --git a/gestaoRaul/balcao/__init__.py b/gestaoRaul/balcao/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gestaoRaul/balcao/__pycache__/__init__.cpython-310.pyc b/gestaoRaul/balcao/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..6cc069d Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/__init__.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/__init__.cpython-313.pyc b/gestaoRaul/balcao/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000..e2446e1 Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/__init__.cpython-313.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/admin.cpython-310.pyc b/gestaoRaul/balcao/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..84b1566 Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/admin.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/admin.cpython-313.pyc b/gestaoRaul/balcao/__pycache__/admin.cpython-313.pyc new file mode 100644 index 0000000..ef38c48 Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/admin.cpython-313.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/apps.cpython-310.pyc b/gestaoRaul/balcao/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000..e358e75 Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/apps.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/apps.cpython-313.pyc b/gestaoRaul/balcao/__pycache__/apps.cpython-313.pyc new file mode 100644 index 0000000..362c70a Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/apps.cpython-313.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/htmx_views.cpython-310.pyc b/gestaoRaul/balcao/__pycache__/htmx_views.cpython-310.pyc new file mode 100644 index 0000000..d2c018f Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/htmx_views.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/htmx_views.cpython-313.pyc b/gestaoRaul/balcao/__pycache__/htmx_views.cpython-313.pyc new file mode 100644 index 0000000..599eb80 Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/htmx_views.cpython-313.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/models.cpython-310.pyc b/gestaoRaul/balcao/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..24d892a Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/models.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/models.cpython-313.pyc b/gestaoRaul/balcao/__pycache__/models.cpython-313.pyc new file mode 100644 index 0000000..ab13c9c Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/models.cpython-313.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/urls.cpython-310.pyc b/gestaoRaul/balcao/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..d331dde Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/urls.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/urls.cpython-313.pyc b/gestaoRaul/balcao/__pycache__/urls.cpython-313.pyc new file mode 100644 index 0000000..f9dd458 Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/urls.cpython-313.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/views.cpython-310.pyc b/gestaoRaul/balcao/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..5c98be6 Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/views.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/views.cpython-313.pyc b/gestaoRaul/balcao/__pycache__/views.cpython-313.pyc new file mode 100644 index 0000000..88ce378 Binary files /dev/null and b/gestaoRaul/balcao/__pycache__/views.cpython-313.pyc differ diff --git a/gestaoRaul/balcao/admin.py b/gestaoRaul/balcao/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/gestaoRaul/balcao/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/gestaoRaul/balcao/apps.py b/gestaoRaul/balcao/apps.py new file mode 100644 index 0000000..a86f71b --- /dev/null +++ b/gestaoRaul/balcao/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ComandasConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'balcao' diff --git a/gestaoRaul/balcao/htmx_views.py b/gestaoRaul/balcao/htmx_views.py new file mode 100644 index 0000000..cc330c3 --- /dev/null +++ b/gestaoRaul/balcao/htmx_views.py @@ -0,0 +1,46 @@ +from django.shortcuts import render, redirect + +from comandas.models import Comanda, ProductComanda +from products.models import Product +from payments.models import Payments +from typePay.models import TypePay + + +def listProduct(request, comanda_id): + product = request.GET.get("search-product") + products = Product.objects.filter(name__icontains=product) + return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products,'comanda_id':comanda_id}) + +def addProduct(request, product_id, comanda_id): + product_comanda = ProductComanda(comanda_id=comanda_id, product_id=product_id) + product_comanda.save() + consumo = ProductComanda.objects.filter(comanda=comanda_id) + total = 0 + for produto in consumo: + total += produto.product.price + return render(request, "htmx_components/htmx_list_products_in_comanda.html",{'consumo': consumo, 'total': total}) + + +def removeProductComanda(request, productComanda_id): + product_comanda = ProductComanda.objects.get(id=productComanda_id) + consumo = ProductComanda.objects.filter(comanda=product_comanda.comanda) + product_comanda.delete() + total = 0 + for produto in consumo: + total += produto.product.price + return render(request, "htmx_components/htmx_list_products_in_comanda.html",{'consumo': consumo, 'total': total}) + + +def paymentComanda(request, comanda_id): + typePayment = TypePay.objects.get(id=1) + consumo = ProductComanda.objects.filter(comanda=comanda_id) + comanda = Comanda.objects.get(name='VENDA BALCÃO') + total = 0 + for produto in consumo: + total += produto.product.price + removeProductComanda(request, produto.id) + pagamento = Payments(value=total, comanda=comanda, type_pay=typePayment,description='VENDA BALÃO') + pagamento.save() + comanda.save() + return redirect('comandas') + diff --git a/gestaoRaul/balcao/migrations/0001_initial.py b/gestaoRaul/balcao/migrations/0001_initial.py new file mode 100644 index 0000000..243b118 --- /dev/null +++ b/gestaoRaul/balcao/migrations/0001_initial.py @@ -0,0 +1,30 @@ +# Generated by Django 5.1.4 on 2024-12-10 01:19 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('clients', '0001_initial'), + ('mesas', '0001_initial'), + ('typePay', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Comanda', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('dt_open', models.DateTimeField(auto_now_add=True)), + ('dt_close', models.DateTimeField(blank=True, null=True)), + ('name', models.CharField(max_length=255)), + ('client', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='clients.client')), + ('mesa', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mesas.mesa')), + ('type_pay', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='typePay.typepay')), + ], + ), + ] diff --git a/gestaoRaul/balcao/migrations/0002_productcomanda.py b/gestaoRaul/balcao/migrations/0002_productcomanda.py new file mode 100644 index 0000000..1e0d178 --- /dev/null +++ b/gestaoRaul/balcao/migrations/0002_productcomanda.py @@ -0,0 +1,25 @@ +# Generated by Django 5.1.4 on 2024-12-10 01:20 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('comandas', '0001_initial'), + ('products', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='ProductComanda', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('data_time', models.DateTimeField(auto_now_add=True)), + ('applicant', models.CharField(blank=True, max_length=255, null=True)), + ('comanda', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='comandas.comanda')), + ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='products.product')), + ], + ), + ] diff --git a/gestaoRaul/balcao/migrations/0003_comanda_status_alter_productcomanda_product.py b/gestaoRaul/balcao/migrations/0003_comanda_status_alter_productcomanda_product.py new file mode 100644 index 0000000..6eb9bab --- /dev/null +++ b/gestaoRaul/balcao/migrations/0003_comanda_status_alter_productcomanda_product.py @@ -0,0 +1,25 @@ +# Generated by Django 5.1.4 on 2024-12-20 12:36 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('comandas', '0002_productcomanda'), + ('products', '0002_product_image_product_quantity'), + ] + + operations = [ + migrations.AddField( + model_name='comanda', + name='status', + field=models.CharField(default='OPEN', max_length=255), + ), + migrations.AlterField( + model_name='productcomanda', + name='product', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='products.product'), + ), + ] diff --git a/gestaoRaul/balcao/migrations/__init__.py b/gestaoRaul/balcao/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gestaoRaul/balcao/migrations/__pycache__/0001_initial.cpython-310.pyc b/gestaoRaul/balcao/migrations/__pycache__/0001_initial.cpython-310.pyc new file mode 100644 index 0000000..6e2bf15 Binary files /dev/null and b/gestaoRaul/balcao/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/migrations/__pycache__/0001_initial.cpython-313.pyc b/gestaoRaul/balcao/migrations/__pycache__/0001_initial.cpython-313.pyc new file mode 100644 index 0000000..d0fb409 Binary files /dev/null and b/gestaoRaul/balcao/migrations/__pycache__/0001_initial.cpython-313.pyc differ diff --git a/gestaoRaul/balcao/migrations/__pycache__/0002_productcomanda.cpython-310.pyc b/gestaoRaul/balcao/migrations/__pycache__/0002_productcomanda.cpython-310.pyc new file mode 100644 index 0000000..0c99ec0 Binary files /dev/null and b/gestaoRaul/balcao/migrations/__pycache__/0002_productcomanda.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/migrations/__pycache__/0002_productcomanda.cpython-313.pyc b/gestaoRaul/balcao/migrations/__pycache__/0002_productcomanda.cpython-313.pyc new file mode 100644 index 0000000..6e8772c Binary files /dev/null and b/gestaoRaul/balcao/migrations/__pycache__/0002_productcomanda.cpython-313.pyc differ diff --git a/gestaoRaul/balcao/migrations/__pycache__/0003_comanda_status_alter_productcomanda_product.cpython-310.pyc b/gestaoRaul/balcao/migrations/__pycache__/0003_comanda_status_alter_productcomanda_product.cpython-310.pyc new file mode 100644 index 0000000..c44a31a Binary files /dev/null and b/gestaoRaul/balcao/migrations/__pycache__/0003_comanda_status_alter_productcomanda_product.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/migrations/__pycache__/0003_comanda_status_alter_productcomanda_product.cpython-313.pyc b/gestaoRaul/balcao/migrations/__pycache__/0003_comanda_status_alter_productcomanda_product.cpython-313.pyc new file mode 100644 index 0000000..14940c1 Binary files /dev/null and b/gestaoRaul/balcao/migrations/__pycache__/0003_comanda_status_alter_productcomanda_product.cpython-313.pyc differ diff --git a/gestaoRaul/balcao/migrations/__pycache__/__init__.cpython-310.pyc b/gestaoRaul/balcao/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..74ce7ad Binary files /dev/null and b/gestaoRaul/balcao/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/migrations/__pycache__/__init__.cpython-313.pyc b/gestaoRaul/balcao/migrations/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000..cf059df Binary files /dev/null and b/gestaoRaul/balcao/migrations/__pycache__/__init__.cpython-313.pyc differ diff --git a/gestaoRaul/balcao/models.py b/gestaoRaul/balcao/models.py new file mode 100644 index 0000000..d0fbe10 --- /dev/null +++ b/gestaoRaul/balcao/models.py @@ -0,0 +1,27 @@ +# from django.db import models + +# from clients.models import Client +# from products.models import Product +# from mesas.models import Mesa +# from typePay.models import TypePay + +# class Comanda(models.Model): +# id = models.AutoField(primary_key=True) +# mesa = models.ForeignKey(Mesa, on_delete=models.CASCADE) +# 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) +# client = models.ForeignKey(Client, on_delete=models.SET_NULL, null=True, blank=True) +# name = models.CharField(max_length=255) +# status = models.CharField(max_length=255, default="OPEN") +# def __str__(self) -> str: +# return self.name + +# class ProductComanda(models.Model): +# id = models.AutoField(primary_key=True) +# comanda = models.ForeignKey(Comanda, on_delete=models.CASCADE) +# data_time = models.DateTimeField(auto_now_add=True) +# product = models.ForeignKey(Product, on_delete=models.PROTECT) +# applicant = models.CharField(max_length=255, null=True, blank=True) +# def __str__(self) -> str: +# return self.comanda.name + " - " + self.product.name \ No newline at end of file diff --git a/gestaoRaul/balcao/templates/viewBalcao.html b/gestaoRaul/balcao/templates/viewBalcao.html new file mode 100644 index 0000000..d9fc81f --- /dev/null +++ b/gestaoRaul/balcao/templates/viewBalcao.html @@ -0,0 +1,201 @@ +{% extends "base.html" %} +{% load static %} + + + + +{% block 'title' %} +Detalhes {{comanda.name}} +{% endblock %} + + + + +{% block 'head' %} + +{% endblock %} + + +{% block 'body' %} + + + +
+
+

Venda Balcão

+
+ + + + + + + + + + + +
+ + + + + + + + + + + {% for item in consumo%} + + + + + + + + + + {% endfor %} + + + + + +
ProdutoPreço
{{item.product.name}}R$ {{item.product.price}}
Total R$ {{total}}
+
+ + + + + +
+ + + +
+ +
+

Adicionar Produto

+
+
+ {% for product in products %} + +
+ {{product.name}}
+ R$ {{product.price}} +
+ {% endfor %} +
+ + +
+ +
+ + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/gestaoRaul/balcao/tests.py b/gestaoRaul/balcao/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/gestaoRaul/balcao/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/gestaoRaul/balcao/urls.py b/gestaoRaul/balcao/urls.py new file mode 100644 index 0000000..b616c19 --- /dev/null +++ b/gestaoRaul/balcao/urls.py @@ -0,0 +1,25 @@ + +from django.urls import path + +from balcao import htmx_views +from . import views + +urlpatterns = [ + # path('', views.comandas, name='comandas'), + path('', views.viewBalcao, name='viewBalcao'), + # path('createComanda/', views.createComanda, name='createComanda'), + +] + + +htmx_urlpatterns = [ + # path('listProduct/', htmx_views.listProduct, name='listProduct'), + path('listProduct//', htmx_views.listProduct, name='listProduct'), + path('addProduct//', htmx_views.addProduct, name='addProduct'), + path('removeProductComanda/', htmx_views.removeProductComanda, name='removeProductComanda'), + # path('closeComanda/', htmx_views.closeComanda, name='closeComanda'), + # path('reopenComanda/', htmx_views.reopenComanda, name='reopenComanda'), + path('paymentComanda/', htmx_views.paymentComanda, name='paymentComanda'), +] + +urlpatterns += htmx_urlpatterns \ No newline at end of file diff --git a/gestaoRaul/balcao/views.py b/gestaoRaul/balcao/views.py new file mode 100644 index 0000000..46db233 --- /dev/null +++ b/gestaoRaul/balcao/views.py @@ -0,0 +1,36 @@ +from django.shortcuts import render, redirect + +from comandas.models import Comanda, ProductComanda +from products.models import Product +from mesas.models import Mesa + + +# def balcao(request): +# comandas = Comanda.objects.filter(status__in=["OPEN", "PAYING"]) +# mesas = Mesa.objects.all() +# return render(request, 'comandas.html', {'comandas': comandas, 'mesas': mesas}) + + + +def viewBalcao(request): + + comanda = Comanda.objects.get(name='VENDA BALCÃO') + consumo = ProductComanda.objects.filter(comanda=comanda.id) + products = Product.objects.all() + total = 0 + for produto in consumo: + total += produto.product.price + + return render(request, 'viewBalcao.html', {'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products}) + + + +# 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.save() + +# return redirect('comandas') + diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index a113d0d..4cbf2c3 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ diff --git a/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-310.pyc b/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-310.pyc index c13e299..8b30748 100644 Binary files a/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-310.pyc and b/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-310.pyc differ diff --git a/gestaoRaul/gestaoRaul/__pycache__/urls.cpython-310.pyc b/gestaoRaul/gestaoRaul/__pycache__/urls.cpython-310.pyc index fd0a074..f3568ea 100644 Binary files a/gestaoRaul/gestaoRaul/__pycache__/urls.cpython-310.pyc and b/gestaoRaul/gestaoRaul/__pycache__/urls.cpython-310.pyc differ diff --git a/gestaoRaul/gestaoRaul/settings.py b/gestaoRaul/gestaoRaul/settings.py index 1655c38..e9b061c 100644 --- a/gestaoRaul/gestaoRaul/settings.py +++ b/gestaoRaul/gestaoRaul/settings.py @@ -53,6 +53,7 @@ INSTALLED_APPS = [ 'categories', 'home', 'payments', + 'balcao', ] MIDDLEWARE = [ diff --git a/gestaoRaul/gestaoRaul/urls.py b/gestaoRaul/gestaoRaul/urls.py index 7115f5f..f861aae 100644 --- a/gestaoRaul/gestaoRaul/urls.py +++ b/gestaoRaul/gestaoRaul/urls.py @@ -26,6 +26,7 @@ urlpatterns = [ path('clients/', include('clients.urls')), path('comandas/', include('comandas.urls')), path('categories/', include('categories.urls')), + path('balcao/', include('balcao.urls')), ] diff --git a/gestaoRaul/templates/base.html b/gestaoRaul/templates/base.html index f342280..38a47df 100644 --- a/gestaoRaul/templates/base.html +++ b/gestaoRaul/templates/base.html @@ -26,7 +26,7 @@
  • Comandas
  • Produtos
  • Categorias
  • -
  • Sobre
  • +
  • Balcao