|
1 | 1 | from django.apps import apps |
| 2 | +from django.conf import settings |
2 | 3 |
|
3 | | -from payroll.apps import PayrollConfig |
| 4 | +is_unit_test_env = getattr(settings, 'IS_UNIT_TEST_ENV', False) |
4 | 5 |
|
5 | 6 | # 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 |
8 | 10 | from django_opensearch_dsl.registries import registry |
9 | 11 | from payroll.models import ( |
10 | 12 | Payroll, |
|
18 | 20 | from invoice.models import Bill |
19 | 21 |
|
20 | 22 | @registry.register_document |
21 | | - class PayrollDocument(Document): |
| 23 | + class PayrollDocument(BaseSyncDocument): |
| 24 | + DASHBOARD_NAME = 'Payment' |
| 25 | + |
22 | 26 | name = opensearch_fields.KeywordField() |
23 | 27 | status = opensearch_fields.KeywordField() |
24 | 28 | payment_method = opensearch_fields.KeywordField() |
@@ -58,7 +62,9 @@ def get_instances_from_related(self, related_instance): |
58 | 62 |
|
59 | 63 |
|
60 | 64 | @registry.register_document |
61 | | - class BenefitConsumptionDocument(Document): |
| 65 | + class BenefitConsumptionDocument(BaseSyncDocument): |
| 66 | + DASHBOARD_NAME = 'Payment' |
| 67 | + |
62 | 68 | photo = opensearch_fields.KeywordField() |
63 | 69 | code = opensearch_fields.KeywordField() |
64 | 70 | date_due = opensearch_fields.DateField() |
@@ -96,7 +102,9 @@ def get_instances_from_related(self, related_instance): |
96 | 102 |
|
97 | 103 |
|
98 | 104 | @registry.register_document |
99 | | - class PayrollBenefitConsumptionDocument(Document): |
| 105 | + class PayrollBenefitConsumptionDocument(BaseSyncDocument): |
| 106 | + DASHBOARD_NAME = 'Payment' |
| 107 | + |
100 | 108 | payroll = opensearch_fields.ObjectField(properties={ |
101 | 109 | 'name': opensearch_fields.KeywordField(), |
102 | 110 | 'status': opensearch_fields.KeywordField(), |
@@ -152,7 +160,9 @@ def get_instances_from_related(self, related_instance): |
152 | 160 |
|
153 | 161 |
|
154 | 162 | @registry.register_document |
155 | | - class BenefitAttachmentDocument(Document): |
| 163 | + class BenefitAttachmentDocument(BaseSyncDocument): |
| 164 | + DASHBOARD_NAME = 'Invoice' |
| 165 | + |
156 | 166 | bill = opensearch_fields.ObjectField(properties={ |
157 | 167 | 'code': opensearch_fields.KeywordField(), |
158 | 168 | 'code_ext': opensearch_fields.KeywordField(), |
|
0 commit comments