@openmrs/esm-billing-app 1.0.2-pre.90 → 1.0.2-pre.905

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.
Files changed (214) hide show
  1. package/.eslintrc +16 -2
  2. package/README.md +54 -9
  3. package/__mocks__/bills.mock.ts +12 -0
  4. package/__mocks__/react-i18next.js +6 -5
  5. package/dist/1119.js +1 -1
  6. package/dist/1146.js +1 -2
  7. package/dist/1146.js.map +1 -1
  8. package/dist/1197.js +1 -1
  9. package/dist/1537.js +1 -0
  10. package/dist/1537.js.map +1 -0
  11. package/dist/1856.js +1 -0
  12. package/dist/1856.js.map +1 -0
  13. package/dist/2146.js +1 -1
  14. package/dist/2524.js +1 -0
  15. package/dist/2524.js.map +1 -0
  16. package/dist/2690.js +1 -1
  17. package/dist/3099.js +1 -1
  18. package/dist/3584.js +1 -1
  19. package/dist/3717.js +2 -0
  20. package/dist/3717.js.map +1 -0
  21. package/dist/4055.js +1 -1
  22. package/dist/4132.js +1 -1
  23. package/dist/4300.js +1 -1
  24. package/dist/4335.js +1 -1
  25. package/dist/4618.js +1 -1
  26. package/dist/4652.js +1 -1
  27. package/dist/4692.js +1 -0
  28. package/dist/4692.js.map +1 -0
  29. package/dist/4724.js +1 -0
  30. package/dist/4724.js.map +1 -0
  31. package/dist/4739.js +1 -1
  32. package/dist/4739.js.map +1 -1
  33. package/dist/4944.js +1 -1
  34. package/dist/5173.js +1 -1
  35. package/dist/5241.js +1 -1
  36. package/dist/5442.js +1 -1
  37. package/dist/5661.js +1 -1
  38. package/dist/6022.js +1 -1
  39. package/dist/6468.js +1 -1
  40. package/dist/6540.js +1 -1
  41. package/dist/6540.js.map +1 -1
  42. package/dist/6679.js +1 -1
  43. package/dist/6840.js +1 -1
  44. package/dist/6859.js +1 -1
  45. package/dist/7097.js +1 -1
  46. package/dist/7159.js +1 -1
  47. package/dist/723.js +1 -1
  48. package/dist/7255.js +1 -1
  49. package/dist/7255.js.map +1 -1
  50. package/dist/7617.js +1 -1
  51. package/dist/795.js +1 -1
  52. package/dist/8163.js +1 -1
  53. package/dist/8349.js +1 -1
  54. package/dist/8618.js +1 -1
  55. package/dist/8708.js +2 -0
  56. package/dist/{6557.js.LICENSE.txt → 8708.js.LICENSE.txt} +22 -0
  57. package/dist/8708.js.map +1 -0
  58. package/dist/890.js +1 -1
  59. package/dist/9214.js +1 -1
  60. package/dist/9538.js +1 -1
  61. package/dist/9569.js +1 -1
  62. package/dist/961.js +1 -1
  63. package/dist/961.js.map +1 -1
  64. package/dist/986.js +1 -1
  65. package/dist/9879.js +1 -1
  66. package/dist/9895.js +1 -1
  67. package/dist/9900.js +1 -1
  68. package/dist/9913.js +1 -1
  69. package/dist/main.js +1 -1
  70. package/dist/main.js.map +1 -1
  71. package/dist/openmrs-esm-billing-app.js +1 -1
  72. package/dist/openmrs-esm-billing-app.js.buildmanifest.json +282 -296
  73. package/dist/openmrs-esm-billing-app.js.map +1 -1
  74. package/dist/routes.json +1 -1
  75. package/e2e/README.md +19 -18
  76. package/e2e/core/test.ts +1 -1
  77. package/e2e/fixtures/api.ts +1 -1
  78. package/e2e/specs/sample-test.spec.ts +0 -1
  79. package/e2e/support/github/Dockerfile +1 -1
  80. package/package.json +18 -15
  81. package/src/bill-history/bill-history.component.tsx +20 -28
  82. package/src/bill-history/bill-history.scss +4 -94
  83. package/src/bill-history/bill-history.test.tsx +37 -78
  84. package/src/bill-item-actions/bill-item-actions.scss +21 -5
  85. package/src/bill-item-actions/edit-bill-item.modal.tsx +225 -0
  86. package/src/bill-item-actions/edit-bill-item.test.tsx +214 -40
  87. package/src/billable-services/bill-waiver/bill-selection.component.tsx +5 -5
  88. package/src/billable-services/bill-waiver/bill-waiver-form.component.tsx +28 -32
  89. package/src/billable-services/bill-waiver/patient-bills.component.tsx +7 -7
  90. package/src/billable-services/bill-waiver/utils.ts +13 -3
  91. package/src/billable-services/{create-edit/add-billable-service.scss → billable-service-form/billable-service-form.scss} +32 -64
  92. package/src/billable-services/billable-service-form/billable-service-form.test.tsx +893 -0
  93. package/src/billable-services/billable-service-form/billable-service-form.workspace.tsx +504 -0
  94. package/src/billable-services/billable-service.resource.ts +42 -26
  95. package/src/billable-services/billable-services-home.component.tsx +13 -42
  96. package/src/billable-services/billable-services-left-panel-link.component.tsx +48 -0
  97. package/src/billable-services/billable-services-left-panel-menu.component.tsx +46 -0
  98. package/src/billable-services/billable-services-menu-item/item.component.tsx +5 -4
  99. package/src/billable-services/billable-services.component.tsx +156 -152
  100. package/src/billable-services/billable-services.scss +29 -0
  101. package/src/billable-services/billable-services.test.tsx +6 -49
  102. package/src/billable-services/cash-point/add-cash-point.modal.tsx +170 -0
  103. package/src/billable-services/cash-point/cash-point-configuration.component.tsx +19 -193
  104. package/src/billable-services/cash-point/cash-point-configuration.scss +1 -5
  105. package/src/billable-services/dashboard/dashboard.component.tsx +0 -2
  106. package/src/billable-services/payment-modes/add-payment-mode.modal.tsx +121 -0
  107. package/src/billable-services/payment-modes/delete-payment-mode.modal.tsx +74 -0
  108. package/src/billable-services/payment-modes/payment-modes-config.component.tsx +125 -0
  109. package/src/billable-services/{payyment-modes → payment-modes}/payment-modes-config.scss +5 -4
  110. package/src/billable-services-admin-card-link.component.test.tsx +2 -2
  111. package/src/billable-services-admin-card-link.component.tsx +1 -1
  112. package/src/billing-dashboard/billing-dashboard.scss +1 -1
  113. package/src/billing-form/billing-checkin-form.component.tsx +21 -17
  114. package/src/billing-form/billing-checkin-form.test.tsx +99 -26
  115. package/src/billing-form/billing-form.component.tsx +222 -292
  116. package/src/billing-form/billing-form.scss +143 -0
  117. package/src/billing-form/visit-attributes/visit-attributes-form.component.tsx +1 -1
  118. package/src/billing.resource.ts +69 -74
  119. package/src/bills-table/bills-table.component.tsx +3 -3
  120. package/src/bills-table/bills-table.test.tsx +98 -54
  121. package/src/config-schema.ts +52 -24
  122. package/src/dashboard.meta.ts +4 -2
  123. package/src/helpers/functions.ts +5 -4
  124. package/src/index.ts +71 -9
  125. package/src/invoice/invoice-table.component.tsx +36 -70
  126. package/src/invoice/invoice-table.scss +8 -5
  127. package/src/invoice/invoice-table.test.tsx +273 -62
  128. package/src/invoice/invoice.component.tsx +39 -32
  129. package/src/invoice/invoice.scss +11 -4
  130. package/src/invoice/invoice.test.tsx +324 -120
  131. package/src/invoice/payments/invoice-breakdown/invoice-breakdown.scss +9 -9
  132. package/src/invoice/payments/payment-form/payment-form.component.tsx +43 -34
  133. package/src/invoice/payments/payment-form/payment-form.scss +5 -6
  134. package/src/invoice/payments/payment-form/payment-form.test.tsx +216 -66
  135. package/src/invoice/payments/payment-history/payment-history.component.tsx +6 -4
  136. package/src/invoice/payments/payment-history/payment-history.test.tsx +9 -14
  137. package/src/invoice/payments/payments.component.tsx +55 -67
  138. package/src/invoice/payments/payments.scss +4 -3
  139. package/src/invoice/payments/payments.test.tsx +282 -0
  140. package/src/invoice/payments/utils.ts +15 -27
  141. package/src/invoice/printable-invoice/print-receipt.component.tsx +3 -2
  142. package/src/invoice/printable-invoice/print-receipt.test.tsx +14 -25
  143. package/src/invoice/printable-invoice/printable-footer.component.tsx +2 -2
  144. package/src/invoice/printable-invoice/printable-footer.test.tsx +4 -13
  145. package/src/invoice/printable-invoice/printable-invoice-header.component.tsx +12 -11
  146. package/src/invoice/printable-invoice/printable-invoice-header.test.tsx +16 -14
  147. package/src/invoice/printable-invoice/printable-invoice.component.tsx +20 -34
  148. package/src/left-panel-link.test.tsx +1 -4
  149. package/src/metrics-cards/metrics-cards.component.tsx +16 -6
  150. package/src/metrics-cards/metrics-cards.scss +4 -0
  151. package/src/metrics-cards/metrics-cards.test.tsx +18 -5
  152. package/src/modal/require-payment-modal.test.tsx +27 -22
  153. package/src/modal/{require-payment-modal.component.tsx → require-payment.modal.tsx} +18 -19
  154. package/src/routes.json +44 -20
  155. package/src/types/index.ts +81 -23
  156. package/translations/am.json +132 -75
  157. package/translations/ar.json +133 -76
  158. package/translations/ar_SY.json +133 -76
  159. package/translations/bn.json +135 -78
  160. package/translations/de.json +133 -76
  161. package/translations/en.json +133 -78
  162. package/translations/en_US.json +133 -76
  163. package/translations/es.json +132 -75
  164. package/translations/es_MX.json +133 -76
  165. package/translations/fr.json +138 -81
  166. package/translations/he.json +132 -75
  167. package/translations/hi.json +133 -76
  168. package/translations/hi_IN.json +133 -76
  169. package/translations/id.json +133 -76
  170. package/translations/it.json +159 -102
  171. package/translations/ka.json +133 -76
  172. package/translations/km.json +132 -75
  173. package/translations/ku.json +133 -76
  174. package/translations/ky.json +133 -76
  175. package/translations/lg.json +133 -76
  176. package/translations/ne.json +133 -76
  177. package/translations/pl.json +133 -76
  178. package/translations/pt.json +133 -76
  179. package/translations/pt_BR.json +133 -76
  180. package/translations/qu.json +133 -76
  181. package/translations/ro_RO.json +222 -165
  182. package/translations/ru_RU.json +133 -76
  183. package/translations/si.json +133 -76
  184. package/translations/sw.json +133 -76
  185. package/translations/sw_KE.json +133 -76
  186. package/translations/tr.json +133 -76
  187. package/translations/tr_TR.json +133 -76
  188. package/translations/uk.json +133 -76
  189. package/translations/uz.json +133 -76
  190. package/translations/uz@Latn.json +133 -76
  191. package/translations/uz_UZ.json +133 -76
  192. package/translations/vi.json +133 -76
  193. package/translations/zh.json +133 -76
  194. package/translations/zh_CN.json +164 -107
  195. package/dist/1146.js.LICENSE.txt +0 -21
  196. package/dist/2352.js +0 -1
  197. package/dist/2352.js.map +0 -1
  198. package/dist/246.js +0 -1
  199. package/dist/246.js.map +0 -1
  200. package/dist/4689.js +0 -2
  201. package/dist/4689.js.map +0 -1
  202. package/dist/6557.js +0 -2
  203. package/dist/6557.js.map +0 -1
  204. package/dist/8638.js +0 -1
  205. package/dist/8638.js.map +0 -1
  206. package/dist/9968.js +0 -1
  207. package/dist/9968.js.map +0 -1
  208. package/src/bill-item-actions/edit-bill-item.component.tsx +0 -221
  209. package/src/billable-services/create-edit/add-billable-service.component.tsx +0 -401
  210. package/src/billable-services/create-edit/add-billable-service.test.tsx +0 -154
  211. package/src/billable-services/dashboard/service-metrics.component.tsx +0 -41
  212. package/src/billable-services/payyment-modes/payment-modes-config.component.tsx +0 -280
  213. package/src/invoice/payments/payments.component.test.tsx +0 -121
  214. /package/dist/{4689.js.LICENSE.txt → 3717.js.LICENSE.txt} +0 -0
