Skip to content

Commit

Permalink
Finish feature/OTC-1022
Browse files Browse the repository at this point in the history
OTC-1022: fix filtering of items in check eligibility
  • Loading branch information
dragos-dobre authored May 6, 2023
2 parents 7f29976 + 0ce2ced commit 5584dcd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions policy/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def get_eligibility(self, insuree, item_or_service, model, req, now):
queryset_item_or_service = InsureePolicy.objects\
.filter(validity_to__isnull=True)\
.filter(policy__validity_to__isnull=True)\
.filter(policy__product__items__validity_to__isnull=True,
.filter(**{f"policy__product__{item_or_service}s__validity_to__isnull": True},
**{f"policy__product__{item_or_service}s__{item_or_service}_id": item_or_service_obj.id}) \
.filter(policy__status=Policy.STATUS_ACTIVE) \
.filter(insuree=insuree) \
Expand All @@ -596,10 +596,10 @@ def get_eligibility(self, insuree, item_or_service, model, req, now):
waiting_period=F(waiting_period_field),
limit_no=F(limit_field)) \
.annotate(min_date=MonthsAdd(Coalesce(F(waiting_period_field), 0), "effective_date")) \
.annotate(count=Coalesce(
.annotate(count=Sum(Coalesce(
f"insuree__claim__{item_or_service}s__qty_approved",
f'insuree__claim__{item_or_service}s__qty_provided'
)) \
))) \
.annotate(left=F("limit_no") - F("count"))

min_date_qs = queryset_item_or_service.aggregate(
Expand Down

0 comments on commit 5584dcd

Please sign in to comment.