(change, add): party status change api added, and celery task changed

This commit is contained in:
behruz-dev
2025-08-26 09:56:23 +05:00
parent 30e0e3462f
commit 77c8bcaae5
3 changed files with 29 additions and 2 deletions

View File

@@ -57,7 +57,6 @@ class PartyCreateSerializer(serializers.Serializer):
total_price=resource.get('total_price'), total_price=resource.get('total_price'),
qqs=resource.get('qqs'), qqs=resource.get('qqs'),
)) ))
create_inventory.delay(resource['wherehouse_id'], resource['quantity'], resource['product_id'], resource['unity_id'], resource['total_price'])
if validated_data.get('currency') == 'uzs': if validated_data.get('currency') == 'uzs':
if resource.get('currency') == 'usd': if resource.get('currency') == 'usd':
usd_value = UsdCourse.objects.first().value usd_value = UsdCourse.objects.first().value

View File

@@ -36,6 +36,7 @@ urlpatterns = [
path( path(
'<uuid:party_id>/order/<uuid:order_id>/remove/', party_views.OrderDeleteToPartyApiView.as_view() '<uuid:party_id>/order/<uuid:order_id>/remove/', party_views.OrderDeleteToPartyApiView.as_view()
), ),
path('<uuid:party_id>/is_made/', party_views.PartyChangeStatusToIsMadeApiView.as_view()),
] ]
)), )),
] ]

View File

@@ -9,6 +9,7 @@ from core.apps.accounts.permissions.permissions import HasRolePermission
from core.apps.orders.serializers import party as serializers from core.apps.orders.serializers import party as serializers
from core.apps.orders.models import Party, PartyAmount, DeletedParty, Order from core.apps.orders.models import Party, PartyAmount, DeletedParty, Order
from core.apps.orders.filters.party import PartyFilter from core.apps.orders.filters.party import PartyFilter
from core.apps.orders.tasks.order import create_inventory
class PartyCreateApiView(generics.GenericAPIView): class PartyCreateApiView(generics.GenericAPIView):
@@ -134,4 +135,30 @@ class OrderDeleteToPartyApiView(generics.GenericAPIView):
) )
party.orders.remove(order) party.orders.remove(order)
return Response({'success': True, 'message': 'Order removed from party'}, status=200) return Response({'success': True, 'message': 'Order removed from party'}, status=200)
class PartyChangeStatusToIsMadeApiView(generics.GenericAPIView):
serializer_class = None
queryset = Party.objects.all()
permission_classes = [HasRolePermission]
required_permission = ['party']
pagination_class = None
def get(self, request, party_id):
party = get_object_or_404(Party, id=party_id)
party.status = 'PARTY_IS_MADE'
party.save()
for order in party.orders.all():
create_inventory.delay(
order.wherehouse.id,
order.quantity,
order.product.id,
order.unity.id,
order.total_price
)
return Response(
{'success': True, 'message': 'party updated'},
status=200
)