@@ -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 ConfigObject {
76
- patientCatergory: Object;
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
- catergoryConcepts: Object;
79
- pageSize;
80
- object;
81
- showEditBillButton: boolean;
82
- postBilledItems: Object;
83
- serviceTypes: Object;
84
- nonPayingPatientCategories: Object;
112
+ pageSize: number;
85
113
  }
@@ -1,8 +1,10 @@
1
- export const dashboardMeta = {
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
  };
@@ -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 t('male', 'Male');
55
+ return getCoreTranslation('male');
55
56
  case 'female':
56
- return t('female', 'Female');
57
+ return getCoreTranslation('female');
57
58
  case 'other':
58
- return t('other', 'Other');
59
+ return getCoreTranslation('other');
59
60
  case 'unknown':
60
- return t('unknown', 'Unknown');
61
+ return getCoreTranslation('unknown');
61
62
  default:
62
63
  return gender;
63
64
  }
package/src/index.ts CHANGED
@@ -3,14 +3,20 @@ 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 { Wallet, Money, Settings } from '@carbon/react/icons';
7
+ import { createBillableServicesLeftPanelLink } from './billable-services/billable-services-left-panel-link.component';
8
+ import { createBillableServicesLeftPanelMenu } from './billable-services/billable-services-left-panel-menu.component';
9
+ import AddCashPointModal from './billable-services/cash-point/add-cash-point.modal';
10
+ import AddPaymentModeModal from './billable-services/payment-modes/add-payment-mode.modal';
6
11
  import appMenu from './billable-services/billable-services-menu-item/item.component';
