@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
|
@@ -1,23 +1,17 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
1
2
|
import { mapBillProperties } from './billing.resource';
|
|
3
|
+
import { calculateTotalAmount } from './helpers/functions';
|
|
2
4
|
import type { LineItem, PatientInvoice, Payment } from './types';
|
|
3
5
|
|
|
4
6
|
type CashPoint = PatientInvoice['cashPoint'];
|
|
5
7
|
type Provider = PatientInvoice['cashier'];
|
|
6
8
|
type Patient = PatientInvoice['patient'];
|
|
7
9
|
|
|
8
|
-
const mockFormatDate = jest.fn((date: Date, options?: Partial<{ mode: string }>) => `formatted-${date}`);
|
|
9
|
-
const mockParseDate = jest.fn((dateString: string): Date => new Date(dateString));
|
|
10
|
-
|
|
11
|
-
jest.mock('@openmrs/esm-framework', () => ({
|
|
12
|
-
formatDate: (date: Date, options?: Partial<{ mode: string }>) => mockFormatDate(date, options),
|
|
13
|
-
parseDate: (dateString: string) => mockParseDate(dateString),
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
10
|
const createLineItem = (overrides: Partial<LineItem> = {}): LineItem => ({
|
|
17
11
|
uuid: 'line-item-uuid',
|
|
18
12
|
item: 'Service Item',
|
|
19
13
|
billableService: 'Billable Service',
|
|
20
|
-
|
|
14
|
+
status: 'PENDING',
|
|
21
15
|
quantity: 1,
|
|
22
16
|
price: 100,
|
|
23
17
|
priceName: 'Standard',
|
|
@@ -74,26 +68,34 @@ const createPayment = (overrides: Partial<Payment> = {}): Payment => ({
|
|
|
74
68
|
...overrides,
|
|
75
69
|
});
|
|
76
70
|
|
|
77
|
-
const createBaseBill = (overrides: Partial<PatientInvoice> = {}): PatientInvoice =>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
71
|
+
const createBaseBill = (overrides: Partial<PatientInvoice> = {}): PatientInvoice => {
|
|
72
|
+
const lineItems = overrides.lineItems ?? [];
|
|
73
|
+
const serverTotal = calculateTotalAmount(lineItems);
|
|
74
|
+
return {
|
|
75
|
+
uuid: 'uuid1',
|
|
76
|
+
display: '12345 - John Doe',
|
|
77
|
+
voided: false,
|
|
78
|
+
voidReason: null,
|
|
79
|
+
adjustedBy: [],
|
|
80
|
+
billAdjusted: null,
|
|
81
|
+
cashPoint: createCashPoint(),
|
|
82
|
+
cashier: createProvider(),
|
|
83
|
+
dateCreated: '2024-01-01T00:00:00Z',
|
|
84
|
+
lineItems,
|
|
85
|
+
patient: createPatient(),
|
|
86
|
+
payments: [],
|
|
87
|
+
receiptNumber: 'R123',
|
|
88
|
+
status: 'PENDING',
|
|
89
|
+
adjustmentReason: null,
|
|
90
|
+
id: 1,
|
|
91
|
+
resourceVersion: '1.0',
|
|
92
|
+
total: serverTotal,
|
|
93
|
+
amountAfterDiscount: serverTotal,
|
|
94
|
+
discounts: [],
|
|
95
|
+
refunds: [],
|
|
96
|
+
...overrides,
|
|
97
|
+
};
|
|
98
|
+
};
|
|
97
99
|
|
|
98
100
|
describe('mapBillProperties', () => {
|
|
99
101
|
describe('Amount calculations', () => {
|
|
@@ -345,8 +347,8 @@ describe('mapBillProperties', () => {
|
|
|
345
347
|
it('Handles partial payment correctly', () => {
|
|
346
348
|
const bill = createBaseBill({
|
|
347
349
|
lineItems: [
|
|
348
|
-
createLineItem({ price: 100, quantity: 1,
|
|
349
|
-
createLineItem({ price: 50, quantity: 1,
|
|
350
|
+
createLineItem({ price: 100, quantity: 1, status: 'PAID' }),
|
|
351
|
+
createLineItem({ price: 50, quantity: 1, status: 'PENDING' }),
|
|
350
352
|
],
|
|
351
353
|
payments: [createPayment({ amountTendered: 100 })],
|
|
352
354
|
});
|
|
@@ -359,7 +361,7 @@ describe('mapBillProperties', () => {
|
|
|
359
361
|
it('Handles overpayment (change due scenario)', () => {
|
|
360
362
|
const bill = createBaseBill({
|
|
361
363
|
status: 'PAID',
|
|
362
|
-
lineItems: [createLineItem({ price: 100, quantity: 1,
|
|
364
|
+
lineItems: [createLineItem({ price: 100, quantity: 1, status: 'PAID' })],
|
|
363
365
|
payments: [createPayment({ amount: 100, amountTendered: 150 })],
|
|
364
366
|
});
|
|
365
367
|
const result = mapBillProperties(bill);
|
|
@@ -371,11 +373,11 @@ describe('mapBillProperties', () => {
|
|
|
371
373
|
it('Handles complex bill with mixed item states', () => {
|
|
372
374
|
const bill = createBaseBill({
|
|
373
375
|
lineItems: [
|
|
374
|
-
createLineItem({
|
|
375
|
-
createLineItem({
|
|
376
|
-
createLineItem({
|
|
376
|
+
createLineItem({ status: 'PAID', voided: false, price: 100, quantity: 1, item: 'Consultation' }),
|
|
377
|
+
createLineItem({ status: 'PENDING', voided: false, price: 50, quantity: 2, item: 'Lab Test' }),
|
|
378
|
+
createLineItem({ status: 'PAID', voided: true, price: 200, quantity: 1, item: 'Canceled X-Ray' }),
|
|
377
379
|
createLineItem({
|
|
378
|
-
|
|
380
|
+
status: 'PAID',
|
|
379
381
|
voided: false,
|
|
380
382
|
price: 25,
|
|
381
383
|
quantity: 3,
|
|
@@ -398,8 +400,8 @@ describe('mapBillProperties', () => {
|
|
|
398
400
|
const bill = createBaseBill({
|
|
399
401
|
status: 'PAID',
|
|
400
402
|
lineItems: [
|
|
401
|
-
createLineItem({
|
|
402
|
-
createLineItem({
|
|
403
|
+
createLineItem({ status: 'PENDING', voided: true }),
|
|
404
|
+
createLineItem({ status: 'PENDING', voided: true }),
|
|
403
405
|
],
|
|
404
406
|
});
|
|
405
407
|
const result = mapBillProperties(bill);
|
|
@@ -411,7 +413,7 @@ describe('mapBillProperties', () => {
|
|
|
411
413
|
|
|
412
414
|
it('Handles bill with no payments yet', () => {
|
|
413
415
|
const bill = createBaseBill({
|
|
414
|
-
lineItems: [createLineItem({ price: 100, quantity: 1,
|
|
416
|
+
lineItems: [createLineItem({ price: 100, quantity: 1, status: 'PENDING' })],
|
|
415
417
|
payments: [],
|
|
416
418
|
});
|
|
417
419
|
const result = mapBillProperties(bill);
|
|
@@ -424,8 +426,8 @@ describe('mapBillProperties', () => {
|
|
|
424
426
|
const bill = createBaseBill({
|
|
425
427
|
status: 'PAID',
|
|
426
428
|
lineItems: [
|
|
427
|
-
createLineItem({ price: 50, quantity: 3,
|
|
428
|
-
createLineItem({ price: 100, quantity: 0,
|
|
429
|
+
createLineItem({ price: 50, quantity: 3, status: 'PAID' }), // Originally 1, adjusted to 3
|
|
430
|
+
createLineItem({ price: 100, quantity: 0, status: 'PAID' }), // Adjusted to 0
|
|
429
431
|
],
|
|
430
432
|
payments: [createPayment({ amountTendered: 150 })],
|
|
431
433
|
});
|
package/src/billing.resource.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import useSWR from 'swr';
|
|
1
|
+
import useSWR, { type KeyedMutator } from 'swr';
|
|
2
2
|
import sortBy from 'lodash-es/sortBy';
|
|
3
3
|
import {
|
|
4
4
|
openmrsFetch,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
type CreateBillPayload,
|
|
18
18
|
type UpdateBillPayload,
|
|
19
19
|
BillStatus,
|
|
20
|
+
type PatientPaymentStatus,
|
|
20
21
|
} from './types';
|
|
21
22
|
|
|
22
23
|
const parsePatientDisplay = (display: string | undefined): { identifier: string; name: string } => {
|
|
@@ -46,15 +47,15 @@ export const mapBillProperties = (bill: PatientInvoice): MappedBill => {
|
|
|
46
47
|
patientName: name,
|
|
47
48
|
identifier: identifier,
|
|
48
49
|
patientUuid: bill?.patient?.uuid,
|
|
50
|
+
visitUuid: bill?.visit?.uuid,
|
|
49
51
|
cashPointUuid: bill?.cashPoint?.uuid,
|
|
50
52
|
cashPointName: bill?.cashPoint?.name,
|
|
51
53
|
cashPointLocation: bill?.cashPoint?.location?.display,
|
|
52
54
|
status: bill.status as BillStatus,
|
|
53
55
|
lineItems: activeLineItems,
|
|
54
56
|
billingService: activeLineItems.map((lineItem) => lineItem?.item || lineItem?.billableService || '--').join(' '),
|
|
55
|
-
totalAmount:
|
|
56
|
-
|
|
57
|
-
.reduce((prev, curr) => prev + curr, 0),
|
|
57
|
+
totalAmount: bill.total,
|
|
58
|
+
netAmount: bill.amountAfterDiscount,
|
|
58
59
|
tenderedAmount: (bill?.payments ?? [])
|
|
59
60
|
.map((item) => item.amountTendered ?? 0)
|
|
60
61
|
.reduce((prev, curr) => prev + curr, 0),
|
|
@@ -93,8 +94,7 @@ export const usePaginatedBills = (pageSize: number, status?: string, patientName
|
|
|
93
94
|
};
|
|
94
95
|
};
|
|
95
96
|
|
|
96
|
-
export const useBills = (patientUuid?: string, billStatus?: string) => {
|
|
97
|
-
// Build URL with status parameter if provided
|
|
97
|
+
export const useBills = (patientUuid?: string, billStatus?: string, visitUuid?: string) => {
|
|
98
98
|
let url = `${apiBasePath}bill?v=full`;
|
|
99
99
|
|
|
100
100
|
if (patientUuid) {
|
|
@@ -105,6 +105,10 @@ export const useBills = (patientUuid?: string, billStatus?: string) => {
|
|
|
105
105
|
url += `&status=${billStatus}`;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
if (visitUuid) {
|
|
109
|
+
url += `&visitUuid=${visitUuid}`;
|
|
110
|
+
}
|
|
111
|
+
|
|
108
112
|
const { data, error, isLoading, isValidating, mutate } = useOpenmrsFetchAll<PatientInvoice>(url);
|
|
109
113
|
|
|
110
114
|
const sortedBills = sortBy(data ?? [], ['dateCreated']).reverse();
|
|
@@ -119,23 +123,42 @@ export const useBills = (patientUuid?: string, billStatus?: string) => {
|
|
|
119
123
|
};
|
|
120
124
|
};
|
|
121
125
|
|
|
122
|
-
export
|
|
126
|
+
export function useBill(
|
|
127
|
+
billUuid: string,
|
|
128
|
+
mapProperties: false,
|
|
129
|
+
): {
|
|
130
|
+
bill: PatientInvoice | null;
|
|
131
|
+
error: any;
|
|
132
|
+
isLoading: boolean;
|
|
133
|
+
isValidating: boolean;
|
|
134
|
+
mutate: KeyedMutator<{ data: PatientInvoice }>;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export function useBill(
|
|
138
|
+
billUuid: string,
|
|
139
|
+
mapProperties?: true,
|
|
140
|
+
): {
|
|
141
|
+
bill: MappedBill | null;
|
|
142
|
+
error: any;
|
|
143
|
+
isLoading: boolean;
|
|
144
|
+
isValidating: boolean;
|
|
145
|
+
mutate: KeyedMutator<{ data: PatientInvoice }>;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export function useBill(billUuid: string, mapProperties = true) {
|
|
123
149
|
const url = `${apiBasePath}bill/${billUuid}`;
|
|
124
150
|
const { data, error, isLoading, isValidating, mutate } = useSWR<{ data: PatientInvoice }>(
|
|
125
151
|
billUuid ? url : null,
|
|
126
152
|
openmrsFetch,
|
|
127
153
|
);
|
|
128
154
|
|
|
129
|
-
|
|
155
|
+
let bill: MappedBill | PatientInvoice | null = null;
|
|
156
|
+
if (data?.data) {
|
|
157
|
+
bill = mapProperties ? mapBillProperties(data.data) : data.data;
|
|
158
|
+
}
|
|
130
159
|
|
|
131
|
-
return {
|
|
132
|
-
|
|
133
|
-
error,
|
|
134
|
-
isLoading,
|
|
135
|
-
isValidating,
|
|
136
|
-
mutate,
|
|
137
|
-
};
|
|
138
|
-
};
|
|
160
|
+
return { bill, error, isLoading, isValidating, mutate };
|
|
161
|
+
}
|
|
139
162
|
|
|
140
163
|
export const processBillPayment = (payload: PaymentRequestPayload, billUuid: string) => {
|
|
141
164
|
const url = `${apiBasePath}bill/${billUuid}/payment`;
|
|
@@ -212,3 +235,29 @@ export const deleteBillItem = (itemUuid: string, voidReason: string) => {
|
|
|
212
235
|
method: 'DELETE',
|
|
213
236
|
});
|
|
214
237
|
};
|
|
238
|
+
|
|
239
|
+
export const deleteBill = (billUuid: string, reason: string) => {
|
|
240
|
+
const url = `${apiBasePath}bill/${billUuid}?reason=${encodeURIComponent(reason)}`;
|
|
241
|
+
|
|
242
|
+
return openmrsFetch(url, {
|
|
243
|
+
method: 'DELETE',
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export const patientPaymentStatusCacheKey = (patientUuid: string) =>
|
|
248
|
+
`${apiBasePath}patientPaymentStatus/${patientUuid}`;
|
|
249
|
+
|
|
250
|
+
export const usePatientPaymentStatus = (patientUuid: string) => {
|
|
251
|
+
const url = patientPaymentStatusCacheKey(patientUuid);
|
|
252
|
+
const { data, error, isLoading, isValidating, mutate } = useSWR<{ data: PatientPaymentStatus }>(
|
|
253
|
+
patientUuid ? url : null,
|
|
254
|
+
openmrsFetch,
|
|
255
|
+
);
|
|
256
|
+
return {
|
|
257
|
+
paymentStatus: data?.data,
|
|
258
|
+
error,
|
|
259
|
+
isLoading,
|
|
260
|
+
isValidating,
|
|
261
|
+
mutate,
|
|
262
|
+
};
|
|
263
|
+
};
|
|
@@ -45,7 +45,7 @@ interface BillDisplayItem extends Omit<MappedBill, 'id'> {
|
|
|
45
45
|
interface BillPaymentStatusFilterItem {
|
|
46
46
|
id: BillStatus | '';
|
|
47
47
|
text: string;
|
|
48
|
-
status:
|
|
48
|
+
status: string;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
const mapLineItems = (bill: MappedBill) =>
|
|
@@ -72,13 +72,24 @@ const BillsTable: React.FC = () => {
|
|
|
72
72
|
},
|
|
73
73
|
{ id: BillStatus.POSTED, text: t('pendingPaymentBills', 'Pending payment'), status: BillStatus.POSTED },
|
|
74
74
|
{ id: BillStatus.PAID, text: t('paidBills', 'Paid bills'), status: BillStatus.PAID },
|
|
75
|
+
{
|
|
76
|
+
id: BillStatus.REFUNDED,
|
|
77
|
+
text: t('refundedBills', 'Refunded bills'),
|
|
78
|
+
status: `${BillStatus.REFUNDED},${BillStatus.PARTIALLY_REFUNDED}`,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: BillStatus.REFUND_REQUESTED,
|
|
82
|
+
text: t('pendingRefundBills', 'Pending refunds'),
|
|
83
|
+
status: BillStatus.REFUND_REQUESTED,
|
|
84
|
+
},
|
|
75
85
|
],
|
|
76
86
|
[t],
|
|
77
87
|
);
|
|
78
88
|
|
|
79
|
-
// Default to '
|
|
89
|
+
// Default to 'PENDING' (pending confirmation) so cashiers see bills awaiting confirmation on load
|
|
80
90
|
const [billPaymentStatus, setBillPaymentStatus] = useState<BillPaymentStatusFilterItem>(
|
|
81
|
-
() =>
|
|
91
|
+
() =>
|
|
92
|
+
billPaymentStatusFilterItems.find((item) => item.id === BillStatus.PENDING) ?? billPaymentStatusFilterItems[0],
|
|
82
93
|
);
|
|
83
94
|
const [searchString, setSearchString] = useState('');
|
|
84
95
|
const debouncedSearchString = useDebounce(searchString, 500);
|
|
@@ -173,7 +184,7 @@ const BillsTable: React.FC = () => {
|
|
|
173
184
|
</div>
|
|
174
185
|
|
|
175
186
|
{isLoading && !bills?.length ? (
|
|
176
|
-
<div className={styles.loaderContainer}
|
|
187
|
+
<div className={styles.loaderContainer} data-testid="bills-table-skeleton">
|
|
177
188
|
<DataTableSkeleton
|
|
178
189
|
rowCount={pageSize}
|
|
179
190
|
showHeader={false}
|