@openmrs/esm-stock-management-app 1.0.1-pre.366 → 1.0.1-pre.368

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,9 +59,9 @@
59
59
  "initial": false,
60
60
  "entry": false,
61
61
  "recorded": false,
62
- "size": 1021542,
62
+ "size": 1024655,
63
63
  "sizes": {
64
- "javascript": 1021332,
64
+ "javascript": 1024445,
65
65
  "consume-shared": 210
66
66
  },
67
67
  "names": [],
@@ -75,7 +75,7 @@
75
75
  "auxiliaryFiles": [
76
76
  "56.js.map"
77
77
  ],
78
- "hash": "39cbceceb641e93e",
78
+ "hash": "2c8d7edfd39db751",
79
79
  "childrenByOrder": {}
80
80
  },
81
81
  {
@@ -110,10 +110,10 @@
110
110
  "initial": true,
111
111
  "entry": true,
112
112
  "recorded": false,
113
- "size": 4770591,
113
+ "size": 4773704,
114
114
  "sizes": {
115
115
  "consume-shared": 252,
116
- "javascript": 4748643,
116
+ "javascript": 4751756,
117
117
  "share-init": 252,
118
118
  "runtime": 21444
119
119
  },
@@ -130,7 +130,7 @@
130
130
  "auxiliaryFiles": [
131
131
  "main.js.map"
132
132
  ],
133
- "hash": "c684d2d0c8d571da",
133
+ "hash": "3e8626336ae7a6e4",
134
134
  "childrenByOrder": {}
135
135
  },
136
136
  {
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-management-dashboard","slot":"stock-management-dashboard-slot","component":"stockManagementDashboard"},{"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"}],"pages":[{"component":"stockManagement","route":"stock-management"}],"version":"1.0.1-pre.366"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-management-dashboard","slot":"stock-management-dashboard-slot","component":"stockManagementDashboard"},{"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"}],"pages":[{"component":"stockManagement","route":"stock-management"}],"version":"1.0.1-pre.368"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-stock-management-app",
3
- "version": "1.0.1-pre.366",
3
+ "version": "1.0.1-pre.368",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Stock management microfrontend for OpenMRS 3.x",
6
6
  "browser": "dist/openmrs-esm-stock-management-app.js",
@@ -59,7 +59,6 @@ const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
59
59
  }
60
60
 
61
61
  let operations: StockOperationType[] | null | undefined;
62
-
63
62
  const tabs: TabItem[] = [
64
63
  {
65
64
  name: isEditing
@@ -86,7 +85,7 @@ const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
86
85
  setManageStockItems(true);
87
86
  setSelectedIndex(1);
88
87
  }}
89
- operation={props.operation}
88
+ operation={props?.operation}
90
89
  />
91
90
  ),
92
91
  },
@@ -124,7 +123,13 @@ const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
124
123
  setup={result}
125
124
  canEdit={canEdit}
126
125
  locked={false}
