refactor: Update project settings, URL configurations, client views, and remove requirements.txt.

This commit is contained in:
2026-02-23 18:44:06 -03:00
parent 2160998c23
commit 7ddaa2d1f9
129 changed files with 888 additions and 40 deletions

View File

@@ -0,0 +1,23 @@
from rest_framework import serializers
from .models import Client
from comandas.models import Comanda, ProductComanda
from payments.models import Payments, somar
from decimal import Decimal
class ClientSerializer(serializers.ModelSerializer):
debt = serializers.SerializerMethodField()
class Meta:
model = Client
fields = ['id', 'name', 'created_at', 'active', 'contact', 'debt']
def get_debt(self, obj):
comandas = Comanda.objects.filter(client=obj, status='FIADO')
total_debt = Decimal(0)
for comanda in comandas:
consumo = ProductComanda.objects.filter(comanda=comanda)
valores = somar(consumo, comanda)
total_debt += valores['totalSemTaxa']
return total_debt