fix
This commit is contained in:
@@ -102,10 +102,6 @@ class PartyAmount(BaseModel):
|
||||
verbose_name = 'Partiya Summasi'
|
||||
verbose_name_plural = 'Partiya summalari'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.calculated_amount < self.paid_amount:
|
||||
self.payment_amount = self.paid_amount - self.calculated_amount
|
||||
return super().save(*args, **kwargs)
|
||||
|
||||
class DeletedParty(BaseModel):
|
||||
party = models.ForeignKey(Party, on_delete=models.CASCADE, related_name='deleted_parties')
|
||||
|
||||
@@ -94,6 +94,8 @@ class PartyCreateSerializer(serializers.Serializer):
|
||||
|
||||
|
||||
class PartyAmountSerializer(serializers.ModelSerializer):
|
||||
payment_amount = serializers.SerializerMethodField(method_name='get_payment_amount')
|
||||
|
||||
class Meta:
|
||||
model = PartyAmount
|
||||
fields = [
|
||||
@@ -107,6 +109,12 @@ class PartyAmountSerializer(serializers.ModelSerializer):
|
||||
"total_expense_amount",
|
||||
]
|
||||
|
||||
def get_payment_amount(self, obj):
|
||||
if obj.calculated_amount < obj.paid_amount:
|
||||
return obj.paid_amount - obj.calculated_amount
|
||||
else:
|
||||
return obj.calculated_amount - obj.paid_amount
|
||||
|
||||
|
||||
class PartyDetailSerializer(serializers.ModelSerializer):
|
||||
orders = OrderListSerializer(many=True)
|
||||
|
||||
Reference in New Issue
Block a user