orders: fixed old bugs

This commit is contained in:
behruz-dev
2025-11-11 16:56:35 +05:00
parent fe1542b540
commit 4aea353b75
3 changed files with 34 additions and 10 deletions

View File

@@ -160,10 +160,8 @@ class PartyChangeStatusToIsMadeApiView(generics.GenericAPIView):
if not serializer.is_valid(raise_exception=True):
return Response({"success": False, "message": serializer.errors}, status=400)
party = get_object_or_404(Party, id=party_id)
party.status = 'PARTY_IS_MADE'
party.closed_date = now().date()
party.save()
data = serializer.validated_data
percentage = 0
for item in data['product']:
order_id = item['order_id']
product_quantity = item['product_quantity']
@@ -185,7 +183,13 @@ class PartyChangeStatusToIsMadeApiView(generics.GenericAPIView):
order.received_count += product_quantity
order.received_date = product_receive_date
order.comletion_percentage = completion_percentage
return Response(
percentage += completion_percentage
if percentage == 100:
party.status = 'PARTY_IS_MADE'
party.process = percentage
party.closed_date = now().date()
party.save()
return Response(
{'success': True, 'message': 'party updated'},
status=200
)