@openmrs/esm-billing-app 1.0.2-pre.74 → 1.0.2-pre.749

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 (196) hide show
  1. package/README.md +55 -9
  2. package/__mocks__/bills.mock.ts +12 -0
  3. package/__mocks__/react-i18next.js +6 -5
  4. package/dist/1119.js +1 -1
  5. package/dist/1146.js +1 -2
  6. package/dist/1146.js.map +1 -1
  7. package/dist/1197.js +1 -1
  8. package/dist/1856.js +1 -0
  9. package/dist/1856.js.map +1 -0
  10. package/dist/2146.js +1 -1
  11. package/dist/2177.js +2 -0
  12. package/dist/2177.js.LICENSE.txt +9 -0
  13. package/dist/2177.js.map +1 -0
  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/3041.js +1 -0
  18. package/dist/3041.js.map +1 -0
  19. package/dist/3099.js +1 -1
  20. package/dist/3584.js +1 -1
  21. package/dist/4055.js +1 -1
  22. package/dist/4132.js +1 -1
  23. package/dist/4225.js +1 -0
  24. package/dist/4225.js.map +1 -0
  25. package/dist/4300.js +1 -1
  26. package/dist/4335.js +1 -1
  27. package/dist/4618.js +1 -1
  28. package/dist/4652.js +1 -1
  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/5422.js +1 -0
  37. package/dist/5422.js.map +1 -0
  38. package/dist/5442.js +1 -1
  39. package/dist/5661.js +1 -1
  40. package/dist/6022.js +1 -1
  41. package/dist/6468.js +1 -1
  42. package/dist/6540.js +1 -1
  43. package/dist/6540.js.map +1 -1
  44. package/dist/6606.js +1 -0
  45. package/dist/6606.js.map +1 -0
  46. package/dist/6679.js +1 -1
  47. package/dist/6840.js +1 -1
  48. package/dist/6859.js +1 -1
  49. package/dist/7097.js +1 -1
  50. package/dist/7159.js +1 -1
  51. package/dist/723.js +1 -1
  52. package/dist/7452.js +2 -0
  53. package/dist/7452.js.map +1 -0
  54. package/dist/7617.js +1 -1
  55. package/dist/795.js +1 -0
  56. package/dist/8163.js +1 -1
  57. package/dist/8349.js +1 -1
  58. package/dist/8618.js +1 -1
  59. package/dist/890.js +1 -1
  60. package/dist/8930.js +2 -0
  61. package/dist/{6525.js.LICENSE.txt → 8930.js.LICENSE.txt} +16 -4
  62. package/dist/8930.js.map +1 -0
  63. package/dist/9214.js +1 -1
  64. package/dist/942.js +1 -0
  65. package/dist/942.js.map +1 -0
  66. package/dist/9538.js +1 -1
  67. package/dist/9569.js +1 -0
  68. package/dist/961.js +1 -1
  69. package/dist/961.js.map +1 -1
  70. package/dist/986.js +1 -1
  71. package/dist/9879.js +1 -1
  72. package/dist/9895.js +1 -1
  73. package/dist/9900.js +1 -1
  74. package/dist/9913.js +1 -1
  75. package/dist/main.js +1 -1
  76. package/dist/main.js.map +1 -1
  77. package/dist/openmrs-esm-billing-app.js +1 -1
  78. package/dist/openmrs-esm-billing-app.js.buildmanifest.json +381 -231
  79. package/dist/openmrs-esm-billing-app.js.map +1 -1
  80. package/dist/routes.json +1 -1
  81. package/e2e/README.md +19 -18
  82. package/e2e/specs/sample-test.spec.ts +0 -1
  83. package/package.json +10 -10
  84. package/src/bill-history/bill-history.component.tsx +17 -25
  85. package/src/bill-history/bill-history.scss +4 -94
  86. package/src/bill-history/bill-history.test.tsx +37 -78
  87. package/src/bill-item-actions/bill-item-actions.scss +0 -4
  88. package/src/bill-item-actions/{edit-bill-item.component.tsx → edit-bill-item.modal.tsx} +58 -56
  89. package/src/bill-item-actions/edit-bill-item.test.tsx +22 -24
  90. package/src/billable-services/bill-waiver/bill-selection.component.tsx +2 -2
  91. package/src/billable-services/bill-waiver/patient-bills.component.tsx +3 -3
  92. package/src/billable-services/billable-service.resource.ts +4 -3
  93. package/src/billable-services/billable-services-home.component.tsx +1 -1
  94. package/src/billable-services/billable-services.component.tsx +115 -132
  95. package/src/billable-services/billable-services.scss +3 -0
  96. package/src/billable-services/billable-services.test.tsx +2 -45
  97. package/src/billable-services/cash-point/add-cash-point.modal.tsx +168 -0
  98. package/src/billable-services/cash-point/cash-point-configuration.component.tsx +17 -192
  99. package/src/billable-services/cash-point/cash-point-configuration.scss +1 -5
  100. package/src/billable-services/create-edit/add-billable-service.component.tsx +28 -24
  101. package/src/billable-services/create-edit/add-billable-service.scss +2 -5
  102. package/src/billable-services/create-edit/add-billable-service.test.tsx +6 -6
  103. package/src/billable-services/create-edit/edit-billable-service.modal.tsx +50 -0
  104. package/src/billable-services/payment-modes/add-payment-mode.modal.tsx +121 -0
  105. package/src/billable-services/payment-modes/delete-payment-mode.modal.tsx +72 -0
  106. package/src/billable-services/payment-modes/payment-modes-config.component.tsx +125 -0
  107. package/src/billable-services/{payyment-modes → payment-modes}/payment-modes-config.scss +5 -1
  108. package/src/billing-form/billing-checkin-form.component.tsx +2 -3
  109. package/src/billing-form/billing-checkin-form.test.tsx +0 -2
  110. package/src/billing-form/billing-form.component.tsx +210 -268
  111. package/src/billing-form/billing-form.scss +143 -0
  112. package/src/billing.resource.ts +16 -19
  113. package/src/bills-table/bills-table.test.tsx +97 -53
  114. package/src/config-schema.ts +52 -18
  115. package/src/dashboard.meta.ts +4 -2
  116. package/src/helpers/functions.ts +5 -4
  117. package/src/index.ts +17 -6
  118. package/src/invoice/invoice-table.component.tsx +24 -54
  119. package/src/invoice/invoice-table.scss +1 -5
  120. package/src/invoice/invoice-table.test.tsx +21 -47
  121. package/src/invoice/invoice.component.tsx +36 -29
  122. package/src/invoice/invoice.scss +7 -4
  123. package/src/invoice/invoice.test.tsx +22 -48
  124. package/src/invoice/payments/payment-form/payment-form.component.tsx +2 -9
  125. package/src/invoice/payments/payment-form/payment-form.test.tsx +14 -46
  126. package/src/invoice/payments/payment-history/payment-history.component.tsx +6 -4
  127. package/src/invoice/payments/payment-history/payment-history.test.tsx +9 -14
  128. package/src/invoice/payments/payments.component.tsx +16 -27
  129. package/src/invoice/payments/{payments.component.test.tsx → payments.test.tsx} +24 -10
  130. package/src/invoice/payments/utils.ts +4 -22
  131. package/src/invoice/printable-invoice/print-receipt.component.tsx +3 -2
  132. package/src/invoice/printable-invoice/print-receipt.test.tsx +14 -25
  133. package/src/invoice/printable-invoice/printable-footer.component.tsx +2 -2
  134. package/src/invoice/printable-invoice/printable-footer.test.tsx +4 -13
  135. package/src/invoice/printable-invoice/printable-invoice-header.component.tsx +12 -11
  136. package/src/invoice/printable-invoice/printable-invoice-header.test.tsx +16 -14
  137. package/src/invoice/printable-invoice/printable-invoice.component.tsx +19 -33
  138. package/src/metrics-cards/metrics-cards.test.tsx +18 -5
  139. package/src/modal/require-payment-modal.test.tsx +25 -20
  140. package/src/modal/{require-payment-modal.component.tsx → require-payment.modal.tsx} +17 -18
  141. package/src/routes.json +22 -2
  142. package/src/types/index.ts +13 -12
  143. package/translations/am.json +33 -16
  144. package/translations/ar.json +33 -16
  145. package/translations/ar_SY.json +33 -16
  146. package/translations/bn.json +38 -21
  147. package/translations/de.json +33 -16
  148. package/translations/en.json +33 -16
  149. package/translations/en_US.json +187 -0
  150. package/translations/es.json +48 -31
  151. package/translations/es_MX.json +33 -16
  152. package/translations/fr.json +47 -30
  153. package/translations/he.json +33 -16
  154. package/translations/hi.json +33 -16
  155. package/translations/hi_IN.json +33 -16
  156. package/translations/id.json +180 -163
  157. package/translations/it.json +70 -53
  158. package/translations/ka.json +187 -0
  159. package/translations/km.json +33 -16
  160. package/translations/ku.json +33 -16
  161. package/translations/ky.json +33 -16
  162. package/translations/lg.json +33 -16
  163. package/translations/ne.json +33 -16
  164. package/translations/pl.json +33 -16
  165. package/translations/pt.json +33 -16
  166. package/translations/pt_BR.json +33 -16
  167. package/translations/qu.json +33 -16
  168. package/translations/ro_RO.json +182 -165
  169. package/translations/ru_RU.json +33 -16
  170. package/translations/si.json +33 -16
  171. package/translations/sw.json +33 -16
  172. package/translations/sw_KE.json +33 -16
  173. package/translations/tr.json +33 -16
  174. package/translations/tr_TR.json +33 -16
  175. package/translations/uk.json +33 -16
  176. package/translations/uz.json +33 -16
  177. package/translations/uz@Latn.json +33 -16
  178. package/translations/uz_UZ.json +33 -16
  179. package/translations/vi.json +33 -16
  180. package/translations/zh.json +33 -16
  181. package/translations/zh_CN.json +91 -74
  182. package/dist/1146.js.LICENSE.txt +0 -21
  183. package/dist/2352.js +0 -1
  184. package/dist/2352.js.map +0 -1
  185. package/dist/246.js +0 -1
  186. package/dist/246.js.map +0 -1
  187. package/dist/6525.js +0 -2
  188. package/dist/6525.js.map +0 -1
  189. package/dist/8556.js +0 -2
  190. package/dist/8556.js.map +0 -1
  191. package/dist/8638.js +0 -1
  192. package/dist/8638.js.map +0 -1
  193. package/dist/9968.js +0 -1
  194. package/dist/9968.js.map +0 -1
  195. package/src/billable-services/payyment-modes/payment-modes-config.component.tsx +0 -280
  196. /package/dist/{8556.js.LICENSE.txt → 7452.js.LICENSE.txt} +0 -0
