some apis of pos
This commit is contained in:
55
apps/warehouse/pos/api/v1/api.py
Normal file
55
apps/warehouse/pos/api/v1/api.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from apps.warehouse.pos.api.v1 import serializers as warehouse_serializers
|
||||
from apps.pos_device.mixins.pos_device_mixin import POSDeviceMixin
|
||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||
from apps.warehouse import models as warehouse_models
|
||||
from common.helpers import get_organization_by_user
|
||||
from rest_framework.permissions import AllowAny
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.response import Response
|
||||
from rest_framework import viewsets, filters
|
||||
from django.db import transaction
|
||||
from rest_framework import status
|
||||
import typing
|
||||
|
||||
|
||||
class InventoryEntryViewSet(viewsets.ModelViewSet, DynamicSearchMixin, POSDeviceMixin):
|
||||
queryset = warehouse_models.InventoryEntry.objects.all()
|
||||
serializer_class = warehouse_serializers.InventoryEntrySerializer
|
||||
permission_classes = [AllowAny]
|
||||
search_fields = [
|
||||
"distribution__distribution_id",
|
||||
"organization__name",
|
||||
"weight",
|
||||
"balance",
|
||||
"lading_number",
|
||||
"is_confirmed",
|
||||
]
|
||||
date_field = "create_date"
|
||||
|
||||
@action(
|
||||
methods=['get'],
|
||||
detail=False,
|
||||
url_path='my_entries',
|
||||
url_name='my_entries',
|
||||
name='my_entries'
|
||||
)
|
||||
def inventory_entries(self, request):
|
||||
""" list of pos inventory entries """
|
||||
|
||||
organization = self.get_device_organization()
|
||||
|
||||
entries = self.queryset.filter(organization=organization)
|
||||
queryset = self.filter_query(entries) # return by search param or all objects
|
||||
|
||||
# paginate & response
|
||||
page = self.paginate_queryset(queryset)
|
||||
if page is not None:
|
||||
serializer = self.get_serializer(page, many=True)
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
|
||||
class InventoryQuotaSaleTransactionViewSet(viewsets.ModelViewSet):
|
||||
queryset = warehouse_models.InventoryQuotaSaleTransaction.objects.all()
|
||||
serializer_class = warehouse_serializers.InventoryQuotaSaleTransactionSerializer
|
||||
filter_backends = [filters.SearchFilter]
|
||||
search_fields = ['']
|
||||
Reference in New Issue
Block a user