fix expence income api

This commit is contained in:
behruz-dev
2025-09-25 18:30:47 +05:00
parent b7100bfac1
commit fde7b1e2a2
2 changed files with 5 additions and 5 deletions

View File

@@ -168,17 +168,17 @@ class ExpenceUpdateSerializer(serializers.ModelSerializer):
if instance.currency == 'uzs':
cash_transaction.expence_balance_uzs -= (old_price - validated_data.get('price'))
cash_transaction.total_balance_uzs -= (old_price - validated_data.get('price'))
payment_type.total_uzs -= (old_price - validated_data.get('price'))
payment_type.total_uzs -= (old_price - validated_data.get('price')) if payment_type.total_uzs > (old_price - validated_data.get('price')) else 0
else:
cash_transaction.expence_balance_usd -= (old_price - validated_data.get('price'))
cash_transaction.total_balance_usd -= (old_price - validated_data.get('price'))
payment_type.total_usd -= (old_price - validated_data.get('price'))
payment_type.total_usd -= (old_price - validated_data.get('price')) if payment_type.total_usd > (old_price - validated_data.get('price')) else 0
elif old_price < validated_data.get('price'):
if instance.currency == 'uzs':
cash_transaction.expence_balance_uzs += (old_price - validated_data.get('price'))
cash_transaction.total_balance_uzs += (old_price - validated_data.get('price'))
payment_type.total_uzs += (old_price - validated_data.get('price'))
payment_type.total_uzs += (old_price - validated_data.get('price'))
else:
cash_transaction.expence_balance_usd += (old_price - validated_data.get('price'))
cash_transaction.total_balance_usd += (old_price - validated_data.get('price'))

View File

@@ -166,11 +166,11 @@ class IncomeUpdateSerializer(serializers.ModelSerializer):
if instance.currency == 'uzs':
cash_transaction.income_balance_uzs -= (old_price - validated_data.get('price'))
cash_transaction.total_balance_uzs -= (old_price - validated_data.get('price'))
payment_type.total_uzs -= (old_price - validated_data.get('price'))
payment_type.total_uzs -= (old_price - validated_data.get('price')) if payment_type.total_uzs > (old_price - validated_data.get('price')) else 0
else:
cash_transaction.income_balance_usd -= (old_price - validated_data.get('price'))
cash_transaction.total_balance_usd -= (old_price - validated_data.get('price'))
payment_type.total_usd -= (old_price - validated_data.get('price'))
payment_type.total_usd -= (old_price - validated_data.get('price')) if payment_type.total_usd > (old_price - validated_data.get('price')) else 0
elif old_price < validated_data.get('price'):
if instance.currency == 'uzs':