import - inventory dashboard / incentive plan search
This commit is contained in:
@@ -10,6 +10,7 @@ from apps.core.api import BaseViewSet
|
||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||
from apps.core.mixins.soft_delete_mixin import SoftDeleteMixin
|
||||
from apps.warehouse import models as warehouse_models
|
||||
from apps.warehouse.services.inventory_entry_dashboard_service import InventoryEntryDashboardService
|
||||
from apps.warehouse.services.transaction_dashboard_service import TransactionDashboardService
|
||||
from apps.warehouse.web.api.v1 import serializers as warehouse_serializers
|
||||
from common.generics import base64_to_image_file
|
||||
@@ -17,7 +18,13 @@ from common.helpers import get_organization_by_user
|
||||
from common.liara_tools import upload_to_liara
|
||||
|
||||
|
||||
class InventoryEntryViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
class InventoryEntryViewSet(
|
||||
BaseViewSet,
|
||||
SoftDeleteMixin,
|
||||
viewsets.ModelViewSet,
|
||||
DynamicSearchMixin,
|
||||
InventoryEntryDashboardService
|
||||
):
|
||||
queryset = warehouse_models.InventoryEntry.objects.all()
|
||||
serializer_class = warehouse_serializers.InventoryEntrySerializer
|
||||
# filter_backends = [filters.SearchFilter]
|
||||
@@ -108,6 +115,34 @@ class InventoryEntryViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet,
|
||||
self.upload_confirmation_document(request, inventory=pk)
|
||||
return Response(status=status.HTTP_200_OK)
|
||||
|
||||
@action(
|
||||
methods=['get'],
|
||||
detail=False,
|
||||
url_path='inventory_dashboard',
|
||||
url_name='inventory_dashboard',
|
||||
name='inventory_dashboard'
|
||||
)
|
||||
def inventory_dashboard(self, request):
|
||||
""" inventory entry dashboard """
|
||||
|
||||
org = get_organization_by_user(request.user)
|
||||
query_param = self.request.query_params # noqa
|
||||
|
||||
# filter by date
|
||||
start_date = query_param.get('start') if 'start' in query_param.keys() else None
|
||||
end_date = query_param.get('end') if 'end' in query_param.keys() else None
|
||||
query_string = query_param.get('search') if 'search' in query_param.keys() else None
|
||||
|
||||
return Response(
|
||||
self.get_dashboard(
|
||||
org=org,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
query_string=query_string,
|
||||
search_fields=self.search_fields,
|
||||
)
|
||||
)
|
||||
|
||||
@action(
|
||||
methods=['get'],
|
||||
detail=True,
|
||||
|
||||
Reference in New Issue
Block a user