diff --git a/source/app/models/main.py b/source/app/models/main.py index 869875c..483e720 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -3303,10 +3303,18 @@ class Facturas(BaseModel): @classmethod def validate_count_partners(cls, ids): filters = (Facturas.id.in_(tuple(ids.keys()))) - partners = (Facturas.select(fn.COUNT(Facturas.cliente)) + # ~ partners = (Facturas.select(fn.COUNT(Facturas.cliente)) + # ~ .where(filters) + # ~ .group_by(Facturas.cliente) + # ~ .order_by(Facturas.cliente).tuples()) + # ~ if len(partners) > 1: + # ~ return False + # ~ return True + partners = (Facturas.select(fn.COUNT(Socios.rfc)) .where(filters) - .group_by(Facturas.cliente) - .order_by(Facturas.cliente).tuples()) + .join(Socios).switch(Facturas) + .group_by(Socios.rfc) + .order_by(Socios.rfc).tuples()) if len(partners) > 1: return False return True