@openmrs/esm-billing-app 1.1.2-pre.8 → 1.2.0
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/.turbo/cache/31f1dfc7f71601df-meta.json +1 -0
- package/.turbo/cache/31f1dfc7f71601df.tar.zst +0 -0
- package/.turbo/turbo-build.log +13 -42
- package/__mocks__/bills.mock.ts +3 -2
- package/dist/1480.js +1 -0
- package/dist/1480.js.map +1 -0
- package/dist/1564.js +1 -0
- package/dist/1564.js.map +1 -0
- package/dist/1578.js +1 -0
- package/dist/1578.js.map +1 -0
- package/dist/1646.js +1 -0
- package/dist/1646.js.map +1 -0
- package/dist/1869.js +1 -0
- package/dist/1869.js.map +1 -0
- package/dist/1877.js +1 -0
- package/dist/1877.js.map +1 -0
- package/dist/1899.js +1 -0
- package/dist/1899.js.map +1 -0
- package/dist/196.js +2 -0
- package/dist/196.js.map +1 -0
- package/dist/2250.js +43 -0
- package/dist/2250.js.map +1 -0
- package/dist/2269.js +1 -0
- package/dist/2269.js.map +1 -0
- package/dist/2317.js +1 -0
- package/dist/2317.js.map +1 -0
- package/dist/2416.js +1 -0
- package/dist/2416.js.map +1 -0
- package/dist/2489.js +1 -0
- package/dist/2489.js.map +1 -0
- package/dist/282.js +1 -0
- package/dist/282.js.map +1 -0
- package/dist/2881.js +1 -0
- package/dist/2881.js.map +1 -0
- package/dist/2997.js +1 -0
- package/dist/2997.js.map +1 -0
- package/dist/3378.js +1 -0
- package/dist/3378.js.map +1 -0
- package/dist/3379.js +1 -0
- package/dist/3379.js.map +1 -0
- package/dist/3784.js +1 -0
- package/dist/3784.js.map +1 -0
- package/dist/3963.js +1 -0
- package/dist/3963.js.map +1 -0
- package/dist/4106.js +1 -0
- package/dist/4106.js.map +1 -0
- package/dist/4111.js +1 -0
- package/dist/4111.js.map +1 -0
- package/dist/434.js +1 -0
- package/dist/434.js.map +1 -0
- package/dist/4348.js +1 -0
- package/dist/4348.js.map +1 -0
- package/dist/4383.js +1 -0
- package/dist/4383.js.map +1 -0
- package/dist/4658.js +1 -0
- package/dist/4658.js.map +1 -0
- package/dist/4870.js +1 -0
- package/dist/4870.js.map +1 -0
- package/dist/4928.js +1 -0
- package/dist/4928.js.map +1 -0
- package/dist/5098.js +1 -0
- package/dist/5098.js.map +1 -0
- package/dist/5117.js +1 -0
- package/dist/5117.js.map +1 -0
- package/dist/5132.js +1 -0
- package/dist/5132.js.map +1 -0
- package/dist/5145.js +1 -0
- package/dist/5145.js.map +1 -0
- package/dist/5390.js +1 -0
- package/dist/5390.js.map +1 -0
- package/dist/5503.js +1 -0
- package/dist/5503.js.map +1 -0
- package/dist/556.js +1 -0
- package/dist/556.js.map +1 -0
- package/dist/5644.js +1 -0
- package/dist/5644.js.map +1 -0
- package/dist/5898.js +1 -0
- package/dist/5898.js.map +1 -0
- package/dist/5940.js +1 -0
- package/dist/5940.js.map +1 -0
- package/dist/6047.js +1 -0
- package/dist/6047.js.map +1 -0
- package/dist/6237.js +1 -0
- package/dist/6237.js.map +1 -0
- package/dist/6362.js +1 -0
- package/dist/6362.js.map +1 -0
- package/dist/6371.js +1 -0
- package/dist/6371.js.map +1 -0
- package/dist/6377.js +1 -0
- package/dist/6377.js.map +1 -0
- package/dist/6444.js +1 -0
- package/dist/6444.js.map +1 -0
- package/dist/6508.js +1 -0
- package/dist/6508.js.map +1 -0
- package/dist/6594.js +1 -0
- package/dist/6594.js.map +1 -0
- package/dist/6724.js +1 -0
- package/dist/6724.js.map +1 -0
- package/dist/6904.js +1 -0
- package/dist/6904.js.map +1 -0
- package/dist/7045.js +1 -0
- package/dist/7045.js.map +1 -0
- package/dist/7175.js +1 -0
- package/dist/7175.js.map +1 -0
- package/dist/7182.js +1 -0
- package/dist/7182.js.map +1 -0
- package/dist/7247.js +1 -0
- package/dist/7247.js.map +1 -0
- package/dist/7742.js +1 -0
- package/dist/7742.js.map +1 -0
- package/dist/7912.js +1 -0
- package/dist/7912.js.map +1 -0
- package/dist/8358.js +1 -0
- package/dist/8358.js.map +1 -0
- package/dist/8359.js +1 -0
- package/dist/8359.js.map +1 -0
- package/dist/8695.js +1 -0
- package/dist/8695.js.map +1 -0
- package/dist/903.js +1 -0
- package/dist/903.js.map +1 -0
- package/dist/9072.js +1 -0
- package/dist/9072.js.map +1 -0
- package/dist/9414.js +1 -0
- package/dist/9414.js.map +1 -0
- package/dist/9655.js +11 -0
- package/dist/9655.js.map +1 -0
- package/dist/9806.js +1 -0
- package/dist/9806.js.map +1 -0
- package/dist/990.js +1 -0
- package/dist/990.js.map +1 -0
- package/dist/main.js +17 -2
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-billing-app.js +6 -1
- package/dist/openmrs-esm-billing-app.js.buildmanifest.json +643 -436
- package/dist/openmrs-esm-billing-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/e2e/commands/billing-operations.ts +21 -0
- package/e2e/commands/types.ts +9 -1
- package/e2e/pages/discounts-page.ts +75 -0
- package/e2e/pages/index.ts +1 -0
- package/e2e/pages/invoice-page.ts +7 -7
- package/e2e/specs/bill-discounts.spec.ts +255 -0
- package/e2e/specs/billing-dashboard.spec.ts +3 -3
- package/e2e/specs/billing-patient-chart.spec.ts +2 -2
- package/package.json +13 -22
- package/rspack.config.js +1 -0
- package/src/bill-history/bill-action-menu.component.tsx +20 -2
- package/src/bill-history/bill-history.test.tsx +23 -22
- package/src/bill-item-actions/edit-bill-item.modal.tsx +1 -1
- package/src/bill-item-actions/edit-bill-item.test.tsx +29 -27
- package/src/billable-services/billable-service-form/billable-service-form.test.tsx +74 -73
- package/src/billable-services/billable-services-home.component.tsx +4 -2
- package/src/billable-services/billable-services.test.tsx +8 -7
- package/src/billable-services/dashboard/dashboard.test.tsx +3 -2
- package/src/billable-services-admin-card-link.test.tsx +2 -1
- package/src/billing-dashboard/billing-dashboard.test.tsx +19 -3
- package/src/billing-form/billing-checkin-form.component.tsx +7 -3
- package/src/billing-form/billing-checkin-form.test.tsx +22 -21
- package/src/billing-form/billing-form.resource.test.ts +7 -6
- package/src/billing-form/billing-form.test.tsx +77 -40
- package/src/billing-form/billing-form.workspace.tsx +25 -6
- package/src/billing-form/visit-attributes/visit-attributes-form.component.tsx +6 -2
- package/src/billing.resource.test.ts +43 -41
- package/src/billing.resource.ts +65 -16
- package/src/bills-table/bills-table.component.tsx +15 -4
- package/src/bills-table/bills-table.test.tsx +72 -71
- package/src/config-schema.ts +0 -7
- package/src/discounts/admin/discount-requests-left-panel-link.component.tsx +43 -0
- package/src/discounts/admin/discount-requests.component.tsx +316 -0
- package/src/discounts/admin/discount-requests.scss +133 -0
- package/src/discounts/admin/discount-requests.test.tsx +104 -0
- package/src/discounts/admin/review-bill-discounts/bill-line-items-table/bill-line-items-table.component.tsx +42 -0
- package/src/discounts/admin/review-bill-discounts/bill-line-items-table/bill-line-items-table.scss +76 -0
- package/src/discounts/admin/review-bill-discounts/bill-payments-table/bill-payments-table.component.tsx +50 -0
- package/src/discounts/admin/review-bill-discounts/bill-payments-table/bill-payments-table.scss +63 -0
- package/src/discounts/admin/review-bill-discounts/bill-receipt-rail/bill-receipt-rail.component.tsx +73 -0
- package/src/discounts/admin/review-bill-discounts/bill-receipt-rail/bill-receipt-rail.scss +54 -0
- package/src/discounts/admin/review-bill-discounts/bill-totals-summary/bill-totals-summary.component.tsx +95 -0
- package/src/discounts/admin/review-bill-discounts/bill-totals-summary/bill-totals-summary.scss +128 -0
- package/src/discounts/admin/review-bill-discounts/discount-card/discount-card.component.tsx +158 -0
- package/src/discounts/admin/review-bill-discounts/discount-card/discount-card.scss +164 -0
- package/src/discounts/admin/review-bill-discounts/discount-review-stack/discount-review-stack.component.tsx +86 -0
- package/src/discounts/admin/review-bill-discounts/discount-review-stack/discount-review-stack.scss +40 -0
- package/src/discounts/admin/review-bill-discounts/review-bill-discounts.modal.scss +14 -0
- package/src/discounts/admin/review-bill-discounts/review-bill-discounts.modal.test.tsx +153 -0
- package/src/discounts/admin/review-bill-discounts/review-bill-discounts.modal.tsx +167 -0
- package/src/discounts/admin/review-bill-discounts/review-bill-discounts.utils.ts +42 -0
- package/src/discounts/discounts-table.component.tsx +109 -0
- package/src/discounts/discounts-table.scss +37 -0
- package/src/discounts/discounts-table.test.tsx +67 -0
- package/src/discounts/discounts.resource.ts +71 -0
- package/src/discounts/request-discount.modal.scss +88 -0
- package/src/discounts/request-discount.modal.test.tsx +161 -0
- package/src/discounts/request-discount.modal.tsx +253 -0
- package/src/index.ts +52 -21
- package/src/invoice/invoice-table.component.tsx +116 -18
- package/src/invoice/invoice-table.test.tsx +165 -13
- package/src/invoice/invoice.component.tsx +111 -7
- package/src/invoice/invoice.test.tsx +366 -66
- package/src/invoice/line-item-action-menu.component.tsx +31 -1
- package/src/invoice/payments/payment-form/payment-form.test.tsx +20 -19
- package/src/invoice/payments/payment-history/payment-history.test.tsx +13 -10
- package/src/invoice/payments/payments.component.tsx +20 -6
- package/src/invoice/payments/payments.test.tsx +88 -23
- package/src/invoice/printable-invoice/print-receipt.test.tsx +10 -28
- package/src/invoice/printable-invoice/printable-footer.test.tsx +5 -4
- package/src/invoice/printable-invoice/printable-invoice-header.component.tsx +3 -3
- package/src/invoice/printable-invoice/printable-invoice-header.test.tsx +26 -11
- package/src/invoice/printable-invoice/printable-invoice.component.tsx +38 -15
- package/src/left-panel-link.test.tsx +3 -3
- package/src/metrics-cards/metrics-cards.test.tsx +11 -10
- package/src/modal/delete-bill-confirmation.modal.test.tsx +134 -0
- package/src/modal/delete-bill-confirmation.modal.tsx +98 -0
- package/src/modal/delete-line-item-confirmation.modal.test.tsx +11 -9
- package/src/modal/finalize-bill-confirmation.modal.test.tsx +10 -8
- package/src/modal/require-payment-modal.test.tsx +12 -11
- package/src/payment-status-tag/payment-status-tag.component.tsx +50 -0
- package/src/payment-status-tag/payment-status-tag.scss +6 -0
- package/src/payment-status-tag/payment-status-tag.test.tsx +113 -0
- package/src/refunds/admin/refund-requests-left-panel-link.component.tsx +43 -0
- package/src/refunds/admin/refund-requests.component.tsx +324 -0
- package/src/refunds/admin/refund-requests.scss +133 -0
- package/src/refunds/admin/refund-requests.test.tsx +99 -0
- package/src/refunds/admin/review-bill-refunds/bill-line-items-table/bill-line-items-table.component.tsx +42 -0
- package/src/refunds/admin/review-bill-refunds/bill-line-items-table/bill-line-items-table.scss +76 -0
- package/src/refunds/admin/review-bill-refunds/bill-payments-table/bill-payments-table.component.tsx +50 -0
- package/src/refunds/admin/review-bill-refunds/bill-payments-table/bill-payments-table.scss +63 -0
- package/src/refunds/admin/review-bill-refunds/bill-receipt-rail/bill-receipt-rail.component.tsx +84 -0
- package/src/refunds/admin/review-bill-refunds/bill-receipt-rail/bill-receipt-rail.scss +54 -0
- package/src/refunds/admin/review-bill-refunds/bill-totals-summary/bill-totals-summary.component.tsx +83 -0
- package/src/refunds/admin/review-bill-refunds/bill-totals-summary/bill-totals-summary.scss +65 -0
- package/src/refunds/admin/review-bill-refunds/refund-card/refund-card.component.tsx +170 -0
- package/src/refunds/admin/review-bill-refunds/refund-card/refund-card.scss +155 -0
- package/src/refunds/admin/review-bill-refunds/refund-review-stack/refund-review-stack.component.tsx +86 -0
- package/src/refunds/admin/review-bill-refunds/refund-review-stack/refund-review-stack.scss +40 -0
- package/src/refunds/admin/review-bill-refunds/review-bill-refunds.modal.scss +14 -0
- package/src/refunds/admin/review-bill-refunds/review-bill-refunds.modal.test.tsx +313 -0
- package/src/refunds/admin/review-bill-refunds/review-bill-refunds.modal.tsx +188 -0
- package/src/refunds/admin/review-bill-refunds/review-bill-refunds.utils.ts +66 -0
- package/src/refunds/refunds-table.component.tsx +137 -0
- package/src/refunds/refunds-table.scss +37 -0
- package/src/refunds/refunds-table.test.tsx +105 -0
- package/src/refunds/refunds.resource.test.ts +44 -0
- package/src/refunds/refunds.resource.ts +42 -0
- package/src/refunds/refunds.types.test.ts +15 -0
- package/src/refunds/request-refund.modal.scss +84 -0
- package/src/refunds/request-refund.modal.test.tsx +204 -0
- package/src/refunds/request-refund.modal.tsx +218 -0
- package/src/routes.json +36 -2
- package/src/types/index.ts +116 -1
- package/src/visit-bills/visit-bills-panel.component.tsx +151 -0
- package/src/visit-bills/visit-bills-panel.scss +31 -0
- package/src/visit-bills/visit-bills-panel.test.tsx +113 -0
- package/tools/empty-module.ts +1 -0
- package/tools/setup-tests.ts +9 -9
- package/translations/am.json +154 -16
- package/translations/ar.json +154 -16
- package/translations/ar_SY.json +154 -16
- package/translations/bn.json +154 -16
- package/translations/cs.json +154 -16
- package/translations/de.json +154 -16
- package/translations/en.json +154 -16
- package/translations/en_US.json +154 -16
- package/translations/es.json +154 -16
- package/translations/es_MX.json +154 -16
- package/translations/fr.json +154 -16
- package/translations/he.json +154 -16
- package/translations/hi.json +154 -16
- package/translations/hi_IN.json +154 -16
- package/translations/id.json +154 -16
- package/translations/it.json +154 -16
- package/translations/ka.json +154 -16
- package/translations/km.json +154 -16
- package/translations/ku.json +154 -16
- package/translations/ky.json +154 -16
- package/translations/lg.json +154 -16
- package/translations/ne.json +154 -16
- package/translations/pl.json +154 -16
- package/translations/pt.json +154 -16
- package/translations/pt_BR.json +154 -16
- package/translations/qu.json +154 -16
- package/translations/ro_RO.json +154 -16
- package/translations/ru_RU.json +154 -16
- package/translations/si.json +154 -16
- package/translations/sq.json +154 -16
- package/translations/sw.json +154 -16
- package/translations/sw_KE.json +154 -16
- package/translations/tr.json +154 -16
- package/translations/tr_TR.json +154 -16
- package/translations/uk.json +154 -16
- package/translations/uz.json +154 -16
- package/translations/uz@Latn.json +154 -16
- package/translations/uz_UZ.json +154 -16
- package/translations/vi.json +154 -16
- package/translations/zh.json +154 -16
- package/translations/zh_CN.json +179 -41
- package/translations/zh_TW.json +154 -16
- package/tsconfig.json +3 -3
- package/vitest.config.js +28 -0
- package/.turbo/cache/6c998b0f30a031ab-meta.json +0 -1
- package/.turbo/cache/6c998b0f30a031ab.tar.zst +0 -0
- package/dist/1119.js +0 -1
- package/dist/1197.js +0 -1
- package/dist/1435.js +0 -1
- package/dist/1435.js.map +0 -1
- package/dist/1807.js +0 -1
- package/dist/1807.js.map +0 -1
- package/dist/2146.js +0 -1
- package/dist/2177.js +0 -2
- package/dist/2177.js.LICENSE.txt +0 -9
- package/dist/2177.js.map +0 -1
- package/dist/2690.js +0 -1
- package/dist/2704.js +0 -1
- package/dist/2704.js.map +0 -1
- package/dist/3002.js +0 -1
- package/dist/3002.js.map +0 -1
- package/dist/3041.js +0 -1
- package/dist/3041.js.map +0 -1
- package/dist/3099.js +0 -1
- package/dist/3184.js +0 -2
- package/dist/3184.js.LICENSE.txt +0 -14
- package/dist/3184.js.map +0 -1
- package/dist/3584.js +0 -1
- package/dist/4055.js +0 -1
- package/dist/4132.js +0 -1
- package/dist/4225.js +0 -1
- package/dist/4225.js.map +0 -1
- package/dist/4300.js +0 -1
- package/dist/4335.js +0 -1
- package/dist/439.js +0 -1
- package/dist/4618.js +0 -1
- package/dist/4652.js +0 -1
- package/dist/4944.js +0 -1
- package/dist/5173.js +0 -1
- package/dist/5241.js +0 -1
- package/dist/5422.js +0 -1
- package/dist/5422.js.map +0 -1
- package/dist/5442.js +0 -1
- package/dist/5661.js +0 -1
- package/dist/6022.js +0 -1
- package/dist/6404.js +0 -1
- package/dist/6404.js.map +0 -1
- package/dist/6468.js +0 -1
- package/dist/6540.js +0 -2
- package/dist/6540.js.LICENSE.txt +0 -9
- package/dist/6540.js.map +0 -1
- package/dist/6589.js +0 -1
- package/dist/6606.js +0 -1
- package/dist/6606.js.map +0 -1
- package/dist/6679.js +0 -1
- package/dist/6792.js +0 -1
- package/dist/6792.js.map +0 -1
- package/dist/6840.js +0 -1
- package/dist/6859.js +0 -1
- package/dist/7097.js +0 -1
- package/dist/7159.js +0 -1
- package/dist/723.js +0 -1
- package/dist/7255.js +0 -1
- package/dist/7255.js.map +0 -1
- package/dist/7617.js +0 -1
- package/dist/795.js +0 -1
- package/dist/8163.js +0 -1
- package/dist/8341.js +0 -2
- package/dist/8341.js.LICENSE.txt +0 -52
- package/dist/8341.js.map +0 -1
- package/dist/8349.js +0 -1
- package/dist/8371.js +0 -1
- package/dist/8421.js +0 -1
- package/dist/8421.js.map +0 -1
- package/dist/8618.js +0 -1
- package/dist/890.js +0 -1
- package/dist/9214.js +0 -1
- package/dist/9538.js +0 -1
- package/dist/9569.js +0 -1
- package/dist/961.js +0 -2
- package/dist/961.js.LICENSE.txt +0 -19
- package/dist/961.js.map +0 -1
- package/dist/986.js +0 -1
- package/dist/9879.js +0 -1
- package/dist/9895.js +0 -1
- package/dist/9900.js +0 -1
- package/dist/9913.js +0 -1
- package/dist/main.js.LICENSE.txt +0 -62
- package/src/billable-services/bill-waiver/bill-selection.component.tsx +0 -76
- package/src/billable-services/bill-waiver/bill-waiver-form.component.tsx +0 -107
- package/src/billable-services/bill-waiver/bill-waiver-form.scss +0 -34
- package/src/billable-services/bill-waiver/bill-waiver.component.tsx +0 -34
- package/src/billable-services/bill-waiver/bill-waiver.scss +0 -10
- package/src/billable-services/bill-waiver/patient-bills.component.tsx +0 -134
- package/webpack.config.js +0 -1
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import {
|
|
4
|
+
DataTable,
|
|
5
|
+
DataTableSkeleton,
|
|
6
|
+
Dropdown,
|
|
7
|
+
InlineLoading,
|
|
8
|
+
Layer,
|
|
9
|
+
Link,
|
|
10
|
+
Pagination,
|
|
11
|
+
Search,
|
|
12
|
+
Table,
|
|
13
|
+
TableBody,
|
|
14
|
+
TableCell,
|
|
15
|
+
TableContainer,
|
|
16
|
+
TableHead,
|
|
17
|
+
TableHeader,
|
|
18
|
+
TableRow,
|
|
19
|
+
Tile,
|
|
20
|
+
} from '@carbon/react';
|
|
21
|
+
import { useTranslation } from 'react-i18next';
|
|
22
|
+
import {
|
|
23
|
+
EmptyCardIllustration,
|
|
24
|
+
ErrorState,
|
|
25
|
+
formatDate,
|
|
26
|
+
isDesktop,
|
|
27
|
+
parseDate,
|
|
28
|
+
showModal,
|
|
29
|
+
useConfig,
|
|
30
|
+
useLayoutType,
|
|
31
|
+
usePagination,
|
|
32
|
+
usePaginationInfo,
|
|
33
|
+
type LayoutType,
|
|
34
|
+
} from '@openmrs/esm-framework';
|
|
35
|
+
import { convertToCurrency } from '../../helpers';
|
|
36
|
+
import { useDiscountRequests } from '../discounts.resource';
|
|
37
|
+
import type { BillingConfig } from '../../config-schema';
|
|
38
|
+
import { BillDiscountStatus, type PatientInvoice } from '../../types';
|
|
39
|
+
import styles from './discount-requests.scss';
|
|
40
|
+
|
|
41
|
+
type FilterValue = 'PENDING' | 'APPROVED' | 'REJECTED' | 'ALL';
|
|
42
|
+
|
|
43
|
+
interface DiscountStatusFilterItem {
|
|
44
|
+
id: FilterValue;
|
|
45
|
+
text: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const filterToStatuses = (value: FilterValue): BillDiscountStatus[] => {
|
|
49
|
+
if (value === 'ALL') {
|
|
50
|
+
return [BillDiscountStatus.PENDING, BillDiscountStatus.APPROVED, BillDiscountStatus.REJECTED];
|
|
51
|
+
}
|
|
52
|
+
return [value as BillDiscountStatus];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const DiscountRequests: React.FC = () => {
|
|
56
|
+
const { t } = useTranslation();
|
|
57
|
+
const { defaultCurrency, pageSize: configuredPageSize } = useConfig<BillingConfig>();
|
|
58
|
+
const layout = useLayoutType();
|
|
59
|
+
const responsiveSize = isDesktop(layout) ? 'sm' : 'lg';
|
|
60
|
+
|
|
61
|
+
const filterItems: DiscountStatusFilterItem[] = useMemo(
|
|
62
|
+
() => [
|
|
63
|
+
{ id: 'PENDING', text: t('pending', 'Pending') },
|
|
64
|
+
{ id: 'APPROVED', text: t('approved', 'Approved') },
|
|
65
|
+
{ id: 'REJECTED', text: t('rejected', 'Rejected') },
|
|
66
|
+
{ id: 'ALL', text: t('all', 'All') },
|
|
67
|
+
],
|
|
68
|
+
[t],
|
|
69
|
+
);
|
|
70
|
+
const [filter, setFilter] = useState<DiscountStatusFilterItem>(filterItems[0]);
|
|
71
|
+
const [currentPageSize, setCurrentPageSize] = useState(configuredPageSize ?? 10);
|
|
72
|
+
const [searchString, setSearchString] = useState('');
|
|
73
|
+
|
|
74
|
+
const { bills, isLoading, error, mutate, isValidating } = useDiscountRequests({
|
|
75
|
+
statuses: filterToStatuses(filter.id),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const filteredBills = useMemo(() => {
|
|
79
|
+
const q = searchString.trim().toLowerCase();
|
|
80
|
+
if (!q) return bills;
|
|
81
|
+
return bills.filter(
|
|
82
|
+
(b) => b.patient?.display?.toLowerCase().includes(q) || b.receiptNumber?.toLowerCase().includes(q),
|
|
83
|
+
);
|
|
84
|
+
}, [bills, searchString]);
|
|
85
|
+
|
|
86
|
+
const { paginated, goTo, results: paginatedBills, currentPage } = usePagination(filteredBills, currentPageSize);
|
|
87
|
+
const { pageSizes } = usePaginationInfo(currentPageSize, filteredBills.length, currentPage, paginatedBills.length);
|
|
88
|
+
|
|
89
|
+
const headers = useMemo(
|
|
90
|
+
() => [
|
|
91
|
+
{ key: 'dateCreated', header: t('date', 'Date') },
|
|
92
|
+
{ key: 'receiptNumber', header: t('invoiceNo', 'Invoice #') },
|
|
93
|
+
{ key: 'patient', header: t('patient', 'Patient') },
|
|
94
|
+
{ key: 'billAmount', header: t('billAmount', 'Bill amount') },
|
|
95
|
+
{ key: 'cashier', header: t('cashier', 'Cashier') },
|
|
96
|
+
],
|
|
97
|
+
[t],
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const handleRowClick = useCallback(
|
|
101
|
+
(bill: PatientInvoice) => {
|
|
102
|
+
const dispose = showModal('review-bill-discounts-modal', {
|
|
103
|
+
bill,
|
|
104
|
+
onMutate: mutate,
|
|
105
|
+
closeModal: () => dispose(),
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
[mutate],
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const rows = useMemo(
|
|
112
|
+
() =>
|
|
113
|
+
paginatedBills.map((bill: PatientInvoice) => ({
|
|
114
|
+
id: bill.uuid,
|
|
115
|
+
dateCreated: bill.dateCreated ? formatDate(parseDate(bill.dateCreated), { mode: 'wide' }) : '--',
|
|
116
|
+
patient: bill.patient?.display ?? '--',
|
|
117
|
+
receiptNumber: bill.receiptNumber ? (
|
|
118
|
+
<Link
|
|
119
|
+
href="#"
|
|
120
|
+
onClick={(e) => {
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
e.stopPropagation();
|
|
123
|
+
handleRowClick(bill);
|
|
124
|
+
}}>
|
|
125
|
+
{bill.receiptNumber}
|
|
126
|
+
</Link>
|
|
127
|
+
) : (
|
|
128
|
+
'--'
|
|
129
|
+
),
|
|
130
|
+
billAmount: convertToCurrency(bill.total ?? 0, defaultCurrency),
|
|
131
|
+
cashier: bill.cashier?.display ?? '--',
|
|
132
|
+
_raw: bill,
|
|
133
|
+
})),
|
|
134
|
+
[paginatedBills, defaultCurrency, handleRowClick],
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const handleSearch = useCallback(
|
|
138
|
+
(e) => {
|
|
139
|
+
setSearchString(e.target.value);
|
|
140
|
+
goTo(1);
|
|
141
|
+
},
|
|
142
|
+
[goTo],
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<main className={styles.container}>
|
|
147
|
+
<main className={styles.servicesTableContainer}>
|
|
148
|
+
<div className={styles.filterContainer}>
|
|
149
|
+
<Dropdown
|
|
150
|
+
className={styles.filterDropdown}
|
|
151
|
+
direction="bottom"
|
|
152
|
+
id="discount-status-filter"
|
|
153
|
+
selectedItem={filter}
|
|
154
|
+
items={filterItems}
|
|
155
|
+
itemToString={(item: DiscountStatusFilterItem) => (item ? item.text : '')}
|
|
156
|
+
label=""
|
|
157
|
+
onChange={({ selectedItem }: { selectedItem: DiscountStatusFilterItem }) => {
|
|
158
|
+
setFilter(selectedItem);
|
|
159
|
+
goTo(1);
|
|
160
|
+
}}
|
|
161
|
+
size={responsiveSize}
|
|
162
|
+
titleText={t('filterBy', 'Filter by:')}
|
|
163
|
+
type="inline"
|
|
164
|
+
/>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<div className={styles.billListContainer}>
|
|
168
|
+
<FilterableTableHeader
|
|
169
|
+
handleSearch={handleSearch}
|
|
170
|
+
isValidating={isValidating}
|
|
171
|
+
layout={layout}
|
|
172
|
+
responsiveSize={responsiveSize}
|
|
173
|
+
searchString={searchString}
|
|
174
|
+
t={t}
|
|
175
|
+
/>
|
|
176
|
+
{isLoading && !bills?.length ? (
|
|
177
|
+
<div className={styles.loaderContainer} role="progressbar" aria-label={t('loadingDescription', 'Loading')}>
|
|
178
|
+
<DataTableSkeleton
|
|
179
|
+
rowCount={currentPageSize}
|
|
180
|
+
showHeader={false}
|
|
181
|
+
showToolbar={false}
|
|
182
|
+
zebra
|
|
183
|
+
columnCount={headers.length}
|
|
184
|
+
/>
|
|
185
|
+
</div>
|
|
186
|
+
) : error ? (
|
|
187
|
+
<div className={styles.errorContainer}>
|
|
188
|
+
<Layer>
|
|
189
|
+
<ErrorState error={error} headerTitle={t('discountRequests', 'Discount requests')} />
|
|
190
|
+
</Layer>
|
|
191
|
+
</div>
|
|
192
|
+
) : rows.length > 0 ? (
|
|
193
|
+
<>
|
|
194
|
+
<DataTable
|
|
195
|
+
isSortable
|
|
196
|
+
rows={rows}
|
|
197
|
+
headers={headers}
|
|
198
|
+
size={responsiveSize}
|
|
199
|
+
useZebraStyles={rows.length > 1}>
|
|
200
|
+
{({ rows: dataRows, headers: dataHeaders, getRowProps, getTableProps }) => (
|
|
201
|
+
<TableContainer>
|
|
202
|
+
<Table {...getTableProps()} aria-label={t('discountRequests', 'Discount requests')}>
|
|
203
|
+
<TableHead>
|
|
204
|
+
<TableRow>
|
|
205
|
+
{dataHeaders.map((header) => (
|
|
206
|
+
<TableHeader key={header.key}>{header.header}</TableHeader>
|
|
207
|
+
))}
|
|
208
|
+
</TableRow>
|
|
209
|
+
</TableHead>
|
|
210
|
+
<TableBody>
|
|
211
|
+
{dataRows.map((row) => (
|
|
212
|
+
<TableRow
|
|
213
|
+
key={row.id}
|
|
214
|
+
{...getRowProps({ row })}
|
|
215
|
+
className={styles.row}
|
|
216
|
+
onClick={() => {
|
|
217
|
+
const match = rows.find((r) => r.id === row.id);
|
|
218
|
+
if (match) handleRowClick(match._raw);
|
|
219
|
+
}}>
|
|
220
|
+
{row.cells.map((cell) => (
|
|
221
|
+
<TableCell key={cell.id}>{cell.value}</TableCell>
|
|
222
|
+
))}
|
|
223
|
+
</TableRow>
|
|
224
|
+
))}
|
|
225
|
+
</TableBody>
|
|
226
|
+
</Table>
|
|
227
|
+
</TableContainer>
|
|
228
|
+
)}
|
|
229
|
+
</DataTable>
|
|
230
|
+
{paginated && (
|
|
231
|
+
<Pagination
|
|
232
|
+
forwardText={t('nextPage', 'Next page')}
|
|
233
|
+
backwardText={t('previousPage', 'Previous page')}
|
|
234
|
+
page={currentPage}
|
|
235
|
+
pageSize={currentPageSize}
|
|
236
|
+
pageSizes={pageSizes}
|
|
237
|
+
totalItems={filteredBills.length}
|
|
238
|
+
size={responsiveSize}
|
|
239
|
+
onChange={({ pageSize: newPageSize, page: newPage }) => {
|
|
240
|
+
if (newPageSize !== currentPageSize) {
|
|
241
|
+
setCurrentPageSize(newPageSize);
|
|
242
|
+
}
|
|
243
|
+
if (newPage !== currentPage) {
|
|
244
|
+
goTo(newPage);
|
|
245
|
+
}
|
|
246
|
+
}}
|
|
247
|
+
/>
|
|
248
|
+
)}
|
|
249
|
+
</>
|
|
250
|
+
) : (
|
|
251
|
+
<Layer className={styles.emptyStateContainer}>
|
|
252
|
+
<Tile className={styles.tile}>
|
|
253
|
+
<div className={styles.illo}>
|
|
254
|
+
<EmptyCardIllustration />
|
|
255
|
+
</div>
|
|
256
|
+
<p className={styles.content}>
|
|
257
|
+
{t('noDiscountRequestsToDisplay', 'There are no discount requests to display.')}
|
|
258
|
+
</p>
|
|
259
|
+
</Tile>
|
|
260
|
+
</Layer>
|
|
261
|
+
)}
|
|
262
|
+
</div>
|
|
263
|
+
</main>
|
|
264
|
+
</main>
|
|
265
|
+
);
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
interface FilterableTableHeaderProps {
|
|
269
|
+
layout: LayoutType;
|
|
270
|
+
handleSearch: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
271
|
+
isValidating: boolean;
|
|
272
|
+
responsiveSize: 'sm' | 'md' | 'lg';
|
|
273
|
+
searchString: string;
|
|
274
|
+
t: (key: string, fallback: string) => string;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function FilterableTableHeader({
|
|
278
|
+
layout,
|
|
279
|
+
handleSearch,
|
|
280
|
+
isValidating,
|
|
281
|
+
responsiveSize,
|
|
282
|
+
searchString,
|
|
283
|
+
t,
|
|
284
|
+
}: FilterableTableHeaderProps) {
|
|
285
|
+
return (
|
|
286
|
+
<>
|
|
287
|
+
<div className={styles.headerContainer}>
|
|
288
|
+
<div
|
|
289
|
+
className={classNames({
|
|
290
|
+
[styles.tabletHeading]: !isDesktop(layout),
|
|
291
|
+
[styles.desktopHeading]: isDesktop(layout),
|
|
292
|
+
})}>
|
|
293
|
+
<h4>{t('discountRequests', 'Discount requests')}</h4>
|
|
294
|
+
</div>
|
|
295
|
+
{isValidating && (
|
|
296
|
+
<div className={styles.backgroundDataFetchingIndicator}>
|
|
297
|
+
<span>
|
|
298
|
+
<InlineLoading />
|
|
299
|
+
</span>
|
|
300
|
+
</div>
|
|
301
|
+
)}
|
|
302
|
+
</div>
|
|
303
|
+
<Search
|
|
304
|
+
closeButtonLabelText={t('clearSearch', 'Clear')}
|
|
305
|
+
data-testid="discountRequestsSearchBar"
|
|
306
|
+
labelText={t('searchDiscountRequests', 'Search discount requests')}
|
|
307
|
+
placeholder={t('searchByPatientOrBill', 'Search by patient name or bill #')}
|
|
308
|
+
value={searchString}
|
|
309
|
+
onChange={handleSearch}
|
|
310
|
+
size={responsiveSize}
|
|
311
|
+
/>
|
|
312
|
+
</>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export default DiscountRequests;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
@use '@carbon/layout';
|
|
2
|
+
@use '@carbon/type';
|
|
3
|
+
@use '@openmrs/esm-styleguide/src/vars' as *;
|
|
4
|
+
|
|
5
|
+
.container {
|
|
6
|
+
height: calc(100vh - layout.$spacing-09);
|
|
7
|
+
margin: layout.$spacing-05;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.servicesTableContainer {
|
|
11
|
+
margin: layout.$spacing-07 layout.$spacing-05;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.sectionMargin {
|
|
15
|
+
margin: layout.$spacing-07 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.emptyStateContainer,
|
|
19
|
+
.loaderContainer,
|
|
20
|
+
.errorContainer {
|
|
21
|
+
@extend .sectionMargin;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.billListContainer {
|
|
25
|
+
background-color: $ui-02;
|
|
26
|
+
border: 1px solid $ui-03;
|
|
27
|
+
width: 100%;
|
|
28
|
+
margin: 0 auto;
|
|
29
|
+
max-width: 95vw;
|
|
30
|
+
padding-bottom: 0;
|
|
31
|
+
|
|
32
|
+
:has(.filterEmptyState) {
|
|
33
|
+
border-bottom: none;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.filterContainer {
|
|
38
|
+
flex: 1;
|
|
39
|
+
|
|
40
|
+
:global(.cds--dropdown__wrapper--inline) {
|
|
41
|
+
gap: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
:global(.cds--list-box__menu-icon) {
|
|
45
|
+
height: 1rem;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:global(.cds--list-box__menu) {
|
|
49
|
+
min-width: max-content;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
:global(.cds--list-box) {
|
|
53
|
+
margin-left: layout.$spacing-03;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.headerContainer {
|
|
58
|
+
display: flex;
|
|
59
|
+
justify-content: space-between;
|
|
60
|
+
align-items: center;
|
|
61
|
+
padding: layout.$spacing-04 layout.$spacing-05;
|
|
62
|
+
background-color: $ui-02;
|
|
63
|
+
gap: layout.$spacing-05;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.row {
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.statusTags {
|
|
71
|
+
display: inline-flex;
|
|
72
|
+
gap: layout.$spacing-02;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.illo {
|
|
76
|
+
margin-top: layout.$spacing-05;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.content {
|
|
80
|
+
@include type.type-style('heading-compact-01');
|
|
81
|
+
color: $text-02;
|
|
82
|
+
margin-top: layout.$spacing-05;
|
|
83
|
+
margin-bottom: layout.$spacing-03;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.desktopHeading,
|
|
87
|
+
.tabletHeading {
|
|
88
|
+
text-align: left;
|
|
89
|
+
text-transform: capitalize;
|
|
90
|
+
flex: 1;
|
|
91
|
+
|
|
92
|
+
h4 {
|
|
93
|
+
@include type.type-style('heading-compact-02');
|
|
94
|
+
color: $text-02;
|
|
95
|
+
|
|
96
|
+
&:after {
|
|
97
|
+
content: '';
|
|
98
|
+
display: block;
|
|
99
|
+
width: 2rem;
|
|
100
|
+
padding-top: 3px;
|
|
101
|
+
border-bottom: 0.375rem solid;
|
|
102
|
+
@include brand-03(border-bottom-color);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.tile {
|
|
108
|
+
text-align: center;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.filterEmptyState {
|
|
112
|
+
display: flex;
|
|
113
|
+
justify-content: center;
|
|
114
|
+
align-items: center;
|
|
115
|
+
padding: layout.$spacing-05;
|
|
116
|
+
margin: layout.$spacing-09;
|
|
117
|
+
text-align: center;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.filterEmptyStateTile {
|
|
121
|
+
margin: auto;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.filterEmptyStateContent {
|
|
125
|
+
@include type.type-style('heading-compact-02');
|
|
126
|
+
color: $text-02;
|
|
127
|
+
margin-bottom: layout.$spacing-03;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.filterEmptyStateHelper {
|
|
131
|
+
@include type.type-style('body-compact-01');
|
|
132
|
+
color: $text-02;
|
|
133
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { showModal } from '@openmrs/esm-framework';
|
|
6
|
+
import DiscountRequests from './discount-requests.component';
|
|
7
|
+
import { useDiscountRequests } from '../discounts.resource';
|
|
8
|
+
import { BillDiscountStatus } from '../../types';
|
|
9
|
+
|
|
10
|
+
vi.mock('@openmrs/esm-framework', () => ({
|
|
11
|
+
showModal: vi.fn(),
|
|
12
|
+
useConfig: () => ({ defaultCurrency: 'USD', pageSize: 10 }),
|
|
13
|
+
formatDate: () => 'date',
|
|
14
|
+
parseDate: (s: string) => new Date(s),
|
|
15
|
+
restBaseUrl: '/ws/rest/v1',
|
|
16
|
+
useLayoutType: () => 'small-desktop',
|
|
17
|
+
isDesktop: () => true,
|
|
18
|
+
usePagination: <T,>(items: T[]) => ({
|
|
19
|
+
paginated: (items?.length ?? 0) > 10,
|
|
20
|
+
goTo: vi.fn(),
|
|
21
|
+
results: items ?? [],
|
|
22
|
+
currentPage: 1,
|
|
23
|
+
}),
|
|
24
|
+
usePaginationInfo: () => ({ pageSizes: [10, 20, 30, 40, 50] }),
|
|
25
|
+
EmptyCardIllustration: () => null,
|
|
26
|
+
ErrorState: ({ headerTitle }: { headerTitle: string }) => <div>{headerTitle} error</div>,
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
(window as any).i18next = { language: 'en-US' };
|
|
30
|
+
vi.mock('../discounts.resource');
|
|
31
|
+
|
|
32
|
+
const sampleBill = {
|
|
33
|
+
uuid: 'b1',
|
|
34
|
+
receiptNumber: 'INV-1',
|
|
35
|
+
status: 'POSTED',
|
|
36
|
+
total: 5000,
|
|
37
|
+
amountAfterDiscount: 5000,
|
|
38
|
+
dateCreated: '2026-05-11T00:00:00.000+0000',
|
|
39
|
+
patient: { display: '10001V - Jane Doe' },
|
|
40
|
+
cashier: { display: 'cashier' },
|
|
41
|
+
discounts: [{ uuid: 'd1', status: BillDiscountStatus.PENDING, voided: false }],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
beforeEach(() => vi.clearAllMocks());
|
|
45
|
+
|
|
46
|
+
describe('DiscountRequests page', () => {
|
|
47
|
+
it('renders an empty state when no bills match', () => {
|
|
48
|
+
vi.mocked(useDiscountRequests).mockReturnValue({
|
|
49
|
+
bills: [],
|
|
50
|
+
totalCount: 0,
|
|
51
|
+
isLoading: false,
|
|
52
|
+
error: null,
|
|
53
|
+
mutate: vi.fn(),
|
|
54
|
+
} as any);
|
|
55
|
+
render(<DiscountRequests />);
|
|
56
|
+
expect(screen.getByText(/no discount requests to display/i)).toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('lists one row per bill with the bill metadata', () => {
|
|
60
|
+
vi.mocked(useDiscountRequests).mockReturnValue({
|
|
61
|
+
bills: [sampleBill],
|
|
62
|
+
totalCount: 1,
|
|
63
|
+
isLoading: false,
|
|
64
|
+
error: null,
|
|
65
|
+
mutate: vi.fn(),
|
|
66
|
+
} as any);
|
|
67
|
+
render(<DiscountRequests />);
|
|
68
|
+
expect(screen.getByText(/INV-1/)).toBeInTheDocument();
|
|
69
|
+
expect(screen.getByText(/10001V - Jane Doe/)).toBeInTheDocument();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('opens the review modal on row click', async () => {
|
|
73
|
+
vi.mocked(useDiscountRequests).mockReturnValue({
|
|
74
|
+
bills: [sampleBill],
|
|
75
|
+
totalCount: 1,
|
|
76
|
+
isLoading: false,
|
|
77
|
+
error: null,
|
|
78
|
+
mutate: vi.fn(),
|
|
79
|
+
} as any);
|
|
80
|
+
const user = userEvent.setup();
|
|
81
|
+
render(<DiscountRequests />);
|
|
82
|
+
await user.click(screen.getByText(/INV-1/));
|
|
83
|
+
expect(showModal).toHaveBeenCalledWith(
|
|
84
|
+
'review-bill-discounts-modal',
|
|
85
|
+
expect.objectContaining({ bill: expect.objectContaining({ uuid: 'b1' }) }),
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('changes the status filter and refetches', async () => {
|
|
90
|
+
const mutate = vi.fn();
|
|
91
|
+
vi.mocked(useDiscountRequests).mockReturnValue({
|
|
92
|
+
bills: [],
|
|
93
|
+
totalCount: 0,
|
|
94
|
+
isLoading: false,
|
|
95
|
+
error: null,
|
|
96
|
+
mutate,
|
|
97
|
+
} as any);
|
|
98
|
+
const user = userEvent.setup();
|
|
99
|
+
render(<DiscountRequests />);
|
|
100
|
+
await user.click(screen.getByRole('combobox'));
|
|
101
|
+
await user.click(screen.getByText(/approved/i));
|
|
102
|
+
expect(vi.mocked(useDiscountRequests).mock.calls.at(-1)?.[0].statuses).toEqual([BillDiscountStatus.APPROVED]);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { useConfig } from '@openmrs/esm-framework';
|
|
4
|
+
import type { BillingConfig } from '../../../../config-schema';
|
|
5
|
+
import { convertToCurrency } from '../../../../helpers';
|
|
6
|
+
import type { LineItem } from '../../../../types';
|
|
7
|
+
import styles from './bill-line-items-table.scss';
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
lineItems: Array<LineItem>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const BillLineItemsTable: React.FC<Props> = ({ lineItems }) => {
|
|
14
|
+
const { t } = useTranslation();
|
|
15
|
+
const { defaultCurrency } = useConfig<BillingConfig>();
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<section className={styles.ledger}>
|
|
19
|
+
<h3 className={styles.ledgerHeading}>{t('lineItems', 'Line items')}</h3>
|
|
20
|
+
<table className={styles.ledgerTable}>
|
|
21
|
+
<thead>
|
|
22
|
+
<tr>
|
|
23
|
+
<th>{t('item', 'Item')}</th>
|
|
24
|
+
<th>{t('qty', 'Qty')}</th>
|
|
25
|
+
<th className={styles.right}>{t('price', 'Price')}</th>
|
|
26
|
+
</tr>
|
|
27
|
+
</thead>
|
|
28
|
+
<tbody>
|
|
29
|
+
{lineItems.map((li: LineItem, idx: number) => (
|
|
30
|
+
<tr key={li.uuid ?? idx}>
|
|
31
|
+
<td className={styles.itemName}>{li.item || li.billableService || '--'}</td>
|
|
32
|
+
<td>{li.quantity}</td>
|
|
33
|
+
<td className={styles.right}>{convertToCurrency(li.price ?? 0, defaultCurrency)}</td>
|
|
34
|
+
</tr>
|
|
35
|
+
))}
|
|
36
|
+
</tbody>
|
|
37
|
+
</table>
|
|
38
|
+
</section>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default BillLineItemsTable;
|
package/src/discounts/admin/review-bill-discounts/bill-line-items-table/bill-line-items-table.scss
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
@use '@carbon/styles/scss/spacing' as *;
|
|
2
|
+
@use '@carbon/styles/scss/type';
|
|
3
|
+
@use '@openmrs/esm-styleguide/src/vars' as *;
|
|
4
|
+
|
|
5
|
+
.ledger {
|
|
6
|
+
margin-bottom: $spacing-05;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.ledgerHeading {
|
|
10
|
+
@include type.type-style('label-01');
|
|
11
|
+
text-transform: uppercase;
|
|
12
|
+
letter-spacing: 0.12em;
|
|
13
|
+
color: var(--cds-text-helper);
|
|
14
|
+
margin: 0 0 $spacing-03;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.ledgerTable {
|
|
18
|
+
width: 100%;
|
|
19
|
+
border-collapse: collapse;
|
|
20
|
+
@include type.type-style('body-compact-01');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ledgerTable thead th {
|
|
24
|
+
text-align: left;
|
|
25
|
+
@include type.type-style('label-01');
|
|
26
|
+
text-transform: uppercase;
|
|
27
|
+
letter-spacing: 0.1em;
|
|
28
|
+
color: var(--cds-text-helper);
|
|
29
|
+
font-weight: 500;
|
|
30
|
+
padding: $spacing-02 0;
|
|
31
|
+
border-bottom: 1px solid $ui-03;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.ledgerTable tbody td {
|
|
35
|
+
padding: $spacing-03 0;
|
|
36
|
+
border-bottom: 1px dashed $ui-03;
|
|
37
|
+
color: var(--cds-text-secondary);
|
|
38
|
+
font-variant-numeric: tabular-nums;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ledgerTable tbody tr:last-child td {
|
|
42
|
+
border-bottom: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.center {
|
|
46
|
+
text-align: center;
|
|
47
|
+
width: 36px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.right {
|
|
51
|
+
text-align: right;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.itemName {
|
|
55
|
+
color: var(--cds-text-primary);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.ref {
|
|
59
|
+
display: inline-block;
|
|
60
|
+
min-width: 20px;
|
|
61
|
+
height: 20px;
|
|
62
|
+
padding: 0 $spacing-02;
|
|
63
|
+
background: $ui-02;
|
|
64
|
+
border: 1px solid $color-gray-30;
|
|
65
|
+
@include type.type-style('code-01');
|
|
66
|
+
font-weight: 500;
|
|
67
|
+
text-align: center;
|
|
68
|
+
line-height: 18px;
|
|
69
|
+
color: var(--cds-text-secondary);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.refSolid {
|
|
73
|
+
background: $ui-05;
|
|
74
|
+
border-color: $ui-05;
|
|
75
|
+
color: $ui-02;
|
|
76
|
+
}
|