7
12
  import BillableServiceHome from './billable-services/billable-services-home.component';
8
13
  import BillableServicesCardLink from './billable-services-admin-card-link.component';
9
14
  import BillHistory from './bill-history/bill-history.component';
10
15
  import BillingCheckInForm from './billing-form/billing-checkin-form.component';
11
- import RequirePaymentModal from './modal/require-payment-modal.component';
16
+ import DeletePaymentModeModal from './billable-services/payment-modes/delete-payment-mode.modal';
17
+ import EditBillLineItemModal from './bill-item-actions/edit-bill-item.modal';
18
+ import RequirePaymentModal from './modal/require-payment.modal';
12
19
  import RootComponent from './root.component';
13
- import ServiceMetrics from './billable-services/dashboard/service-metrics.component';
14
20
  import VisitAttributeTags from './invoice/payments/visit-tags/visit-attribute.component';
15
21
 
16
22
  const moduleName = '@openmrs/esm-billing-app';
@@ -35,11 +41,13 @@ export function startupApp() {
35
41
  defineConfigSchema(moduleName, configSchema);
36
42
  }
37
43
 
44
+ // t('billingHistory', 'Billing History')
38
45
  export const billingSummaryDashboardLink = getSyncLifecycle(
39
46
  createDashboardLink({ ...dashboardMeta, moduleName }),
40
47
  options,
41
48
  );
42
49
 
50
+ // t('billableServices', 'Billable services')
43
51
  export const billableServicesAppMenuItem = getSyncLifecycle(appMenu, options);
44
52
 
45
53
  export const billableServicesCardLink = getSyncLifecycle(BillableServicesCardLink, options);
@@ -52,16 +60,70 @@ export const billingPatientSummary = getSyncLifecycle(BillHistory, options);
52
60
 
53
61
  export const requirePaymentModal = getSyncLifecycle(RequirePaymentModal, options);
54
62
 
55
- export const root = getSyncLifecycle(RootComponent, options);
63
+ export const addPaymentModeModal = getSyncLifecycle(AddPaymentModeModal, options);
56
64
 
57
- export const serviceMetrics = getSyncLifecycle(ServiceMetrics, options);
65
+ export const deletePaymentModeModal = getSyncLifecycle(DeletePaymentModeModal, options);
58
66
 
59
- export const visitAttributeTags = getSyncLifecycle(VisitAttributeTags, options);
67
+ export const addCashPointModal = getSyncLifecycle(AddCashPointModal, options);
60
68
 
61
- export const editBillLineItemDialog = getAsyncLifecycle(() => import('./bill-item-actions/edit-bill-item.component'), {
62
- featureName: 'edit bill line item',
63
- moduleName,
64
- });
69
+ export const editBillLineItemModal = getSyncLifecycle(EditBillLineItemModal, options);
70
+
71
+ export const root = getSyncLifecycle(RootComponent, options);
72
+
73
+ export const visitAttributeTags = getSyncLifecycle(VisitAttributeTags, options);
65
74
 
