@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,164 @@
|
|
|
1
|
+
@use '@carbon/styles/scss/spacing' as *;
|
|
2
|
+
@use '@carbon/styles/scss/type';
|
|
3
|
+
@use '@openmrs/esm-styleguide/src/vars' as *;
|
|
4
|
+
|
|
5
|
+
.card {
|
|
6
|
+
position: relative;
|
|
7
|
+
border: 1px solid $ui-03;
|
|
8
|
+
background: $ui-02;
|
|
9
|
+
padding: $spacing-05 $spacing-05 $spacing-04 $spacing-06;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.card::before {
|
|
13
|
+
content: '';
|
|
14
|
+
position: absolute;
|
|
15
|
+
left: 0;
|
|
16
|
+
top: 0;
|
|
17
|
+
bottom: 0;
|
|
18
|
+
width: 4px;
|
|
19
|
+
background: $color-gray-30;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.cardPending::before {
|
|
23
|
+
background: $inverse-support-03;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.cardApproved::before {
|
|
27
|
+
background: $support-02;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.cardRejected::before {
|
|
31
|
+
background: $danger;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.cardTop {
|
|
35
|
+
display: flex;
|
|
36
|
+
justify-content: space-between;
|
|
37
|
+
align-items: flex-start;
|
|
38
|
+
gap: $spacing-04;
|
|
39
|
+
margin-bottom: $spacing-03;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.cardScope {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: $spacing-03;
|
|
46
|
+
flex-wrap: wrap;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.cardRef {
|
|
50
|
+
display: inline-block;
|
|
51
|
+
width: 22px;
|
|
52
|
+
height: 22px;
|
|
53
|
+
background: $ui-05;
|
|
54
|
+
color: $ui-02;
|
|
55
|
+
@include type.type-style('code-01');
|
|
56
|
+
font-weight: 500;
|
|
57
|
+
text-align: center;
|
|
58
|
+
line-height: 22px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.cardScopeName {
|
|
62
|
+
@include type.type-style('heading-02');
|
|
63
|
+
color: var(--cds-text-primary);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.cardScopeKind {
|
|
67
|
+
@include type.type-style('label-01');
|
|
68
|
+
text-transform: uppercase;
|
|
69
|
+
letter-spacing: 0.1em;
|
|
70
|
+
color: var(--cds-text-helper);
|
|
71
|
+
border-left: 1px solid $ui-03;
|
|
72
|
+
padding-left: $spacing-03;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.cardFigure {
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: baseline;
|
|
78
|
+
gap: $spacing-03;
|
|
79
|
+
margin-bottom: $spacing-04;
|
|
80
|
+
font-variant-numeric: tabular-nums;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.cardAmount {
|
|
84
|
+
@include type.type-style('heading-05');
|
|
85
|
+
letter-spacing: -0.015em;
|
|
86
|
+
color: var(--cds-text-primary);
|
|
87
|
+
line-height: 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.cardAmountMinus {
|
|
91
|
+
color: $danger;
|
|
92
|
+
margin-right: 2px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.cardAmountVoided {
|
|
96
|
+
color: var(--cds-text-helper);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.cardValue {
|
|
100
|
+
@include type.type-style('code-01');
|
|
101
|
+
color: var(--cds-text-helper);
|
|
102
|
+
padding: 3px $spacing-02;
|
|
103
|
+
background: $ui-01;
|
|
104
|
+
border: 1px solid $ui-03;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.cardJustification {
|
|
108
|
+
@include type.type-style('body-01');
|
|
109
|
+
font-style: italic;
|
|
110
|
+
color: var(--cds-text-secondary);
|
|
111
|
+
padding: $spacing-01 0 $spacing-01 $spacing-03;
|
|
112
|
+
margin: 0 0 $spacing-04;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.cardAlert {
|
|
116
|
+
margin: 0 0 $spacing-04 !important;
|
|
117
|
+
max-width: 100% !important;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.cardFooter {
|
|
121
|
+
display: flex;
|
|
122
|
+
align-items: center;
|
|
123
|
+
justify-content: space-between;
|
|
124
|
+
gap: $spacing-04;
|
|
125
|
+
padding-top: $spacing-03;
|
|
126
|
+
border-top: 1px solid $ui-03;
|
|
127
|
+
flex-wrap: wrap;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.cardByline {
|
|
131
|
+
@include type.type-style('label-01');
|
|
132
|
+
color: var(--cds-text-helper);
|
|
133
|
+
display: flex;
|
|
134
|
+
gap: $spacing-02;
|
|
135
|
+
align-items: center;
|
|
136
|
+
flex-wrap: wrap;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.cardByline strong {
|
|
140
|
+
font-weight: 500;
|
|
141
|
+
color: var(--cds-text-secondary);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.cardBylineSep {
|
|
145
|
+
color: $color-gray-30;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.cardActions {
|
|
149
|
+
display: flex;
|
|
150
|
+
gap: $spacing-02;
|
|
151
|
+
align-items: center;
|
|
152
|
+
flex-wrap: nowrap;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.cardActions :global(.cds--btn) {
|
|
156
|
+
min-width: 7rem;
|
|
157
|
+
justify-content: center;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.confirmCopy {
|
|
161
|
+
@include type.type-style('body-compact-01');
|
|
162
|
+
color: var(--cds-text-secondary);
|
|
163
|
+
margin-right: $spacing-02;
|
|
164
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import DiscountCard from '../discount-card/discount-card.component';
|
|
4
|
+
import type { BillDiscount, LineItem } from '../../../../types';
|
|
5
|
+
import styles from './discount-review-stack.scss';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
pendingDiscounts: BillDiscount[];
|
|
9
|
+
confirmedDiscounts: BillDiscount[];
|
|
10
|
+
lineItems: Array<LineItem>;
|
|
11
|
+
busy: string | null;
|
|
12
|
+
rejectingId: string | null;
|
|
13
|
+
deletingId: string | null;
|
|
14
|
+
canDecide: boolean;
|
|
15
|
+
onApprove: (d: BillDiscount) => void;
|
|
16
|
+
onStartReject: (uuid: string) => void;
|
|
17
|
+
onCancelReject: () => void;
|
|
18
|
+
onConfirmReject: (d: BillDiscount) => void;
|
|
19
|
+
onStartDelete: (uuid: string) => void;
|
|
20
|
+
onCancelDelete: () => void;
|
|
21
|
+
onConfirmDelete: (d: BillDiscount) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const DiscountReviewStack: React.FC<Props> = ({
|
|
25
|
+
pendingDiscounts,
|
|
26
|
+
confirmedDiscounts,
|
|
27
|
+
lineItems,
|
|
28
|
+
busy,
|
|
29
|
+
rejectingId,
|
|
30
|
+
deletingId,
|
|
31
|
+
canDecide,
|
|
32
|
+
onApprove,
|
|
33
|
+
onStartReject,
|
|
34
|
+
onCancelReject,
|
|
35
|
+
onConfirmReject,
|
|
36
|
+
onStartDelete,
|
|
37
|
+
onCancelDelete,
|
|
38
|
+
onConfirmDelete,
|
|
39
|
+
}) => {
|
|
40
|
+
const { t } = useTranslation();
|
|
41
|
+
|
|
42
|
+
const renderCard = (d: BillDiscount) => (
|
|
43
|
+
<DiscountCard
|
|
44
|
+
key={d.uuid}
|
|
45
|
+
discount={d}
|
|
46
|
+
lineItems={lineItems}
|
|
47
|
+
busy={busy}
|
|
48
|
+
rejectingId={rejectingId}
|
|
49
|
+
deletingId={deletingId}
|
|
50
|
+
canDecide={canDecide}
|
|
51
|
+
onApprove={onApprove}
|
|
52
|
+
onStartReject={onStartReject}
|
|
53
|
+
onCancelReject={onCancelReject}
|
|
54
|
+
onConfirmReject={onConfirmReject}
|
|
55
|
+
onStartDelete={onStartDelete}
|
|
56
|
+
onCancelDelete={onCancelDelete}
|
|
57
|
+
onConfirmDelete={onConfirmDelete}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<section className={styles.review}>
|
|
63
|
+
{pendingDiscounts.length > 0 && (
|
|
64
|
+
<div>
|
|
65
|
+
<div className={styles.groupHeader}>
|
|
66
|
+
<h3 className={styles.groupTitle}>{t('pendingDiscounts', 'Pending discounts')}</h3>
|
|
67
|
+
<span className={styles.groupCount}>{pendingDiscounts.length}</span>
|
|
68
|
+
</div>
|
|
69
|
+
<div className={styles.stack}>{pendingDiscounts.map(renderCard)}</div>
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
|
|
73
|
+
{confirmedDiscounts.length > 0 && (
|
|
74
|
+
<div>
|
|
75
|
+
<div className={styles.groupHeader}>
|
|
76
|
+
<h3 className={styles.groupTitle}>{t('confirmedDiscounts', 'Confirmed discounts')}</h3>
|
|
77
|
+
<span className={styles.groupCount}>{confirmedDiscounts.length}</span>
|
|
78
|
+
</div>
|
|
79
|
+
<div className={styles.stack}>{confirmedDiscounts.map(renderCard)}</div>
|
|
80
|
+
</div>
|
|
81
|
+
)}
|
|
82
|
+
</section>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default React.memo(DiscountReviewStack);
|
package/src/discounts/admin/review-bill-discounts/discount-review-stack/discount-review-stack.scss
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@use '@carbon/styles/scss/spacing' as *;
|
|
2
|
+
@use '@carbon/styles/scss/type';
|
|
3
|
+
@use '@openmrs/esm-styleguide/src/vars' as *;
|
|
4
|
+
|
|
5
|
+
.review {
|
|
6
|
+
padding: $spacing-06 $spacing-07 $spacing-07;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: $spacing-06;
|
|
10
|
+
background: $ui-02;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.groupHeader {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: baseline;
|
|
16
|
+
gap: $spacing-03;
|
|
17
|
+
margin-bottom: $spacing-04;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.groupTitle {
|
|
21
|
+
@include type.type-style('label-01');
|
|
22
|
+
text-transform: uppercase;
|
|
23
|
+
letter-spacing: 0.12em;
|
|
24
|
+
color: var(--cds-text-helper);
|
|
25
|
+
margin: 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.groupCount {
|
|
29
|
+
@include type.type-style('code-01');
|
|
30
|
+
color: var(--cds-text-helper);
|
|
31
|
+
padding: 2px $spacing-02;
|
|
32
|
+
background: $ui-01;
|
|
33
|
+
border: 1px solid $ui-03;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.stack {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
gap: $spacing-04;
|
|
40
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest';
|
|
3
|
+
import { useBill } from '../../../billing.resource';
|
|
4
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
6
|
+
import { showSnackbar } from '@openmrs/esm-framework';
|
|
7
|
+
import ReviewBillDiscountsModal from './review-bill-discounts.modal';
|
|
8
|
+
import { decideDiscount, voidDiscount } from '../../discounts.resource';
|
|
9
|
+
import {
|
|
10
|
+
BillDiscountStatus,
|
|
11
|
+
BillDiscountType,
|
|
12
|
+
BillStatus,
|
|
13
|
+
type BillDiscount,
|
|
14
|
+
type PatientInvoice,
|
|
15
|
+
} from '../../../types';
|
|
16
|
+
|
|
17
|
+
vi.mock('@openmrs/esm-framework', () => ({
|
|
18
|
+
showSnackbar: vi.fn(),
|
|
19
|
+
useConfig: vi.fn().mockReturnValue({ defaultCurrency: 'USD' }),
|
|
20
|
+
useSession: vi.fn().mockReturnValue({ user: { uuid: 'admin-uuid' } }),
|
|
21
|
+
formatDate: () => 'date',
|
|
22
|
+
parseDate: (s: string) => new Date(s),
|
|
23
|
+
getCoreTranslation: (key: string) => key,
|
|
24
|
+
restBaseUrl: '/ws/rest/v1',
|
|
25
|
+
}));
|
|
26
|
+
vi.mock('../../discounts.resource');
|
|
27
|
+
vi.mock('../../../billing.resource', () => ({
|
|
28
|
+
useBill: vi.fn().mockReturnValue({ bill: null, mutate: vi.fn(), isLoading: false, isValidating: false }),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
(window as any).i18next = { language: 'en-US' };
|
|
32
|
+
|
|
33
|
+
beforeEach(() => vi.clearAllMocks());
|
|
34
|
+
|
|
35
|
+
const makeDiscount = (overrides: Partial<BillDiscount> = {}): BillDiscount => ({
|
|
36
|
+
uuid: 'd1',
|
|
37
|
+
billUuid: 'b1',
|
|
38
|
+
lineItemUuid: null,
|
|
39
|
+
discountType: BillDiscountType.FIXED_AMOUNT,
|
|
40
|
+
discountValue: 100,
|
|
41
|
+
discountAmount: 100,
|
|
42
|
+
justification: 'goodwill',
|
|
43
|
+
initiator: { uuid: 'u1', display: 'Cashier A' },
|
|
44
|
+
approver: null,
|
|
45
|
+
dateCreated: '2026-05-11T00:00:00.000+0000',
|
|
46
|
+
status: BillDiscountStatus.PENDING,
|
|
47
|
+
voided: false,
|
|
48
|
+
...overrides,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const makeBill = (overrides: Partial<PatientInvoice> = {}): PatientInvoice =>
|
|
52
|
+
({
|
|
53
|
+
uuid: 'b1',
|
|
54
|
+
receiptNumber: 'INV-1',
|
|
55
|
+
status: BillStatus.POSTED,
|
|
56
|
+
total: 1000,
|
|
57
|
+
amountAfterDiscount: 1000,
|
|
58
|
+
dateCreated: '2026-05-11T00:00:00.000+0000',
|
|
59
|
+
patient: { display: 'Jane Doe' },
|
|
60
|
+
cashier: { display: 'cashier' },
|
|
61
|
+
lineItems: [],
|
|
62
|
+
payments: [],
|
|
63
|
+
discounts: [],
|
|
64
|
+
...overrides,
|
|
65
|
+
}) as unknown as PatientInvoice;
|
|
66
|
+
|
|
67
|
+
describe('ReviewBillDiscountsModal', () => {
|
|
68
|
+
it('disables approve and reject on a bill that is neither PENDING nor POSTED', () => {
|
|
69
|
+
const bill = makeBill({
|
|
70
|
+
status: BillStatus.PAID,
|
|
71
|
+
discounts: [makeDiscount()],
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
render(<ReviewBillDiscountsModal closeModal={vi.fn()} bill={bill} onMutate={vi.fn()} />);
|
|
75
|
+
|
|
76
|
+
expect(screen.getByRole('button', { name: /approve/i })).toBeDisabled();
|
|
77
|
+
expect(screen.getByRole('button', { name: /reject/i })).toBeDisabled();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('blocks approve when it would make the amount due negative', async () => {
|
|
81
|
+
const user = userEvent.setup();
|
|
82
|
+
const bill = makeBill({
|
|
83
|
+
status: BillStatus.POSTED,
|
|
84
|
+
total: 1000,
|
|
85
|
+
amountAfterDiscount: 200,
|
|
86
|
+
discounts: [makeDiscount({ discountAmount: 500 })],
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
render(<ReviewBillDiscountsModal closeModal={vi.fn()} bill={bill} onMutate={vi.fn()} />);
|
|
90
|
+
|
|
91
|
+
await user.click(screen.getByRole('button', { name: /approve/i }));
|
|
92
|
+
|
|
93
|
+
await waitFor(() => expect(showSnackbar).toHaveBeenCalledWith(expect.objectContaining({ kind: 'error' })));
|
|
94
|
+
expect(decideDiscount).not.toHaveBeenCalled();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('blocks voiding an approved discount on a fully paid bill', async () => {
|
|
98
|
+
const user = userEvent.setup();
|
|
99
|
+
const bill = makeBill({
|
|
100
|
+
status: BillStatus.PAID,
|
|
101
|
+
total: 1000,
|
|
102
|
+
amountAfterDiscount: 900,
|
|
103
|
+
payments: [{ uuid: 'p1', amountTendered: 900, voided: false } as any],
|
|
104
|
+
discounts: [makeDiscount({ status: BillDiscountStatus.APPROVED, discountAmount: 100 })],
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
render(<ReviewBillDiscountsModal closeModal={vi.fn()} bill={bill} onMutate={vi.fn()} />);
|
|
108
|
+
|
|
109
|
+
// Carbon's danger--tertiary button prepends a visually-hidden "danger" span
|
|
110
|
+
// to the accessible name; match by trailing text.
|
|
111
|
+
await user.click(screen.getByRole('button', { name: /delete$/i }));
|
|
112
|
+
await user.click(screen.getByRole('button', { name: /confirm delete$/i }));
|
|
113
|
+
|
|
114
|
+
await waitFor(() => expect(showSnackbar).toHaveBeenCalledWith(expect.objectContaining({ kind: 'error' })));
|
|
115
|
+
expect(voidDiscount).not.toHaveBeenCalled();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('does not close the modal after a successful approve', async () => {
|
|
119
|
+
const user = userEvent.setup();
|
|
120
|
+
const closeModal = vi.fn();
|
|
121
|
+
const onMutate = vi.fn();
|
|
122
|
+
|
|
123
|
+
vi.mocked(decideDiscount).mockResolvedValue({
|
|
124
|
+
...makeDiscount(),
|
|
125
|
+
status: BillDiscountStatus.APPROVED,
|
|
126
|
+
} as any);
|
|
127
|
+
|
|
128
|
+
const bill = makeBill({
|
|
129
|
+
status: BillStatus.POSTED,
|
|
130
|
+
total: 1000,
|
|
131
|
+
amountAfterDiscount: 1000,
|
|
132
|
+
discounts: [makeDiscount({ discountAmount: 100 })],
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
render(<ReviewBillDiscountsModal closeModal={closeModal} bill={bill} onMutate={onMutate} />);
|
|
136
|
+
|
|
137
|
+
await user.click(screen.getByRole('button', { name: /approve/i }));
|
|
138
|
+
|
|
139
|
+
await waitFor(() => expect(showSnackbar).toHaveBeenCalledWith(expect.objectContaining({ kind: 'success' })));
|
|
140
|
+
expect(closeModal).not.toHaveBeenCalled();
|
|
141
|
+
expect(onMutate).toHaveBeenCalledOnce();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('renders a progress bar and hides content while isLoading', () => {
|
|
145
|
+
(useBill as Mock).mockReturnValue({ bill: null, mutate: vi.fn(), isLoading: true, isValidating: false });
|
|
146
|
+
|
|
147
|
+
const bill = makeBill({ discounts: [makeDiscount()] });
|
|
148
|
+
render(<ReviewBillDiscountsModal closeModal={vi.fn()} bill={bill} onMutate={vi.fn()} />);
|
|
149
|
+
|
|
150
|
+
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
|
151
|
+
expect(screen.queryByRole('button', { name: /approve/i })).not.toBeInTheDocument();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import { ModalBody, ModalHeader, ProgressBar } from '@carbon/react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { showSnackbar, useSession } from '@openmrs/esm-framework';
|
|
5
|
+
import BillReceiptRail from './bill-receipt-rail/bill-receipt-rail.component';
|
|
6
|
+
import DiscountReviewStack from './discount-review-stack/discount-review-stack.component';
|
|
7
|
+
import { useBill } from '../../../billing.resource';
|
|
8
|
+
import { decideDiscount, voidDiscount } from '../../discounts.resource';
|
|
9
|
+
import { useReviewBillModel } from './review-bill-discounts.utils';
|
|
10
|
+
import { BillDiscountStatus, BillStatus, type BillDiscount, type PatientInvoice } from '../../../types';
|
|
11
|
+
import styles from './review-bill-discounts.modal.scss';
|
|
12
|
+
|
|
13
|
+
const extractErrorMessage = (e: any): string =>
|
|
14
|
+
e?.responseBody?.error?.message ?? (e instanceof Error ? e.message : String(e));
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
closeModal: () => void;
|
|
18
|
+
bill: PatientInvoice;
|
|
19
|
+
onMutate: () => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const ReviewBillDiscountsModal: React.FC<Props> = ({ closeModal, bill, onMutate }) => {
|
|
23
|
+
const { t } = useTranslation();
|
|
24
|
+
const session = useSession();
|
|
25
|
+
const { bill: localBill, mutate: localMutate, isLoading, isValidating } = useBill(bill.uuid, false);
|
|
26
|
+
const activeBill = localBill ?? bill;
|
|
27
|
+
const [busy, setBusy] = useState<string | null>(null);
|
|
28
|
+
const [rejectingId, setRejectingId] = useState<string | null>(null);
|
|
29
|
+
const [deletingId, setDeletingId] = useState<string | null>(null);
|
|
30
|
+
const canDecide = activeBill.status === BillStatus.PENDING || activeBill.status === BillStatus.POSTED;
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
pendingDiscounts,
|
|
34
|
+
confirmedDiscounts,
|
|
35
|
+
approvedDiscounts,
|
|
36
|
+
lineItems,
|
|
37
|
+
payments,
|
|
38
|
+
paymentsTotal,
|
|
39
|
+
subtotal,
|
|
40
|
+
currentNet,
|
|
41
|
+
outstanding,
|
|
42
|
+
} = useReviewBillModel(activeBill);
|
|
43
|
+
|
|
44
|
+
const handleApprove = useCallback(
|
|
45
|
+
async (d: BillDiscount) => {
|
|
46
|
+
if (!canDecide) return;
|
|
47
|
+
if (outstanding - d.discountAmount < 0) {
|
|
48
|
+
showSnackbar({
|
|
49
|
+
title: t('approveBlocked', 'Cannot approve discount'),
|
|
50
|
+
subtitle: t('approveBlockedNegativeDue', 'Approving this discount would push the amount due below zero.'),
|
|
51
|
+
kind: 'error',
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
setBusy(d.uuid);
|
|
56
|
+
try {
|
|
57
|
+
await decideDiscount(d.uuid, BillDiscountStatus.APPROVED, session.user.uuid);
|
|
58
|
+
showSnackbar({ title: t('discountApproved', 'Discount approved'), kind: 'success' });
|
|
59
|
+
await localMutate();
|
|
60
|
+
onMutate();
|
|
61
|
+
} catch (e: unknown) {
|
|
62
|
+
showSnackbar({
|
|
63
|
+
title: t('approveFailed', 'Approve failed'),
|
|
64
|
+
subtitle: extractErrorMessage(e),
|
|
65
|
+
kind: 'error',
|
|
66
|
+
});
|
|
67
|
+
} finally {
|
|
68
|
+
setBusy(null);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
[canDecide, outstanding, t, session.user.uuid, localMutate, onMutate],
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const confirmReject = useCallback(
|
|
75
|
+
async (d: BillDiscount) => {
|
|
76
|
+
if (!canDecide) return;
|
|
77
|
+
setBusy(d.uuid);
|
|
78
|
+
try {
|
|
79
|
+
await decideDiscount(d.uuid, BillDiscountStatus.REJECTED, session.user.uuid);
|
|
80
|
+
showSnackbar({ title: t('discountRejected', 'Discount rejected'), kind: 'success' });
|
|
81
|
+
await localMutate();
|
|
82
|
+
onMutate();
|
|
83
|
+
} catch (e: unknown) {
|
|
84
|
+
showSnackbar({ title: t('rejectFailed', 'Reject failed'), subtitle: extractErrorMessage(e), kind: 'error' });
|
|
85
|
+
} finally {
|
|
86
|
+
setBusy(null);
|
|
87
|
+
setRejectingId(null);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
[canDecide, t, session.user.uuid, localMutate, onMutate],
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const confirmDelete = useCallback(
|
|
94
|
+
async (d: BillDiscount) => {
|
|
95
|
+
if (d.status === BillDiscountStatus.APPROVED && outstanding <= 0) {
|
|
96
|
+
showSnackbar({
|
|
97
|
+
title: t('deleteBlocked', 'Cannot delete discount'),
|
|
98
|
+
subtitle: t('deleteBlockedFullyPaid', 'An approved discount cannot be removed once the bill is fully paid.'),
|
|
99
|
+
kind: 'error',
|
|
100
|
+
});
|
|
101
|
+
setDeletingId(null);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
setBusy(d.uuid);
|
|
105
|
+
try {
|
|
106
|
+
await voidDiscount(d.uuid, 'Deleted by admin');
|
|
107
|
+
showSnackbar({ title: t('discountDeleted', 'Discount deleted'), kind: 'success' });
|
|
108
|
+
await localMutate();
|
|
109
|
+
onMutate();
|
|
110
|
+
} catch (e: unknown) {
|
|
111
|
+
showSnackbar({ title: t('deleteFailed', 'Delete failed'), subtitle: extractErrorMessage(e), kind: 'error' });
|
|
112
|
+
} finally {
|
|
113
|
+
setBusy(null);
|
|
114
|
+
setDeletingId(null);
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
[outstanding, t, localMutate, onMutate],
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const handleCancelReject = useCallback(() => setRejectingId(null), []);
|
|
121
|
+
const handleCancelDelete = useCallback(() => setDeletingId(null), []);
|
|
122
|
+
|
|
123
|
+
const showProgress = !!busy || isLoading || isValidating;
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<>
|
|
127
|
+
<ModalHeader closeModal={closeModal} title={t('reviewDiscounts', 'Review discounts')} />
|
|
128
|
+
<ModalBody>
|
|
129
|
+
{showProgress ? (
|
|
130
|
+
<ProgressBar label="" hideLabel />
|
|
131
|
+
) : (
|
|
132
|
+
<div className={styles.layout}>
|
|
133
|
+
<BillReceiptRail
|
|
134
|
+
bill={activeBill}
|
|
135
|
+
lineItems={lineItems}
|
|
136
|
+
payments={payments}
|
|
137
|
+
paymentsTotal={paymentsTotal}
|
|
138
|
+
subtotal={subtotal}
|
|
139
|
+
currentNet={currentNet}
|
|
140
|
+
outstanding={outstanding}
|
|
141
|
+
approvedDiscounts={approvedDiscounts}
|
|
142
|
+
pendingDiscounts={pendingDiscounts}
|
|
143
|
+
/>
|
|
144
|
+
<DiscountReviewStack
|
|
145
|
+
pendingDiscounts={pendingDiscounts}
|
|
146
|
+
confirmedDiscounts={confirmedDiscounts}
|
|
147
|
+
lineItems={lineItems}
|
|
148
|
+
busy={busy}
|
|
149
|
+
rejectingId={rejectingId}
|
|
150
|
+
deletingId={deletingId}
|
|
151
|
+
canDecide={canDecide}
|
|
152
|
+
onApprove={handleApprove}
|
|
153
|
+
onStartReject={setRejectingId}
|
|
154
|
+
onCancelReject={handleCancelReject}
|
|
155
|
+
onConfirmReject={confirmReject}
|
|
156
|
+
onStartDelete={setDeletingId}
|
|
157
|
+
onCancelDelete={handleCancelDelete}
|
|
158
|
+
onConfirmDelete={confirmDelete}
|
|
159
|
+
/>
|
|
160
|
+
</div>
|
|
161
|
+
)}
|
|
162
|
+
</ModalBody>
|
|
163
|
+
</>
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export default ReviewBillDiscountsModal;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BillDiscountStatus,
|
|
5
|
+
type BillDiscount,
|
|
6
|
+
type LineItem,
|
|
7
|
+
type PatientInvoice,
|
|
8
|
+
type Payment,
|
|
9
|
+
} from '../../../types';
|
|
10
|
+
|
|
11
|
+
export function useReviewBillModel(bill: PatientInvoice) {
|
|
12
|
+
const activeDiscounts: BillDiscount[] = useMemo(
|
|
13
|
+
() => (bill.discounts ?? []).filter((d: BillDiscount) => !d.voided),
|
|
14
|
+
[bill.discounts],
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const pendingDiscounts = activeDiscounts.filter((d) => d.status === BillDiscountStatus.PENDING);
|
|
18
|
+
const confirmedDiscounts = activeDiscounts.filter((d) => d.status !== BillDiscountStatus.PENDING);
|
|
19
|
+
const approvedDiscounts = activeDiscounts.filter((d) => d.status === BillDiscountStatus.APPROVED);
|
|
20
|
+
|
|
21
|
+
const lineItems = (bill.lineItems ?? []).filter((li: LineItem) => !li.voided);
|
|
22
|
+
|
|
23
|
+
const payments = (bill.payments ?? []).filter((p: Payment) => !p.voided);
|
|
24
|
+
const paymentsTotal = payments.reduce((sum: number, p: Payment) => sum + (p.amountTendered ?? 0), 0);
|
|
25
|
+
|
|
26
|
+
const subtotal = bill.total;
|
|
27
|
+
const currentNet = bill.amountAfterDiscount;
|
|
28
|
+
const outstanding = currentNet - paymentsTotal;
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
activeDiscounts,
|
|
32
|
+
pendingDiscounts,
|
|
33
|
+
confirmedDiscounts,
|
|
34
|
+
approvedDiscounts,
|
|
35
|
+
lineItems,
|
|
36
|
+
payments,
|
|
37
|
+
paymentsTotal,
|
|
38
|
+
subtotal,
|
|
39
|
+
currentNet,
|
|
40
|
+
outstanding,
|
|
41
|
+
};
|
|
42
|
+
}
|