Skip to content

Commit

Permalink
Merge pull request #36 from cloudblue/LITE-31021-billing-request-repo…
Browse files Browse the repository at this point in the history
…rts-filter-by-date-range-not-working

LITE-31021 Billing request report filter by date range was not working
  • Loading branch information
akodelia authored Oct 17, 2024
2 parents b3bba10 + 16454fe commit 75c2569
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions reports/billing_requests/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def generate(

def _get_requests(client, parameters):
query = R()
query &= R().created.ge(parameters['date']['after'])
query &= R().created.le(parameters['date']['before'])
query &= R().events.created.at.ge(parameters['date']['after'])
query &= R().events.created.at.le(parameters['date']['before'])

if parameters.get('product') and parameters['product']['all'] is False:
query &= R().asset.product.id.oneof(parameters['product']['choices'])
Expand Down
24 changes: 18 additions & 6 deletions tests/test_billing_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def test_generate(progress, client_factory, response_factory, billing_request):

responses.append(
response_factory(
query='and(ge(created,2020-12-01T00:00:00),le(created,2021-01-01T00:00:00))',
query=(
'and(ge(events.created.at,2020-12-01T00:00:00),'
'le(events.created.at,2021-01-01T00:00:00))'
),
value=[billing_request],
),
)
Expand Down Expand Up @@ -86,9 +89,12 @@ def test_generate_additional(progress, client_factory, response_factory, billing

responses.append(
response_factory(
query='and(ge(created,2020-12-01T00:00:00),le(created,2021-01-01T00:00:00),'
'in(asset.product.id,(PRD-276-377-545)),in(asset.marketplace.id,(MP-123)),'
'in(asset.connection.hub.id,(HB-123)))',
query=(
'and(ge(events.created.at,2020-12-01T00:00:00),'
'le(events.created.at,2021-01-01T00:00:00),'
'in(asset.product.id,(PRD-276-377-545)),in(asset.marketplace.id,(MP-123)),'
'in(asset.connection.hub.id,(HB-123)))'
),
value=[billing_request],
),
)
Expand All @@ -109,7 +115,10 @@ def test_generate_csv_renderer(progress, client_factory, response_factory, billi
)
responses.append(
response_factory(
query='and(ge(created,2020-12-01T00:00:00),le(created,2021-01-01T00:00:00))',
query=(
'and(ge(events.created.at,2020-12-01T00:00:00),'
'le(events.created.at,2021-01-01T00:00:00))'
),
value=[billing_request],
),
)
Expand All @@ -133,7 +142,10 @@ def test_generate_json_renderer(progress, client_factory, response_factory, bill
)
responses.append(
response_factory(
query='and(ge(created,2020-12-01T00:00:00),le(created,2021-01-01T00:00:00))',
query=(
'and(ge(events.created.at,2020-12-01T00:00:00),'
'le(events.created.at,2021-01-01T00:00:00))'
),
value=[billing_request],
),
)
Expand Down

0 comments on commit 75c2569

Please sign in to comment.