@@ -0,0 +1,72 @@
1
+ import React, { useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Button, ModalBody, ModalFooter, ModalHeader } from '@carbon/react';
4
+ import { showSnackbar, openmrsFetch, restBaseUrl, getCoreTranslation } from '@openmrs/esm-framework';
5
+
6
+ interface DeletePaymentModeModalProps {
7
+ closeModal: () => void;
8
+ paymentModeUuid: string;
9
+ paymentModeName: string;
10
+ onPaymentModeDeleted: () => void;
11
+ }
12
+
13
+ const DeletePaymentModeModal: React.FC<DeletePaymentModeModalProps> = ({
14
+ closeModal,
15
+ paymentModeUuid,
16
+ paymentModeName,
17
+ onPaymentModeDeleted,
18
+ }) => {
19
+ const { t } = useTranslation();
20
+ const [isDeleting, setIsDeleting] = useState(false);
21
+
22
+ const handleDelete = async () => {
23
+ setIsDeleting(true);
24
+ try {
25
+ await openmrsFetch(`${restBaseUrl}/billing/paymentMode/${paymentModeUuid}`, {
26
+ method: 'DELETE',
27
+ });
28
+
29
+ showSnackbar({
30
+ title: t('success', 'Success'),
31
+ subtitle: t('paymentModeDeleted', 'Payment mode was successfully deleted.'),
32
+ kind: 'success',
33
+ });
34
+
35
+ closeModal();
36
+ onPaymentModeDeleted();
37
+ } catch (err) {
38
+ showSnackbar({
39
+ title: getCoreTranslation('error'),
40
+ subtitle: err?.message || t('errorDeletingPaymentMode', 'An error occurred while deleting the payment mode.'),
41
+ kind: 'error',
42
+ isLowContrast: false,
43
+ });
44
+ } finally {
45
+ setIsDeleting(false);
46
+ }
47
+ };
48
+
49
+ return (
50
+ <>
51
+ <ModalHeader closeModal={closeModal} title={t('deletePaymentMode', 'Delete Payment Mode')} />
52
+ <ModalBody>
53
+ <p>{t('confirmDeleteMessage', 'Are you sure you want to delete this payment mode? Proceed cautiously.')}</p>
54
+ {paymentModeName && (
55
+ <p>
56
+ <strong>{t('paymentModeName', 'Payment Mode Name: {{paymentModeName}}', { paymentModeName })}</strong>
57
+ </p>
58
+ )}
59
+ </ModalBody>
60
+ <ModalFooter>
61
+ <Button kind="secondary" onClick={closeModal}>
62
+ {getCoreTranslation('cancel')}
63
+ </Button>
64
+ <Button kind="danger" onClick={handleDelete} disabled={isDeleting}>
65
+ {isDeleting ? t('deleting', 'Deleting') + '...' : getCoreTranslation('delete')}
66
+ </Button>
67
+ </ModalFooter>
68
+ </>
69
+ );
70
+ };
71
+
72
+ export default DeletePaymentModeModal;
@@ -0,0 +1,125 @@
1
+ import React, { useState, useEffect, useCallback } from 'react';
2
+ import {
3
+ Button,
4
+ DataTable,
5
+ OverflowMenu,
6
+ OverflowMenuItem,
7
+ Table,
8
+ TableBody,
9
+ TableCell,
10
+ TableContainer,
11
+ TableHead,
12
+ TableHeader,
13
+ TableRow,
14
+ } from '@carbon/react';
15
+ import { Add } from '@carbon/react/icons';
16
+ import { useTranslation } from 'react-i18next';
17
+ import { showSnackbar, openmrsFetch, restBaseUrl, showModal, getCoreTranslation } from '@openmrs/esm-framework';
18
+ import { CardHeader } from '@openmrs/esm-patient-common-lib';
19
+ import styles from './payment-modes-config.scss';
20
+
21
+ const PaymentModesConfig: React.FC = () => {
22
+ const { t } = useTranslation();
23
+ const [paymentModes, setPaymentModes] = useState([]);
24
+
25
+ const fetchPaymentModes = useCallback(async () => {
26
+ try {
27
+ const response = await openmrsFetch(`${restBaseUrl}/billing/paymentMode?v=full`);
28
+ setPaymentModes(response.data.results || []);
29
+ } catch (err) {
30
+ showSnackbar({
31
+ title: getCoreTranslation('error'),
32
+ subtitle: t('errorFetchingPaymentModes', 'An error occurred while fetching payment modes.'),
33
+ kind: 'error',
34
+ isLowContrast: false,
35
+ });
36
+ }
37
+ }, [t]);
38
+
39
+ useEffect(() => {
40
+ fetchPaymentModes();
41
+ }, [fetchPaymentModes]);
42
+
43
+ const handleAddPaymentMode = () => {
44
+ showModal('add-payment-mode-modal', {
45
+ onPaymentModeAdded: fetchPaymentModes,
46
+ });
47
+ };
48
+
49
+ const handleDeletePaymentMode = (paymentMode) => {
50
+ showModal('delete-payment-mode-modal', {
51
+ paymentModeUuid: paymentMode.uuid,
52
+ paymentModeName: paymentMode.name,
53
+ onPaymentModeDeleted: fetchPaymentModes,
54
+ });
55
+ };
56
+
57
+ const rowData = paymentModes.map((mode) => ({
58
+ id: mode.uuid,
59
+ name: mode.name,
60
+ description: mode.description || '--',
61
+ }));
62
+
63
+ const headerData = [
64
+ { key: 'name', header: t('name', 'Name') },
65
+ { key: 'description', header: t('description', 'Description') },
66
+ { key: 'actions', header: getCoreTranslation('actions') },
67
+ ];
68
+
69
+ return (
70
+ <div className={styles.container}>
71
+ <div className={styles.card}>
72
+ <CardHeader title={t('paymentModeHistory', 'Payment Mode History')}>
73
+ <Button renderIcon={Add} onClick={handleAddPaymentMode} kind="ghost">
74
+ {t('addNewPaymentMode', 'Add New Payment Mode')}
75
+ </Button>
76
+ </CardHeader>
77
+ <div className={styles.historyContainer}>
78
+ <DataTable rows={rowData} headers={headerData} isSortable size="lg">
79
+ {({ rows, headers, getTableProps, getHeaderProps, getRowProps }) => (
80
+ <TableContainer>
81
+ <Table className={styles.table} {...getTableProps()}>
82
+ <TableHead>
83
+ <TableRow>
84
+ {headers.map((header) => (
85
+ <TableHeader key={header.key} {...getHeaderProps({ header })}>
86
+ {header.header}
87
+ </TableHeader>
88
+ ))}
89
+ </TableRow>
90
+ </TableHead>
91
+ <TableBody>
92
+ {rows.map((row) => (
93
+ <TableRow key={row.id} {...getRowProps({ row })}>
94
+ {row.cells.map((cell) =>
95
+ cell.info.header !== 'actions' ? (
96
+ <TableCell key={cell.id}>{cell.value}</TableCell>
97
+ ) : (
98
+ <TableCell key={cell.id}>
99
+ <OverflowMenu>
100
+ <OverflowMenuItem
101
+ className={styles.menuItem}
102
+ itemText={getCoreTranslation('delete')}
103
+ onClick={() => {
104
+ const selected = paymentModes.find((p) => p.uuid === row.id);
105
+ handleDeletePaymentMode(selected);
106
+ }}
107
+ />
108
+ </OverflowMenu>
109
+ </TableCell>
110
+ ),
111
+ )}
112
+ </TableRow>
113
+ ))}
114
+ </TableBody>
115
+ </Table>
116
+ </TableContainer>
117
+ )}
118
+ </DataTable>
119
+ </div>
120
+ </div>
121
+ </div>
122
+ );
123
+ };
124
+
125
+ export default PaymentModesConfig;
@@ -20,4 +20,8 @@
20
20
  .table {
21
21
  width: 100%;
22
22
  table-layout: auto;
23
- }
23
+ }
24
+
25
+ .menuItem {
26
+ max-width: none;
27
+ }
@@ -1,12 +1,11 @@
1
1
  import React, { useCallback, useState } from 'react';
