This commit is contained in:
behruz-dev
2025-10-28 16:44:29 +05:00
parent 0899595781
commit a542613841
3 changed files with 8 additions and 6 deletions

View File

@@ -3,6 +3,7 @@ from django.db import transaction
from rest_framework import serializers
from core.apps.finance.models import Expence
from core.apps.notifications.utils.notify_user import notify_user
class ExpenceCreateSerializer(serializers.ModelSerializer):
@@ -33,7 +34,7 @@ class ExpenceCreateSerializer(serializers.ModelSerializer):
)
cash_transaction = expence.cash_transaction
payment_type = expence.payment_type
user = self.context.get('user')
if validated_data.get('currency') == 'uzs':
cash_transaction.expence_balance_uzs += expence.price
cash_transaction.total_balance_uzs = cash_transaction.income_balance_uzs - cash_transaction.expence_balance_uzs
@@ -69,7 +70,10 @@ class ExpenceCreateSerializer(serializers.ModelSerializer):
expence.counterparty.debit_usd += validated_data.get('price')
expence.counterparty.total_debit += expence.price
expence.counterparty.save()
body = f"""
{user.full_name} {expence.price} {expence.currency.upper()}... \n screen: /monitoring
"""
notify_user(user=user, title="Tasdiqlang yoki rad eting", body=body)
cash_transaction.save()
payment_type.save()
return expence

View File

@@ -85,9 +85,7 @@ class MultipleOrderCreateSerializer(serializers.Serializer):
employee=self.context.get('user'),
)
orders.append(order)
body = f"""
{user.full_name} {order.project_folder.name} uchun {order.wherehouse.name} ombor ga {order.quantity} {order.unity.value} {order.product.name} ga buyurtma berdi. Buyurtma
yetkazish sanasi {common_date}
body = f"""{user.full_name} {order.project_folder.name} uchun {order.wherehouse.name} ombor ga {order.quantity} {order.unity.value} {order.product.name} ga buyurtma berdi. Buyurtma yetkazish sanasi {common_date} \n screen: /supply
"""
notify_user(user=user, title="Ta'minot",body=body)