change type

This commit is contained in:
behruz-dev
2025-10-07 16:28:28 +05:00
parent 50e989f8e1
commit aa8be776bc
2 changed files with 36 additions and 8 deletions

View File

@@ -0,0 +1,28 @@
# Generated by Django 5.2.4 on 2025-10-07 16:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('orders', '0026_alter_order_qqs_alter_order_qqs_price_and_more'),
]
operations = [
migrations.AlterField(
model_name='partyamount',
name='calculated_amount',
field=models.BigIntegerField(default=0),
),
migrations.AlterField(
model_name='partyamount',
name='cost_amount',
field=models.BigIntegerField(default=0),
),
migrations.AlterField(
model_name='partyamount',
name='paid_amount',
field=models.BigIntegerField(default=0),
),
]

View File

@@ -70,11 +70,11 @@ class Party(BaseModel):
self.process = 75
elif self.status == 'PARTY_IS_MADE':
self.process = 100
# if hasattr(self, 'party_amount') and self.party_amount.paid_amount > 0 and self.party_amount.payment_amount > 0:
# self.payment_percentage = (self.party_amount.paid_amount / self.party_amount.payment_amount) * 100
# self.party_amount.save()
# else:
# self.payment_percentage = 100
if hasattr(self, 'party_amount') and self.party_amount.paid_amount > 0 and self.party_amount.payment_amount > 0:
self.payment_percentage = (self.party_amount.paid_amount / self.party_amount.payment_amount) * 100
self.party_amount.save()
else:
self.payment_percentage = 100
return super().save(*args, **kwargs)
class Meta:
@@ -85,9 +85,9 @@ class Party(BaseModel):
class PartyAmount(BaseModel):
party = models.OneToOneField(Party, on_delete=models.CASCADE, related_name='party_amount')
total_price = models.PositiveBigIntegerField()
cost_amount = models.PositiveBigIntegerField(default=0)
calculated_amount = models.PositiveBigIntegerField(default=0)
paid_amount = models.PositiveBigIntegerField(default=0)
cost_amount = models.BigIntegerField(default=0)
calculated_amount = models.BigIntegerField(default=0)
paid_amount = models.BigIntegerField(default=0)
payment_amount = models.BigIntegerField(default=0)
def __str__(self):