@openmrs/esm-billing-app 1.0.2-pre.78 → 1.0.2-pre.790

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 (203) 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/4055.js +1 -1
  23. package/dist/4132.js +1 -1
  24. package/dist/4225.js +1 -0
  25. package/dist/4225.js.map +1 -0
  26. package/dist/4300.js +1 -1
  27. package/dist/4335.js +1 -1
  28. package/dist/4618.js +1 -1
  29. package/dist/4652.js +1 -1
  30. package/dist/4724.js +1 -0
  31. package/dist/4724.js.map +1 -0
  32. package/dist/4739.js +1 -1
  33. package/dist/4739.js.map +1 -1
  34. package/dist/4944.js +1 -1
  35. package/dist/5173.js +1 -1
  36. package/dist/5241.js +1 -1
  37. package/dist/5422.js +1 -0
  38. package/dist/5422.js.map +1 -0
  39. package/dist/5442.js +1 -1
  40. package/dist/5661.js +1 -1
  41. package/dist/6022.js +1 -1
  42. package/dist/6468.js +1 -1
  43. package/dist/6540.js +1 -1
  44. package/dist/6540.js.map +1 -1
  45. package/dist/6606.js +1 -0
  46. package/dist/6606.js.map +1 -0
  47. package/dist/6679.js +1 -1
  48. package/dist/6840.js +1 -1
  49. package/dist/6859.js +1 -1
  50. package/dist/7097.js +1 -1
  51. package/dist/7159.js +1 -1
  52. package/dist/723.js +1 -1
  53. package/dist/7452.js +2 -0
  54. package/dist/7452.js.map +1 -0
  55. package/dist/7617.js +1 -1
  56. package/dist/795.js +1 -1
  57. package/dist/8163.js +1 -1
  58. package/dist/8349.js +1 -1
  59. package/dist/8618.js +1 -1
  60. package/dist/890.js +1 -1
  61. package/dist/8930.js +2 -0
  62. package/dist/{6525.js.LICENSE.txt → 8930.js.LICENSE.txt} +16 -4
  63. package/dist/8930.js.map +1 -0
  64. package/dist/9214.js +1 -1
  65. package/dist/942.js +1 -0
  66. package/dist/942.js.map +1 -0
  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 +368 -262
  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 +17 -25
  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 +0 -4
  92. package/src/bill-item-actions/{edit-bill-item.component.tsx → edit-bill-item.modal.tsx} +100 -78
  93. package/src/bill-item-actions/edit-bill-item.test.tsx +116 -31
  94. package/src/billable-services/bill-waiver/bill-selection.component.tsx +2 -2
  95. package/src/billable-services/bill-waiver/patient-bills.component.tsx +3 -3
  96. package/src/billable-services/billable-service.resource.ts +17 -9
  97. package/src/billable-services/billable-services-home.component.tsx +1 -1
  98. package/src/billable-services/billable-services.component.tsx +142 -145
  99. package/src/billable-services/billable-services.scss +3 -0
  100. package/src/billable-services/billable-services.test.tsx +2 -45
  101. package/src/billable-services/cash-point/add-cash-point.modal.tsx +168 -0
  102. package/src/billable-services/cash-point/cash-point-configuration.component.tsx +18 -192
  103. package/src/billable-services/cash-point/cash-point-configuration.scss +1 -5
  104. package/src/billable-services/create-edit/add-billable-service.component.tsx +345 -298
  105. package/src/billable-services/create-edit/add-billable-service.scss +5 -6
  106. package/src/billable-services/create-edit/add-billable-service.test.tsx +37 -36
  107. package/src/billable-services/create-edit/edit-billable-service.modal.tsx +51 -0
  108. package/src/billable-services/payment-modes/add-payment-mode.modal.tsx +121 -0
  109. package/src/billable-services/payment-modes/delete-payment-mode.modal.tsx +72 -0
  110. package/src/billable-services/payment-modes/payment-modes-config.component.tsx +125 -0
  111. package/src/billable-services/{payyment-modes → payment-modes}/payment-modes-config.scss +5 -4
  112. package/src/billing-form/billing-checkin-form.component.tsx +2 -3
  113. package/src/billing-form/billing-checkin-form.test.tsx +97 -24
  114. package/src/billing-form/billing-form.component.tsx +216 -269
  115. package/src/billing-form/billing-form.scss +143 -0
  116. package/src/billing.resource.ts +16 -19
  117. package/src/bills-table/bills-table.test.tsx +98 -54
  118. package/src/config-schema.ts +52 -24
  119. package/src/dashboard.meta.ts +4 -2
  120. package/src/helpers/functions.ts +5 -4
  121. package/src/index.ts +17 -6
  122. package/src/invoice/invoice-table.component.tsx +35 -69
  123. package/src/invoice/invoice-table.scss +1 -5
  124. package/src/invoice/invoice-table.test.tsx +273 -62
  125. package/src/invoice/invoice.component.tsx +36 -29
  126. package/src/invoice/invoice.scss +7 -4
  127. package/src/invoice/invoice.test.tsx +324 -120
  128. package/src/invoice/payments/payment-form/payment-form.component.tsx +43 -34
  129. package/src/invoice/payments/payment-form/payment-form.scss +5 -6
  130. package/src/invoice/payments/payment-form/payment-form.test.tsx +216 -66
  131. package/src/invoice/payments/payment-history/payment-history.component.tsx +6 -4
  132. package/src/invoice/payments/payment-history/payment-history.test.tsx +9 -14
  133. package/src/invoice/payments/payments.component.tsx +53 -65
  134. package/src/invoice/payments/payments.test.tsx +282 -0
  135. package/src/invoice/payments/utils.ts +5 -23
  136. package/src/invoice/printable-invoice/print-receipt.component.tsx +3 -2
  137. package/src/invoice/printable-invoice/print-receipt.test.tsx +14 -25
  138. package/src/invoice/printable-invoice/printable-footer.component.tsx +2 -2
  139. package/src/invoice/printable-invoice/printable-footer.test.tsx +4 -13
  140. package/src/invoice/printable-invoice/printable-invoice-header.component.tsx +12 -11
  141. package/src/invoice/printable-invoice/printable-invoice-header.test.tsx +16 -14
  142. package/src/invoice/printable-invoice/printable-invoice.component.tsx +19 -33
  143. package/src/left-panel-link.test.tsx +1 -4
  144. package/src/metrics-cards/metrics-cards.test.tsx +18 -5
  145. package/src/modal/require-payment-modal.test.tsx +27 -22
  146. package/src/modal/{require-payment-modal.component.tsx → require-payment.modal.tsx} +17 -18
  147. package/src/routes.json +22 -2
  148. package/src/types/index.ts +26 -17
  149. package/translations/am.json +70 -21
  150. package/translations/ar.json +70 -21
  151. package/translations/ar_SY.json +70 -21
  152. package/translations/bn.json +75 -26
  153. package/translations/de.json +70 -21
  154. package/translations/en.json +70 -21
  155. package/translations/en_US.json +70 -21
  156. package/translations/es.json +70 -21
  157. package/translations/es_MX.json +70 -21
  158. package/translations/fr.json +83 -34
  159. package/translations/he.json +70 -21
  160. package/translations/hi.json +70 -21
  161. package/translations/hi_IN.json +70 -21
  162. package/translations/id.json +70 -21
  163. package/translations/it.json +105 -56
  164. package/translations/ka.json +70 -21
  165. package/translations/km.json +70 -21
  166. package/translations/ku.json +70 -21
  167. package/translations/ky.json +70 -21
  168. package/translations/lg.json +70 -21
  169. package/translations/ne.json +70 -21
  170. package/translations/pl.json +70 -21
  171. package/translations/pt.json +70 -21
  172. package/translations/pt_BR.json +70 -21
  173. package/translations/qu.json +70 -21
  174. package/translations/ro_RO.json +214 -165
  175. package/translations/ru_RU.json +70 -21
  176. package/translations/si.json +70 -21
  177. package/translations/sw.json +70 -21
  178. package/translations/sw_KE.json +70 -21
  179. package/translations/tr.json +70 -21
  180. package/translations/tr_TR.json +70 -21
  181. package/translations/uk.json +70 -21
  182. package/translations/uz.json +70 -21
  183. package/translations/uz@Latn.json +70 -21
  184. package/translations/uz_UZ.json +70 -21
  185. package/translations/vi.json +70 -21
  186. package/translations/zh.json +70 -21
  187. package/translations/zh_CN.json +125 -76
  188. package/dist/1146.js.LICENSE.txt +0 -21
  189. package/dist/2352.js +0 -1
  190. package/dist/2352.js.map +0 -1
  191. package/dist/246.js +0 -1
  192. package/dist/246.js.map +0 -1
  193. package/dist/6525.js +0 -2
  194. package/dist/6525.js.map +0 -1
  195. package/dist/8556.js +0 -2
  196. package/dist/8556.js.map +0 -1
  197. package/dist/8638.js +0 -1
  198. package/dist/8638.js.map +0 -1
  199. package/dist/9968.js +0 -1
  200. package/dist/9968.js.map +0 -1
  201. package/src/billable-services/payyment-modes/payment-modes-config.component.tsx +0 -280
  202. package/src/invoice/payments/payments.component.test.tsx +0 -121
  203. /package/dist/{8556.js.LICENSE.txt → 7452.js.LICENSE.txt} +0 -0
