This commit is contained in:
behruz-dev
2025-11-12 14:23:38 +05:00
parent 2a67e69d06
commit e26f443791
2 changed files with 5 additions and 1 deletions

View File

@@ -78,6 +78,7 @@ class Party(BaseModel):
percentage += order.completion_percentage
if percentage > 0 and count > 0:
self.process = percentage / count
self.party_amount.save()
return super().save(*args, **kwargs)
@@ -98,6 +99,8 @@ class PartyAmount(BaseModel):
overdue_amount = models.DecimalField(max_digits=15, decimal_places=2, default=0.00)
def save(self, *args, **kwargs):
self.total_price = self.party.orders.aggregate(total_price=models.Sum('total_price'))['total_price'] or 0
self.calculated_amount = self.total_price
if self.calculated_amount < self.paid_amount:
self.overdue_amount = self.paid_amount - self.calculated_amount
self.payment_amount = 0