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' %} + + +
+| Produto | +Preço | +|
|---|---|---|
| {{item.product.name}} | +R$ {{item.product.price}} | ++ |
| Total R$ {{total}} | +||