@openmrs/esm-stock-management-app 1.0.1-pre.575 → 1.0.1-pre.581

Sign up to get free protection for your applications and to get access to all the features.
@@ -85,10 +85,10 @@
85
85
  "initial": true,
86
86
  "entry": true,
87
87
  "recorded": false,
88
- "size": 5455010,
88
+ "size": 5462033,
89
89
  "sizes": {
90
90
  "consume-shared": 252,
91
- "javascript": 5433060,
91
+ "javascript": 5440083,
92
92
  "share-init": 252,
93
93
  "runtime": 21446
94
94
  },
@@ -105,7 +105,7 @@
105
105
  "auxiliaryFiles": [
106
106
  "main.js.map"
107
107
  ],
108
- "hash": "a6543a485c11a757",
108
+ "hash": "be3e73b29e57c5a8",
109
109
  "childrenByOrder": {}
110
110
  },
111
111
  {
@@ -367,9 +367,9 @@
367
367
  "initial": false,
368
368
  "entry": false,
369
369
  "recorded": false,
370
- "size": 1786583,
370
+ "size": 1793606,
371
371
  "sizes": {
372
- "javascript": 1786373,
372
+ "javascript": 1793396,
373
373
  "consume-shared": 210
374
374
  },
375
375
  "names": [],
@@ -383,7 +383,7 @@
383
383
  "auxiliaryFiles": [
384
384
  "769.js.map"
385
385
  ],
386
- "hash": "7b4f5169d581d958",
386
+ "hash": "e2537e91c7068592",
387
387
  "childrenByOrder": {}
388
388
  },
389
389
  {
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.575"}
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.581"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-stock-management-app",
3
- "version": "1.0.1-pre.575",
3
+ "version": "1.0.1-pre.581",
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",
@@ -8,4 +8,5 @@ export interface StockItemInventory {
8
8
  quantityUoM: string;
9
9
  quantityFactor: string;
10
10
  expiration: Date;
11
+ quantityUoMUuid?: string;
11
12
  }
@@ -64,7 +64,11 @@ const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
64
64
  ) {
65
65
  setRequisition(props.model?.uuid);
66
66
  }
67
- }, [currentStockOperationType, props.model?.operationType]);
67
+ }, [
68
+ currentStockOperationType,
69
+ props.model?.operationType,
70
+ props.model?.uuid,
71
+ ]);
68
72
 
69
73
  useEffect(() => {
70
74
  if (
@@ -79,7 +83,7 @@ const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
79
83
  setOperationLinks(resp.data?.results);
80
84
  });
81
85
  }
82
- }, [currentStockOperationType, requisition, props.model?.uuid]);
86
+ }, [currentStockOperationType, requisition, props.model?.uuid, isEditing]);
83
87
 
84
88
  const [selectedIndex, setSelectedIndex] = useState(0);
85
89
  const [canDisplayReceivedItems, setCanDisplayReceivedItems] = useState(false);
@@ -12,6 +12,7 @@ import {
12
12
  } from "@carbon/react";
13
13
  import { TrashCan } from "@carbon/react/icons";
14
14
  import { StockOperationItemFormData } from "../validation-schema";
15
+ import QtyUomSelector from "../qty-uom-selector/qty-uom-selector.component";
15
16
  import StockItemSelector from "../stock-item-selector/stock-item-selector.component";
