calculate party process and payment_percentag
This commit is contained in:
@@ -59,6 +59,22 @@ class Party(BaseModel):
|
||||
def __str__(self):
|
||||
return f'P - {self.number}'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.status in ['NEW', 'CANCELLED', 'DRAFT']:
|
||||
self.process = 0
|
||||
elif self.status == 'EXPECTED':
|
||||
self.process = 25
|
||||
elif self.status == 'PROCESS':
|
||||
self.process = 50
|
||||
elif self.status == 'PURCHASED':
|
||||
self.process = 75
|
||||
elif self.status == 'PARTY_IS_MADE':
|
||||
self.process == 100
|
||||
if self.party_amount and self.party_amount.paid_amount > 0:
|
||||
self.payment_percentage = (self.party_amount.paid_amount / self.party_amount.payment_amount) * 100
|
||||
self.party_amount.save()
|
||||
return super().save(args, kwargs)
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Partiya'
|
||||
verbose_name_plural = 'Partiyalar'
|
||||
|
||||
Reference in New Issue
Block a user