@kenyaemr/esm-billing-app 5.4.2-pre.2244 → 5.4.2-pre.2248
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/turbo-build.log +1 -1
- package/dist/964.js +1 -1
- package/dist/964.js.map +1 -1
- package/dist/kenyaemr-esm-billing-app.js.buildmanifest.json +6 -6
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/invoice/payments/payments.test.tsx +111 -19
- package/src/invoice/payments/utils.ts +2 -5
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemr":"^19.0.0"},"pages":[{"component":"billableServicesHome","route":"billable-services"},{"component":"requirePaymentModal","routeRegex":"^patient/.+/chart","online":true,"offline":false}],"extensions":[{"component":"benefitsPackageDashboardLink","name":"benefits-package-dashboard-link","slot":"patient-chart-dashboard-slot","meta":{"name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot","path":"insurance-benefits","columns":1,"columnSpan":1},"featureFlag":"healthInformationExchange"},{"component":"benefitsPackage","name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot"},{"component":"root","name":"billing-dashboard-root","slot":"billing-dashboard-slot"},{"component":"benefitsEligibilyRequestForm","name":"benefits-eligibility-request-form"},{"component":"benefitsPreAuthForm","name":"benefits-pre-auth-form"},{"name":"billing-patient-summary","component":"billingPatientSummary","slot":"patient-chart-billing-dashboard-slot","order":10,"meta":{"columnSpan":4}},{"name":"billing-summary-dashboard-link","component":"billingSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-billing-dashboard-slot","path":"Billing","layoutMode":"anchored"}},{"name":"billing-check-in-form","slot":"extra-visit-attribute-slot","component":"billingCheckInForm"},{"name":"require-billing-modal","component":"requirePaymentModal"},{"name":"patient-banner-billing-tags","component":"visitAttributeTags","slot":"patient-banner-tags-slot","order":2},{"name":"initiate-payment-modal","component":"initiatePaymentDialog"},{"name":"delete-billableservice-modal","component":"deleteBillableServiceModal"},{"name":"refund-bill-modal","component":"refundBillModal"},{"name":"delete-bill-modal","component":"deleteBillModal"},{"name":"lab-order-billable-item","component":"labOrder","slot":"top-of-lab-order-form-slot"},{"name":"procedure-order-billable-item","component":"procedureOrder","slot":"top-of-procedure-order-form-slot"},{"name":"imaging-order-billable-item","component":"imagingOrder","slot":"top-of-imaging-order-form-slot"},{"name":"price-info-order","component":"priceInfoOrder"},{"name":"drug-order-billable-item","component":"drugOrder","slot":"medication-info-slot"},{"name":"order-action-button","component":"orderActionButton","slots":["prescription-action-button-slot","imaging-orders-action","procedure-orders-action","tests-ordered-actions-slot"],"order":0},{"component":"billingOverviewLink","name":"billing-overview-link","order":0,"slot":"billing-dashboard-group-nav-slot"},{"component":"billDepositDashboardLink","name":"bill-deposit-dashboard-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentHistoryLink","name":"payment-history-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentPointsLink","name":"payment-points-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentModesLink","name":"payment-modes-link","slot":"billing-dashboard-group-nav-slot"},{"component":"billManagerLink","name":"bill-manager-link","slot":"billing-dashboard-group-nav-slot"},{"component":"chargeableItemsLink","name":"chargeable-items-link","slot":"billing-dashboard-group-nav-slot"},{"component":"billableExemptionsLink","name":"billable-exemptions-link","slot":"billing-dashboard-group-nav-slot"},{"component":"claimsManagementOverviewDashboardLink","name":"claims-management-overview-link","order":0,"slot":"claims-management-dashboard-link-slot"},{"component":"preAuthRequestsDashboardLink","name":"preauthrequest-overview-link","slot":"claims-management-dashboard-link-slot"},{"component":"claimsOverview","name":"claims-overview-dashboard-link","slot":"claims-management-overview-slot"},{"component":"waiveBillActionButton","name":"waive-bill-action-button","slot":"bill-actions-slot"},{"component":"deleteBillActionButton","name":"delete-bill-action-button","slot":"bill-actions-slot"},{"component":"refundLineItem","name":"refund-line-item","slot":"bill-actions-overflow-menu-slot"},{"name":"edit-line-item","component":"editLineItem","slot":"bill-actions-overflow-menu-slot"},{"name":"cancel-line-item","component":"cancelLineItem","slot":"bill-actions-overflow-menu-slot"}],"workspaces":[{"name":"create-bill-workspace","component":"createBillWorkspace","title":"Create Bill Workspace","type":"other-form"},{"name":"waive-bill-form","component":"waiveBillForm","title":"Waive Bill Form","type":"other-form"},{"name":"edit-bill-form","component":"editBillForm","title":"Edit Bill Form","type":"other-form"},{"name":"billable-service-form","component":"addServiceForm","title":"Create Charge Item Form","type":"other-form"},{"name":"commodity-form","component":"addCommodityForm","title":"Create Charge Item Form","type":"other-form"},{"name":"billing-form","component":"billingForm","title":"Billing Form","type":"other-form","width":"extra-wide"},{"name":"payment-mode-workspace","component":"paymentModeWorkspace","title":"Payment Mode Workspace","type":"other-form"},{"name":"cancel-bill-workspace","component":"cancelBillWorkspace","title":"Cancel Bill Workspace","type":"other-form"},{"name":"add-deposit-workspace","component":"addDepositWorkspace","title":"Add Deposit","type":"other-form"},{"name":"deposit-transaction-workspace","component":"depositTransactionWorkspace","title":"Deposit Transaction","type":"other-form"}],"modals":[{"name":"create-payment-point","component":"createPaymentPoint"},{"name":"clock-out-modal","component":"clockOut"},{"name":"bulk-import-billable-services-modal","component":"bulkImportBillableServicesModal"},{"name":"delete-payment-mode-modal","component":"deletePaymentModeModal"},{"name":"manage-claim-request-modal","component":"manageClaimRequestModal"},{"name":"paid-bill-receipt-print-preview-modal","component":"paidBillReceiptPrintPreviewModal"},{"name":"clock-in-modal","component":"clockIn"},{"name":"create-bill-item-modal","component":"createBillItemModal"},{"name":"delete-deposit-modal","component":"deleteDepositModal"},{"name":"reverse-transaction-modal","component":"reverseTransactionModal"}],"version":"5.4.2-pre.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemr":"^19.0.0"},"pages":[{"component":"billableServicesHome","route":"billable-services"},{"component":"requirePaymentModal","routeRegex":"^patient/.+/chart","online":true,"offline":false}],"extensions":[{"component":"benefitsPackageDashboardLink","name":"benefits-package-dashboard-link","slot":"patient-chart-dashboard-slot","meta":{"name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot","path":"insurance-benefits","columns":1,"columnSpan":1},"featureFlag":"healthInformationExchange"},{"component":"benefitsPackage","name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot"},{"component":"root","name":"billing-dashboard-root","slot":"billing-dashboard-slot"},{"component":"benefitsEligibilyRequestForm","name":"benefits-eligibility-request-form"},{"component":"benefitsPreAuthForm","name":"benefits-pre-auth-form"},{"name":"billing-patient-summary","component":"billingPatientSummary","slot":"patient-chart-billing-dashboard-slot","order":10,"meta":{"columnSpan":4}},{"name":"billing-summary-dashboard-link","component":"billingSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-billing-dashboard-slot","path":"Billing","layoutMode":"anchored"}},{"name":"billing-check-in-form","slot":"extra-visit-attribute-slot","component":"billingCheckInForm"},{"name":"require-billing-modal","component":"requirePaymentModal"},{"name":"patient-banner-billing-tags","component":"visitAttributeTags","slot":"patient-banner-tags-slot","order":2},{"name":"initiate-payment-modal","component":"initiatePaymentDialog"},{"name":"delete-billableservice-modal","component":"deleteBillableServiceModal"},{"name":"refund-bill-modal","component":"refundBillModal"},{"name":"delete-bill-modal","component":"deleteBillModal"},{"name":"lab-order-billable-item","component":"labOrder","slot":"top-of-lab-order-form-slot"},{"name":"procedure-order-billable-item","component":"procedureOrder","slot":"top-of-procedure-order-form-slot"},{"name":"imaging-order-billable-item","component":"imagingOrder","slot":"top-of-imaging-order-form-slot"},{"name":"price-info-order","component":"priceInfoOrder"},{"name":"drug-order-billable-item","component":"drugOrder","slot":"medication-info-slot"},{"name":"order-action-button","component":"orderActionButton","slots":["prescription-action-button-slot","imaging-orders-action","procedure-orders-action","tests-ordered-actions-slot"],"order":0},{"component":"billingOverviewLink","name":"billing-overview-link","order":0,"slot":"billing-dashboard-group-nav-slot"},{"component":"billDepositDashboardLink","name":"bill-deposit-dashboard-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentHistoryLink","name":"payment-history-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentPointsLink","name":"payment-points-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentModesLink","name":"payment-modes-link","slot":"billing-dashboard-group-nav-slot"},{"component":"billManagerLink","name":"bill-manager-link","slot":"billing-dashboard-group-nav-slot"},{"component":"chargeableItemsLink","name":"chargeable-items-link","slot":"billing-dashboard-group-nav-slot"},{"component":"billableExemptionsLink","name":"billable-exemptions-link","slot":"billing-dashboard-group-nav-slot"},{"component":"claimsManagementOverviewDashboardLink","name":"claims-management-overview-link","order":0,"slot":"claims-management-dashboard-link-slot"},{"component":"preAuthRequestsDashboardLink","name":"preauthrequest-overview-link","slot":"claims-management-dashboard-link-slot"},{"component":"claimsOverview","name":"claims-overview-dashboard-link","slot":"claims-management-overview-slot"},{"component":"waiveBillActionButton","name":"waive-bill-action-button","slot":"bill-actions-slot"},{"component":"deleteBillActionButton","name":"delete-bill-action-button","slot":"bill-actions-slot"},{"component":"refundLineItem","name":"refund-line-item","slot":"bill-actions-overflow-menu-slot"},{"name":"edit-line-item","component":"editLineItem","slot":"bill-actions-overflow-menu-slot"},{"name":"cancel-line-item","component":"cancelLineItem","slot":"bill-actions-overflow-menu-slot"}],"workspaces":[{"name":"create-bill-workspace","component":"createBillWorkspace","title":"Create Bill Workspace","type":"other-form"},{"name":"waive-bill-form","component":"waiveBillForm","title":"Waive Bill Form","type":"other-form"},{"name":"edit-bill-form","component":"editBillForm","title":"Edit Bill Form","type":"other-form"},{"name":"billable-service-form","component":"addServiceForm","title":"Create Charge Item Form","type":"other-form"},{"name":"commodity-form","component":"addCommodityForm","title":"Create Charge Item Form","type":"other-form"},{"name":"billing-form","component":"billingForm","title":"Billing Form","type":"other-form","width":"extra-wide"},{"name":"payment-mode-workspace","component":"paymentModeWorkspace","title":"Payment Mode Workspace","type":"other-form"},{"name":"cancel-bill-workspace","component":"cancelBillWorkspace","title":"Cancel Bill Workspace","type":"other-form"},{"name":"add-deposit-workspace","component":"addDepositWorkspace","title":"Add Deposit","type":"other-form"},{"name":"deposit-transaction-workspace","component":"depositTransactionWorkspace","title":"Deposit Transaction","type":"other-form"}],"modals":[{"name":"create-payment-point","component":"createPaymentPoint"},{"name":"clock-out-modal","component":"clockOut"},{"name":"bulk-import-billable-services-modal","component":"bulkImportBillableServicesModal"},{"name":"delete-payment-mode-modal","component":"deletePaymentModeModal"},{"name":"manage-claim-request-modal","component":"manageClaimRequestModal"},{"name":"paid-bill-receipt-print-preview-modal","component":"paidBillReceiptPrintPreviewModal"},{"name":"clock-in-modal","component":"clockIn"},{"name":"create-bill-item-modal","component":"createBillItemModal"},{"name":"delete-deposit-modal","component":"deleteDepositModal"},{"name":"reverse-transaction-modal","component":"reverseTransactionModal"}],"version":"5.4.2-pre.2248"}
|
package/package.json
CHANGED
|
@@ -20,23 +20,49 @@ jest.mock('../../billing.resource', () => ({
|
|
|
20
20
|
jest.mock('../../payment-points/use-clock-in-status');
|
|
21
21
|
const mockedUseClockInStatus = useClockInStatus as jest.Mock;
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
const updatedMockPaymentModes: PaymentMethod[] = mockPaymentModes.map((mode) => {
|
|
24
|
+
const baseMode = {
|
|
25
|
+
...mode,
|
|
26
|
+
retireReason: null,
|
|
27
|
+
auditInfo: {
|
|
28
|
+
dateCreated: '2024-01-01',
|
|
29
|
+
creator: {
|
|
30
|
+
uuid: 'user-1',
|
|
31
|
+
display: 'Test User',
|
|
32
|
+
links: [{ rel: 'self', uri: '/ws/rest/v1/user/user-1', resourceAlias: 'user' }],
|
|
33
|
+
},
|
|
34
|
+
dateChanged: null,
|
|
35
|
+
changedBy: null,
|
|
33
36
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
sortOrder: null,
|
|
38
|
+
resourceVersion: '1.8',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Add attribute types for Mobile Money payment method
|
|
42
|
+
if (mode.name === 'Mobile Money') {
|
|
43
|
+
return {
|
|
44
|
+
...baseMode,
|
|
45
|
+
attributeTypes: [
|
|
46
|
+
{
|
|
47
|
+
uuid: 'd453e528-0264-4d6e-ae23-bc0b777e1146',
|
|
48
|
+
name: 'Reference Number',
|
|
49
|
+
description: 'Reference Number',
|
|
50
|
+
retired: false,
|
|
51
|
+
attributeOrder: 0,
|
|
52
|
+
format: 'java.lang.String',
|
|
53
|
+
foreignKey: null,
|
|
54
|
+
regExp: null,
|
|
55
|
+
required: true,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
...baseMode,
|
|
63
|
+
attributeTypes: mode.attributeTypes || [],
|
|
64
|
+
};
|
|
65
|
+
});
|
|
40
66
|
|
|
41
67
|
// Update mockLineItems to include all required properties
|
|
42
68
|
const updatedMockLineItems: LineItem[] = mockLineItems.map((item) => ({
|
|
@@ -52,6 +78,10 @@ const updatedMockLineItems: LineItem[] = mockLineItems.map((item) => ({
|
|
|
52
78
|
}));
|
|
53
79
|
|
|
54
80
|
describe('Payment', () => {
|
|
81
|
+
beforeEach(() => {
|
|
82
|
+
jest.clearAllMocks();
|
|
83
|
+
});
|
|
84
|
+
|
|
55
85
|
test('should display error when posting payment fails', async () => {
|
|
56
86
|
const user = userEvent.setup();
|
|
57
87
|
const mockFieldErrorResponse = {
|
|
@@ -85,12 +115,16 @@ describe('Payment', () => {
|
|
|
85
115
|
const addPaymentMethod = screen.getByRole('button', { name: /Add payment option/i });
|
|
86
116
|
await user.click(addPaymentMethod);
|
|
87
117
|
await user.click(screen.getByRole('combobox', { name: /Payment method/i }));
|
|
88
|
-
const
|
|
89
|
-
await user.click(
|
|
118
|
+
const mobileMoneyOption = screen.getByRole('option', { name: /Mobile Money/i });
|
|
119
|
+
await user.click(mobileMoneyOption);
|
|
90
120
|
|
|
91
121
|
const amountInput = screen.getByRole('spinbutton', { name: /Amount/i });
|
|
92
122
|
await user.type(amountInput, '100');
|
|
93
123
|
|
|
124
|
+
// Fill in the reference number field for Mobile Money payment
|
|
125
|
+
const referenceInput = screen.getByRole('textbox', { name: /Reference Number/i });
|
|
126
|
+
await user.type(referenceInput, 'MPESA123456');
|
|
127
|
+
|
|
94
128
|
const submitButton = screen.getByRole('button', { name: /Process Payment/i });
|
|
95
129
|
await user.click(submitButton);
|
|
96
130
|
|
|
@@ -187,7 +221,17 @@ describe('Payment', () => {
|
|
|
187
221
|
],
|
|
188
222
|
patient: 'b2fcf02b-7ee3-4d16-a48f-576be2b103aa',
|
|
189
223
|
payments: [
|
|
190
|
-
{
|
|
224
|
+
{
|
|
225
|
+
amount: 100,
|
|
226
|
+
amountTendered: 100,
|
|
227
|
+
attributes: [
|
|
228
|
+
{
|
|
229
|
+
attributeType: 'd453e528-0264-4d6e-ae23-bc0b777e1146',
|
|
230
|
+
value: 'MPESA123456',
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
instanceType: '28989582-e8c3-46b0-96d0-c249cb06d5c6',
|
|
234
|
+
},
|
|
191
235
|
],
|
|
192
236
|
status: 'PENDING',
|
|
193
237
|
},
|
|
@@ -204,6 +248,54 @@ describe('Payment', () => {
|
|
|
204
248
|
});
|
|
205
249
|
});
|
|
206
250
|
|
|
251
|
+
test('should process payment with correct payload for payment method without attributes', async () => {
|
|
252
|
+
const user = userEvent.setup();
|
|
253
|
+
mockProcessBillPayment.mockResolvedValueOnce({} as any);
|
|
254
|
+
mockUsePaymentModes.mockReturnValue({
|
|
255
|
+
paymentModes: updatedMockPaymentModes,
|
|
256
|
+
isLoading: false,
|
|
257
|
+
error: null,
|
|
258
|
+
mutate: jest.fn(),
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
mockedUseClockInStatus.mockReturnValue({
|
|
262
|
+
globalActiveSheet: mockedActiveSheet,
|
|
263
|
+
localActiveSheet: undefined,
|
|
264
|
+
isClockedIn: true,
|
|
265
|
+
error: null,
|
|
266
|
+
isLoading: false,
|
|
267
|
+
isClockedInCurrentPaymentPoint: false,
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
render(<Payments bill={mockBill as any} selectedLineItems={updatedMockLineItems} />);
|
|
271
|
+
const addPaymentMethod = screen.getByRole('button', { name: /Add payment option/i });
|
|
272
|
+
await user.click(addPaymentMethod);
|
|
273
|
+
await user.click(screen.getByRole('combobox', { name: /Payment method/i }));
|
|
274
|
+
const cashOption = screen.getByRole('option', { name: /Cash/i });
|
|
275
|
+
await user.click(cashOption);
|
|
276
|
+
|
|
277
|
+
const amountInput = screen.getByRole('spinbutton', { name: /Amount/i });
|
|
278
|
+
await user.type(amountInput, '100');
|
|
279
|
+
|
|
280
|
+
const submitButton = screen.getByRole('button', { name: /Process Payment/i });
|
|
281
|
+
await user.click(submitButton);
|
|
282
|
+
|
|
283
|
+
expect(mockProcessBillPayment).toHaveBeenCalledTimes(1);
|
|
284
|
+
expect(mockProcessBillPayment).toHaveBeenCalledWith(
|
|
285
|
+
expect.objectContaining({
|
|
286
|
+
payments: [
|
|
287
|
+
{
|
|
288
|
+
amount: 100,
|
|
289
|
+
amountTendered: 100,
|
|
290
|
+
attributes: [],
|
|
291
|
+
instanceType: '63eff7a4-6f82-43c4-a333-dbcc58fe9f74',
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
}),
|
|
295
|
+
'6eb8d678-514d-46ad-9554-51e48d96d567',
|
|
296
|
+
);
|
|
297
|
+
});
|
|
298
|
+
|
|
207
299
|
test('should automatically focus on the payment method field when user clicks add payment options', async () => {
|
|
208
300
|
const user = userEvent.setup();
|
|
209
301
|
mockUsePaymentModes.mockReturnValue({
|
|
@@ -144,11 +144,8 @@ export const createPaymentPayload = (
|
|
|
144
144
|
[...currentPayments, ...existingPayments]?.map((payment) => ({
|
|
145
145
|
amount: payment.amount,
|
|
146
146
|
amountTendered: payment.amountTendered,
|
|
147
|
-
attributes: payment.attributes
|
|
148
|
-
|
|
149
|
-
value: attribute.value,
|
|
150
|
-
})),
|
|
151
|
-
instanceType: payment.instanceType.uuid,
|
|
147
|
+
attributes: payment.attributes,
|
|
148
|
+
instanceType: payment?.instanceType,
|
|
152
149
|
})) ?? [];
|
|
153
150
|
const totalPaidAmount = consolidatedPayments.reduce((sum, payment) => sum + payment.amountTendered, 0);
|
|
154
151
|
|