Skip to content

Commit c240893

Browse files
authored
Merge pull request #80 from Y-Note-SAS/feature-36908
fix(invoice): add subject_type_filter and thirdparty_type_filter params
2 parents ba89207 + 5b3a99d commit c240893

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

invoice/gql/invoice/query.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ class InvoiceQueryMixin:
1717
dateValidFrom__Gte=graphene.DateTime(),
1818
dateValidTo__Lte=graphene.DateTime(),
1919
applyDefaultValidityFilter=graphene.Boolean(),
20-
client_mutation_id=graphene.String()
20+
client_mutation_id=graphene.String(),
21+
subject_type_filter=graphene.String(),
22+
thirdparty_type_filter=graphene.String(),
2123
)
2224

2325
def resolve_invoice(self, info, **kwargs):
@@ -29,11 +31,11 @@ def resolve_invoice(self, info, **kwargs):
2931
if client_mutation_id:
3032
filters.append(Q(mutations__mutation__client_mutation_id=client_mutation_id))
3133

32-
subject_type = kwargs.get("subject_type", None)
34+
subject_type = kwargs.pop("subject_type_filter", None)
3335
if subject_type:
3436
filters.append(Q(subject_type__model=subject_type))
3537

36-
thirdparty_type = kwargs.get("thirdparty_type", None)
38+
thirdparty_type = kwargs.pop("thirdparty_type_filter", None)
3739
if thirdparty_type:
3840
filters.append(Q(thirdparty_type__model=thirdparty_type))
3941

invoice/tests/gql/invoice_schema.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ class InvoiceGQLTest(InvoiceGQLTestCase):
2121

2222
search_for_invoice_query = F'''
2323
query {{
24-
invoice(code_Iexact:"{DEFAULT_TEST_INVOICE_PAYLOAD['code']}"){{
24+
invoice(
25+
code_Iexact:"{DEFAULT_TEST_INVOICE_PAYLOAD['code']}",
26+
subjectTypeFilter: "contract",
27+
thirdpartyTypeFilter: "insuree"
28+
){{
2529
edges {{
2630
node {{
2731
isDeleted,
@@ -54,12 +58,11 @@ def test_mutation_invoice_generate_for_time_frame(self):
5458
mutation = self.create_invoice_mutation
5559
self.graph_client.execute(mutation, context=self.user_context.get_request())
5660
signal_receiver_mock.assert_called_once_with(**_expected_call_args)
57-
pass
5861

5962
def test_fetch_invoice_query(self):
6063
output = self.graph_client.execute(self.search_for_invoice_query, context=self.user_context.get_request())
61-
expected = \
62-
{'data': {
64+
expected = {
65+
'data': {
6366
'invoice': {
6467
'edges': [
6568
{'node': {
@@ -71,7 +74,11 @@ def test_fetch_invoice_query(self):
7174
'thirdpartyType': self.invoice.thirdparty_type.id,
7275
'subjectId': F'{self.invoice.subject.id}',
7376
'subjectType': self.invoice.subject_type.id
74-
}}]}}}
77+
}}
78+
]
79+
}
80+
}
81+
}
7582

7683
self.assertEqual(output, expected)
7784

@@ -84,4 +91,4 @@ def setup_test_signal(self, receiver_mock):
8491
'invoice_creation_from_calculation',
8592
receiver_mock,
8693
bind_type=ServiceSignalBindType.AFTER
87-
)
94+
)

0 commit comments

Comments
 (0)