2
2
  import { Dropdown, InlineLoading, InlineNotification } from '@carbon/react';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { showSnackbar, useConfig } from '@openmrs/esm-framework';
4
+ import { showSnackbar, getCoreTranslation } from '@openmrs/esm-framework';
5
5
  import { useCashPoint, useBillableItems, createPatientBill } from './billing-form.resource';
6
6
  import VisitAttributesForm from './visit-attributes/visit-attributes-form.component';
7
7
  import styles from './billing-checkin-form.scss';
8
8
 
9
- const DEFAULT_PRICE = 500.00001;
10
9
  const PENDING_PAYMENT_STATUS = 'PENDING';
11
10
 
12
11
  type BillingCheckInFormProps = {
@@ -74,7 +73,7 @@ const BillingCheckInForm: React.FC<BillingCheckInFormProps> = ({ patientUuid, se
74
73
  return (
75
74
  <InlineLoading
76
75
  status="active"
77
- iconDescription={t('loading', 'Loading')}
76
+ iconDescription={getCoreTranslation('loading')}
78
77
  description={t('loadingBillingServices', 'Loading billing services...')}
79
78
  />
80
79
  );
@@ -42,8 +42,6 @@ const mockBillableItems = [
42
42
 
43
43
  const mockUseCashPoint = useCashPoint as jest.MockedFunction<typeof useCashPoint>;
44
44
  const mockUseBillableItems = useBillableItems as jest.MockedFunction<typeof useBillableItems>;
45
- const mockCreatePatientBill = createPatientBill as jest.MockedFunction<typeof createPatientBill>;
46
- const mockusePaymentMethods = usePaymentMethods as jest.MockedFunction<typeof usePaymentMethods>;
47
45
 
48
46
  jest.mock('./billing-form.resource', () => ({
49
47
  useBillableItems: jest.fn(),