@@ -4,15 +4,15 @@ import { Printer } from '@carbon/react/icons';
4
4
  import { useParams } from 'react-router-dom';
5
5
  import { useReactToPrint } from 'react-to-print';
6
6
  import { useTranslation } from 'react-i18next';
7
- import { ExtensionSlot, useConfig, usePatient } from '@openmrs/esm-framework';
8
- import { ErrorState } from '@openmrs/esm-patient-common-lib';
9
- import { convertToCurrency } from '../helpers';
10
- import { type LineItem } from '../types';
11
- import { useBill } from '../billing.resource';
7
+ import { ExtensionSlot, showSnackbar, useConfig, usePatient } from '@openmrs/esm-framework';
12
8
  import InvoiceTable from './invoice-table.component';
13
9
  import Payments from './payments/payments.component';
14
10
  import PrintReceipt from './printable-invoice/print-receipt.component';
15
11
  import PrintableInvoice from './printable-invoice/printable-invoice.component';
12
+ import { ErrorState } from '@openmrs/esm-patient-common-lib';
13
+ import { convertToCurrency } from '../helpers';
14
+ import { useBill, useDefaultFacility } from '../billing.resource';
15
+ import type { BillingConfig } from '../config-schema';
16
16
  import styles from './invoice.scss';
17
17
 
