Skip to content

Commit b26d34d

Browse files
author
Jan
authored
Merge pull request #67 from openimis/feature/CM-1000
CM-1000: added adjustments for enabling or disabling opensearch synch
2 parents 480f548 + 6b66135 commit b26d34d

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

payroll/apps.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"csv_reconciliation_paid_no": "No",
4242
"payroll_delete_event": "payroll.payroll_delete",
4343
"benefit_delete_event": "payroll.benefit_delete",
44-
"opensearch_synch": False,
4544

4645
"gateway_base_url": "http://41.175.18.170:8070/api/mobile/v1/",
4746
"endpoint_payment": "mock/payment",
@@ -82,7 +81,6 @@ class PayrollConfig(AppConfig):
8281
csv_reconciliation_paid_no = None
8382
payroll_delete_event = None
8483
benefit_delete_event = None
85-
opensearch_synch = None
8684

8785
gateway_base_url = None
8886
endpoint_payment = None

payroll/documents.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from django.apps import apps
2+
from django.conf import settings
23

3-
from payroll.apps import PayrollConfig
4+
is_unit_test_env = getattr(settings, 'IS_UNIT_TEST_ENV', False)
45

56
# Check if the 'opensearch_reports' app is in INSTALLED_APPS
6-
if 'opensearch_reports' in apps.app_configs and PayrollConfig.opensearch_synch:
7-
from django_opensearch_dsl import Document, fields as opensearch_fields
7+
if 'opensearch_reports' in apps.app_configs and not is_unit_test_env:
8+
from opensearch_reports.service import BaseSyncDocument
9+
from django_opensearch_dsl import fields as opensearch_fields
810
from django_opensearch_dsl.registries import registry
911
from payroll.models import (
1012
Payroll,
@@ -18,7 +20,9 @@
1820
from invoice.models import Bill
1921

2022
@registry.register_document
21-
class PayrollDocument(Document):
23+
class PayrollDocument(BaseSyncDocument):
24+
DASHBOARD_NAME = 'Payment'
25+
2226
name = opensearch_fields.KeywordField()
2327
status = opensearch_fields.KeywordField()
2428
payment_method = opensearch_fields.KeywordField()
@@ -58,7 +62,9 @@ def get_instances_from_related(self, related_instance):
5862

5963

6064
@registry.register_document
61-
class BenefitConsumptionDocument(Document):
65+
class BenefitConsumptionDocument(BaseSyncDocument):
66+
DASHBOARD_NAME = 'Payment'
67+
6268
photo = opensearch_fields.KeywordField()
6369
code = opensearch_fields.KeywordField()
6470
date_due = opensearch_fields.DateField()
@@ -96,7 +102,9 @@ def get_instances_from_related(self, related_instance):
96102

97103

98104
@registry.register_document
99-
class PayrollBenefitConsumptionDocument(Document):
105+
class PayrollBenefitConsumptionDocument(BaseSyncDocument):
106+
DASHBOARD_NAME = 'Payment'
107+
100108
payroll = opensearch_fields.ObjectField(properties={
101109
'name': opensearch_fields.KeywordField(),
102110
'status': opensearch_fields.KeywordField(),
@@ -152,7 +160,9 @@ def get_instances_from_related(self, related_instance):
152160

153161

154162
@registry.register_document
155-
class BenefitAttachmentDocument(Document):
163+
class BenefitAttachmentDocument(BaseSyncDocument):
164+
DASHBOARD_NAME = 'Invoice'
165+
156166
bill = opensearch_fields.ObjectField(properties={
157167
'code': opensearch_fields.KeywordField(),
158168
'code_ext': opensearch_fields.KeywordField(),

0 commit comments

Comments
 (0)