127
- model={isEditing ? props?.model : result?.dto}
126
+ model={
127
+ isEditing
128
+ ? props?.model
129
+ : props?.operation?.name === "Stock Issue"
130
+ ? props?.model
131
+ : result?.dto
132
+ }
128
133
  requiresDispatchAcknowledgement={
129
134
  isEditing
130
135
  ? props?.model?.operationType === "return" ||
@@ -58,7 +58,6 @@ function shouldDeleteDestinationUuid(operationType) {
58
58
 
59
59
  export function createBaseOperationPayload(model, item, operationType) {
60
60
  const req = Object.assign(model, item);
61
-
62
61
  const propertiesToDelete = [
63
62
  "submitted",
64
63
  "cancelledByFamilyName",
@@ -105,6 +104,5 @@ export function createBaseOperationPayload(model, item, operationType) {
105
104
  if (shouldDeleteDestinationUuid(operationType)) {
106
105
  delete req.destinationUuid;
107
106
  }
108
-
109
107
  return req;
110
108
  }
@@ -36,10 +36,7 @@ import rootStyles from "../../root.scss";
36
36
  import { ResourceRepresentation } from "../../core/api/api";
37
37
  import { useStockOperationPages } from "../stock-operations-table.resource";
38
38
  import { useStockOperationContext } from "./stock-operation-context/useStockOperationContext";
39
- import {
40
- createBaseOperationPayload,
41
- getRequisitionStockOperations,
42
- } from "./add-stock-utils";
39
+ import { createBaseOperationPayload } from "./add-stock-utils";
43
40
 
44
41
  interface BaseOperationDetailsProps {
45
42
  isEditing?: boolean;
@@ -70,8 +67,8 @@ const BaseOperationDetails: React.FC<BaseOperationDetailsProps> = ({
70
67
  v: ResourceRepresentation.Full,
71
68
  totalCount: true,
72
69
  });
73
- const requisitionStockOperations = getRequisitionStockOperations(items);
74
- const operationType = operationFromString(operation.operationType);
70
+ const operationType = operationFromString(operation?.operationType);
71
+ const issueStockOperation = mapIssueStockLocations(model);
75
72
 
76
73
  const {
77
74
  handleSubmit,
@@ -79,7 +76,7 @@ const BaseOperationDetails: React.FC<BaseOperationDetailsProps> = ({
79
76
  formState: { errors },
80
77
  setValue,
81
78
  } = useForm<StockOperationFormData>({
82
- defaultValues: model,
79
+ defaultValues: operationType === "stockissue" ? issueStockOperation : model,
83
80
  mode: "all",
84
81
  resolver: zodResolver(operationSchema(operationType)),
85
82
  });
@@ -112,34 +109,6 @@ const BaseOperationDetails: React.FC<BaseOperationDetailsProps> = ({
112
109
  <form
113
110
  className={`${rootStyles.formContainer} ${rootStyles.verticalForm}`}
114
111
  >
115
- {operationType === OperationType.STOCK_ISSUE_OPERATION_TYPE && (
116
- <Controller
117
- control={control}
118
- name="requisitionStockOperationUuid"
119
- render={({ field }) => (
120
- <ComboBox
121
- id="requisitionStockOperationUuid"
122
- items={requisitionStockOperations}
123
- onChange={(data: { selectedItem: StockOperationDTO }) => {
124
- field.onChange(data.selectedItem.uuid);
125
- Object.assign(
126
- model.stockOperationItems,
127
- data.selectedItem.stockOperationItems
128
- );
129
- setFormContext({
130
- stockItems: data.selectedItem.stockOperationItems,
131
- });
132
- }}
133
- itemToString={(item) => `${item?.operationNumber}` ?? ""}
134
- titleText={t("requisitionStockOperation", "Requisition")}
135
- invalid={!!errors.requisitionStockOperationUuid}
136
- invalidText={errors.requisitionStockOperationUuid?.message}
137
- placeholder={t("chooseARequisition", "Choose a requisition")}
138
- />
139
- )}
140
- />
141
- )}
142
-
143
112
  {canEdit && (
144
113
  <Controller
145
114
  control={control}
@@ -210,7 +179,11 @@ const BaseOperationDetails: React.FC<BaseOperationDetailsProps> = ({
210
179
  {(!canEdit || isEditing || lockSource) && (
211
180
  <TextInput
212
181
  id="sourceUuidLbl"
213
- value={model?.sourceName ?? ""}
182
+ value={
183
+ operationType === "stockissue"
184
+ ? issueStockOperation.sourceName
185
+ : model?.sourceName ?? ""
186
+ }
214
187
  readOnly={true}
215
188
  labelText={operation?.hasDestination ? "From" : "From"}
216
189
  />
@@ -237,7 +210,11 @@ const BaseOperationDetails: React.FC<BaseOperationDetailsProps> = ({
237
210
  {(!canEdit || isEditing || lockDestination) && (
238
211
  <TextInput
239
212
  id="destinationUuidLbl"
240
- value={model?.destinationName ?? ""}
213
+ value={
214
+ operationType === "stockissue"
215
+ ? issueStockOperation.destinationName
216
+ : model?.destinationName ?? ""
217
+ }
241
218
  readOnly={true}
242
219
  labelText={operation?.hasSource ? "To" : "To"}
243
220
  />
@@ -348,5 +325,19 @@ const BaseOperationDetails: React.FC<BaseOperationDetailsProps> = ({
348
325
  </div>
349
326
  );
350
327
  };
328
+ function mapIssueStockLocations(stockOperation) {
329
+ /** Since we are using requisition information to issue stock,
330
+ please note that the locations will be inverted: the destination listed on the requisition will become the issuing location.
331
+ */
332
+ const { sourceUuid, sourceName, destinationUuid, destinationName } =
333
+ stockOperation;
334
+ return {
335
+ ...stockOperation,
336
+ sourceUuid: destinationUuid,
337
+ sourceName: destinationName,
338
+ destinationUuid: sourceUuid,
339
+ destinationName: sourceName,
340
+ };
341
+ }
351
342
 
352
343
  export default BaseOperationDetails;
@@ -12,7 +12,10 @@ import {
12
12
  updateStockOperation,
13
13
  } from "./stock-operations.resource";
14
14
  import AddStockOperation from "./add-stock-operation/add-stock-operation.component";
15
- import { StockOperationType } from "../core/api/types/stockOperation/StockOperationType";
15
+ import {
16
+ OperationType,
17
+ StockOperationType,
18
+ } from "../core/api/types/stockOperation/StockOperationType";
16
19
  import { useLocation } from "react-router-dom";
17
20
  import { extractErrorMessagesFromResponse } from "../constants";
18
21
  import { handleMutate } from "./swr-revalidation";
@@ -28,6 +31,17 @@ export const addOrEditStockOperation = async (
28
31
  if (operation.operationType === "requisition") {
29
32
  delete payload.destinationName;
30
33
  }
34
+ if (operation.operationType === OperationType.STOCK_ISSUE_OPERATION_TYPE) {
35
+ const stockIssueOpsTypeUuid = "66666666-6666-6666-6666-666666666666";
36
+ delete payload.completedDate;
37
+ delete payload.completedBy;
38
+ delete payload.completedByFamilyName;
39
+ delete payload.completedByGivenName;
40
+ delete payload.operationTypeUuid;
41
+ delete payload.permission;
42
+ delete payload.locked;
43
+ payload["operationTypeUuid"] = stockIssueOpsTypeUuid;
44
+ }
31
45
  const response: FetchResponse<StockOperationDTO> = await (isEditing
32
46
  ? updateStockOperation
33
47
  : createStockOperation)(payload);
@@ -20,7 +20,7 @@ const StockOperationIssueStockButton: React.FC<
20
20
  uuid: "",
21
21
  name: "Stock Issue",
22
22
  description: "",
23
- operationType: "",
23
+ operationType: "stockissue",
24
24
  hasSource: false,
25
25
  sourceType: "Location",
26
26
  hasDestination: false,
@@ -40,8 +40,9 @@ const StockOperationIssueStockButton: React.FC<
40
40
  voided: false,
41
41
  };
42
42
 
43
+ const modifiedOperation = addRequisitionStockOperation(operation);
43
44
  const handleButtonClick = () => {
44
- launchAddOrEditDialog(operation, false, type, operations, false);
45
+ launchAddOrEditDialog(modifiedOperation, false, type, operations, false);
45
46
  };
46
47
 
47
48
  return (
@@ -54,5 +55,12 @@ const StockOperationIssueStockButton: React.FC<
54
55
  </Button>
55
56
  );
56
57
  };
58
+ function addRequisitionStockOperation(stockOperation) {
59
+ const { uuid } = stockOperation;
60
+ return {
61
+ ...stockOperation,
62
+ requisitionStockOperationUuid: uuid,
63
+ };
64
+ }
57
65
 
58
66
  export default StockOperationIssueStockButton;
@@ -169,9 +169,6 @@ export const operationSchema = (operation: OperationType): z.Schema => {
169
169
  .min(1, {
170
170
  message: "Destination Required",
171
171
  }),
172
- requisitionStockOperationUuid: z.string({
173
- required_error: "Requisition stock uuid required",
174
- }),
175
172
  })
176
173
  );
177
174
  case OperationType.RETURN_OPERATION_TYPE: