@openmrs/esm-billing-app 1.0.2-pre.84 → 1.0.2-pre.849

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/1856.js +1 -0
  10. package/dist/1856.js.map +1 -0
  11. package/dist/2146.js +1 -1
  12. package/dist/2177.js +2 -0
  13. package/dist/2177.js.LICENSE.txt +9 -0
  14. package/dist/2177.js.map +1 -0
  15. package/dist/2524.js +1 -0
  16. package/dist/2524.js.map +1 -0
  17. package/dist/2690.js +1 -1
  18. package/dist/3041.js +1 -0
  19. package/dist/3041.js.map +1 -0
  20. package/dist/3099.js +1 -1
  21. package/dist/3584.js +1 -1
  22. package/dist/3717.js +2 -0
  23. package/dist/3717.js.map +1 -0
  24. package/dist/4055.js +1 -1
  25. package/dist/4132.js +1 -1
  26. package/dist/4225.js +1 -0
  27. package/dist/4225.js.map +1 -0
  28. package/dist/4300.js +1 -1
  29. package/dist/4335.js +1 -1
  30. package/dist/4344.js +1 -0
  31. package/dist/4344.js.map +1 -0
  32. package/dist/4618.js +1 -1
  33. package/dist/4652.js +1 -1
  34. package/dist/4724.js +1 -0
  35. package/dist/4724.js.map +1 -0
  36. package/dist/4739.js +1 -1
  37. package/dist/4739.js.map +1 -1
  38. package/dist/4944.js +1 -1
  39. package/dist/5173.js +1 -1
  40. package/dist/5241.js +1 -1
  41. package/dist/5422.js +1 -0
  42. package/dist/5422.js.map +1 -0
  43. package/dist/5442.js +1 -1
  44. package/dist/5661.js +1 -1
  45. package/dist/6022.js +1 -1
  46. package/dist/6295.js +2 -0
  47. package/dist/{6525.js.LICENSE.txt → 6295.js.LICENSE.txt} +16 -4
  48. package/dist/6295.js.map +1 -0
  49. package/dist/6468.js +1 -1
  50. package/dist/6540.js +1 -1
  51. package/dist/6540.js.map +1 -1
  52. package/dist/6606.js +1 -0
  53. package/dist/6606.js.map +1 -0
  54. package/dist/6679.js +1 -1
  55. package/dist/6840.js +1 -1
  56. package/dist/6859.js +1 -1
  57. package/dist/7097.js +1 -1
  58. package/dist/7159.js +1 -1
  59. package/dist/723.js +1 -1
  60. package/dist/7617.js +1 -1
  61. package/dist/795.js +1 -1
  62. package/dist/8163.js +1 -1
  63. package/dist/8349.js +1 -1
  64. package/dist/8618.js +1 -1
  65. package/dist/890.js +1 -1
  66. package/dist/9214.js +1 -1
  67. package/dist/9538.js +1 -1
  68. package/dist/9569.js +1 -1
  69. package/dist/961.js +1 -1
  70. package/dist/961.js.map +1 -1
  71. package/dist/986.js +1 -1
  72. package/dist/9879.js +1 -1
  73. package/dist/9895.js +1 -1
  74. package/dist/9900.js +1 -1
  75. package/dist/9913.js +1 -1
  76. package/dist/main.js +1 -1
  77. package/dist/main.js.map +1 -1
  78. package/dist/openmrs-esm-billing-app.js +1 -1
  79. package/dist/openmrs-esm-billing-app.js.buildmanifest.json +388 -282
  80. package/dist/openmrs-esm-billing-app.js.map +1 -1
  81. package/dist/routes.json +1 -1
  82. package/e2e/README.md +19 -18
  83. package/e2e/core/test.ts +1 -1
  84. package/e2e/fixtures/api.ts +1 -1
  85. package/e2e/specs/sample-test.spec.ts +0 -1
  86. package/e2e/support/github/Dockerfile +1 -1
  87. package/package.json +13 -10
  88. package/src/bill-history/bill-history.component.tsx +20 -28
  89. package/src/bill-history/bill-history.scss +4 -94
  90. package/src/bill-history/bill-history.test.tsx +37 -78
  91. package/src/bill-item-actions/bill-item-actions.scss +21 -5
  92. package/src/bill-item-actions/edit-bill-item.modal.tsx +225 -0
  93. package/src/bill-item-actions/edit-bill-item.test.tsx +214 -40
  94. package/src/billable-services/bill-waiver/bill-selection.component.tsx +5 -5
  95. package/src/billable-services/bill-waiver/bill-waiver-form.component.tsx +28 -32
  96. package/src/billable-services/bill-waiver/patient-bills.component.tsx +7 -7
  97. package/src/billable-services/bill-waiver/utils.ts +13 -3
  98. package/src/billable-services/billable-service.resource.ts +28 -12
  99. package/src/billable-services/billable-services-home.component.tsx +4 -4
  100. package/src/billable-services/billable-services.component.tsx +149 -148
  101. package/src/billable-services/billable-services.scss +3 -0
  102. package/src/billable-services/billable-services.test.tsx +6 -49
  103. package/src/billable-services/cash-point/add-cash-point.modal.tsx +168 -0
  104. package/src/billable-services/cash-point/cash-point-configuration.component.tsx +19 -193
  105. package/src/billable-services/cash-point/cash-point-configuration.scss +1 -5
  106. package/src/billable-services/create-edit/add-billable-service.component.tsx +356 -300
  107. package/src/billable-services/create-edit/add-billable-service.scss +6 -65
  108. package/src/billable-services/create-edit/add-billable-service.test.tsx +167 -81
  109. package/src/billable-services/create-edit/edit-billable-service.modal.tsx +51 -0
  110. package/src/billable-services/dashboard/service-metrics.component.tsx +11 -3
  111. package/src/billable-services/payment-modes/add-payment-mode.modal.tsx +121 -0
  112. package/src/billable-services/payment-modes/delete-payment-mode.modal.tsx +72 -0
  113. package/src/billable-services/payment-modes/payment-modes-config.component.tsx +125 -0
  114. package/src/billable-services/{payyment-modes → payment-modes}/payment-modes-config.scss +5 -4
  115. package/src/billing-dashboard/billing-dashboard.scss +1 -1
  116. package/src/billing-form/billing-checkin-form.component.tsx +21 -17
  117. package/src/billing-form/billing-checkin-form.test.tsx +99 -26
  118. package/src/billing-form/billing-form.component.tsx +222 -292
  119. package/src/billing-form/billing-form.scss +143 -0
  120. package/src/billing-form/visit-attributes/visit-attributes-form.component.tsx +1 -1
  121. package/src/billing.resource.ts +69 -74
  122. package/src/bills-table/bills-table.component.tsx +3 -3
  123. package/src/bills-table/bills-table.test.tsx +98 -54
  124. package/src/config-schema.ts +52 -24
  125. package/src/dashboard.meta.ts +4 -2
  126. package/src/helpers/functions.ts +5 -4
  127. package/src/index.ts +17 -6
  128. package/src/invoice/invoice-table.component.tsx +36 -70
  129. package/src/invoice/invoice-table.scss +8 -5
  130. package/src/invoice/invoice-table.test.tsx +273 -62
  131. package/src/invoice/invoice.component.tsx +39 -32
  132. package/src/invoice/invoice.scss +11 -4
  133. package/src/invoice/invoice.test.tsx +324 -120
  134. package/src/invoice/payments/invoice-breakdown/invoice-breakdown.scss +9 -9
  135. package/src/invoice/payments/payment-form/payment-form.component.tsx +43 -34
  136. package/src/invoice/payments/payment-form/payment-form.scss +5 -6
  137. package/src/invoice/payments/payment-form/payment-form.test.tsx +216 -66
  138. package/src/invoice/payments/payment-history/payment-history.component.tsx +6 -4
  139. package/src/invoice/payments/payment-history/payment-history.test.tsx +9 -14
  140. package/src/invoice/payments/payments.component.tsx +55 -67
  141. package/src/invoice/payments/payments.scss +4 -3
  142. package/src/invoice/payments/payments.test.tsx +282 -0
  143. package/src/invoice/payments/utils.ts +15 -27
  144. package/src/invoice/printable-invoice/print-receipt.component.tsx +3 -2
  145. package/src/invoice/printable-invoice/print-receipt.test.tsx +14 -25
  146. package/src/invoice/printable-invoice/printable-footer.component.tsx +2 -2
  147. package/src/invoice/printable-invoice/printable-footer.test.tsx +4 -13
  148. package/src/invoice/printable-invoice/printable-invoice-header.component.tsx +12 -11
  149. package/src/invoice/printable-invoice/printable-invoice-header.test.tsx +16 -14
  150. package/src/invoice/printable-invoice/printable-invoice.component.tsx +20 -34
  151. package/src/left-panel-link.test.tsx +1 -4
  152. package/src/metrics-cards/metrics-cards.component.tsx +12 -2
  153. package/src/metrics-cards/metrics-cards.scss +4 -0
  154. package/src/metrics-cards/metrics-cards.test.tsx +18 -5
  155. package/src/modal/require-payment-modal.test.tsx +27 -22
  156. package/src/modal/{require-payment-modal.component.tsx → require-payment.modal.tsx} +18 -19
  157. package/src/routes.json +25 -7
  158. package/src/types/index.ts +80 -18
  159. package/translations/am.json +125 -74
  160. package/translations/ar.json +126 -75
  161. package/translations/ar_SY.json +126 -75
  162. package/translations/bn.json +128 -77
  163. package/translations/de.json +126 -75
  164. package/translations/en.json +126 -75
  165. package/translations/en_US.json +126 -75
  166. package/translations/es.json +125 -74
  167. package/translations/es_MX.json +126 -75
  168. package/translations/fr.json +131 -80
  169. package/translations/he.json +125 -74
  170. package/translations/hi.json +126 -75
  171. package/translations/hi_IN.json +126 -75
  172. package/translations/id.json +126 -75
  173. package/translations/it.json +152 -101
  174. package/translations/ka.json +126 -75
  175. package/translations/km.json +125 -74
  176. package/translations/ku.json +126 -75
  177. package/translations/ky.json +126 -75
  178. package/translations/lg.json +126 -75
  179. package/translations/ne.json +126 -75
  180. package/translations/pl.json +126 -75
  181. package/translations/pt.json +126 -75
  182. package/translations/pt_BR.json +126 -75
  183. package/translations/qu.json +126 -75
  184. package/translations/ro_RO.json +216 -165
  185. package/translations/ru_RU.json +126 -75
  186. package/translations/si.json +126 -75
  187. package/translations/sw.json +126 -75
  188. package/translations/sw_KE.json +126 -75
  189. package/translations/tr.json +126 -75
  190. package/translations/tr_TR.json +126 -75
  191. package/translations/uk.json +126 -75
  192. package/translations/uz.json +126 -75
  193. package/translations/uz@Latn.json +126 -75
  194. package/translations/uz_UZ.json +126 -75
  195. package/translations/vi.json +126 -75
  196. package/translations/zh.json +126 -75
  197. package/translations/zh_CN.json +158 -107
  198. package/dist/1146.js.LICENSE.txt +0 -21
  199. package/dist/2352.js +0 -1
  200. package/dist/2352.js.map +0 -1
  201. package/dist/246.js +0 -1
  202. package/dist/246.js.map +0 -1
  203. package/dist/6525.js +0 -2
  204. package/dist/6525.js.map +0 -1
  205. package/dist/8556.js +0 -2
  206. package/dist/8556.js.map +0 -1
  207. package/dist/8638.js +0 -1
  208. package/dist/8638.js.map +0 -1
  209. package/dist/9968.js +0 -1
  210. package/dist/9968.js.map +0 -1
  211. package/src/bill-item-actions/edit-bill-item.component.tsx +0 -221
  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/{8556.js.LICENSE.txt → 3717.js.LICENSE.txt} +0 -0
