finance, orders and counterparty: fix all bugs

This commit is contained in:
behruz-dev
2025-11-11 16:26:07 +05:00
parent 25898a7864
commit db8218de21
3 changed files with 4 additions and 5 deletions

View File

@@ -157,14 +157,13 @@ class CounterpartyBalance(BaseModel):
orders__counterparty=self.counterparty,
is_deleted=False,
currency='uzs'
).aggregate(total_price=models.Sum('party_amount__paid_amount'))['total_price'] or 0
).distinct().aggregate(total_price=models.Sum('party_amount__paid_amount'))['total_price'] or 0
income = Income.objects.filter(currency='uzs', counterparty=self.counterparty).aggregate(
total_price=models.Sum("price")
)['total_price'] or 0
expence = Expence.objects.filter(currency='uzs', counterparty=self.counterparty).aggregate(
total_price=models.Sum("price")
)['total_price'] or 0
print(party_total_amount, income, expence)
return (party_total_amount + income) - expence
def __str__(self):