16
17
  import {
17
18
  Control,
@@ -33,8 +34,11 @@ import { StockItemPackagingUOMDTO } from "../../core/api/types/stockItem/StockIt
33
34
  import { StockItemInventory } from "../../core/api/types/stockItem/StockItemInventory";
34
35
  import { StockOperationItemDTO } from "../../core/api/types/stockOperation/StockOperationItemDTO";
35
36
  import { StockItemDTO } from "../../core/api/types/stockItem/StockItem";
36
- import QtyUomSelector from "../qty-uom-selector/qty-uom-selector.component";
37
37
  import BatchNoSelector from "../batch-no-selector/batch-no-selector.component";
38
+ import {
39
+ getStockItemInventory,
40
+ StockItemInventoryFilter,
41
+ } from "../stock-operations.resource";
38
42
 
39
43
  import styles from "./stock-items-addition-row.scss";
40
44
 
@@ -46,6 +50,8 @@ interface StockItemsAdditionRowProps {
46
50
  requiresBatchUuid?: boolean;
47
51
  canUpdateBatchInformation?: boolean;
48
52
  canCapturePurchasePrice?: boolean;
53
+ stockOperationUuid?: string;
54
+ locationUuid?: string;
49
55
  batchNos?: {
50
56
  [key: string]: StockBatchDTO[];
51
57
  };
@@ -86,19 +92,26 @@ const StockItemsAdditionRow: React.FC<StockItemsAdditionRowProps> = ({
86
92
  requiresBatchUuid,
87
93
  canUpdateBatchInformation,
88
94
  canCapturePurchasePrice,
89
- batchBalance,
90
95
  control,
91
96
  setValue,
92
97
  errors,
93
98
  remove,
94
99
  fields,
100
+ stockOperationUuid,
101
+ locationUuid,
95
102
  }) => {
96
103
  const [stockItemUuid, setStockItemUuid] = useState<
97
104
  string | null | undefined
98
105
  >();
99
- const [stockItemExpiry, setStockItemExpiy] = useState<
100
- Date | null | undefined
101
- >();
106
+
107
+ const [batchBalances, setBatchBalances] = useState<{ [key: number]: any }>(
108
+ {}
109
+ );
110
+ const [stockItemExpiries, setStockItemExpiries] = useState<{
111
+ [key: number]: Date | null | undefined;
112
+ }>({});
113
+
114
+ const [qtyInputErrors, setQtyErrors] = useState({});
102
115
 
103
116
  const handleStockItemChange = (index: number, data?: StockItemDTO) => {
104
117
  if (!data) return;
@@ -125,16 +138,99 @@ const StockItemsAdditionRow: React.FC<StockItemsAdditionRowProps> = ({
125
138
  item.stockItemPackagingUOMName = null;
126
139
 
127
140
  item.stockBatchUuid = null;
128
- if (requiresBatchUuid) {
129
- // handleStockBatchSearch(row, "", data.selectedItem?.uuid);
130
- }
141
+
142
+ setValue(`stockItems.${index}.stockItemUuid`, item?.stockItemUuid);
143
+ setValue(`stockItems.${index}.stockItemName`, item?.stockItemName);
144
+ }
145
+ };
146
+
147
+ const handleFetchBatchBalance = ({
148
+ stockItemUuid,
149
+ stockBatchUuid,
150
+ index,
151
+ excludeExpired = true,
152
+ }) => {
153
+ const filters: StockItemInventoryFilter = {
154
+ stockBatchUuid,
155
+ stockItemUuid,
156
+ stockOperationUuid,
157
+ excludeExpired,
158
+ locationUuid,
159
+ groupBy: "LocationStockItemBatchNo",
160
+ };
161
+ if (stockBatchUuid) {
162
+ getStockItemInventory(filters)
163
+ .then(({ data }) => data)
164
+ .then((res: any) => {
165
+ if ((res as any).error) {
166
+ return;
167
+ }
168
+ const inventory: StockItemInventory = (
169
+ res?.results as StockItemInventory[]
170
+ )?.[0];
171
+
172
+ const newBatchBalance = inventory
173
+ ? {
174
+ quantity: inventory.quantity,
175
+ quantityUoM: inventory.quantityUoM,
176
+ quantityUoMUuid: inventory.quantityUoMUuid,
177
+ }
178
+ : { quantity: 0, quantityUoM: null };
179
+
180
+ setBatchBalances((prevBalances) => ({
181
+ ...prevBalances,
182
+ [index]: newBatchBalance,
183
+ }));
184
+
185
+ setValue(
186
+ `stockItems.${index}.stockItemPackagingUOMUuid`,
187
+ inventory.quantityUoMUuid
188
+ );
189
+
190
+ setValue(
191
+ `stockItems.${index}.stockItemPackagingUOMName`,
192
+ inventory.quantityUoM
193
+ );
194
+ })
195
+ .catch((error: any) => {
196
+ if ((error as any).error) {
197
+ return;
198
+ }
199
+ return;
200
+ });
201
+ } else {
202
+ setBatchBalances((prevBalances) => ({
203
+ ...prevBalances,
204
+ [index]: null,
205
+ }));
131
206
  }
132
207
  };
133
208
 
209
+ const handleInputChange = (e: any, index: number) => {
210
+ const inputValue = e?.target?.value;
211
+ const maxQuantity = Number(batchBalances[index]?.quantity);
212
+
213
+ if (inputValue > maxQuantity) {
214
+ setQtyErrors((prevErrors) => ({
215
+ ...prevErrors,
216
+ [`stockItems.${index}.quantity`]: `Quantity cannot exceed ${maxQuantity}`,
217
+ }));
218
+ } else {
219
+ setQtyErrors((prevErrors) => {
220
+ const newErrors = { ...prevErrors };
221
+ delete newErrors[`stockItems.${index}.quantity`];
222
+ return newErrors;
223
+ });
224
+ }
225
+ setValue(`stockItems.${index}.quantity`, inputValue);
226
+ };
227
+
134
228
  return (
135
229
  <>
136
230
  {fields?.map((row, index) => {
137
231
  const stockItemId = `stockItems.${index}.stockItemUuid`;
232
+ const currentBatchBalance = batchBalances[index];
233
+ const currentStockItemExpiry = stockItemExpiries[index];
138
234
  return (
139
235
  <TableRow
140
236
  className={isDesktop ? styles.desktopRow : styles.tabletRow}
@@ -198,11 +294,27 @@ const StockItemsAdditionRow: React.FC<StockItemsAdditionRowProps> = ({
198
294
  `stockItems.${index}.batchNo`,
199
295
  item?.batchNo ?? ""
200
296
  );
297
+
201
298
  setValue(
202
299
  `stockItems.${index}.expiration`,
203
300
  item?.expiration
204
301
  );
205
- setStockItemExpiy(item?.expiration);
302
+
303
+ setValue(
304
+ `stockItems.${index}.hasExpiration`,
305
+ item?.expiration ? true : false
306
+ );
307
+
308
+ setStockItemExpiries((prevExpiries) => ({
309
+ ...prevExpiries,
310
+ [index]: item?.expiration ?? null,
311
+ }));
312
+
313
+ handleFetchBatchBalance({
314
+ stockItemUuid: row?.stockItemUuid,
315
+ stockBatchUuid: item?.uuid,
316
+ index,
317
+ });
206
318
  }}
207
319
  placeholder={"Filter..."}
208
320
  invalid={!!errors?.stockItems?.[index]?.stockBatchUuid}
@@ -243,7 +355,9 @@ const StockItemsAdditionRow: React.FC<StockItemsAdditionRowProps> = ({
243
355
  id={`expiration-input-${row.uuid}`}
244
356
  name="operationDate"
245
357
  placeholder={DATE_PICKER_FORMAT}
246
- defaultValue={formatForDatePicker(row?.expiration)}
358
+ defaultValue={formatForDatePicker(
359
+ currentStockItemExpiry || row?.expiration
360
+ )}
247
361
  invalid={!!errors?.stockItems?.[index]?.expiration}
248
362
  />
249
363
  </DatePicker>
@@ -254,7 +368,7 @@ const StockItemsAdditionRow: React.FC<StockItemsAdditionRowProps> = ({
254
368
  ) &&
255
369
  !canEdit) ||
256
370
  requiresBatchUuid) &&
257
- formatForDatePicker(row.expiration)}
371
+ formatForDatePicker(currentStockItemExpiry || row.expiration)}
258
372
  </TableCell>
259
373
  )}
260
374
  <TableCell>
@@ -263,33 +377,36 @@ const StockItemsAdditionRow: React.FC<StockItemsAdditionRowProps> = ({
263
377
  className="small-placeholder-text"
264
378
  size="sm"
265
379
  id={`qty-${row?.uuid}`}
380
+ min={1}
381
+ max={Number(currentBatchBalance?.quantity)}
266
382
  hideSteppers={true}
267
383
  allowEmpty={true}
268
- onChange={(e: any) =>
269
- setValue(`stockItems.${index}.quantity`, e?.target?.value)
270
- }
384
+ onChange={(e: any) => handleInputChange(e, index)}
271
385
  value={row?.quantity ?? ""}
272
- invalidText={errors?.stockItems?.[index]?.quantity?.message}
386
+ invalidText={
387
+ errors?.stockItems?.[index]?.quantity?.message ||
388
+ qtyInputErrors[`stockItems.${index}.quantity`]
389
+ }
273
390
  placeholder={
274
391
  requiresBatchUuid &&
275
392
  !requiresActualBatchInformation &&
276
- row?.stockBatchUuid in batchBalance
393
+ currentBatchBalance
277
394
  ? `Bal: ${
278
- batchBalance[
279
- row?.stockBatchUuid
280
- ]?.quantity?.toLocaleString() ?? ""
281
- } ${
282
- batchBalance[row?.stockBatchUuid]?.quantityUoM ?? ""
283
- }`
395
+ currentBatchBalance?.quantity?.toLocaleString() ?? ""
396
+ } ${currentBatchBalance?.quantityUoM ?? ""}`
284
397
  : ""
285
398
  }
286
- invalid={!!errors?.stockItems?.[index]?.quantity}
399
+ invalid={
400
+ !!errors?.stockItems?.[index]?.quantity ||
401
+ !!qtyInputErrors[`stockItems.${index}.quantity`]
402
+ }
287
403
  />
288
404
  )}
289
405
  {!canEdit && row?.quantity?.toLocaleString()}
290
406
  </TableCell>
407
+ {/* Qty UoM Cell (Non-editable) */}
291
408
  <TableCell>
292
- {canEdit && (
409
+ {canEdit && !currentBatchBalance?.quantityUoM ? (
293
410
  <QtyUomSelector
294
411
  stockItemUuid={row.stockItemUuid}
295
412
  onStockPackageChanged={(selectedItem) => {
@@ -306,10 +423,15 @@ const StockItemsAdditionRow: React.FC<StockItemsAdditionRowProps> = ({
306
423
  controllerName={`stockItems.${index}.stockItemPackagingUOMUuid`}
307
424
  name={`stockItems.${index}.stockItemPackagingUOMUuid`}
308
425
  />
426
+ ) : currentBatchBalance?.quantityUoM ? (
427
+ currentBatchBalance.quantityUoM
428
+ ) : (
429
+ row?.stockItemPackagingUOMName
309
430
  )}
431
+
310
432
  {!canEdit && row?.stockItemPackagingUOMName}
311
433
  </TableCell>
312
- {canCapturePurchasePrice && (
434
+ {canCapturePurchasePrice ? (
313
435
  <TableCell>
314
436
  {canEdit && (
315
437
  <NumberInput
@@ -330,6 +452,8 @@ const StockItemsAdditionRow: React.FC<StockItemsAdditionRowProps> = ({
330
452
  )}
331
453
  {!canEdit && row?.purchasePrice?.toLocaleString()}
332
454
  </TableCell>
455
+ ) : (
456
+ setValue(`stockItems.${index}.purchasePrice`, null)
333
457
  )}
334
458
  {canEdit && (
335
459
  <TableCell>
@@ -241,6 +241,8 @@ const StockItemsAddition: React.FC<StockItemsAdditionProps> = ({
241
241
  { uuid: `new-item-1`, id: `new-item-1` },
242
242
  ]
243
243
  }
244
+ stockOperationUuid={model.uuid ?? ""}
245
+ locationUuid={model.atLocationUuid ?? ""}
244
246
  batchBalance={batchBalance}
245
247
  batchNos={batchNos}
246
248
  control={control}
@@ -59,12 +59,16 @@ const BatchNoSelector = <T,>(props: BatchNoSelectorProps<T>) => {
59
59
  return item;
60
60
  });
61
61
 
62
+ const filteredBatches = stockItemBatchesInfo?.filter(
63
+ (s) => s.quantity !== undefined && s.quantity !== 0
64
+ );
65
+
62
66
  useEffect(() => {
63
67
  if (
64
68
  !isLoading &&
65
69
  stockItemBatchNos &&
66
70
  props.selectedItem &&
67
- stockItemBatchNos.length === 0
71
+ (stockItemBatchNos.length === 0 || filteredBatches.length === 0)
68
72
  ) {
69
73
  setValidationMessage(
70
74
  "No stock batch numbers defined. Do a initial/receipt stock operation first."
@@ -72,7 +76,7 @@ const BatchNoSelector = <T,>(props: BatchNoSelectorProps<T>) => {
72
76
  } else {
73
77
  setValidationMessage(null);
74
78
  }
75
- }, [isLoading, stockItemBatchNos, props.selectedItem]);
79
+ }, [isLoading, stockItemBatchNos, props.selectedItem, filteredBatches]);
76
80
 
77
81
  if (isLoading) return <InlineLoading status="active" />;
78
82
 
@@ -90,7 +94,7 @@ const BatchNoSelector = <T,>(props: BatchNoSelectorProps<T>) => {
90
94
  controllerName={props.controllerName}
91
95
  id={props.name}
92
96
  size={"sm"}
93
- items={stockItemBatchesInfo || []}
97
+ items={filteredBatches || []}
94
98
  onChange={(data: { selectedItem?: StockBatchDTO }) => {
95
99
  setSelectedItem(data.selectedItem || null);
96
100
  props.onBatchNoChanged?.(data.selectedItem);
@@ -98,7 +102,7 @@ const BatchNoSelector = <T,>(props: BatchNoSelectorProps<T>) => {
98
102
  }}
99
103
  initialSelectedItem={initialSelectedItem}
100
104
  itemToString={(s: StockBatchDTO) =>
101
- s?.batchNo ? `${s?.batchNo} | Qty: ${s?.quantity ?? ""}` : ""
105
+ s?.batchNo ? `${s?.batchNo}` : ""
102
106
  }
103
107
  placeholder={props.placeholder}
104
108
  invalid={props.invalid}
@@ -68,7 +68,7 @@ const StockItemSelector = <T,>(props: StockItemSelectorProps<T>) => {
68
68
  };
69
69
 
70
70
  function stockItemName(item: StockItemDTO): string {
71
- return item.drugName || item.conceptName;
71
+ return item?.drugName || item?.conceptName;
72
72
  }
73
73
 
74
74
  export default StockItemSelector;
@@ -210,7 +210,7 @@ export function getStockOperationItemsCost(filter: StockOperationFilter) {
210
210
  export function getStockItemInventory(filter: StockItemInventoryFilter) {
211
211
  const apiUrl = `${restBaseUrl}/stockmanagement/stockiteminventory${toQueryParams(
212
212
  filter
213
- )}`;
213
+ )}&v=default`;
214
214
  const abortController = new AbortController();
215
215
  return openmrsFetch(apiUrl, {
216
216
  method: "GET",