mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
fix: conexão com api de pagamento de multiplas comandas ok
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -2,10 +2,12 @@ from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
|
||||
from clients.models import Client
|
||||
from products.models import Product
|
||||
from mesas.models import Mesa
|
||||
from typePay.models import TypePay
|
||||
# from payments.models import Payments
|
||||
|
||||
class Comanda(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
@@ -27,4 +29,6 @@ class ProductComanda(models.Model):
|
||||
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
|
||||
return self.comanda.name + " - " + self.product.name
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from django.db.models import Count, F
|
||||
|
||||
from comandas.models import Comanda, ProductComanda
|
||||
from clients.models import Client
|
||||
from payments.models import Payments
|
||||
from payments.models import Payments, somar
|
||||
from orders.models import Order
|
||||
from products.models import Product
|
||||
from mesas.models import Mesa
|
||||
@@ -23,22 +23,22 @@ def comandas(request):
|
||||
return render(request, 'comandas.html', {'comandas': comandas, 'mesas': mesas})
|
||||
|
||||
|
||||
def somar(consumo:ProductComanda, comanda:Comanda):
|
||||
parcial = Payments.objects.filter(comanda=comanda)
|
||||
totalParcial = Decimal(0)
|
||||
total:Decimal = Decimal(0)
|
||||
for p in parcial:
|
||||
totalParcial += p.value
|
||||
for produto in consumo:
|
||||
total += Decimal(produto.product.price)
|
||||
valores = {
|
||||
'total':total,
|
||||
'parcial':totalParcial,
|
||||
'taxa': round(total * Decimal(0.1), 2),
|
||||
'totalSemTaxa':total - totalParcial,
|
||||
'totalComTaxa': round((total - totalParcial)+(total * Decimal(0.1)),2)
|
||||
}
|
||||
return valores
|
||||
# def somar(consumo:ProductComanda, comanda:Comanda):
|
||||
# parcial = Payments.objects.filter(comanda=comanda)
|
||||
# totalParcial = Decimal(0)
|
||||
# total:Decimal = Decimal(0)
|
||||
# for p in parcial:
|
||||
# totalParcial += p.value
|
||||
# for produto in consumo:
|
||||
# total += Decimal(produto.product.price)
|
||||
# valores = {
|
||||
# 'total':total,
|
||||
# 'parcial':totalParcial,
|
||||
# 'taxa': round(total * Decimal(0.1), 2),
|
||||
# 'totalSemTaxa':total - totalParcial,
|
||||
# 'totalComTaxa': round((total - totalParcial)+(total * Decimal(0.1)),2)
|
||||
# }
|
||||
# return valores
|
||||
|
||||
@group_required(groupName='Garçom')
|
||||
def viewComanda(request):
|
||||
|
||||
Reference in New Issue
Block a user