diff --git a/cope2n-api/fwd/settings.py b/cope2n-api/fwd/settings.py index 86d4832..8f05d50 100755 --- a/cope2n-api/fwd/settings.py +++ b/cope2n-api/fwd/settings.py @@ -245,6 +245,7 @@ FIELDS_BY_SUB = { BAD_THRESHOLD = 0.75 NEED_REVIEW = 1.0 +DOC_TYPES = ["imei", "invoice"] SUB_FOR_BILLING = ["all", "seao"] FIELD = ["imei_number", "purchase_date", "retailername", "sold_to_party", "invoice_no"] diff --git a/cope2n-api/fwd_api/api/accuracy_view.py b/cope2n-api/fwd_api/api/accuracy_view.py index ec48e65..327b469 100755 --- a/cope2n-api/fwd_api/api/accuracy_view.py +++ b/cope2n-api/fwd_api/api/accuracy_view.py @@ -78,6 +78,7 @@ class AccuracyViewSet(viewsets.ViewSet): description='Which subsidiary to be included', type=OpenApiTypes.STR, enum=list(settings.SUBS.keys()), + required=True ), OpenApiParameter( name='request_id', @@ -138,6 +139,7 @@ class AccuracyViewSet(viewsets.ViewSet): location=OpenApiParameter.QUERY, description='Filter by document type', type=OpenApiTypes.STR, + enum=list(settings.DOC_TYPES.keys()), required=False ), ], @@ -231,7 +233,10 @@ class AccuracyViewSet(viewsets.ViewSet): if reviewed_result: base_query &= Q(reviewed_result__icontains=reviewed_result) if doc_type: - base_query &= Q(doc_type__icontains=doc_type) + if doc_type.lower() == 'invoice': + base_query &= Q(doc_type__regex=r'^invoice(,\s*invoice)*$') + elif doc_type.lower() == 'imei': + base_query &= Q(doc_type__regex=r'^imei(,\s*imei)*$') if isinstance(max_accuracy, float): base_query &= Q(raw_accuracy__lt=(