18
18
  interface InvoiceDetailsProps {
@@ -22,25 +22,20 @@ interface InvoiceDetailsProps {
22
22
 
23
23
  const Invoice: React.FC = () => {
24
24
  const { t } = useTranslation();
25
+ const { data } = useDefaultFacility();
25
26
  const { billUuid, patientUuid } = useParams();
26
27
  const { patient, isLoading: isLoadingPatient } = usePatient(patientUuid);
27
28
  const { bill, isLoading: isLoadingBill, error, mutate } = useBill(billUuid);
28
29
  const [isPrinting, setIsPrinting] = useState(false);
29
- const [selectedLineItems, setSelectedLineItems] = useState<LineItem[]>([]);
30
30
  const componentRef = useRef<HTMLDivElement>(null);
31
31
  const onBeforeGetContentResolve = useRef<(() => void) | null>(null);
32
- const { defaultCurrency } = useConfig();
33
- const handleSelectItem = (lineItems: LineItem[]) => {
34
- setSelectedLineItems(lineItems);
35
- };
32
+ const { defaultCurrency } = useConfig<BillingConfig>();
36
33
 
37
34
  const handleAfterPrint = useCallback(() => {
38
35
  onBeforeGetContentResolve.current = null;
39
36
  setIsPrinting(false);
40
37
  }, []);
41
38
 
42
- const reactToPrintContent = useCallback(() => componentRef.current, []);
43
-
44
39
  const handleOnBeforeGetContent = useCallback(() => {
45
40
  return new Promise<void>((resolve) => {
46
41
  if (patient && bill) {
@@ -51,11 +46,17 @@ const Invoice: React.FC = () => {
51
46
  }, [bill, patient]);
52
47
 
53
48
  const handlePrint = useReactToPrint({
54
- content: reactToPrintContent,
49
+ contentRef: componentRef,
55
50
  documentTitle: `Invoice ${bill?.receiptNumber} - ${patient?.name?.[0]?.given?.join(' ')} ${patient?.name?.[0].family}`,
56
- onBeforeGetContent: handleOnBeforeGetContent,
51
+ onBeforePrint: handleOnBeforeGetContent,
57
52
  onAfterPrint: handleAfterPrint,
58
- removeAfterPrint: true,
53
+ preserveAfterPrint: false,
54
+ onPrintError: (_, error) =>
55
+ showSnackbar({
56
+ title: t('errorPrintingInvoice', 'Error printing invoice'),
57
+ kind: 'error',
58
+ subtitle: error.message,
59
+ }),
59
60
  });
60
61
 
61
62
  useEffect(() => {
@@ -64,11 +65,14 @@ const Invoice: React.FC = () => {
64
65
  }
65
66
  }, [isPrinting]);
66
67
 
67
- useEffect(() => {
68
- const unPaidLineItems = bill?.lineItems?.filter((item) => item.paymentStatus === 'PENDING') ?? [];
69
- setSelectedLineItems(unPaidLineItems);
70
- }, [bill?.lineItems]);
71
-
68
+ // Do not remove this comment. Adds the translation keys for the invoice details
69
+ /**
70
+ * t('totalAmount', 'Total Amount')
71
+ * t('amountTendered', 'Amount Tendered')
72
+ * t('invoiceNumber', 'Invoice Number')
73
+ * t('dateAndTime', 'Date And Time')
74
+ * t('invoiceStatus', 'Invoice Status')
75
+ */
72
76
  const invoiceDetails = {
73
77
  'Total Amount': convertToCurrency(bill?.totalAmount, defaultCurrency),
74
78
  'Amount Tendered': convertToCurrency(bill?.tenderedAmount, defaultCurrency),
@@ -77,14 +81,14 @@ const Invoice: React.FC = () => {
77
81
  'Invoice Status': bill?.status,
78
82
  };
79
83
 
80
- if (isLoadingPatient && isLoadingBill) {
84
+ if (isLoadingPatient || isLoadingBill) {
81
85
  return (
82
86
  <div className={styles.invoiceContainer}>
83
87
  <InlineLoading
84
88
  className={styles.loader}
85
89
  status="active"
86
90
  iconDescription="Loading"
87
- description="Loading patient header..."
91
+ description={t('loadingBillInfo', 'Loading bill information...')}
88
92
  />
89
93
  </div>
90
94
  );
@@ -109,7 +113,7 @@ const Invoice: React.FC = () => {
109
113
  </section>
110
114
  <div>
111
115
  <Button
112
- disabled={isPrinting}
116
+ disabled={isPrinting || isLoadingPatient || isLoadingBill}
113
117
  onClick={handlePrint}
114
118
  renderIcon={(props) => <Printer size={24} {...props} />}
115
119
  iconDescription="Print bill"
@@ -120,20 +124,23 @@ const Invoice: React.FC = () => {
120
124
  </div>
121
125
  </div>
122
126
 
123
- <InvoiceTable bill={bill} isLoadingBill={isLoadingBill} onSelectItem={handleSelectItem} />
124
- <Payments bill={bill} mutate={mutate} selectedLineItems={selectedLineItems} />
127
+ <InvoiceTable bill={bill} isLoadingBill={isLoadingBill} />
128
+ <Payments bill={bill} mutate={mutate} />
125
129
 
126
- <div className={styles.printContainer} ref={componentRef}>
127
- {isPrinting && <PrintableInvoice bill={bill} patient={patient} isLoading={isLoadingPatient} />}
128
- </div>
130
+ {bill && patient && (
131
+ <div className={styles.printContainer}>
132
+ <PrintableInvoice bill={bill} patient={patient} defaultFacility={data} componentRef={componentRef} />
133
+ </div>
134
+ )}
129
135
  </div>
130
136
  );
131
137
  };
132
138
 
133
139
  function InvoiceDetails({ label, value }: InvoiceDetailsProps) {
140
+ const { t } = useTranslation();
134
141
  return (
135
142
  <div>
136
- <h1 className={styles.label}>{label}</h1>
143
+ <h1 className={styles.label}>{t(label)}</h1>
137
144
  <span className={styles.value}>{value}</span>
138
145
  </div>
139
146
  );
@@ -78,16 +78,19 @@
78
78
  color: colors.$cool-gray-90;
79
79
  }
80
80
 
81
- @media screen {
82
- .printContainer {
83
- background-color: colors.$white;
84
- display: none;
81
+ .printContainer {
82
+ background-color: colors.$white;
83
+ display: none;
84
+
85
+ @media print {
86
+ display: block !important;
85
87
  }
86
88
  }
87
89
 
88
90
  @media print {
89
91
  html,
90
92
  body {
93
+ display: block !important;
91
94
  background-color: colors.$white !important;
92
95
  }
93
96
  }