@openmrs/esm-stock-management-app 1.0.1-pre.597 → 1.0.1-pre.606
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/173.js +1 -1
- package/dist/173.js.map +1 -1
- package/dist/574.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +9 -9
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +19 -12
- package/src/stock-operations/add-stock-operation/base-operation-details.component.tsx +1 -1
- package/src/stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component.tsx +1 -1
- package/src/stock-operations/stock-operations-dialog/stock-operations-approve-button.component.tsx +1 -1
- package/src/stock-operations/stock-operations-dialog/stock-operations-approve-dispatch-button.component.tsx +2 -2
- package/src/stock-operations/stock-print-reports/StockOperationReport.tsx +3 -3
- package/src/stock-sources/stock-sources-delete/stock-sources-delete.test.tsx +25 -16
- package/translations/en.json +1 -1
@@ -85,9 +85,9 @@
|
|
85
85
|
"initial": false,
|
86
86
|
"entry": false,
|
87
87
|
"recorded": false,
|
88
|
-
"size":
|
88
|
+
"size": 1840985,
|
89
89
|
"sizes": {
|
90
|
-
"javascript":
|
90
|
+
"javascript": 1840775,
|
91
91
|
"consume-shared": 210
|
92
92
|
},
|
93
93
|
"names": [],
|
@@ -101,7 +101,7 @@
|
|
101
101
|
"auxiliaryFiles": [
|
102
102
|
"173.js.map"
|
103
103
|
],
|
104
|
-
"hash": "
|
104
|
+
"hash": "32293cb595f3bc1a",
|
105
105
|
"childrenByOrder": {}
|
106
106
|
},
|
107
107
|
{
|
@@ -109,10 +109,10 @@
|
|
109
109
|
"initial": true,
|
110
110
|
"entry": true,
|
111
111
|
"recorded": false,
|
112
|
-
"size":
|
112
|
+
"size": 5509412,
|
113
113
|
"sizes": {
|
114
114
|
"consume-shared": 252,
|
115
|
-
"javascript":
|
115
|
+
"javascript": 5487462,
|
116
116
|
"share-init": 252,
|
117
117
|
"runtime": 21446
|
118
118
|
},
|
@@ -129,7 +129,7 @@
|
|
129
129
|
"auxiliaryFiles": [
|
130
130
|
"main.js.map"
|
131
131
|
],
|
132
|
-
"hash": "
|
132
|
+
"hash": "eadc2b790e0bb731",
|
133
133
|
"childrenByOrder": {}
|
134
134
|
},
|
135
135
|
{
|
@@ -251,9 +251,9 @@
|
|
251
251
|
"initial": false,
|
252
252
|
"entry": false,
|
253
253
|
"recorded": false,
|
254
|
-
"size":
|
254
|
+
"size": 11501,
|
255
255
|
"sizes": {
|
256
|
-
"javascript":
|
256
|
+
"javascript": 11501
|
257
257
|
},
|
258
258
|
"names": [],
|
259
259
|
"idHints": [],
|
@@ -265,7 +265,7 @@
|
|
265
265
|
"574.js"
|
266
266
|
],
|
267
267
|
"auxiliaryFiles": [],
|
268
|
-
"hash": "
|
268
|
+
"hash": "b881a6484ecb0d98",
|
269
269
|
"childrenByOrder": {}
|
270
270
|
},
|
271
271
|
{
|
package/dist/routes.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-nav-menu","slot":"stock-sidebar-slot","component":"stockNavMenu","online":true,"offline":true},{"name":"overview-db-link","slot":"stock-page-dashboard-slot","component":"stockOverviewLink","meta":{"name":"overview","slot":"overview-dashboard-slot","title":"overview"},"order":0,"online":true,"offline":true},{"name":"stock-overview-db","slot":"overview-dashboard-slot","component":"stockOverview"},{"name":"operations-db-link","slot":"stock-page-dashboard-slot","component":"stockOperationsLink","meta":{"name":"operations","slot":"operations-dashboard-slot","title":"operations"},"order":2,"online":true,"offline":true},{"name":"stock-operations-db","slot":"operations-dashboard-slot","component":"stockOperations"},{"name":"items-db-link","slot":"stock-page-dashboard-slot","component":"stockItemsLink","meta":{"name":"items","slot":"items-dashboard-slot","title":"items"},"order":1,"online":true,"offline":true},{"name":"stock-items-db","slot":"items-dashboard-slot","component":"stockItems"},{"name":"user-scopes-db-link","slot":"stock-page-dashboard-slot","component":"stockUserScopesLink","meta":{"name":"user-scopes","slot":"user-scopes-dashboard-slot","title":"user-scopes"},"order":3,"online":true,"offline":true},{"name":"stock-user-scopes-db","slot":"user-scopes-dashboard-slot","component":"stockUserScopes"},{"name":"sources-db-link","slot":"stock-page-dashboard-slot","component":"stockSourcesLink","meta":{"name":"sources","slot":"sources-dashboard-slot","title":"Sources"},"order":2,"online":true,"offline":true},{"name":"stock-sources-db","slot":"sources-dashboard-slot","component":"stockSources"},{"name":"locations-db-link","slot":"stock-page-dashboard-slot","component":"stockLocationsLink","meta":{"name":"locations","slot":"locations-dashboard-slot","title":"Locations"},"order":4,"online":true,"offline":true},{"name":"stock-locations-db","slot":"locations-dashboard-slot","component":"stockLocations"},{"name":"reports-db-link","slot":"stock-page-dashboard-slot","component":"stockReportsLink","meta":{"name":"reports","slot":"reports-dashboard-slot","title":"Reports"},"order":5,"online":true,"offline":true},{"name":"stock-reports-db","slot":"reports-dashboard-slot","component":"stockReports"},{"name":"settings-db-link","slot":"stock-page-dashboard-slot","component":"stockSettingsLink","meta":{"name":"settings","slot":"settings-dashboard-slot","title":"Settings"},"order":6,"online":true,"offline":true},{"name":"stock-settings-db","slot":"settings-dashboard-slot","component":"stockSettings"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"root","route":"stock-management"}],"version":"1.0.1-pre.
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-nav-menu","slot":"stock-sidebar-slot","component":"stockNavMenu","online":true,"offline":true},{"name":"overview-db-link","slot":"stock-page-dashboard-slot","component":"stockOverviewLink","meta":{"name":"overview","slot":"overview-dashboard-slot","title":"overview"},"order":0,"online":true,"offline":true},{"name":"stock-overview-db","slot":"overview-dashboard-slot","component":"stockOverview"},{"name":"operations-db-link","slot":"stock-page-dashboard-slot","component":"stockOperationsLink","meta":{"name":"operations","slot":"operations-dashboard-slot","title":"operations"},"order":2,"online":true,"offline":true},{"name":"stock-operations-db","slot":"operations-dashboard-slot","component":"stockOperations"},{"name":"items-db-link","slot":"stock-page-dashboard-slot","component":"stockItemsLink","meta":{"name":"items","slot":"items-dashboard-slot","title":"items"},"order":1,"online":true,"offline":true},{"name":"stock-items-db","slot":"items-dashboard-slot","component":"stockItems"},{"name":"user-scopes-db-link","slot":"stock-page-dashboard-slot","component":"stockUserScopesLink","meta":{"name":"user-scopes","slot":"user-scopes-dashboard-slot","title":"user-scopes"},"order":3,"online":true,"offline":true},{"name":"stock-user-scopes-db","slot":"user-scopes-dashboard-slot","component":"stockUserScopes"},{"name":"sources-db-link","slot":"stock-page-dashboard-slot","component":"stockSourcesLink","meta":{"name":"sources","slot":"sources-dashboard-slot","title":"Sources"},"order":2,"online":true,"offline":true},{"name":"stock-sources-db","slot":"sources-dashboard-slot","component":"stockSources"},{"name":"locations-db-link","slot":"stock-page-dashboard-slot","component":"stockLocationsLink","meta":{"name":"locations","slot":"locations-dashboard-slot","title":"Locations"},"order":4,"online":true,"offline":true},{"name":"stock-locations-db","slot":"locations-dashboard-slot","component":"stockLocations"},{"name":"reports-db-link","slot":"stock-page-dashboard-slot","component":"stockReportsLink","meta":{"name":"reports","slot":"reports-dashboard-slot","title":"Reports"},"order":5,"online":true,"offline":true},{"name":"stock-reports-db","slot":"reports-dashboard-slot","component":"stockReports"},{"name":"settings-db-link","slot":"stock-page-dashboard-slot","component":"stockSettingsLink","meta":{"name":"settings","slot":"settings-dashboard-slot","title":"Settings"},"order":6,"online":true,"offline":true},{"name":"stock-settings-db","slot":"settings-dashboard-slot","component":"stockSettings"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"root","route":"stock-management"}],"version":"1.0.1-pre.606"}
|
package/package.json
CHANGED
@@ -30,6 +30,7 @@ import {
|
|
30
30
|
StockOperationType,
|
31
31
|
StockOperationTypeCanBeRelatedToRequisition,
|
32
32
|
operationFromString,
|
33
|
+
StockOperationTypeRequiresDispatchAcknowledgement,
|
33
34
|
} from "../../core/api/types/stockOperation/StockOperationType";
|
34
35
|
import {
|
35
36
|
getStockOperationLinks,
|
@@ -52,6 +53,9 @@ const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
|
|
52
53
|
props?.isEditing
|
53
54
|
);
|
54
55
|
|
56
|
+
const [requiresDispatchAcknowledgement, setRequiresDispatchAcknowledgement] =
|
57
|
+
useState(false);
|
58
|
+
|
55
59
|
const currentStockOperationType = types?.results?.find(
|
56
60
|
(p) => p.operationType === props.model?.operationType
|
57
61
|
);
|
@@ -88,6 +92,18 @@ const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
|
|
88
92
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
89
93
|
const [canDisplayReceivedItems, setCanDisplayReceivedItems] = useState(false);
|
90
94
|
|
95
|
+
useEffect(() => {
|
96
|
+
const validOperationType = Object.values(OperationType).includes(
|
97
|
+
props.model.operationType as OperationType
|
98
|
+
)
|
99
|
+
? (props.model.operationType as OperationType)
|
100
|
+
: OperationType.RETURN_OPERATION_TYPE;
|
101
|
+
|
102
|
+
setRequiresDispatchAcknowledgement(
|
103
|
+
StockOperationTypeRequiresDispatchAcknowledgement(validOperationType)
|
104
|
+
);
|
105
|
+
}, [props.model.operationType]);
|
106
|
+
|
91
107
|
useEffect(() => {
|
92
108
|
setCanDisplayReceivedItems(
|
93
109
|
props?.model?.permission?.canDisplayReceivedItems ?? false
|
@@ -467,24 +483,15 @@ const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
|
|
467
483
|
{!props?.model?.permission?.canEdit &&
|
468
484
|
props?.model?.permission?.canApprove && (
|
469
485
|
<>
|
470
|
-
{(
|
471
|
-
? props?.model?.operationTypeName ===
|
472
|
-
OperationType.RETURN_OPERATION_TYPE ||
|
473
|
-
props?.model?.operationTypeName ===
|
474
|
-
OperationType.STOCK_ISSUE_OPERATION_TYPE
|
475
|
-
: true) && (
|
486
|
+
{!requiresDispatchAcknowledgement && (
|
476
487
|
<div style={{ margin: "2px" }}>
|
477
488
|
<StockOperationApprovalButton
|
478
489
|
operation={props?.model}
|
479
490
|
/>
|
480
491
|
</div>
|
481
492
|
)}
|
482
|
-
|
483
|
-
|
484
|
-
OperationType.RETURN_OPERATION_TYPE ||
|
485
|
-
props?.model?.operationTypeName ===
|
486
|
-
OperationType.STOCK_ISSUE_OPERATION_TYPE
|
487
|
-
: true) && (
|
493
|
+
|
494
|
+
{requiresDispatchAcknowledgement && (
|
488
495
|
<div style={{ margin: "2px" }}>
|
489
496
|
<StockOperationApproveDispatchButton
|
490
497
|
operation={props?.model}
|
@@ -165,7 +165,7 @@ const BaseOperationDetails: React.FC<BaseOperationDetailsProps> = ({
|
|
165
165
|
{model?.operationNumber && (
|
166
166
|
<TextInput
|
167
167
|
id="operationNoLbl"
|
168
|
-
value={model
|
168
|
+
value={model?.operationNumber}
|
169
169
|
readOnly={true}
|
170
170
|
labelText={t("operationNumber", "Operation Number")}
|
171
171
|
/>
|
package/src/stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component.tsx
CHANGED
@@ -36,7 +36,7 @@ const EditStockOperationActionMenu: React.FC<
|
|
36
36
|
iconDescription={t("editStockOperation", "Edit Stock Operation")}
|
37
37
|
renderIcon={showIcon ? Edit : undefined}
|
38
38
|
>
|
39
|
-
{showprops && model
|
39
|
+
{showprops && model?.operationNumber}
|
40
40
|
</Button>
|
41
41
|
);
|
42
42
|
};
|
@@ -18,7 +18,7 @@ const StockOperationApproveDispatchButton: React.FC<
|
|
18
18
|
const dispose = showModal("stock-operation-dialog", {
|
19
19
|
title: "Dispatch",
|
20
20
|
operation: operation,
|
21
|
-
requireReason:
|
21
|
+
requireReason: false,
|
22
22
|
closeModal: () => dispose(),
|
23
23
|
});
|
24
24
|
}, [operation]);
|
@@ -28,7 +28,7 @@ const StockOperationApproveDispatchButton: React.FC<
|
|
28
28
|
onClick={launchApproveDispatchModal}
|
29
29
|
renderIcon={(props) => <Departure size={16} {...props} />}
|
30
30
|
>
|
31
|
-
{t("
|
31
|
+
{t("dispatch", "Dispatch")}
|
32
32
|
</Button>
|
33
33
|
);
|
34
34
|
};
|
@@ -63,7 +63,7 @@ export const BuildStockOperationData = async (
|
|
63
63
|
: "";
|
64
64
|
}
|
65
65
|
data.remarks = currentOperation.remarks;
|
66
|
-
data.operationNumber = currentOperation
|
66
|
+
data.operationNumber = currentOperation?.operationNumber;
|
67
67
|
data.operationDate =
|
68
68
|
parentOperation?.operationDate ?? currentOperation?.operationDate;
|
69
69
|
data.location =
|
@@ -80,10 +80,10 @@ export const BuildStockOperationData = async (
|
|
80
80
|
}`;
|
81
81
|
data.organizationName = HEALTH_CENTER_NAME;
|
82
82
|
data.documentTitle = `${currentOperation.operationTypeName} ${
|
83
|
-
currentOperation
|
83
|
+
currentOperation?.operationNumber
|
84
84
|
}${
|
85
85
|
parentOperation
|
86
|
-
? ` of ${parentOperation.operationTypeName} ${parentOperation
|
86
|
+
? ` of ${parentOperation.operationTypeName} ${parentOperation?.operationNumber}`
|
87
87
|
: ""
|
88
88
|
}`;
|
89
89
|
data.items = stockOperationItems.map((p) => {
|
@@ -45,14 +45,17 @@ describe("StockSourcesDeleteActionMenu", () => {
|
|
45
45
|
const { getByRole } = render(<StockSourcesDeleteActionMenu uuid={uuid} />);
|
46
46
|
const button = getByRole("button", { name: "deleteSource" });
|
47
47
|
fireEvent.click(button);
|
48
|
-
expect(showModal).toHaveBeenCalledWith(
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
expect(showModal).toHaveBeenCalledWith(
|
49
|
+
"delete-stock-modal",
|
50
|
+
expect.objectContaining({
|
51
|
+
close: expect.any(Function),
|
52
|
+
uuid: uuid,
|
53
|
+
onConfirmation: expect.any(Function),
|
54
|
+
})
|
55
|
+
);
|
53
56
|
});
|
54
57
|
|
55
|
-
it(
|
58
|
+
it("calls onConfirmation when delete is clicked", () => {
|
56
59
|
const mockOnConfirmation = jest.fn();
|
57
60
|
const mockClose = jest.fn();
|
58
61
|
|
@@ -65,7 +68,7 @@ describe("StockSourcesDeleteActionMenu", () => {
|
|
65
68
|
|
66
69
|
expect(screen.getByText(/deleteStockUserScope/i)).toBeInTheDocument();
|
67
70
|
|
68
|
-
const deleteButton = screen.getByRole(
|
71
|
+
const deleteButton = screen.getByRole("button", { name: /delete/i });
|
69
72
|
fireEvent.click(deleteButton);
|
70
73
|
|
71
74
|
expect(mockOnConfirmation).toHaveBeenCalledTimes(1);
|
@@ -75,7 +78,7 @@ describe("StockSourcesDeleteActionMenu", () => {
|
|
75
78
|
it("calls deleteStockSource with the correct UUID on confirmation", async () => {
|
76
79
|
const mockOnConfirmation = jest.fn();
|
77
80
|
const mockClose = jest.fn();
|
78
|
-
|
81
|
+
|
79
82
|
render(
|
80
83
|
<DeleteConfirmation
|
81
84
|
close={mockClose}
|
@@ -85,10 +88,10 @@ describe("StockSourcesDeleteActionMenu", () => {
|
|
85
88
|
}}
|
86
89
|
/>
|
87
90
|
);
|
88
|
-
|
89
|
-
const deleteButton = screen.getByRole(
|
91
|
+
|
92
|
+
const deleteButton = screen.getByRole("button", { name: /delete/i });
|
90
93
|
fireEvent.click(deleteButton);
|
91
|
-
|
94
|
+
|
92
95
|
expect(mockOnConfirmation).toHaveBeenCalledTimes(1);
|
93
96
|
expect(deleteStockSource).toHaveBeenCalledWith([uuid]);
|
94
97
|
});
|
@@ -109,17 +112,21 @@ describe("StockSourcesDeleteActionMenu", () => {
|
|
109
112
|
/>
|
110
113
|
);
|
111
114
|
|
112
|
-
const deleteButton = screen.getByRole(
|
115
|
+
const deleteButton = screen.getByRole("button", { name: /delete/i });
|
113
116
|
fireEvent.click(deleteButton);
|
114
117
|
|
115
118
|
await waitFor(() => {
|
116
119
|
expect(deleteStockSource).toHaveBeenCalledWith([uuid]);
|
117
|
-
expect(handleMutate).toHaveBeenCalledWith(
|
120
|
+
expect(handleMutate).toHaveBeenCalledWith(
|
121
|
+
"/openmrs/ws/rest/v1/stocksource"
|
122
|
+
);
|
118
123
|
});
|
119
124
|
});
|
120
125
|
|
121
126
|
it("calls showSnackbar with the correct parameters on deletion error", async () => {
|
122
|
-
(deleteStockSource as jest.Mock).mockRejectedValueOnce(
|
127
|
+
(deleteStockSource as jest.Mock).mockRejectedValueOnce(
|
128
|
+
new Error("Deletion failed")
|
129
|
+
);
|
123
130
|
|
124
131
|
const mockOnConfirmation = jest.fn();
|
125
132
|
const mockClose = jest.fn();
|
@@ -140,7 +147,7 @@ describe("StockSourcesDeleteActionMenu", () => {
|
|
140
147
|
/>
|
141
148
|
);
|
142
149
|
|
143
|
-
const deleteButton = screen.getByRole(
|
150
|
+
const deleteButton = screen.getByRole("button", { name: /delete/i });
|
144
151
|
fireEvent.click(deleteButton);
|
145
152
|
|
146
153
|
await waitFor(() => {
|
@@ -153,7 +160,9 @@ describe("StockSourcesDeleteActionMenu", () => {
|
|
153
160
|
});
|
154
161
|
|
155
162
|
it("handles the error state correctly when the delete action fails", async () => {
|
156
|
-
(deleteStockSource as jest.Mock).mockRejectedValueOnce(
|
163
|
+
(deleteStockSource as jest.Mock).mockRejectedValueOnce(
|
164
|
+
new Error("Deletion failed")
|
165
|
+
);
|
157
166
|
|
158
167
|
const mockOnConfirmation = jest.fn();
|
159
168
|
const mockClose = jest.fn();
|
package/translations/en.json
CHANGED