@@ -2,59 +2,23 @@ import React, { useState, useEffect, useCallback } from 'react';
2
2
  import {
3
3
  Button,
4
4
  DataTable,
5
- TableContainer,
6
5
  Table,
7
- TableHead,
8
- TableRow,
9
- TableHeader,
10
6
  TableBody,
11
7
  TableCell,
12
- Modal,
13
- TextInput,
14
- OverflowMenu,
15
- OverflowMenuItem,
16
- Dropdown,
8
+ TableContainer,
9
+ TableHead,
10
+ TableHeader,
11
+ TableRow,
17
12
  } from '@carbon/react';
18
13
  import { Add } from '@carbon/react/icons';
19
14
  import { useTranslation } from 'react-i18next';
20
- import { useForm, Controller } from 'react-hook-form';
21
- import { z } from 'zod';
22
- import { zodResolver } from '@hookform/resolvers/zod';
23
- import { showSnackbar, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
15
+ import { showSnackbar, openmrsFetch, restBaseUrl, showModal, getCoreTranslation } from '@openmrs/esm-framework';
24
16
  import { CardHeader } from '@openmrs/esm-patient-common-lib';
25
17
  import styles from './cash-point-configuration.scss';
26
18
 
27
- // Validation schema
28
- const cashPointSchema = z.object({
29
- name: z.string().min(1, 'Cash Point Name is required'),
30
- uuid: z
31
- .string()
32
- .min(1, 'UUID is required')
33
- .regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, 'Invalid UUID format'),
34
- location: z.string().min(1, 'Location is required'),
35
- });
36
-
37
- type CashPointFormValues = z.infer<typeof cashPointSchema>;
38
-
39
19
  const CashPointConfiguration: React.FC = () => {
40
20
  const { t } = useTranslation();
41
21
  const [cashPoints, setCashPoints] = useState([]);
42
- const [locations, setLocations] = useState([]);
43
- const [isModalOpen, setIsModalOpen] = useState(false);
44
-
45
- const {
46
- control,
47
- handleSubmit,
48
- reset,
49
- formState: { errors, isSubmitting },
50
- } = useForm<CashPointFormValues>({
51
- resolver: zodResolver(cashPointSchema),
52
- defaultValues: {
53
- name: '',
54
- uuid: '',
55
- location: '',
56
- },
57
- });
58
22
 
59
23
  const fetchCashPoints = useCallback(async () => {
60
24
  try {
@@ -62,7 +26,7 @@ const CashPointConfiguration: React.FC = () => {
62
26
  setCashPoints(response.data.results || []);
63
27
  } catch (err) {
64
28
  showSnackbar({
65
- title: t('error', 'Error'),
29
+ title: getCoreTranslation('error'),
66
30
  subtitle: t('errorFetchingCashPoints', 'An error occurred while fetching cash points.'),
67
31
  kind: 'error',
68
32
  isLowContrast: false,
@@ -70,87 +34,15 @@ const CashPointConfiguration: React.FC = () => {
70
34
  }
71
35
  }, [t]);
72
36
 
73
- const fetchLocations = useCallback(async () => {
74
- try {
75
- const response = await openmrsFetch(`${restBaseUrl}/location?v=default`);
76
- const allLocations = response.data.results.map((loc) => ({
77
- id: loc.uuid,
78
- label: loc.display,
79
- }));
80
- setLocations(allLocations);
81
- } catch (err) {
82
- showSnackbar({
83
- title: t('error', 'Error'),
84
- subtitle: t('errorFetchingLocations', 'An error occurred while fetching locations.'),
85
- kind: 'error',
86
- isLowContrast: false,
87
- });
88
- }
89
- }, [t]);
90
-
91
37
  useEffect(() => {
92
38
  fetchCashPoints();
93
- fetchLocations();
94
- }, [fetchCashPoints, fetchLocations]);
95
-
96
- const onSubmit = async (data: CashPointFormValues) => {
97
- const isDuplicate = cashPoints.some(
98
- (point) => point.name.toLowerCase() === data.name.toLowerCase() || point.uuid === data.uuid,
99
- );
39
+ }, [fetchCashPoints]);
100
40
 
101
- if (isDuplicate) {
102
- showSnackbar({
103
- title: t('error', 'Error'),
104
- subtitle: t(
105
- 'duplicateCashPointError',
106
- 'A cash point with the same name or UUID already exists. Please use a unique name and UUID.',
107
- ),
108
- kind: 'error',
109
- isLowContrast: false,
110
- });
111
- return;
112
- }
113
-
114
- try {
115
- const response = await openmrsFetch(`${restBaseUrl}/billing/cashPoint`, {
116
- method: 'POST',
117
- headers: {
118
- 'Content-Type': 'application/json',
119
- },
120
- body: {
121
- name: data.name,
122
- uuid: data.uuid,
123
- location: { uuid: data.location },
124
- },
125
- });
126
-
127
- if (response.ok) {
128
- showSnackbar({
129
- title: t('success', 'Success'),
130
- subtitle: t('cashPointSaved', 'Cash point was successfully saved.'),
131
- kind: 'success',
132
- });
133
-
134
- setIsModalOpen(false);
135
- reset({ name: '', uuid: '', location: '' });
136
- fetchCashPoints();
137
- } else {
138
- const errorData = response.data || {};
139
- showSnackbar({
140
- title: t('error', 'Error'),
141
- subtitle: errorData.message || t('errorSavingCashPoint', 'An error occurred while saving the cash point.'),
142
- kind: 'error',
143
- isLowContrast: false,
144
- });
145
- }
146
- } catch (err) {
147
- showSnackbar({
148
- title: t('error', 'Error'),
149
- subtitle: t('errorSavingCashPoint', 'An error occurred while saving the cash point.'),
150
- kind: 'error',
151
- isLowContrast: false,
152
- });
153
- }
41
+ const handleAddCashPoint = () => {
42
+ const dispose = showModal('add-cash-point-modal', {
43
+ onCashPointAdded: fetchCashPoints,
44
+ closeModal: () => dispose(),
45
+ });
154
46
  };
155
47
 
156
48
  const rowData = cashPoints.map((point) => ({
@@ -164,18 +56,17 @@ const CashPointConfiguration: React.FC = () => {
164
56
  { key: 'name', header: t('name', 'Name') },
165
57
  { key: 'uuid', header: t('uuid', 'UUID') },
166
58
  { key: 'location', header: t('location', 'Location') },
167
- { key: 'actions', header: t('actions', 'Actions') },
168
59
  ];
169
60
 
170
61
  return (
171
62
  <div className={styles.container}>
172
63
  <div className={styles.card}>
173
- <CardHeader title={t('cashPointHistory', 'Cash Point History')}>
174
- <Button renderIcon={Add} onClick={() => setIsModalOpen(true)} kind="ghost">
175
- {t('addCashPoint', 'Add New Cash Point')}
64
+ <CardHeader title={t('cashPointHistory', 'Cash point history')}>
65
+ <Button renderIcon={Add} onClick={handleAddCashPoint} kind="ghost">
66
+ {t('addNewCashPoint', 'Add new cash point')}
176
67
  </Button>
177
68
  </CardHeader>
178
- <div className={styles.billHistoryContainer}>
69
+ <div>
179
70
  <DataTable rows={rowData} headers={headerData} isSortable size="lg">
180
71
  {({ rows, headers, getTableProps, getHeaderProps, getRowProps }) => (
181
72
  <TableContainer>
@@ -192,17 +83,9 @@ const CashPointConfiguration: React.FC = () => {
192
83
  <TableBody>
193
84
  {rows.map((row) => (
194
85
  <TableRow key={row.id} {...getRowProps({ row })}>
195
- {row.cells.map((cell) =>
196
- cell.info.header !== 'actions' ? (
197
- <TableCell key={cell.id}>{cell.value}</TableCell>
198
- ) : (
199
- <TableCell key={cell.id}>
200
- <OverflowMenu>
201
- <OverflowMenuItem itemText={t('delete', 'Delete')} disabled />
202
- </OverflowMenu>
203
- </TableCell>
204
- ),
205
- )}
86
+ {row.cells.map((cell) => (
87
+ <TableCell key={cell.id}>{cell.value}</TableCell>
88
+ ))}
206
89
  </TableRow>
207
90
  ))}
208
91
  </TableBody>
@@ -212,63 +95,6 @@ const CashPointConfiguration: React.FC = () => {
212
95
  </DataTable>
213
96
  </div>
214
97
  </div>
215
-
216
- {/* Modal for Adding New Cash Point */}
217
- <Modal
218
- open={isModalOpen}
219
- modalHeading={t('addCashPoint', 'Add Cash Point')}
220
- onRequestClose={() => setIsModalOpen(false)}
221
- onRequestSubmit={handleSubmit(onSubmit)}
222
- primaryButtonText={t('save', 'Save')}
223
- secondaryButtonText={t('cancel', 'Cancel')}
224
- isPrimaryButtonDisabled={isSubmitting}>
225
- <form>
226
- <Controller
227
- name="name"
228
- control={control}
229
- render={({ field }) => (
230
- <TextInput
231
- id="cash-point-name"
232
- labelText={t('cashPointName', 'Cash Point Name')}
233
- placeholder={t('cashPointNamePlaceholder', 'e.g., Pharmacy Cash Point')}
234
- invalid={!!errors.name}
235
- invalidText={errors.name?.message}
236
- {...field}
237
- />
238
- )}
239
- />
240
- <Controller
241
- name="uuid"
242
- control={control}
243
- render={({ field }) => (
244
- <TextInput
245
- id="cash-point-uuid"
246
- labelText={t('cashPointUuid', 'Cash Point UUID')}
247
- placeholder={t('cashPointUuidPlaceholder', 'Enter UUID')}
248
- invalid={!!errors.uuid}
249
- invalidText={errors.uuid?.message}
250
- {...field}
251
- />
252
- )}
253
- />
254
- <Controller
255
- name="location"
256
- control={control}
257
- render={({ field }) => (
258
- <Dropdown
259
- id="cash-point-location"
260
- label={t('location', 'Select Location')}
261
- titleText={t('cashPointLocation', 'Cash Point Location')}
262
- items={locations}
263
- selectedItem={locations.find((loc) => loc.id === field.value)}
264
- onChange={({ selectedItem }) => field.onChange(selectedItem?.id)}
265
- invalid={!!errors.location}
266
- invalidText={errors.location?.message}
267
- />
268
- )}
269
- />
270
- </form>
271
- </Modal>
272
98
  </div>
273
99
  );
274
100
  };
@@ -13,11 +13,7 @@
13
13
  padding: layout.$spacing-05;
14
14
  }
15
15
 
16
- .billHistoryContainer {
17
- margin-top: layout.$spacing-05;
18
- }
19
-
20
16
  .table {
21
17
  width: 100%;
22
18
  table-layout: auto;
23
- }
19
+ }