66
75
  // t('billingForm', 'Billing form')
67
76
  export const billingFormWorkspace = getAsyncLifecycle(() => import('./billing-form/billing-form.component'), options);
77
+
78
+ // t('billableServiceForm', 'Billable service form')
79
+ export const billableServiceFormWorkspace = getAsyncLifecycle(
80
+ () => import('./billable-services/billable-service-form/billable-service-form.workspace'),
81
+ options,
82
+ );
83
+
84
+ // t('billableServices', 'Billable services')
85
+ export const billableServicesLeftPanelLink = getSyncLifecycle(
86
+ createBillableServicesLeftPanelLink({
87
+ name: 'billable-services',
88
+ title: 'Billable Services',
89
+ path: '',
90
+ icon: Wallet,
91
+ }),
92
+ options,
93
+ );
94
+
95
+ // t('billWaiver', 'Bill waiver')
96
+ export const billWaiverLeftPanelLink = getSyncLifecycle(
97
+ createBillableServicesLeftPanelLink({
98
+ name: 'bill-waiver',
99
+ title: 'Bill waiver',
100
+ path: 'waive-bill',
101
+ icon: Money,
102
+ privilege: 'coreapps.systemAdministration',
103
+ }),
104
+ options,
105
+ );
106
+
107
+ // t('billingSettings', 'Billing settings')
108
+ // t('cashPointConfig', 'Cash point configuration')
109
+ // t('paymentModesConfig', 'Payment modes configuration')
110
+ export const billingSettingsLeftPanelMenu = getSyncLifecycle(
111
+ createBillableServicesLeftPanelMenu({
112
+ title: 'Billing settings',
113
+ icon: Settings,
114
+ privilege: 'coreapps.systemAdministration',
115
+ items: [
116
+ {
117
+ name: 'cash-point-config',
118
+ title: 'Cash point configuration',
119
+ path: 'cash-point-config',
120
+ },
121
+ {
122
+ name: 'payment-modes-config',
123
+ title: 'Payment modes configuration',
124
+ path: 'payment-modes-config',
125
+ },
126
+ ],
127
+ }),
128
+ options,
129
+ );
@@ -1,4 +1,4 @@
1
- import React, { useMemo, useState, useEffect, useCallback } from 'react';
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 { isDesktop, showModal, useConfig, useDebounce, useLayoutType } from '@openmrs/esm-framework';
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, isSelectable = true, isLoadingBill, onSelectItem }) => {
39
+ const InvoiceTable: React.FC<InvoiceTableProps> = ({ bill, isLoadingBill }) => {
35
40
  const { t } = useTranslation();
36
- const { defaultCurrency, showEditBillButton } = useConfig();
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: 'No', key: 'no', width: 7 }, // Width as a percentage
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: t('actions', 'Actions'), key: 'actionButton' },
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-dialog', {
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
- {showEditBillButton ? (
104
- <Button
105
- data-testid={`edit-button-${item.uuid}`}
106
- renderIcon={Edit}
107
- hasIconOnly
108
- kind="ghost"
109
- iconDescription={t('editThisBillItem', 'Edit this bill item')}
110
- tooltipPosition="left"
111
- onClick={() => handleSelectBillItem(item)}
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, showEditBillButton, t, handleSelectBillItem],
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.invoiceContainer}>
153
- <DataTable headers={tableHeaders} isSortable rows={tableRows} size={responsiveSize} useZebraStyles>
154
- {({ rows, headers, getRowProps, getSelectionProps, getTableProps, getToolbarProps }) => (
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="Invoice line items"
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 {