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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. package/dist/769.js +1 -0
  2. package/dist/769.js.map +1 -0
  3. package/dist/main.js +1 -1
  4. package/dist/main.js.map +1 -1
  5. package/dist/openmrs-esm-stock-management-app.js +1 -1
  6. package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +28 -28
  7. package/dist/openmrs-esm-stock-management-app.js.map +1 -1
  8. package/dist/routes.json +1 -1
  9. package/package.json +1 -1
  10. package/src/core/api/types/stockItem/StockItemInventory.ts +1 -0
  11. package/src/core/components/card/metrics-card.scss +7 -7
  12. package/src/core/components/overlay/overlay.scss +6 -6
  13. package/src/core/components/privilages-component/privilages.scss +6 -5
  14. package/src/core/components/side-nav/side-nav.scss +12 -12
  15. package/src/core/components/table/table.scss +16 -16
  16. package/src/core/components/tabs/vertical-tabs.scss +15 -15
  17. package/src/dashboard/home-dashboard.scss +1 -1
  18. package/src/stock-home/stock-home-detail-card.scss +7 -7
  19. package/src/stock-home/stock-home.scss +7 -7
  20. package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +2 -4
  21. package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.scss +33 -4
  22. package/src/stock-items/stock-items-table.scss +8 -9
  23. package/src/stock-management-header/stock-management-header.scss +5 -5
  24. package/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +6 -2
  25. package/src/stock-operations/add-stock-operation/add-stock-operation.scss +5 -5
  26. package/src/stock-operations/add-stock-operation/base-operation-details.component.tsx +2 -4
  27. package/src/stock-operations/add-stock-operation/base-operation-details.scss +30 -0
  28. package/src/stock-operations/add-stock-operation/stock-items-addition-row.component.tsx +149 -25
  29. package/src/stock-operations/add-stock-operation/stock-items-addition.component.tsx +2 -0
  30. package/src/stock-operations/batch-no-selector/batch-no-selector.component.tsx +8 -4
  31. package/src/stock-operations/stock-item-selector/stock-item-selector.component.tsx +1 -1
  32. package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.scss +5 -5
  33. package/src/stock-operations/stock-operations-table.scss +8 -9
  34. package/src/stock-operations/stock-operations.resource.ts +1 -1
  35. package/src/stock-reports/report-list/stock-reports.scss +2 -1
  36. package/src/stock-settings/stock-settings.component.tsx +1 -1
  37. package/src/stock-settings/stock-settings.scss +7 -4
  38. package/src/stock-sources/add-stock-sources/add-stock-sources.scss +6 -6
  39. package/src/stock-sources/delete-stock-modal.component.tsx +3 -3
  40. package/src/stock-sources/delete-stock-modal.scss +11 -0
  41. package/src/stock-sources/stock-sources-filter/stock-sources-filter.scss +3 -1
  42. package/src/stock-sources/stock-sources.scss +9 -9
  43. package/src/stock-user-role-scopes/delete-stock-user-scope-modal.component.tsx +1 -1
  44. package/src/stock-user-role-scopes/delete-stock-user-scope-modal.scss +11 -0
  45. package/src/stock-user-role-scopes/stock-user-role-scopes.scss +8 -7
  46. package/dist/281.js +0 -1
  47. package/dist/281.js.map +0 -1
  48. package/src/root.scss +0 -108
@@ -1,13 +1,13 @@
1
- @use '@carbon/styles/scss/spacing';
2
- @use '@carbon/styles/scss/type';
1
+ @use '@carbon/layout';
2
+ @use '@carbon/type';
3
3
  @use '@carbon/colors';
4
- @import '~@openmrs/esm-styleguide/src/vars';
4
+ @use '~@openmrs/esm-styleguide/src/vars' as *;
5
5
  .cardContainer {
6
6
  background-color: colors.$white;
7
7
  display: flex;
8
8
  justify-content: space-between;
9
- margin: 0 spacing.$spacing-05 0 spacing.$spacing-05;
9
+ margin: 0 layout.$spacing-05 0 layout.$spacing-05;
10
10
  flex-flow: row wrap;
11
- column-gap: spacing.$spacing-05;
12
- row-gap: spacing.$spacing-05;
13
- }
11
+ column-gap: layout.$spacing-05;
12
+ row-gap: layout.$spacing-05;
13
+ }
@@ -20,7 +20,7 @@ import StockItemCategorySelector from "../stock-item-category-selector/stock-ite
20
20
  import StockItemUnitsEdit from "../stock-item-units-edit/stock-item-units-edit.component";
21
21
  import { SaveStockItem } from "../../types";
22
22
  import ConceptsSelector from "../concepts-selector/concepts-selector.component";
23
- import rootStyles from "../../../root.scss";
23
+ import styles from "../../add-stock-item/add-stock-item.scss";
24
24
  import { closeOverlay } from "../../../core/components/overlay/hook";
25
25
  import { expirationOptions, radioOptions } from "./stock-item-details.resource";
26
26
  import { restBaseUrl } from "@openmrs/esm-framework";
