From 0475667afc0d321d2f7de8837a3800703df98b16 Mon Sep 17 00:00:00 2001 From: Sravan Kumar <30795376+Sravanksk@users.noreply.github.com> Date: Thu, 21 Apr 2022 09:52:15 +0530 Subject: [PATCH] Handle stats mapping api for config updates (#53) Handle stats mapping api for config updates (#53) --- fyle_accounting_mappings/views.py | 13 +++++++++++-- setup.py | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/fyle_accounting_mappings/views.py b/fyle_accounting_mappings/views.py index b0ea0d0..7c0214c 100644 --- a/fyle_accounting_mappings/views.py +++ b/fyle_accounting_mappings/views.py @@ -173,20 +173,29 @@ class MappingStatsView(ListCreateAPIView): """ def get(self, request, *args, **kwargs): source_type = self.request.query_params.get('source_type') + destination_type = self.request.query_params.get('destination_type') assert_valid(source_type is not None, 'query param source_type not found') + assert_valid(destination_type is not None, 'query param destination_type not found') total_attributes_count = ExpenseAttribute.objects.filter( attribute_type=source_type, workspace_id=self.kwargs['workspace_id'] ).count() if source_type == 'EMPLOYEE': + filters = {} + + if destination_type == 'VENDOR': + filters['destination_vendor__attribute_type'] = destination_type + else: + filters['destination_employee__attribute_type'] = destination_type + mapped_attributes_count = EmployeeMapping.objects.filter( - workspace_id=self.kwargs['workspace_id'] + **filters, workspace_id=self.kwargs['workspace_id'] ).count() else: mapped_attributes_count = Mapping.objects.filter( - source_type=source_type, workspace_id=self.kwargs['workspace_id'] + source_type=source_type, destination_type=destination_type, workspace_id=self.kwargs['workspace_id'] ).count() return Response( diff --git a/setup.py b/setup.py index e96b924..3bc3c38 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='fyle-accounting-mappings', - version='1.14.0', + version='1.15.0', author='Shwetabh Kumar', author_email='shwetabh.kumar@fyle.in', description='Django application to store the fyle accounting mappings in a generic manner',