change price type int -> decimal field
This commit is contained in:
@@ -93,7 +93,6 @@ class IncomeDeleteApiView(generics.GenericAPIView):
|
||||
comment = serializer.validated_data.get('comment')
|
||||
currency = income.currency.lower()
|
||||
|
||||
# Deleted record yaratish
|
||||
DeletedIncome.objects.create(
|
||||
income=income,
|
||||
comment=comment
|
||||
@@ -104,57 +103,47 @@ class IncomeDeleteApiView(generics.GenericAPIView):
|
||||
counterparty = income.counterparty
|
||||
|
||||
if currency == 'uzs':
|
||||
# Balanslarni qaytarish (o'chirilgani teskari qilish)
|
||||
cash_transaction.income_balance_uzs -= income.price # ✅ INCOME BALANCE KAMAYISHI KERAK
|
||||
cash_transaction.income_balance_uzs -= income.price
|
||||
cash_transaction.total_balance_uzs = (
|
||||
cash_transaction.income_balance_uzs - cash_transaction.expence_balance_uzs
|
||||
)
|
||||
payment_type.total_uzs -= income.price # ✅ QAYTARISH
|
||||
payment_type.total_uzs -= income.price
|
||||
|
||||
# Kontrapartiya hisobini qaytarish
|
||||
if counterparty:
|
||||
if counterparty.kredit_uzs > 0:
|
||||
# Agar kredit bo'lsa, uni kamayitish (teskari)
|
||||
counterparty.kredit_uzs -= income.price
|
||||
counterparty.total_kredit -= income.price
|
||||
|
||||
counterparty.debit_uzs += income.price
|
||||
counterparty.total_debit += income.price
|
||||
else:
|
||||
# Agar debit bo'lsa, uni oshirish (teskari)
|
||||
counterparty.debit_uzs += income.price
|
||||
counterparty.total_debit += income.price
|
||||
|
||||
counterparty.save()
|
||||
|
||||
elif currency == 'usd':
|
||||
# Balanslarni qaytarish (o'chirilgani teskari qilish)
|
||||
cash_transaction.income_balance_usd -= income.price # ✅ INCOME BALANCE KAMAYISHI KERAK
|
||||
cash_transaction.income_balance_usd -= income.price
|
||||
cash_transaction.total_balance_usd = (
|
||||
cash_transaction.income_balance_usd - cash_transaction.expence_balance_usd
|
||||
)
|
||||
payment_type.total_usd -= income.price # ✅ QAYTARISH
|
||||
payment_type.total_usd -= income.price
|
||||
|
||||
# Kontrapartiya hisobini qaytarish
|
||||
if counterparty:
|
||||
if counterparty.kredit_usd > 0:
|
||||
# Agar kredit bo'lsa, uni kamayitish (teskari)
|
||||
counterparty.kredit_usd -= income.price
|
||||
counterparty.total_kredit -= income.price
|
||||
|
||||
counterparty.debit_usd += income.price
|
||||
counterparty.total_debit += income.price
|
||||
else:
|
||||
# Agar debit bo'lsa, uni oshirish (teskari)
|
||||
counterparty.debit_usd += income.price
|
||||
counterparty.total_debit += income.price
|
||||
|
||||
counterparty.save()
|
||||
|
||||
# is_deleted = True qilish (hard delete emas, soft delete)
|
||||
income.is_deleted = True
|
||||
|
||||
# Barcha o'zgarishlari saqlash
|
||||
cash_transaction.save()
|
||||
payment_type.save()
|
||||
income.save()
|
||||
|
||||
Reference in New Issue
Block a user