@@ -70,9 +70,7 @@ const StockItemDetails = forwardRef<never, StockItemDetailsProps>(
70
70
  }, [model.hasExpiration, model.isDrug]);
71
71
 
72
72
  return (
73
- <form
74
- className={`${rootStyles.formContainer} ${rootStyles.verticalForm}`}
75
- >
73
+ <form className={`${styles.formContainer} ${styles.verticalForm}`}>
76
74
  {!isEditing && (
77
75
  <FormGroup
78
76
  className="clear-margin-bottom"
@@ -1,9 +1,9 @@
1
- @use '@carbon/styles/scss/spacing';
2
- @use '@carbon/styles/scss/type';
3
- @import '~@openmrs/esm-styleguide/src/vars';
1
+ @use '@carbon/layout';
2
+ @use '@carbon/type';
3
+ @use '~@openmrs/esm-styleguide/src/vars' as *;
4
4
 
5
5
  .section {
6
- margin: spacing.$spacing-03;
6
+ margin: layout.$spacing-03;
7
7
  }
8
8
 
9
9
  .form {
@@ -11,3 +11,32 @@
11
11
  gap: 1.5rem;
12
12
  padding-top: 1rem;
13
13
  }
14
+
15
+ .formContainer {
16
+ height: calc(100vh - 100px) !important;
17
+ overflow: scroll;
18
+ padding: 0 1rem;
19
+ }
20
+
21
+ .verticalForm {
22
+ display: flex;
23
+ grid-row-gap: 2em;
24
+ padding-top: layout.$spacing-05;
25
+ align-content: space-between;
26
+ flex-direction: column;
27
+
28
+ :global(.cds--form-item) {
29
+ flex: none !important;
30
+ }
31
+
32
+ :global(.cds--label) {
33
+ color: black;
34
+ display: inline-block;
35
+ font-size: var(--cds-label-01-font-size);
36
+ font-weight: bold;
37
+ letter-spacing: var(--cds-label-01-letter-spacing, .32px);
38
+ line-height: layout.$spacing-05;
39
+ margin-bottom: layout.$spacing-03;
40
+ vertical-align: baseline;
41
+ }
42
+ }
@@ -1,18 +1,17 @@
1
- @use '@carbon/styles/scss/spacing';
1
+ @use '@carbon/layout';
2
2
  @use '@carbon/styles/scss/type';
3
- @import "~@openmrs/esm-styleguide/src/vars";
4
- @import '../root.scss';
3
+ @use '~@openmrs/esm-styleguide/src/vars' as *;
5
4
 
6
5
  .headerBtnContainer {
7
6
  background-color: $ui-background;
8
- padding: spacing.$spacing-05;
7
+ padding: layout.$spacing-05;
9
8
  text-align: right;
10
9
  }
11
10
 
12
11
  .tileContainer {
13
12
  background-color: $ui-02;
14
13
  border-top: 1px solid $ui-03;
15
- padding: 5rem 0;
14
+ padding: layout.$spacing-11 0;
16
15
  }
17
16
 
18
17
  .tile {
@@ -78,12 +77,12 @@
78
77
  }
79
78
 
80
79
  .dateAlign {
81
- padding-top: spacing.$spacing-03;
80
+ padding-top: layout.$spacing-03;
82
81
  height: 100%;
83
82
  }
84
83
 
85
84
  .filtersAlign {
86
- padding-bottom: spacing.$spacing-03;
85
+ padding-bottom: layout.$spacing-03;
87
86
 
88
87
  :global(.cds--list-box__menu) {
89
88
  min-width: 15rem;
@@ -95,5 +94,5 @@
95
94
  display: flex;
96
95
  align-items: center;
97
96
  justify-content: space-between;
98
- margin-bottom: spacing.$spacing-05;
99
- }
97
+ margin-bottom: layout.$spacing-05;
98
+ }
@@ -1,12 +1,12 @@
1
- @use '@carbon/styles/scss/colors';
2
- @use '@carbon/styles/scss/spacing';
3
- @use '@carbon/styles/scss/type';
4
- @import '~@openmrs/esm-styleguide/src/vars';
1
+ @use '@carbon/colors';
2
+ @use '@carbon/layout';
3
+ @use '@carbon/type';
4
+ @use '~@openmrs/esm-styleguide/src/vars' as *;
5
5
 
6
6
  .header {
7
7
  @include type.type-style('body-compact-02');
8
8
  color: colors.$gray-70;
9
- height: spacing.$spacing-12;
9
+ height: layout.$spacing-12;
10
10
  background-color: $ui-02;
11
11
  display: flex;
12
12
  padding-left: 8px;
@@ -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);
@@ -1,14 +1,14 @@
1
- @use '@carbon/styles/scss/spacing';
2
- @use '@carbon/styles/scss/type';
3
- @import '~@openmrs/esm-styleguide/src/vars';
1
+ @use '@carbon/layout';
2
+ @use '@carbon/type';
3
+ @use '~@openmrs/esm-styleguide/src/vars' as *;
4
4
  .sectionTitle {
5
5
  @include type.type-style('heading-compact-02');
6
6
  color: $text-02;
7
- margin-bottom: spacing.$spacing-04;
7
+ margin-bottom: layout.$spacing-04;
8
8
  }
9
9
 
10
10
  .modalBody {
11
- padding-bottom: spacing.$spacing-05;
11
+ padding-bottom: layout.$spacing-05;
12
12
  }
13
13
 
14
14
  .actionsContainer {
@@ -35,7 +35,7 @@ import { useStockOperationPages } from "../stock-operations-table.resource";
35
35
  import { createBaseOperationPayload } from "./add-stock-utils";
36
36
  import { showSnackbar, useSession } from "@openmrs/esm-framework";
37
37
 
38
- import rootStyles from "../../root.scss";
38
+ import styles from "../add-stock-operation/base-operation-details.scss";
39
39
 
40
40
  interface BaseOperationDetailsProps {
41
41
  isEditing?: boolean;
@@ -116,9 +116,7 @@ const BaseOperationDetails: React.FC<BaseOperationDetailsProps> = ({
116
116
  };
117
117
  return (
118
118
  <div style={{ margin: "10px" }}>
119
- <form
120
- className={`${rootStyles.formContainer} ${rootStyles.verticalForm}`}
121
- >
119
+ <form className={`${styles.formContainer} ${styles.verticalForm}`}>
122
120
  {canEdit && (
123
121
  <Controller
124
122
  control={control}
@@ -0,0 +1,30 @@
1
+ @use '@carbon/layout';
2
+ @use '@carbon/type';
3
+ @use '~@openmrs/esm-styleguide/src/vars' as *;
4
+
5
+ .verticalForm {
6
+ display: flex;
7
+ grid-row-gap: 2em;
8
+ padding-top: layout.$spacing-05;
9
+ align-content: space-between;
10
+ flex-direction: column;
11
+
12
+ :global(.cds--form-item) {
13
+ flex: none !important;
14
+ }
15
+
16
+ :global(.cds--label) {
17
+ color: black;
18
+ display: inline-block;
19
+ font-size: var(--cds-label-01-font-size);
20
+ font-weight: bold;
21
+ letter-spacing: var(--cds-label-01-letter-spacing, .32px);
22
+ line-height: layout.$spacing-05;
23
+ margin-bottom: layout.$spacing-03;
24
+ vertical-align: baseline;
25
+ }
26
+ }
27
+
28
+ .formContainer {
29
+ margin: layout.$spacing-05;
30
+ }
@@ -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;
@@ -1,14 +1,14 @@
1
- @use '@carbon/styles/scss/spacing';
2
- @use '@carbon/styles/scss/type';
1
+ @use '@carbon/layout';
2
+ @use '@carbon/type';
3
3
 
4
4
  .section {
5
- margin: spacing.$spacing-03;
5
+ margin: layout.$spacing-03;
6
6
  }
7
7
 
8
8
  .sectionTitle {
9
- margin-bottom: spacing.$spacing-04;
9
+ margin-bottom: layout.$spacing-04;
10
10
  }
11
11
 
12
12
  .modalBody {
13
- padding-bottom: spacing.$spacing-05;
13
+ padding-bottom: layout.$spacing-05;
14
14
  }
@@ -1,12 +1,11 @@
1
- @use '@carbon/styles/scss/spacing';
2
- @use '@carbon/styles/scss/type';
3
- @import "~@openmrs/esm-styleguide/src/vars";
4
- @import '../root.scss';
1
+ @use '@carbon/layout';
2
+ @use '@carbon/type';
3
+ @use '~@openmrs/esm-styleguide/src/vars' as *;
5
4
 
6
5
  .tileContainer {
7
6
  background-color: $ui-02;
8
7
  border-top: 1px solid $ui-03;
9
- padding: 5rem 0;
8
+ padding: layout.$spacing-11 0;
10
9
  }
11
10
 
12
11
  .tile {
@@ -23,7 +22,7 @@
23
22
  .content {
24
23
  @include type.type-style('heading-compact-02');
25
24
  color: $text-02;
26
- margin-bottom: 0.5rem;
25
+ margin-bottom: layout.$spacing-03;
27
26
  }
28
27
 
29
28
  .helper {
@@ -42,7 +41,7 @@
42
41
  }
43
42
 
44
43
  .dateAlign {
45
- padding-top: spacing.$spacing-03;
44
+ padding-top: layout.$spacing-03;
46
45
  height: 100%;
47
46
  }
48
47
 
@@ -50,12 +49,12 @@
50
49
  display: flex;
51
50
  align-items: center;
52
51
  justify-content: space-between;
53
- margin-bottom: spacing.$spacing-05;
52
+ margin-bottom: layout.$spacing-05;
54
53
  }
55
54
 
56
55
  .rowLoadingContainer {
57
56
  text-align: center;
58
- padding: 5rem 2rem;
57
+ padding: layout.$spacing-11 2rem;
59
58
  margin: auto;
60
59
  width: 20%;
61
60
  }
@@ -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",