@openmrs/esm-billing-app 1.0.2-pre.86 → 1.0.2-pre.863
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +16 -2
- package/README.md +54 -9
- package/__mocks__/bills.mock.ts +12 -0
- package/__mocks__/react-i18next.js +6 -5
- package/dist/1119.js +1 -1
- package/dist/1146.js +1 -2
- package/dist/1146.js.map +1 -1
- package/dist/1197.js +1 -1
- package/dist/1856.js +1 -0
- package/dist/1856.js.map +1 -0
- package/dist/2146.js +1 -1
- package/dist/2177.js +2 -0
- package/dist/2177.js.LICENSE.txt +9 -0
- package/dist/2177.js.map +1 -0
- package/dist/2524.js +1 -0
- package/dist/2524.js.map +1 -0
- package/dist/2690.js +1 -1
- package/dist/3041.js +1 -0
- package/dist/3041.js.map +1 -0
- package/dist/3099.js +1 -1
- package/dist/3584.js +1 -1
- package/dist/3717.js +2 -0
- package/dist/3717.js.map +1 -0
- package/dist/4055.js +1 -1
- package/dist/4132.js +1 -1
- package/dist/4225.js +1 -0
- package/dist/4225.js.map +1 -0
- package/dist/4300.js +1 -1
- package/dist/4335.js +1 -1
- package/dist/4344.js +1 -0
- package/dist/4344.js.map +1 -0
- package/dist/4618.js +1 -1
- package/dist/4652.js +1 -1
- package/dist/4724.js +1 -0
- package/dist/4724.js.map +1 -0
- package/dist/4739.js +1 -1
- package/dist/4739.js.map +1 -1
- package/dist/4944.js +1 -1
- package/dist/5173.js +1 -1
- package/dist/5241.js +1 -1
- package/dist/5422.js +1 -0
- package/dist/5422.js.map +1 -0
- package/dist/5442.js +1 -1
- package/dist/5661.js +1 -1
- package/dist/6022.js +1 -1
- package/dist/6295.js +2 -0
- package/dist/{6525.js.LICENSE.txt → 6295.js.LICENSE.txt} +16 -4
- package/dist/6295.js.map +1 -0
- package/dist/6468.js +1 -1
- package/dist/6540.js +1 -1
- package/dist/6540.js.map +1 -1
- package/dist/6606.js +1 -0
- package/dist/6606.js.map +1 -0
- package/dist/6679.js +1 -1
- package/dist/6840.js +1 -1
- package/dist/6859.js +1 -1
- package/dist/7097.js +1 -1
- package/dist/7159.js +1 -1
- package/dist/723.js +1 -1
- package/dist/7617.js +1 -1
- package/dist/795.js +1 -1
- package/dist/8163.js +1 -1
- package/dist/8349.js +1 -1
- package/dist/8618.js +1 -1
- package/dist/890.js +1 -1
- package/dist/9214.js +1 -1
- package/dist/9538.js +1 -1
- package/dist/9569.js +1 -1
- package/dist/961.js +1 -1
- package/dist/961.js.map +1 -1
- package/dist/986.js +1 -1
- package/dist/9879.js +1 -1
- package/dist/9895.js +1 -1
- package/dist/9900.js +1 -1
- package/dist/9913.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-billing-app.js +1 -1
- package/dist/openmrs-esm-billing-app.js.buildmanifest.json +388 -282
- package/dist/openmrs-esm-billing-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/e2e/README.md +19 -18
- package/e2e/core/test.ts +1 -1
- package/e2e/fixtures/api.ts +1 -1
- package/e2e/specs/sample-test.spec.ts +0 -1
- package/e2e/support/github/Dockerfile +1 -1
- package/package.json +13 -10
- package/src/bill-history/bill-history.component.tsx +20 -28
- package/src/bill-history/bill-history.scss +4 -94
- package/src/bill-history/bill-history.test.tsx +37 -78
- package/src/bill-item-actions/bill-item-actions.scss +21 -5
- package/src/bill-item-actions/edit-bill-item.modal.tsx +225 -0
- package/src/bill-item-actions/edit-bill-item.test.tsx +214 -40
- package/src/billable-services/bill-waiver/bill-selection.component.tsx +5 -5
- package/src/billable-services/bill-waiver/bill-waiver-form.component.tsx +28 -32
- package/src/billable-services/bill-waiver/patient-bills.component.tsx +7 -7
- package/src/billable-services/bill-waiver/utils.ts +13 -3
- package/src/billable-services/billable-service.resource.ts +42 -26
- package/src/billable-services/billable-services-home.component.tsx +4 -4
- package/src/billable-services/billable-services.component.tsx +149 -148
- package/src/billable-services/billable-services.scss +3 -0
- package/src/billable-services/billable-services.test.tsx +6 -49
- package/src/billable-services/cash-point/add-cash-point.modal.tsx +168 -0
- package/src/billable-services/cash-point/cash-point-configuration.component.tsx +19 -193
- package/src/billable-services/cash-point/cash-point-configuration.scss +1 -5
- package/src/billable-services/create-edit/add-billable-service.component.tsx +365 -299
- package/src/billable-services/create-edit/add-billable-service.scss +7 -68
- package/src/billable-services/create-edit/add-billable-service.test.tsx +167 -81
- package/src/billable-services/create-edit/edit-billable-service.modal.tsx +51 -0
- package/src/billable-services/dashboard/service-metrics.component.tsx +11 -3
- package/src/billable-services/payment-modes/add-payment-mode.modal.tsx +121 -0
- package/src/billable-services/payment-modes/delete-payment-mode.modal.tsx +74 -0
- package/src/billable-services/payment-modes/payment-modes-config.component.tsx +125 -0
- package/src/billable-services/{payyment-modes → payment-modes}/payment-modes-config.scss +5 -4
- package/src/billing-dashboard/billing-dashboard.scss +1 -1
- package/src/billing-form/billing-checkin-form.component.tsx +21 -17
- package/src/billing-form/billing-checkin-form.test.tsx +99 -26
- package/src/billing-form/billing-form.component.tsx +222 -292
- package/src/billing-form/billing-form.scss +143 -0
- package/src/billing-form/visit-attributes/visit-attributes-form.component.tsx +1 -1
- package/src/billing.resource.ts +69 -74
- package/src/bills-table/bills-table.component.tsx +3 -3
- package/src/bills-table/bills-table.test.tsx +98 -54
- package/src/config-schema.ts +52 -24
- package/src/dashboard.meta.ts +4 -2
- package/src/helpers/functions.ts +5 -4
- package/src/index.ts +17 -6
- package/src/invoice/invoice-table.component.tsx +36 -70
- package/src/invoice/invoice-table.scss +8 -5
- package/src/invoice/invoice-table.test.tsx +273 -62
- package/src/invoice/invoice.component.tsx +39 -32
- package/src/invoice/invoice.scss +11 -4
- package/src/invoice/invoice.test.tsx +324 -120
- package/src/invoice/payments/invoice-breakdown/invoice-breakdown.scss +9 -9
- package/src/invoice/payments/payment-form/payment-form.component.tsx +43 -34
- package/src/invoice/payments/payment-form/payment-form.scss +5 -6
- package/src/invoice/payments/payment-form/payment-form.test.tsx +216 -66
- package/src/invoice/payments/payment-history/payment-history.component.tsx +6 -4
- package/src/invoice/payments/payment-history/payment-history.test.tsx +9 -14
- package/src/invoice/payments/payments.component.tsx +55 -67
- package/src/invoice/payments/payments.scss +4 -3
- package/src/invoice/payments/payments.test.tsx +282 -0
- package/src/invoice/payments/utils.ts +15 -27
- package/src/invoice/printable-invoice/print-receipt.component.tsx +3 -2
- package/src/invoice/printable-invoice/print-receipt.test.tsx +14 -25
- package/src/invoice/printable-invoice/printable-footer.component.tsx +2 -2
- package/src/invoice/printable-invoice/printable-footer.test.tsx +4 -13
- package/src/invoice/printable-invoice/printable-invoice-header.component.tsx +12 -11
- package/src/invoice/printable-invoice/printable-invoice-header.test.tsx +16 -14
- package/src/invoice/printable-invoice/printable-invoice.component.tsx +20 -34
- package/src/left-panel-link.test.tsx +1 -4
- package/src/metrics-cards/metrics-cards.component.tsx +12 -2
- package/src/metrics-cards/metrics-cards.scss +4 -0
- package/src/metrics-cards/metrics-cards.test.tsx +18 -5
- package/src/modal/require-payment-modal.test.tsx +27 -22
- package/src/modal/{require-payment-modal.component.tsx → require-payment.modal.tsx} +18 -19
- package/src/routes.json +25 -7
- package/src/types/index.ts +81 -23
- package/translations/am.json +125 -74
- package/translations/ar.json +126 -75
- package/translations/ar_SY.json +126 -75
- package/translations/bn.json +128 -77
- package/translations/de.json +126 -75
- package/translations/en.json +126 -75
- package/translations/en_US.json +126 -75
- package/translations/es.json +125 -74
- package/translations/es_MX.json +126 -75
- package/translations/fr.json +131 -80
- package/translations/he.json +125 -74
- package/translations/hi.json +126 -75
- package/translations/hi_IN.json +126 -75
- package/translations/id.json +126 -75
- package/translations/it.json +152 -101
- package/translations/ka.json +126 -75
- package/translations/km.json +125 -74
- package/translations/ku.json +126 -75
- package/translations/ky.json +126 -75
- package/translations/lg.json +126 -75
- package/translations/ne.json +126 -75
- package/translations/pl.json +126 -75
- package/translations/pt.json +126 -75
- package/translations/pt_BR.json +126 -75
- package/translations/qu.json +126 -75
- package/translations/ro_RO.json +216 -165
- package/translations/ru_RU.json +126 -75
- package/translations/si.json +126 -75
- package/translations/sw.json +126 -75
- package/translations/sw_KE.json +126 -75
- package/translations/tr.json +126 -75
- package/translations/tr_TR.json +126 -75
- package/translations/uk.json +126 -75
- package/translations/uz.json +126 -75
- package/translations/uz@Latn.json +126 -75
- package/translations/uz_UZ.json +126 -75
- package/translations/vi.json +126 -75
- package/translations/zh.json +126 -75
- package/translations/zh_CN.json +158 -107
- package/dist/1146.js.LICENSE.txt +0 -21
- package/dist/2352.js +0 -1
- package/dist/2352.js.map +0 -1
- package/dist/246.js +0 -1
- package/dist/246.js.map +0 -1
- package/dist/6525.js +0 -2
- package/dist/6525.js.map +0 -1
- package/dist/8556.js +0 -2
- package/dist/8556.js.map +0 -1
- package/dist/8638.js +0 -1
- package/dist/8638.js.map +0 -1
- package/dist/9968.js +0 -1
- package/dist/9968.js.map +0 -1
- package/src/bill-item-actions/edit-bill-item.component.tsx +0 -221
- package/src/billable-services/payyment-modes/payment-modes-config.component.tsx +0 -280
- package/src/invoice/payments/payments.component.test.tsx +0 -121
- /package/dist/{8556.js.LICENSE.txt → 3717.js.LICENSE.txt} +0 -0
package/src/config-schema.ts
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import { Type } from '@openmrs/esm-framework';
|
|
2
|
-
|
|
3
|
-
export interface BillingConfig {}
|
|
1
|
+
import { Type, validators } from '@openmrs/esm-framework';
|
|
4
2
|
|
|
5
3
|
export const configSchema = {
|
|
4
|
+
logo: {
|
|
5
|
+
src: {
|
|
6
|
+
_type: Type.String,
|
|
7
|
+
_default: '',
|
|
8
|
+
_description: 'The path or URL to the logo image. If set to an empty string, the alt text will be used.',
|
|
9
|
+
_validators: [validators.isUrl],
|
|
10
|
+
},
|
|
11
|
+
alt: {
|
|
12
|
+
_type: Type.String,
|
|
13
|
+
_default: '',
|
|
14
|
+
_description:
|
|
15
|
+
'The alternative text for the logo image, displayed when the image cannot be loaded or on hover. If not provided and src is empty, the default OpenMRS SVG sprite will be used.',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
country: {
|
|
19
|
+
_type: Type.String,
|
|
20
|
+
_description: 'The text that gets printed on the top right of the invoice, typically the name of the country',
|
|
21
|
+
_default: 'Kenya',
|
|
22
|
+
},
|
|
6
23
|
patientCatergory: {
|
|
7
24
|
_type: Type.Object,
|
|
8
25
|
_description: 'Patient Category Custom UUIDs',
|
|
@@ -15,7 +32,6 @@ export const configSchema = {
|
|
|
15
32
|
formPayloadPending: '919b51c9-8e2e-468f-8354-181bf3e55786',
|
|
16
33
|
},
|
|
17
34
|
},
|
|
18
|
-
|
|
19
35
|
catergoryConcepts: {
|
|
20
36
|
_type: Type.Object,
|
|
21
37
|
_description: 'Patient Category Concept UUIDs',
|
|
@@ -25,7 +41,6 @@ export const configSchema = {
|
|
|
25
41
|
insuranceDetails: 'beac329b-f1dc-4a33-9e7c-d95821a137a6',
|
|
26
42
|
},
|
|
27
43
|
},
|
|
28
|
-
|
|
29
44
|
nonPayingPatientCategories: {
|
|
30
45
|
_type: Type.Object,
|
|
31
46
|
_description: 'Concept UUIDs for non-paying patient categories',
|
|
@@ -34,7 +49,6 @@ export const configSchema = {
|
|
|
34
49
|
student: '159465AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
|
35
50
|
},
|
|
36
51
|
},
|
|
37
|
-
|
|
38
52
|
postBilledItems: {
|
|
39
53
|
_type: Type.Object,
|
|
40
54
|
_description: 'Post Bill Items such as cashPoints, cashier, priceUUid when submitting a bill',
|
|
@@ -44,7 +58,6 @@ export const configSchema = {
|
|
|
44
58
|
priceUuid: '7b9171ac-d3c1-49b4-beff-c9902aee5245',
|
|
45
59
|
},
|
|
46
60
|
},
|
|
47
|
-
|
|
48
61
|
serviceTypes: {
|
|
49
62
|
_type: Type.Object,
|
|
50
63
|
_description: 'Post Bill Items such as cashPoints, cashier, priceUUid when submitting a bill',
|
|
@@ -52,34 +65,49 @@ export const configSchema = {
|
|
|
52
65
|
billableService: '21b8cf43-9f9f-4d02-9f4a-d710ece54261',
|
|
53
66
|
},
|
|
54
67
|
},
|
|
55
|
-
|
|
56
68
|
defaultCurrency: {
|
|
57
69
|
_type: Type.String,
|
|
58
70
|
_description: 'The default currency for the application. Specify the currency code (e.g., KES, UGX, GBP).',
|
|
59
71
|
_default: 'KES',
|
|
60
72
|
},
|
|
61
|
-
|
|
62
73
|
pageSize: {
|
|
63
74
|
_type: Type.Number,
|
|
64
75
|
_description: 'The default page size',
|
|
65
76
|
_default: 10,
|
|
66
77
|
},
|
|
67
|
-
|
|
68
|
-
showEditBillButton: {
|
|
69
|
-
_type: Type.Boolean,
|
|
70
|
-
_description: 'Whether to show the edit bill button or not.',
|
|
71
|
-
_default: false,
|
|
72
|
-
},
|
|
73
78
|
};
|
|
74
79
|
|
|
75
|
-
export interface
|
|
76
|
-
|
|
80
|
+
export interface BillingConfig {
|
|
81
|
+
logo: {
|
|
82
|
+
src: string;
|
|
83
|
+
alt: string;
|
|
84
|
+
};
|
|
85
|
+
country: string;
|
|
86
|
+
patientCatergory: {
|
|
87
|
+
paymentDetails: string;
|
|
88
|
+
paymentMethods: string;
|
|
89
|
+
policyNumber: string;
|
|
90
|
+
insuranceScheme: string;
|
|
91
|
+
patientCategory: string;
|
|
92
|
+
formPayloadPending: string;
|
|
93
|
+
};
|
|
94
|
+
catergoryConcepts: {
|
|
95
|
+
payingDetails: string;
|
|
96
|
+
nonPayingDetails: string;
|
|
97
|
+
insuranceDetails: string;
|
|
98
|
+
};
|
|
99
|
+
nonPayingPatientCategories: {
|
|
100
|
+
childUnder5: string;
|
|
101
|
+
student: string;
|
|
102
|
+
};
|
|
103
|
+
postBilledItems: {
|
|
104
|
+
cashPoint: string;
|
|
105
|
+
cashier: string;
|
|
106
|
+
priceUuid: string;
|
|
107
|
+
};
|
|
108
|
+
serviceTypes: {
|
|
109
|
+
billableService: string;
|
|
110
|
+
};
|
|
77
111
|
defaultCurrency: string;
|
|
78
|
-
|
|
79
|
-
pageSize;
|
|
80
|
-
object;
|
|
81
|
-
showEditBillButton: boolean;
|
|
82
|
-
postBilledItems: Object;
|
|
83
|
-
serviceTypes: Object;
|
|
84
|
-
nonPayingPatientCategories: Object;
|
|
112
|
+
pageSize: number;
|
|
85
113
|
}
|
package/src/dashboard.meta.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { type DashboardLinkConfig } from '@openmrs/esm-patient-common-lib';
|
|
2
|
+
|
|
3
|
+
export const dashboardMeta: DashboardLinkConfig & { slot: string; columns: number; hideDashboardTitle: boolean } = {
|
|
2
4
|
slot: 'patient-chart-billing-dashboard-slot',
|
|
3
5
|
columns: 1,
|
|
4
6
|
title: 'Billing history',
|
|
5
7
|
hideDashboardTitle: true,
|
|
6
|
-
icon: '',
|
|
8
|
+
icon: 'omrs-icon-money',
|
|
7
9
|
path: 'Billing history',
|
|
8
10
|
};
|
package/src/helpers/functions.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getCoreTranslation } from '@openmrs/esm-framework';
|
|
1
2
|
import { type Payment, type LineItem } from '../types';
|
|
2
3
|
|
|
3
4
|
// amount already paid
|
|
@@ -51,13 +52,13 @@ export const convertToCurrency = (amountToConvert: number, currencyType?: string
|
|
|
51
52
|
export const getGender = (gender: string, t) => {
|
|
52
53
|
switch (gender) {
|
|
53
54
|
case 'male':
|
|
54
|
-
return
|
|
55
|
+
return getCoreTranslation('male');
|
|
55
56
|
case 'female':
|
|
56
|
-
return
|
|
57
|
+
return getCoreTranslation('female');
|
|
57
58
|
case 'other':
|
|
58
|
-
return
|
|
59
|
+
return getCoreTranslation('other');
|
|
59
60
|
case 'unknown':
|
|
60
|
-
return
|
|
61
|
+
return getCoreTranslation('unknown');
|
|
61
62
|
default:
|
|
62
63
|
return gender;
|
|
63
64
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,12 +3,17 @@ import { createDashboardLink } from '@openmrs/esm-patient-common-lib';
|
|
|
3
3
|
import { createLeftPanelLink } from './left-panel-link.component';
|
|
4
4
|
import { dashboardMeta } from './dashboard.meta';
|
|
5
5
|
import { defineConfigSchema, getAsyncLifecycle, getSyncLifecycle } from '@openmrs/esm-framework';
|
|
6
|
+
import AddCashPointModal from './billable-services/cash-point/add-cash-point.modal';
|
|
7
|
+
import AddPaymentModeModal from './billable-services/payment-modes/add-payment-mode.modal';
|
|
6
8
|
import appMenu from './billable-services/billable-services-menu-item/item.component';
|
|
7
9
|
import BillableServiceHome from './billable-services/billable-services-home.component';
|
|
8
10
|
import BillableServicesCardLink from './billable-services-admin-card-link.component';
|
|
9
11
|
import BillHistory from './bill-history/bill-history.component';
|
|
10
12
|
import BillingCheckInForm from './billing-form/billing-checkin-form.component';
|
|
11
|
-
import
|
|
13
|
+
import DeletePaymentModeModal from './billable-services/payment-modes/delete-payment-mode.modal';
|
|
14
|
+
import EditBillableServiceModal from './billable-services/create-edit/edit-billable-service.modal';
|
|
15
|
+
import EditBillLineItemModal from './bill-item-actions/edit-bill-item.modal';
|
|
16
|
+
import RequirePaymentModal from './modal/require-payment.modal';
|
|
12
17
|
import RootComponent from './root.component';
|
|
13
18
|
import ServiceMetrics from './billable-services/dashboard/service-metrics.component';
|
|
14
19
|
import VisitAttributeTags from './invoice/payments/visit-tags/visit-attribute.component';
|
|
@@ -35,6 +40,7 @@ export function startupApp() {
|
|
|
35
40
|
defineConfigSchema(moduleName, configSchema);
|
|
36
41
|
}
|
|
37
42
|
|
|
43
|
+
// t('billingHistory', 'Billing History')
|
|
38
44
|
export const billingSummaryDashboardLink = getSyncLifecycle(
|
|
39
45
|
createDashboardLink({ ...dashboardMeta, moduleName }),
|
|
40
46
|
options,
|
|
@@ -52,16 +58,21 @@ export const billingPatientSummary = getSyncLifecycle(BillHistory, options);
|
|
|
52
58
|
|
|
53
59
|
export const requirePaymentModal = getSyncLifecycle(RequirePaymentModal, options);
|
|
54
60
|
|
|
61
|
+
export const addPaymentModeModal = getSyncLifecycle(AddPaymentModeModal, options);
|
|
62
|
+
|
|
63
|
+
export const deletePaymentModeModal = getSyncLifecycle(DeletePaymentModeModal, options);
|
|
64
|
+
|
|
65
|
+
export const addCashPointModal = getSyncLifecycle(AddCashPointModal, options);
|
|
66
|
+
|
|
67
|
+
export const editBillableServiceModal = getSyncLifecycle(EditBillableServiceModal, options);
|
|
68
|
+
|
|
69
|
+
export const editBillLineItemModal = getSyncLifecycle(EditBillLineItemModal, options);
|
|
70
|
+
|
|
55
71
|
export const root = getSyncLifecycle(RootComponent, options);
|
|
56
72
|
|
|
57
73
|
export const serviceMetrics = getSyncLifecycle(ServiceMetrics, options);
|
|
58
74
|
|
|
59
75
|
export const visitAttributeTags = getSyncLifecycle(VisitAttributeTags, options);
|
|
60
76
|
|
|
61
|
-
export const editBillLineItemDialog = getAsyncLifecycle(() => import('./bill-item-actions/edit-bill-item.component'), {
|
|
62
|
-
featureName: 'edit bill line item',
|
|
63
|
-
moduleName,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
77
|
// t('billingForm', 'Billing form')
|
|
67
78
|
export const billingFormWorkspace = getAsyncLifecycle(() => import('./billing-form/billing-form.component'), options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo, useState,
|
|
1
|
+
import React, { useMemo, useState, useCallback } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
import fuzzy from 'fuzzy';
|
|
4
4
|
import {
|
|
@@ -13,42 +13,38 @@ import {
|
|
|
13
13
|
TableHead,
|
|
14
14
|
TableHeader,
|
|
15
15
|
TableRow,
|
|
16
|
-
TableSelectRow,
|
|
17
16
|
TableToolbarSearch,
|
|
18
17
|
Tile,
|
|
19
18
|
type DataTableRow,
|
|
20
19
|
} from '@carbon/react';
|
|
21
20
|
import { Edit } from '@carbon/react/icons';
|
|
22
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
isDesktop,
|
|
23
|
+
showModal,
|
|
24
|
+
useConfig,
|
|
25
|
+
useDebounce,
|
|
26
|
+
useLayoutType,
|
|
27
|
+
getCoreTranslation,
|
|
28
|
+
} from '@openmrs/esm-framework';
|
|
23
29
|
import { type LineItem, type MappedBill } from '../types';
|
|
24
30
|
import { convertToCurrency } from '../helpers';
|
|
31
|
+
import type { BillingConfig } from '../config-schema';
|
|
25
32
|
import styles from './invoice-table.scss';
|
|
26
33
|
|
|
27
34
|
type InvoiceTableProps = {
|
|
28
35
|
bill: MappedBill;
|
|
29
|
-
isSelectable?: boolean;
|
|
30
36
|
isLoadingBill?: boolean;
|
|
31
|
-
onSelectItem?: (selectedLineItems: LineItem[]) => void;
|
|
32
37
|
};
|
|
33
38
|
|
|
34
|
-
const InvoiceTable: React.FC<InvoiceTableProps> = ({ bill,
|
|
39
|
+
const InvoiceTable: React.FC<InvoiceTableProps> = ({ bill, isLoadingBill }) => {
|
|
35
40
|
const { t } = useTranslation();
|
|
36
|
-
const { defaultCurrency
|
|
41
|
+
const { defaultCurrency } = useConfig<BillingConfig>();
|
|
37
42
|
const layout = useLayoutType();
|
|
38
43
|
const lineItems = useMemo(() => bill?.lineItems ?? [], [bill?.lineItems]);
|
|
39
|
-
const paidLineItems = useMemo(() => lineItems?.filter((item) => item.paymentStatus === 'PAID') ?? [], [lineItems]);
|
|
40
44
|
const responsiveSize = isDesktop(layout) ? 'sm' : 'lg';
|
|
41
|
-
|
|
42
|
-
const [selectedLineItems, setSelectedLineItems] = useState(paidLineItems ?? []);
|
|
43
45
|
const [searchTerm, setSearchTerm] = useState('');
|
|
44
46
|
const debouncedSearchTerm = useDebounce(searchTerm);
|
|
45
47
|
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (onSelectItem) {
|
|
48
|
-
onSelectItem(selectedLineItems);
|
|
49
|
-
}
|
|
50
|
-
}, [selectedLineItems, onSelectItem]);
|
|
51
|
-
|
|
52
48
|
const filteredLineItems = useMemo(() => {
|
|
53
49
|
if (!debouncedSearchTerm) {
|
|
54
50
|
return lineItems;
|
|
@@ -65,19 +61,19 @@ const InvoiceTable: React.FC<InvoiceTableProps> = ({ bill, isSelectable = true,
|
|
|
65
61
|
}, [debouncedSearchTerm, lineItems]);
|
|
66
62
|
|
|
67
63
|
const tableHeaders = [
|
|
68
|
-
{ header: '
|
|
69
|
-
{ header: 'Bill item', key: 'billItem', width: 25 },
|
|
70
|
-
{ header: 'Bill code', key: 'billCode', width: 20 },
|
|
71
|
-
{ header: 'Status', key: 'status', width: 25 },
|
|
72
|
-
{ header: 'Quantity', key: 'quantity', width: 15 },
|
|
73
|
-
{ header: 'Price', key: 'price', width: 24 },
|
|
74
|
-
{ header: 'Total', key: 'total', width: 15 },
|
|
75
|
-
{ header:
|
|
64
|
+
{ header: t('number', 'Number'), key: 'no', width: 7 }, // Width as a percentage
|
|
65
|
+
{ header: t('billItem', 'Bill item'), key: 'billItem', width: 25 },
|
|
66
|
+
{ header: t('billCode', 'Bill code'), key: 'billCode', width: 20 },
|
|
67
|
+
{ header: t('status', 'Status'), key: 'status', width: 25 },
|
|
68
|
+
{ header: t('quantity', 'Quantity'), key: 'quantity', width: 15 },
|
|
69
|
+
{ header: t('price', 'Price'), key: 'price', width: 24 },
|
|
70
|
+
{ header: t('total', 'Total'), key: 'total', width: 15 },
|
|
71
|
+
{ header: getCoreTranslation('actions'), key: 'actionButton' },
|
|
76
72
|
];
|
|
77
73
|
|
|
78
74
|
const handleSelectBillItem = useCallback(
|
|
79
75
|
(row: LineItem) => {
|
|
80
|
-
const dispose = showModal('edit-bill-line-item-
|
|
76
|
+
const dispose = showModal('edit-bill-line-item-modal', {
|
|
81
77
|
bill,
|
|
82
78
|
item: row,
|
|
83
79
|
closeModal: () => dispose(),
|
|
@@ -97,27 +93,23 @@ const InvoiceTable: React.FC<InvoiceTableProps> = ({ bill, isSelectable = true,
|
|
|
97
93
|
status: item.paymentStatus,
|
|
98
94
|
quantity: item.quantity,
|
|
99
95
|
price: convertToCurrency(item.price, defaultCurrency),
|
|
100
|
-
total: item.price * item.quantity,
|
|
96
|
+
total: convertToCurrency(item.price * item.quantity, defaultCurrency),
|
|
101
97
|
actionButton: (
|
|
102
98
|
<span>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
/>
|
|
113
|
-
) : (
|
|
114
|
-
'--'
|
|
115
|
-
)}
|
|
99
|
+
<Button
|
|
100
|
+
data-testid={`edit-button-${item.uuid}`}
|
|
101
|
+
renderIcon={Edit}
|
|
102
|
+
hasIconOnly
|
|
103
|
+
kind="ghost"
|
|
104
|
+
iconDescription={t('editThisBillItem', 'Edit this bill item')}
|
|
105
|
+
tooltipPosition="left"
|
|
106
|
+
onClick={() => handleSelectBillItem(item)}
|
|
107
|
+
/>
|
|
116
108
|
</span>
|
|
117
109
|
),
|
|
118
110
|
};
|
|
119
111
|
}) ?? [],
|
|
120
|
-
[filteredLineItems, bill?.receiptNumber, defaultCurrency,
|
|
112
|
+
[filteredLineItems, bill?.receiptNumber, defaultCurrency, t, handleSelectBillItem],
|
|
121
113
|
);
|
|
122
114
|
|
|
123
115
|
if (isLoadingBill) {
|
|
@@ -135,23 +127,10 @@ const InvoiceTable: React.FC<InvoiceTableProps> = ({ bill, isSelectable = true,
|
|
|
135
127
|
);
|
|
136
128
|
}
|
|
137
129
|
|
|
138
|
-
const handleRowSelection = (row: typeof DataTableRow, checked: boolean) => {
|
|
139
|
-
const matchingRow = filteredLineItems.find((item) => item.uuid === row.id);
|
|
140
|
-
let newSelectedLineItems;
|
|
141
|
-
|
|
142
|
-
if (checked) {
|
|
143
|
-
newSelectedLineItems = [...selectedLineItems, matchingRow];
|
|
144
|
-
} else {
|
|
145
|
-
newSelectedLineItems = selectedLineItems.filter((item) => item.uuid !== row.id);
|
|
146
|
-
}
|
|
147
|
-
setSelectedLineItems(newSelectedLineItems);
|
|
148
|
-
onSelectItem(newSelectedLineItems);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
130
|
return (
|
|
152
|
-
<div className={styles.
|
|
153
|
-
<DataTable headers={tableHeaders}
|
|
154
|
-
{({ rows, headers, getRowProps,
|
|
131
|
+
<div className={styles.lineItemsWrapper}>
|
|
132
|
+
<DataTable headers={tableHeaders} rows={tableRows} size={responsiveSize} useZebraStyles>
|
|
133
|
+
{({ rows, headers, getRowProps, getTableProps }) => (
|
|
155
134
|
<TableContainer
|
|
156
135
|
description={
|
|
157
136
|
<span className={styles.tableDescription}>
|
|
@@ -168,11 +147,10 @@ const InvoiceTable: React.FC<InvoiceTableProps> = ({ bill, isSelectable = true,
|
|
|
168
147
|
/>
|
|
169
148
|
<Table
|
|
170
149
|
{...getTableProps()}
|
|
171
|
-
aria-label=
|
|
150
|
+
aria-label={t('invoiceLineItems', 'Invoice line items')}
|
|
172
151
|
className={`${styles.invoiceTable} billingTable`}>
|
|
173
152
|
<TableHead>
|
|
174
153
|
<TableRow>
|
|
175
|
-
{rows.length > 1 && isSelectable ? <TableHeader /> : null}
|
|
176
154
|
{headers.map((header) => (
|
|
177
155
|
<TableHeader key={header.key}>{header.header}</TableHeader>
|
|
178
156
|
))}
|
|
@@ -186,18 +164,6 @@ const InvoiceTable: React.FC<InvoiceTableProps> = ({ bill, isSelectable = true,
|
|
|
186
164
|
{...getRowProps({
|
|
187
165
|
row,
|
|
188
166
|
})}>
|
|
189
|
-
{rows.length > 1 && isSelectable && (
|
|
190
|
-
<TableSelectRow
|
|
191
|
-
aria-label="Select row"
|
|
192
|
-
{...getSelectionProps({ row })}
|
|
193
|
-
disabled={tableRows[index].status === 'PAID'}
|
|
194
|
-
onChange={(checked: boolean) => handleRowSelection(row, checked)}
|
|
195
|
-
checked={
|
|
196
|
-
tableRows[index].status === 'PAID' ||
|
|
197
|
-
Boolean(selectedLineItems?.find((item) => item?.uuid === row?.id))
|
|
198
|
-
}
|
|
199
|
-
/>
|
|
200
|
-
)}
|
|
201
167
|
{row.cells.map((cell) => (
|
|
202
168
|
<TableCell key={cell.id}>{cell.value}</TableCell>
|
|
203
169
|
))}
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
@use '@carbon/type';
|
|
4
4
|
@use '@openmrs/esm-styleguide/src/vars' as *;
|
|
5
5
|
|
|
6
|
+
.lineItemsWrapper {
|
|
7
|
+
border: 1px solid colors.$gray-20;
|
|
8
|
+
border-radius: 4px;
|
|
9
|
+
background-color: colors.$white;
|
|
10
|
+
margin-bottom: layout.$spacing-05;
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
.filterEmptyState {
|
|
7
14
|
align-items: center;
|
|
8
15
|
background-color: white;
|
|
@@ -29,11 +36,7 @@
|
|
|
29
36
|
|
|
30
37
|
.headerContainer {
|
|
31
38
|
background-color: colors.$gray-10;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.invoiceContainer {
|
|
35
|
-
border: 1px solid $ui-03;
|
|
36
|
-
}
|
|
39
|
+
}c
|
|
37
40
|
|
|
38
41
|
.searchbox {
|
|
39
42
|
input:focus {
|