@openmrs/esm-stock-management-app 3.3.1 → 3.3.2-pre.116

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.
Files changed (309) hide show
  1. package/README.md +20 -0
  2. package/dist/1164.js +1 -1
  3. package/dist/1164.js.map +1 -1
  4. package/dist/1207.js +1 -0
  5. package/dist/1207.js.map +1 -0
  6. package/dist/1209.js +1 -0
  7. package/dist/1209.js.map +1 -0
  8. package/dist/1480.js +1 -1
  9. package/dist/1480.js.map +1 -1
  10. package/dist/1600.js +1 -1
  11. package/dist/1600.js.map +1 -1
  12. package/dist/1646.js +1 -1
  13. package/dist/1646.js.map +1 -1
  14. package/dist/1869.js +1 -1
  15. package/dist/1869.js.map +1 -1
  16. package/dist/1877.js +1 -1
  17. package/dist/1877.js.map +1 -1
  18. package/dist/1878.js +1 -1
  19. package/dist/1878.js.map +1 -1
  20. package/dist/2317.js +1 -1
  21. package/dist/2317.js.map +1 -1
  22. package/dist/2392.js +11 -11
  23. package/dist/2392.js.map +1 -1
  24. package/dist/2416.js +1 -1
  25. package/dist/2416.js.map +1 -1
  26. package/dist/2713.js +1 -1
  27. package/dist/2713.js.map +1 -1
  28. package/dist/282.js +1 -1
  29. package/dist/282.js.map +1 -1
  30. package/dist/2881.js +1 -1
  31. package/dist/2881.js.map +1 -1
  32. package/dist/3378.js +1 -1
  33. package/dist/3378.js.map +1 -1
  34. package/dist/3576.js +2 -2
  35. package/dist/3576.js.map +1 -1
  36. package/dist/3588.js +1 -0
  37. package/dist/3588.js.map +1 -0
  38. package/dist/3936.js +12 -12
  39. package/dist/3936.js.map +1 -1
  40. package/dist/3963.js +1 -1
  41. package/dist/3963.js.map +1 -1
  42. package/dist/4106.js +1 -1
  43. package/dist/4106.js.map +1 -1
  44. package/dist/4111.js +1 -1
  45. package/dist/4111.js.map +1 -1
  46. package/dist/4214.js +1 -1
  47. package/dist/4214.js.map +1 -1
  48. package/dist/434.js +1 -1
  49. package/dist/434.js.map +1 -1
  50. package/dist/4348.js +1 -1
  51. package/dist/4348.js.map +1 -1
  52. package/dist/4383.js +1 -1
  53. package/dist/4383.js.map +1 -1
  54. package/dist/4658.js +1 -1
  55. package/dist/4658.js.map +1 -1
  56. package/dist/4928.js +1 -1
  57. package/dist/4928.js.map +1 -1
  58. package/dist/5117.js +1 -1
  59. package/dist/5117.js.map +1 -1
  60. package/dist/5132.js +1 -1
  61. package/dist/5132.js.map +1 -1
  62. package/dist/5145.js +1 -1
  63. package/dist/5145.js.map +1 -1
  64. package/dist/5503.js +1 -1
  65. package/dist/5503.js.map +1 -1
  66. package/dist/556.js +1 -1
  67. package/dist/556.js.map +1 -1
  68. package/dist/5644.js +1 -1
  69. package/dist/5644.js.map +1 -1
  70. package/dist/5838.js +1 -1
  71. package/dist/5838.js.map +1 -1
  72. package/dist/5940.js +1 -1
  73. package/dist/5940.js.map +1 -1
  74. package/dist/5996.js +1 -1
  75. package/dist/5996.js.map +1 -1
  76. package/dist/6047.js +1 -1
  77. package/dist/6047.js.map +1 -1
  78. package/dist/6105.js +1 -1
  79. package/dist/6105.js.map +1 -1
  80. package/dist/6371.js +1 -1
  81. package/dist/6371.js.map +1 -1
  82. package/dist/6377.js +1 -1
  83. package/dist/6377.js.map +1 -1
  84. package/dist/6444.js +1 -1
  85. package/dist/6444.js.map +1 -1
  86. package/dist/6508.js +1 -1
  87. package/dist/6508.js.map +1 -1
  88. package/dist/6724.js +1 -1
  89. package/dist/6724.js.map +1 -1
  90. package/dist/6904.js +1 -1
  91. package/dist/6904.js.map +1 -1
  92. package/dist/6981.js +1 -1
  93. package/dist/6981.js.map +1 -1
  94. package/dist/7037.js +1 -1
  95. package/dist/7045.js +1 -1
  96. package/dist/7045.js.map +1 -1
  97. package/dist/7175.js +1 -1
  98. package/dist/7175.js.map +1 -1
  99. package/dist/7182.js +1 -1
  100. package/dist/7182.js.map +1 -1
  101. package/dist/7742.js +1 -1
  102. package/dist/7742.js.map +1 -1
  103. package/dist/7912.js +1 -1
  104. package/dist/7912.js.map +1 -1
  105. package/dist/8156.js +1 -1
  106. package/dist/8156.js.map +1 -1
  107. package/dist/822.js +1 -1
  108. package/dist/822.js.map +1 -1
  109. package/dist/8358.js +1 -1
  110. package/dist/8358.js.map +1 -1
  111. package/dist/8359.js +1 -1
  112. package/dist/8359.js.map +1 -1
  113. package/dist/8473.js +1 -0
  114. package/dist/8473.js.map +1 -0
  115. package/dist/854.js +1 -0
  116. package/dist/854.js.map +1 -0
  117. package/dist/8661.js +1 -1
  118. package/dist/8661.js.map +1 -1
  119. package/dist/8695.js +1 -1
  120. package/dist/8695.js.map +1 -1
  121. package/dist/8990.js +1 -1
  122. package/dist/8990.js.map +1 -1
  123. package/dist/903.js +1 -1
  124. package/dist/903.js.map +1 -1
  125. package/dist/9072.js +1 -1
  126. package/dist/9072.js.map +1 -1
  127. package/dist/9154.js +1 -1
  128. package/dist/9154.js.map +1 -1
  129. package/dist/9806.js +1 -1
  130. package/dist/9806.js.map +1 -1
  131. package/dist/openmrs-esm-stock-management-app.js +2 -2
  132. package/dist/openmrs-esm-stock-management-app.js.map +1 -1
  133. package/dist/routes.json +1 -1
  134. package/package.json +3 -2
  135. package/src/config-schema.ts +38 -0
  136. package/src/constants.ts +0 -13
  137. package/src/stock-home/expired-stock.modal.tsx +2 -6
  138. package/src/stock-home/expired-stock.test.tsx +23 -0
  139. package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +3 -3
  140. package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.test.tsx +69 -0
  141. package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.tsx +1 -1
  142. package/src/stock-items/validationSchema.test.ts +51 -0
  143. package/src/stock-items/validationSchema.ts +10 -1
  144. package/src/stock-locations/stock-locations-table.resource.test.ts +24 -2
  145. package/src/stock-lookups/stock-lookups.resource.ts +6 -2
  146. package/src/stock-operations/stock-operations-forms/steps/base-operation-details-form-step.test.tsx +64 -0
  147. package/src/stock-operations/stock-operations-forms/steps/base-operation-details-form-step.tsx +16 -5
  148. package/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.component.tsx +21 -3
  149. package/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.test.tsx +126 -0
  150. package/src/stock-operations/stock-print-reports/StockOperationReport.test.ts +15 -0
  151. package/src/stock-operations/stock-print-reports/StockOperationReport.tsx +5 -2
  152. package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.test.tsx +49 -0
  153. package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.workspace.tsx +6 -21
  154. package/translations/am.json +1 -0
  155. package/translations/ar.json +1 -0
  156. package/translations/ar_SY.json +1 -0
  157. package/translations/bn.json +1 -0
  158. package/translations/cs.json +1 -0
  159. package/translations/de.json +1 -0
  160. package/translations/en.json +1 -0
  161. package/translations/en_US.json +1 -0
  162. package/translations/es.json +1 -0
  163. package/translations/es_MX.json +1 -0
  164. package/translations/fr.json +1 -0
  165. package/translations/he.json +1 -0
  166. package/translations/hi.json +1 -0
  167. package/translations/hi_IN.json +1 -0
  168. package/translations/id.json +1 -0
  169. package/translations/it.json +1 -0
  170. package/translations/ka.json +1 -0
  171. package/translations/km.json +1 -0
  172. package/translations/ku.json +1 -0
  173. package/translations/ky.json +1 -0
  174. package/translations/lg.json +1 -0
  175. package/translations/ne.json +1 -0
  176. package/translations/pl.json +1 -0
  177. package/translations/pt.json +1 -0
  178. package/translations/pt_BR.json +1 -0
  179. package/translations/qu.json +1 -0
  180. package/translations/ro_RO.json +1 -0
  181. package/translations/ru_RU.json +1 -0
  182. package/translations/si.json +1 -0
  183. package/translations/sq.json +1 -0
  184. package/translations/sw.json +1 -0
  185. package/translations/sw_KE.json +1 -0
  186. package/translations/tr.json +1 -0
  187. package/translations/tr_TR.json +1 -0
  188. package/translations/uk.json +1 -0
  189. package/translations/uz.json +1 -0
  190. package/translations/uz@Latn.json +1 -0
  191. package/translations/uz_UZ.json +1 -0
  192. package/translations/vi.json +1 -0
  193. package/translations/zh.json +1 -0
  194. package/translations/zh_CN.json +1 -0
  195. package/translations/zh_TW.json +1 -0
  196. package/coverage/__mocks__/index.html +0 -161
  197. package/coverage/__mocks__/index.ts.html +0 -91
  198. package/coverage/__mocks__/operation-type.mock.ts.html +0 -1681
  199. package/coverage/__mocks__/react-i18next.js.html +0 -259
  200. package/coverage/__mocks__/workspace2-props.mock.ts.html +0 -145
  201. package/coverage/base.css +0 -224
  202. package/coverage/block-navigation.js +0 -87
  203. package/coverage/clover.xml +0 -1659
  204. package/coverage/coverage-final.json +0 -69
  205. package/coverage/favicon.png +0 -0
  206. package/coverage/index.html +0 -611
  207. package/coverage/prettify.css +0 -1
  208. package/coverage/prettify.js +0 -2
  209. package/coverage/sort-arrow-sprite.png +0 -0
  210. package/coverage/sorter.js +0 -210
  211. package/coverage/src/constants.ts.html +0 -598
  212. package/coverage/src/core/api/api.ts.html +0 -181
  213. package/coverage/src/core/api/index.html +0 -116
  214. package/coverage/src/core/api/types/BatchJob.ts.html +0 -415
  215. package/coverage/src/core/api/types/index.html +0 -116
  216. package/coverage/src/core/api/types/stockOperation/StockOperationStatus.ts.html +0 -139
  217. package/coverage/src/core/api/types/stockOperation/StockOperationType.ts.html +0 -460
  218. package/coverage/src/core/api/types/stockOperation/index.html +0 -131
  219. package/coverage/src/core/components/carbon/controlled-number-input.component.tsx.html +0 -226
  220. package/coverage/src/core/components/carbon/controlled-radio-button-group.component.tsx.html +0 -253
  221. package/coverage/src/core/components/carbon/controlled-text-input.component.tsx.html +0 -202
  222. package/coverage/src/core/components/carbon/index.html +0 -146
  223. package/coverage/src/core/hooks/debounce-hook.ts.html +0 -181
  224. package/coverage/src/core/hooks/index.html +0 -116
  225. package/coverage/src/core/utils/datetimeUtils.ts.html +0 -289
  226. package/coverage/src/core/utils/index.html +0 -131
  227. package/coverage/src/core/utils/utils.ts.html +0 -382
  228. package/coverage/src/index.html +0 -131
  229. package/coverage/src/stock-items/add-bulk-stock-item/add-stock-items-bulk-import-action-button.component.tsx.html +0 -151
  230. package/coverage/src/stock-items/add-bulk-stock-item/index.html +0 -131
  231. package/coverage/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.modal.tsx.html +0 -340
  232. package/coverage/src/stock-items/add-stock-item/add-stock-action-button.component.tsx.html +0 -145
  233. package/coverage/src/stock-items/add-stock-item/add-stock-item.component.tsx.html +0 -376
  234. package/coverage/src/stock-items/add-stock-item/batch-information/batch-information.resource.ts.html +0 -262
  235. package/coverage/src/stock-items/add-stock-item/batch-information/index.html +0 -116
  236. package/coverage/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx.html +0 -301
  237. package/coverage/src/stock-items/add-stock-item/concepts-selector/index.html +0 -116
  238. package/coverage/src/stock-items/add-stock-item/drug-selector/drug-selector.component.tsx.html +0 -454
  239. package/coverage/src/stock-items/add-stock-item/drug-selector/index.html +0 -116
  240. package/coverage/src/stock-items/add-stock-item/index.html +0 -131
  241. package/coverage/src/stock-items/add-stock-item/stock-item-category-selector/index.html +0 -116
  242. package/coverage/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.component.tsx.html +0 -319
  243. package/coverage/src/stock-items/add-stock-item/stock-item-details/index.html +0 -131
  244. package/coverage/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx.html +0 -862
  245. package/coverage/src/stock-items/add-stock-item/stock-item-details/stock-item-details.resource.ts.html +0 -142
  246. package/coverage/src/stock-items/components/filter-stock-items/filter-stock-items.component.tsx.html +0 -166
  247. package/coverage/src/stock-items/components/filter-stock-items/index.html +0 -116
  248. package/coverage/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx.html +0 -169
  249. package/coverage/src/stock-items/edit-stock-item/index.html +0 -116
  250. package/coverage/src/stock-items/index.html +0 -161
  251. package/coverage/src/stock-items/stock-item.utils.tsx.html +0 -103
  252. package/coverage/src/stock-items/stock-items-table.component.tsx.html +0 -910
  253. package/coverage/src/stock-items/stock-items.resource.ts.html +0 -1342
  254. package/coverage/src/stock-items/validationSchema.ts.html +0 -325
  255. package/coverage/src/stock-locations/add-location.modal.tsx.html +0 -289
  256. package/coverage/src/stock-locations/index.html +0 -146
  257. package/coverage/src/stock-locations/location-admin-form.component.tsx.html +0 -574
  258. package/coverage/src/stock-locations/stock-locations-table.resource.ts.html +0 -370
  259. package/coverage/src/stock-lookups/index.html +0 -116
  260. package/coverage/src/stock-lookups/stock-lookups.resource.ts.html +0 -997
  261. package/coverage/src/stock-operations/index.html +0 -131
  262. package/coverage/src/stock-operations/stock-operation.utils.tsx.html +0 -184
  263. package/coverage/src/stock-operations/stock-operations-forms/hooks/index.html +0 -161
  264. package/coverage/src/stock-operations/stock-operations-forms/hooks/useFilterableStockItems.ts.html +0 -211
  265. package/coverage/src/stock-operations/stock-operations-forms/hooks/useOperationTypePermisions.ts.html +0 -172
  266. package/coverage/src/stock-operations/stock-operations-forms/hooks/useSearchUser.ts.html +0 -226
  267. package/coverage/src/stock-operations/stock-operations-forms/hooks/useStockItemBatchNumbers.ts.html +0 -208
  268. package/coverage/src/stock-operations/stock-operations-forms/index.html +0 -116
  269. package/coverage/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.component.tsx.html +0 -439
  270. package/coverage/src/stock-operations/stock-operations-forms/input-components/index.html +0 -176
  271. package/coverage/src/stock-operations/stock-operations-forms/input-components/quantity-uom-selector.component.tsx.html +0 -259
  272. package/coverage/src/stock-operations/stock-operations-forms/input-components/stock-item-search.component.tsx.html +0 -319
  273. package/coverage/src/stock-operations/stock-operations-forms/input-components/stock-operation-reason-selector.component.tsx.html +0 -286
  274. package/coverage/src/stock-operations/stock-operations-forms/input-components/users-selector.component.tsx.html +0 -412
  275. package/coverage/src/stock-operations/stock-operations-forms/steps/base-operation-details-form-step.tsx.html +0 -868
  276. package/coverage/src/stock-operations/stock-operations-forms/steps/index.html +0 -236
  277. package/coverage/src/stock-operations/stock-operations-forms/steps/quantity-uom-cell.component.tsx.html +0 -184
  278. package/coverage/src/stock-operations/stock-operations-forms/steps/received-items.component.tsx.html +0 -433
  279. package/coverage/src/stock-operations/stock-operations-forms/steps/stock-availability-cell.component.tsx.html +0 -238
  280. package/coverage/src/stock-operations/stock-operations-forms/steps/stock-operation-item-batch-no-cell.component.tsx.html +0 -205
  281. package/coverage/src/stock-operations/stock-operations-forms/steps/stock-operation-item-cell.component.tsx.html +0 -232
  282. package/coverage/src/stock-operations/stock-operations-forms/steps/stock-operation-item-expiry-cell.component.tsx.html +0 -208
  283. package/coverage/src/stock-operations/stock-operations-forms/steps/stock-operation-items-form-step.component.tsx.html +0 -910
  284. package/coverage/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.component.tsx.html +0 -850
  285. package/coverage/src/stock-operations/stock-operations-forms/stock-item-form/index.html +0 -116
  286. package/coverage/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.workspace.tsx.html +0 -781
  287. package/coverage/src/stock-operations/stock-operations-forms/stock-operation-form.component.tsx.html +0 -973
  288. package/coverage/src/stock-operations/stock-operations-forms/stock-operation-stepper/index.html +0 -116
  289. package/coverage/src/stock-operations/stock-operations-forms/stock-operation-stepper/stock-operation-stepper.component.tsx.html +0 -238
  290. package/coverage/src/stock-operations/validation-schema.ts.html +0 -847
  291. package/coverage/src/stock-reports/report-list/index.html +0 -116
  292. package/coverage/src/stock-reports/report-list/stock-report-status.utils.ts.html +0 -130
  293. package/coverage/src/stock-sources/add-stock-source-button.component.tsx.html +0 -145
  294. package/coverage/src/stock-sources/add-stock-sources/add-stock-sources.workspace.tsx.html +0 -550
  295. package/coverage/src/stock-sources/add-stock-sources/index.html +0 -116
  296. package/coverage/src/stock-sources/edit-stock-source/edit-stock-source.component.tsx.html +0 -175
  297. package/coverage/src/stock-sources/edit-stock-source/index.html +0 -116
  298. package/coverage/src/stock-sources/index.html +0 -146
  299. package/coverage/src/stock-sources/stock-sources-delete/index.html +0 -116
  300. package/coverage/src/stock-sources/stock-sources-delete/stock-sources-delete.component.tsx.html +0 -277
  301. package/coverage/src/stock-sources/stock-sources-filter/index.html +0 -116
  302. package/coverage/src/stock-sources/stock-sources-filter/stock-sources-filter.component.tsx.html +0 -235
  303. package/coverage/src/stock-sources/stock-sources-items-table.component.tsx.html +0 -661
  304. package/coverage/src/stock-sources/stock-sources.resource.ts.html +0 -295
  305. package/coverage/src/stock-user-role-scopes/delete-stock-user-scope.modal.tsx.html +0 -214
  306. package/coverage/src/stock-user-role-scopes/index.html +0 -116
  307. package/coverage/src/utils.ts.html +0 -133
  308. package/dist/138.js +0 -1
  309. package/dist/138.js.map +0 -1
@@ -15,6 +15,11 @@ export const configSchema = {
15
15
  _default: true,
16
16
  _description: 'Enable or disable the print button in the stock management UI',
17
17
  },
18
+ facilityName: {
19
+ _type: Type.String,
20
+ _default: 'Health Center',
21
+ _description: 'The facility name shown on requisition, stock transfer and goods received printouts',
22
+ },
18
23
  logo: {
19
24
  src: {
20
25
  _type: Type.String,
@@ -32,6 +37,12 @@ export const configSchema = {
32
37
  _description: 'The organization name displayed when image is absent',
33
38
  },
34
39
  },
40
+ mainStoreLocationTag: {
41
+ _type: Type.String,
42
+ _default: 'Main Store',
43
+ _description:
44
+ "The name of the location tag for the main store. The source or destination of a new stock operation is prefilled when this is the only tag the operation type allows on that side. It needs to match a tag in the backend's operation type location scopes",
45
+ },
35
46
  packingUnitsUUID: {
36
47
  _type: Type.ConceptUuid,
37
48
  _description: 'UUID for the packaging unit',
@@ -57,6 +68,29 @@ export const configSchema = {
57
68
  _description: 'UUID for the stock item category',
58
69
  _default: '8ccf6066-9297-4d76-aaf3-00aa3714d198',
59
70
  },
71
+ stockLocationTags: {
72
+ _type: Type.Array,
73
+ _elements: {
74
+ _type: Type.String,
75
+ },
76
+ _default: ['Main Store', 'Main Pharmacy', 'Dispensary'],
77
+ _description:
78
+ "The names of the location tags for stock locations. Locations without one of these tags don't appear in the stock locations table, the user role scope form, stock rules, reports or the location filters. This doesn't change which locations stock operations accept. That comes from each operation type's location scopes in the backend, which default to Main Store, Main Pharmacy and Dispensary",
79
+ },
80
+ stockRoleUUIDs: {
81
+ _type: Type.Array,
82
+ _elements: {
83
+ _type: Type.UUID,
84
+ },
85
+ _default: [
86
+ 'd210eb66-2188-11ed-9dff-507b9dea1806',
87
+ 'cca4be4b-2188-11ed-9dff-507b9dea1806',
88
+ '84bdd876-4694-11ed-8109-00155dcc3fc0',
89
+ 'a49be648-6b0a-11ed-93a2-806d973f13a9',
90
+ '2083fd40-3391-11ed-a667-507b9dea1806',
91
+ ],
92
+ _description: 'The UUIDs of the roles that identify stock roles in the user role scope form',
93
+ },
60
94
  stockSourceTypeUUID: {
61
95
  _type: Type.ConceptUuid,
62
96
  _description: 'UUID for the stock source types',
@@ -78,16 +112,20 @@ export type ConfigObject = {
78
112
  autoPopulateResponsiblePerson: boolean;
79
113
  dispensingUnitsUUID: string;
80
114
  enablePrintButton: boolean;
115
+ facilityName: string;
81
116
  logo: {
82
117
  src: string;
83
118
  alt: string;
84
119
  name: string;
85
120
  };
121
+ mainStoreLocationTag: string;
86
122
  packingUnitsUUID: string;
87
123
  printBalanceOnHand: boolean;
88
124
  printItemCost: boolean;
89
125
  stockAdjustmentReasonUUID: string;
90
126
  stockItemCategoryUUID: string;
127
+ stockLocationTags: Array<string>;
128
+ stockRoleUUIDs: Array<string>;
91
129
  stockSourceTypeUUID: string;
92
130
  stockTakeReasonUUID: string;
93
131
  useItemCommonNameAsDisplay: boolean;
package/src/constants.ts CHANGED
@@ -79,27 +79,14 @@ export const TASK_STOCKMANAGEMENT_REPORTS_MUTATE = 'Task: stockmanagement.report
79
79
 
80
80
  /** @type {string}: Task: stockmanagement.reports.mutate, Able to create stock reports*/
81
81
 
82
- export const INVENTORY_CLERK_ROLE_UUID = 'd210eb66-2188-11ed-9dff-507b9dea1806';
83
- export const INVENTORY_MANAGER_ROLE_UUID = 'cca4be4b-2188-11ed-9dff-507b9dea1806';
84
- export const INVENTORY_DISPENSING_ROLE_UUID = '84bdd876-4694-11ed-8109-00155dcc3fc0';
85
- export const INVENTORY_REPORTING_ROLE_UUID = 'a49be648-6b0a-11ed-93a2-806d973f13a9';
86
- export const INVENTORY_ADMINISTRATOR_ROLE_UUID = '2083fd40-3391-11ed-a667-507b9dea1806';
87
-
88
82
  export const STOCK_OPERATION_PRINT_DISABLE_BALANCE_ON_HAND = true;
89
83
  export const STOCK_OPERATION_PRINT_DISABLE_COSTS = true;
90
- export const HEALTH_CENTER_NAME = 'Health Center';
91
84
  export const PRINT_LOGO = 'moduleResources/stockmanagement/assets/print-logo.svg';
92
- export const PRINT_LOGO_TEXT = 'Ministry of Health';
93
85
 
94
- export const MAIN_STORE_LOCATION_TAG = 'Main Store';
95
86
  export const BASE_OPENMRS_APP_URL = '/openmrs/';
96
87
 
97
88
  export const STOCKMGMT_RESOURCE_URL = '/openmrs/stockmanagement/spa.page/';
98
89
  export const STOCKMGMT_SPA_PAGE_URL = '/openmrs/stockmanagement/spa.page';
99
- export const URL_PRINT_LOGO = () =>
100
- PRINT_LOGO
101
- ? `${BASE_OPENMRS_APP_URL}${PRINT_LOGO}`
102
- : 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
103
90
  export const CLOSE_PRINT_AFTER_PRINT = true;
104
91
  export const ALLOW_STOCK_ISSUE_WITHOUT_REQUISITION = false;
105
92
 
@@ -11,6 +11,7 @@ import {
11
11
  TableRow,
12
12
  } from '@carbon/react';
13
13
  import { useTranslation } from 'react-i18next';
14
+ import { formatDate as formatDisplayDate } from '@openmrs/esm-framework';
14
15
 
15
16
  interface ExpiredStockModalProps {
16
17
  closeModal: () => void;
@@ -30,12 +31,7 @@ const ExpiredStockModal = ({ closeModal, expiredStock }: ExpiredStockModalProps)
30
31
 
31
32
  const formatDate = (dateString) => {
32
33
  if (!dateString) return 'N/A';
33
- const date = new Date(dateString);
34
- return new Intl.DateTimeFormat('en-GB', {
35
- year: 'numeric',
36
- month: 'short',
37
- day: '2-digit',
38
- }).format(date);
34
+ return formatDisplayDate(new Date(dateString), { time: false, noToday: true });
39
35
  };
40
36
 
41
37
  return (
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { afterEach, describe, expect, it, vi } from 'vitest';
3
+ import { render, screen } from '@testing-library/react';
4
+ import ExpiredStockModal from './expired-stock.modal';
5
+
6
+ const expiredStock = [{ drugName: 'Paracetamol', batchNo: 'B1', quantity: 5, expiration: '2026-01-15T12:00:00.000Z' }];
7
+
8
+ describe('ExpiredStockModal', () => {
9
+ afterEach(() => {
10
+ vi.unstubAllGlobals();
11
+ });
12
+
13
+ it.each([
14
+ ['en', /Jan/],
15
+ ['fr', /janv/],
16
+ ])("formats expiration dates in the user's locale (%s)", (language, expected) => {
17
+ vi.stubGlobal('i18next', { language });
18
+
19
+ render(<ExpiredStockModal closeModal={vi.fn()} expiredStock={expiredStock} />);
20
+
21
+ expect(screen.getByRole('cell', { name: expected })).toBeInTheDocument();
22
+ });
23
+ });
@@ -43,10 +43,10 @@ const StockItemDetails = ({ stockItem, handleTabChange, onCloseWorkspace }: Stoc
43
43
 
44
44
  const { errors } = formState;
45
45
  const handleSave: SubmitHandler<StockItemFormData> = async (formValues) => {
46
+ // The backend rejects a reorder level unit without a reorder level, so clear both together
47
+ const payload = formValues.reorderLevel == null ? { ...formValues, reorderLevelUoMUuid: null } : formValues;
46
48
  try {
47
- const response = stockItem
48
- ? await updateStockItem(stockItem?.uuid, formValues)
49
- : await createStockItem(formValues);
49
+ const response = stockItem ? await updateStockItem(stockItem?.uuid, payload) : await createStockItem(payload);
50
50
  if (response?.data) {
51
51
  showSnackbar({
52
52
  isLowContrast: true,
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
3
+ import { render, screen } from '@testing-library/react';
4
+ import { useForm } from 'react-hook-form';
5
+ import { type StockItemDTO } from '../../../core/api/types/stockItem/StockItem';
6
+ import { useStockItem } from '../../stock-items.resource';
7
+ import { type StockItemFormData } from '../../validationSchema';
8
+ import StockItemUnitsEdit from './stock-item-units-edit.component';
9
+
10
+ vi.mock('../../stock-items.resource', () => ({
11
+ useStockItem: vi.fn(),
12
+ }));
13
+
14
+ const mockUseStockItem = vi.mocked(useStockItem);
15
+
16
+ const packagingUnits = [
17
+ {
18
+ uuid: 'reorder-unit',
19
+ stockItemUuid: 'item-uuid',
20
+ packagingUomName: 'Box',
21
+ factor: 10,
22
+ isDefaultStockOperationsUoM: false,
23
+ isDispensingUnit: false,
24
+ },
25
+ {
26
+ uuid: 'purchase-unit',
27
+ stockItemUuid: 'item-uuid',
28
+ packagingUomName: 'Vial',
29
+ factor: 1,
30
+ isDefaultStockOperationsUoM: false,
31
+ isDispensingUnit: false,
32
+ },
33
+ ];
34
+
35
+ const stockItem = {
36
+ uuid: 'item-uuid',
37
+ reorderLevel: 5,
38
+ reorderLevelUoMUuid: 'reorder-unit',
39
+ purchasePrice: 20,
40
+ purchasePriceUoMUuid: 'purchase-unit',
41
+ packagingUnits,
42
+ } as StockItemDTO;
43
+
44
+ const Harness = ({ item }: { item: StockItemDTO }) => {
45
+ const { control, formState } = useForm<StockItemFormData>({ defaultValues: item as StockItemFormData });
46
+ return <StockItemUnitsEdit stockItemUuid={item.uuid} control={control} formState={formState} />;
47
+ };
48
+
49
+ describe('StockItemUnitsEdit', () => {
50
+ beforeEach(() => {
51
+ mockUseStockItem.mockReturnValue({ isLoading: false, item: stockItem, error: undefined });
52
+ });
53
+
54
+ it('shows the saved reorder level unit rather than the purchase price unit', () => {
55
+ render(<Harness item={stockItem} />);
56
+
57
+ expect(screen.getByRole('combobox', { name: /reorder level packaging unit/i })).toHaveValue('Box - 10 ');
58
+ expect(screen.getByRole('combobox', { name: /purchase price packaging unit/i })).toHaveValue('Vial - 1 ');
59
+ });
60
+
61
+ it('leaves the reorder level unit blank when no reorder unit is saved', () => {
62
+ const itemWithoutReorderUnit = { ...stockItem, reorderLevelUoMUuid: null };
63
+ mockUseStockItem.mockReturnValue({ isLoading: false, item: itemWithoutReorderUnit, error: undefined });
64
+
65
+ render(<Harness item={itemWithoutReorderUnit} />);
66
+
67
+ expect(screen.getByRole('combobox', { name: /reorder level packaging unit/i })).toHaveValue('');
68
+ });
69
+ });
@@ -64,7 +64,7 @@ const StockItemUnitsEdit: React.FC<StockItemUnitsEditProps> = ({ stockItemUuid,
64
64
  />
65
65
  )}
66
66
  <DispensingPackageMeasurement
67
- dispensingUnitPackagingUoMUuid={stockItem?.purchasePriceUoMUuid}
67
+ dispensingUnitPackagingUoMUuid={stockItem?.reorderLevelUoMUuid}
68
68
  name="reorderLevelUoMUuid"
69
69
  controllerName="reorderLevelUoMUuid"
70
70
  control={control}
@@ -0,0 +1,51 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { createStockItemDetailsSchema } from './validationSchema';
3
+
4
+ const mockT = ((key: string, defaultValue?: string) => defaultValue || key) as any;
5
+
6
+ describe('createStockItemDetailsSchema', () => {
7
+ const base = {
8
+ isDrug: false,
9
+ hasExpiration: false,
10
+ };
11
+
12
+ it('allows reorder level without unit when reorder level is null or undefined', () => {
13
+ const schema = createStockItemDetailsSchema(mockT);
14
+ expect(schema.safeParse({ ...base, reorderLevel: null, reorderLevelUoMUuid: null }).success).toBe(true);
15
+ expect(schema.safeParse({ ...base }).success).toBe(true);
16
+ });
17
+
18
+ it('allows reorder level with unit when set', () => {
19
+ const schema = createStockItemDetailsSchema(mockT);
20
+ const result = schema.safeParse({ ...base, reorderLevel: 10, reorderLevelUoMUuid: 'abc-123' });
21
+ expect(result.success).toBe(true);
22
+ });
23
+
24
+ it('requires reorder level unit when reorder level is set (> 0)', () => {
25
+ const schema = createStockItemDetailsSchema(mockT);
26
+ const result = schema.safeParse({ ...base, reorderLevel: 10, reorderLevelUoMUuid: null });
27
+ expect(result.success).toBe(false);
28
+ if (result.success === false) {
29
+ expect(result.error.issues.some((issue) => issue.path.includes('reorderLevelUoMUuid'))).toBe(true);
30
+ }
31
+ });
32
+
33
+ it('requires reorder level unit when reorder level is greater than 0', () => {
34
+ const schema = createStockItemDetailsSchema(mockT);
35
+ const result = schema.safeParse({ ...base, reorderLevel: 5, reorderLevelUoMUuid: undefined });
36
+ expect(result.success).toBe(false);
37
+ });
38
+
39
+ it('requires reorder level unit when reorder level is 0', () => {
40
+ const schema = createStockItemDetailsSchema(mockT);
41
+ const result = schema.safeParse({ ...base, reorderLevel: 0, reorderLevelUoMUuid: null });
42
+ expect(result.success).toBe(false);
43
+ });
44
+
45
+ it('treats a cleared reorder level as unset rather than 0', () => {
46
+ const schema = createStockItemDetailsSchema(mockT);
47
+ const result = schema.safeParse({ ...base, reorderLevel: '', reorderLevelUoMUuid: null });
48
+ expect(result.success).toBe(true);
49
+ expect(result.success && result.data.reorderLevel).toBeNull();
50
+ });
51
+ });
@@ -32,7 +32,7 @@ export const createStockItemDetailsSchema = (t: TFunction) =>
32
32
  dispensingUnitPackagingUoMName: z.string().nullish(),
33
33
  defaultStockOperationsUoMUuid: z.string().nullish(),
34
34
  defaultStockOperationsUoMName: z.string().nullish(),
35
- reorderLevel: z.coerce.number().nullish(),
35
+ reorderLevel: z.preprocess((value) => (value === '' ? null : value), z.coerce.number().nullish()),
36
36
  reorderLevelUoMUuid: z.string().nullish(),
37
37
  reorderLevelUoMName: z.string().nullish(),
38
38
  dateCreated: z.coerce.date().nullish(),
@@ -75,6 +75,15 @@ export const createStockItemDetailsSchema = (t: TFunction) =>
75
75
  message: t('purchasePriceUoMRequired', 'Purchase price packaging unit is required when purchase price is set'),
76
76
  path: ['purchasePriceUoMUuid'],
77
77
  },
78
+ )
79
+ .refine(
80
+ ({ reorderLevel, reorderLevelUoMUuid }) => {
81
+ return reorderLevel != null ? !!reorderLevelUoMUuid : true;
82
+ },
83
+ {
84
+ message: t('reorderLevelUoMRequired', 'Reorder level packaging unit is required when reorder level is set'),
85
+ path: ['reorderLevelUoMUuid'],
86
+ },
78
87
  );
79
88
 
80
89
  export type StockItemFormData = z.infer<ReturnType<typeof createStockItemDetailsSchema>>;
@@ -1,8 +1,13 @@
1
1
  import { renderHook } from '@testing-library/react';
2
- import { expect, it, vi } from 'vitest';
3
- import { useFhirFetchAll } from '@openmrs/esm-framework';
2
+ import { beforeEach, expect, it, vi } from 'vitest';
3
+ import { getDefaultsFromConfigSchema, useConfig, useFhirFetchAll } from '@openmrs/esm-framework';
4
+ import { configSchema } from '../config-schema';
4
5
  import { useStockLocationPages } from './stock-locations-table.resource';
5
6
 
7
+ beforeEach(() => {
8
+ vi.mocked(useConfig).mockReturnValue(getDefaultsFromConfigSchema(configSchema));
9
+ });
10
+
6
11
  it('exposes the FHIR list mutator through the location pagination hook', async () => {
7
12
  const mutate = vi.fn();
8
13
  vi.mocked(useFhirFetchAll).mockReturnValue({
@@ -21,3 +26,20 @@ it('exposes the FHIR list mutator through the location pagination hook', async (
21
26
  await result.current.mutate();
22
27
  expect(mutate).toHaveBeenCalledOnce();
23
28
  });
29
+
30
+ it('fetches locations with the default RefApp stock location tags', () => {
31
+ vi.mocked(useFhirFetchAll).mockReturnValue({ data: [], isLoading: false } as never);
32
+ renderHook(() => useStockLocationPages({}));
33
+ expect(useFhirFetchAll).toHaveBeenCalledWith(
34
+ expect.stringMatching(/\/Location\?_summary=data&_tag=Main%20Store,Main%20Pharmacy,Dispensary$/),
35
+ );
36
+ });
37
+
38
+ it('fetches locations with the configured stock location tags', () => {
39
+ vi.mocked(useConfig).mockReturnValue({ stockLocationTags: ['Central Store', 'Ward'] });
40
+ vi.mocked(useFhirFetchAll).mockReturnValue({ data: [], isLoading: false } as never);
41
+ renderHook(() => useStockLocationPages({}));
42
+ expect(useFhirFetchAll).toHaveBeenCalledWith(
43
+ expect.stringMatching(/\/Location\?_summary=data&_tag=Central%20Store,Ward$/),
44
+ );
45
+ });
@@ -8,8 +8,10 @@ import {
8
8
  openmrsFetch,
9
9
  useSession,
10
10
  restBaseUrl,
11
+ useConfig,
11
12
  useFhirFetchAll,
12
13
  } from '@openmrs/esm-framework';
14
+ import { type ConfigObject } from '../config-schema';
13
15
  import { type Concept } from '../core/api/types/concept/Concept';
14
16
  import { type Drug } from '../core/api/types/concept/Drug';
15
17
  import { type OpenMRSLocation, type OpenMRSLocationTag } from '../core/api/types/Location';
@@ -51,10 +53,12 @@ export function useStockLocations(filter: LocationFilterCriteria) {
51
53
  };
52
54
  }
53
55
  /* Get locations tagged to perform stock related activities.
54
- Unless a location is tag as main store, main pharmacy or dispensing, it will not be fetched.
56
+ Unless a location has one of the tags configured in `stockLocationTags`, it will not be fetched.
55
57
  */
56
58
  export function useStockTagLocations() {
57
- const apiUrl = `${fhirBaseUrl}/Location?_summary=data&_tag=main store,main pharmacy,dispensary `;
59
+ const { stockLocationTags } = useConfig<ConfigObject>();
60
+ const tags = stockLocationTags.map((tag) => encodeURIComponent(tag)).join(',');
61
+ const apiUrl = `${fhirBaseUrl}/Location?_summary=data&_tag=${tags}`;
58
62
  const { data, error, isLoading, mutate } = useFhirFetchAll<fhir.Location>(apiUrl);
59
63
 
60
64
  return {
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
3
+ import { render } from '@testing-library/react';
4
+ import { FormProvider, useForm, type UseFormReturn } from 'react-hook-form';
5
+ import { useConfig } from '@openmrs/esm-framework';
6
+ import { requisitionOperationTypeMock } from '@mocks';
7
+ import { type StockOperationType } from '../../../core/api/types/stockOperation/StockOperationType';
8
+ import { type StockOperationItemDtoSchema } from '../../validation-schema';
9
+ import useParties from '../hooks/useParties';
10
+ import BaseOperationDetailsFormStep from './base-operation-details-form-step';
11
+
12
+ vi.mock('../hooks/useParties', () => ({ default: vi.fn() }));
13
+ vi.mock('../hooks/useOperationTypePermisions', () => ({ default: vi.fn(() => ({})) }));
14
+ vi.mock('../input-components/users-selector.component', () => ({ default: () => null }));
15
+ vi.mock('../input-components/stock-operation-reason-selector.component', () => ({ default: () => null }));
16
+
17
+ const stockOperationType = {
18
+ ...requisitionOperationTypeMock,
19
+ hasSource: true,
20
+ hasDestination: true,
21
+ } as unknown as StockOperationType;
22
+
23
+ function setupStep(tag: string) {
24
+ vi.mocked(useParties).mockReturnValue({
25
+ sourceTags: [tag],
26
+ destinationTags: [tag],
27
+ sourceParties: [{ uuid: 'source-party-uuid' }],
28
+ destinationParties: [{ uuid: 'destination-party-uuid' }],
29
+ isLoading: false,
30
+ error: undefined,
31
+ } as never);
32
+
33
+ let form: UseFormReturn<StockOperationItemDtoSchema>;
34
+ const Wrapper = () => {
35
+ form = useForm<StockOperationItemDtoSchema>();
36
+ return (
37
+ <FormProvider {...form}>
38
+ <BaseOperationDetailsFormStep stockOperationType={stockOperationType} />
39
+ </FormProvider>
40
+ );
41
+ };
42
+ render(<Wrapper />);
43
+ return form;
44
+ }
45
+
46
+ describe('BaseOperationDetailsFormStep', () => {
47
+ beforeEach(() => {
48
+ vi.mocked(useConfig).mockReturnValue({ mainStoreLocationTag: 'Central Store' });
49
+ });
50
+
51
+ it('prefills the source and destination when the only allowed tag is the configured main store tag', () => {
52
+ const form = setupStep('Central Store');
53
+
54
+ expect(form.getValues('sourceUuid')).toBe('source-party-uuid');
55
+ expect(form.getValues('destinationUuid')).toBe('destination-party-uuid');
56
+ });
57
+
58
+ it('does not prefill the source and destination for any other tag', () => {
59
+ const form = setupStep('Main Store');
60
+
61
+ expect(form.getValues('sourceUuid')).toBeUndefined();
62
+ expect(form.getValues('destinationUuid')).toBeUndefined();
63
+ });
64
+ });
@@ -13,8 +13,9 @@ import {
13
13
  import { ArrowRight } from '@carbon/react/icons';
14
14
  import { Controller, useFormContext } from 'react-hook-form';
15
15
  import { useTranslation } from 'react-i18next';
16
- import { ErrorState } from '@openmrs/esm-framework';
17
- import { DATE_PICKER_CONTROL_FORMAT, DATE_PICKER_FORMAT, MAIN_STORE_LOCATION_TAG } from '../../../constants';
16
+ import { ErrorState, useConfig } from '@openmrs/esm-framework';
17
+ import { type ConfigObject } from '../../../config-schema';
18
+ import { DATE_PICKER_CONTROL_FORMAT, DATE_PICKER_FORMAT } from '../../../constants';
18
19
  import { type Party } from '../../../core/api/types/Party';
19
20
  import { type StockOperationDTO } from '../../../core/api/types/stockOperation/StockOperationDTO';
20
21
  import { OperationType, type StockOperationType } from '../../../core/api/types/stockOperation/StockOperationType';
@@ -37,6 +38,7 @@ const BaseOperationDetailsFormStep: FC<BaseOperationDetailsFormStepProps> = ({
37
38
  onNext,
38
39
  }) => {
39
40
  const { t } = useTranslation();
41
+ const { mainStoreLocationTag } = useConfig<ConfigObject>();
40
42
  const operationTypePermision = useOperationTypePermisions(stockOperationType);
41
43
  const {
42
44
  destinationParties,
@@ -71,7 +73,7 @@ const BaseOperationDetailsFormStep: FC<BaseOperationDetailsFormStepProps> = ({
71
73
  // Prefill default locaton with current location if is a new operation
72
74
  if (!stockOperation && stockOperationType.operationType !== OperationType.STOCK_ISSUE_OPERATION_TYPE) {
73
75
  if (stockOperationType?.hasSource) {
74
- const shouldLockSource = sourceTags.length === 1 && sourceTags[0] === MAIN_STORE_LOCATION_TAG;
76
+ const shouldLockSource = sourceTags.length === 1 && sourceTags[0] === mainStoreLocationTag;
75
77
  if (shouldLockSource && sourceParties?.length) {
76
78
  const party = sourceParties[0];
77
79
  form.setValue('sourceUuid', party.uuid);
@@ -79,14 +81,23 @@ const BaseOperationDetailsFormStep: FC<BaseOperationDetailsFormStepProps> = ({
79
81
  }
80
82
 
81
83
  if (stockOperationType?.hasDestination) {
82
- const shouldLockDestination = destinationTags.length === 1 && destinationTags[0] === MAIN_STORE_LOCATION_TAG;
84
+ const shouldLockDestination = destinationTags.length === 1 && destinationTags[0] === mainStoreLocationTag;
83
85
  if (shouldLockDestination && destinationParties?.length) {
84
86
  const party = destinationParties[0];
85
87
  form.setValue('destinationUuid', party.uuid);
86
88
  }
87
89
  }
88
90
  }
89
- }, [sourceParties, destinationParties, stockOperation, stockOperationType, form, destinationTags, sourceTags]);
91
+ }, [
92
+ sourceParties,
93
+ destinationParties,
94
+ stockOperation,
95
+ stockOperationType,
96
+ form,
97
+ destinationTags,
98
+ sourceTags,
99
+ mainStoreLocationTag,
100
+ ]);
90
101
 
91
102
  if (isPartiesLoading)
92
103
  return (
@@ -8,6 +8,10 @@ import { createStockOperation, deleteStockOperationItem, updateStockOperation }
8
8
  import { extractErrorMessagesFromResponse } from '../../../constants';
9
9
  import { useHandleMutate } from '../../../utils';
10
10
  import { OperationType, type StockOperationType } from '../../../core/api/types/stockOperation/StockOperationType';
11
+ import {
12
+ StockOperationStatusNew,
13
+ StockOperationStatusReturned,
14
+ } from '../../../core/api/types/stockOperation/StockOperationStatus';
11
15
  import { otherUser } from '../../../core/utils/utils';
12
16
  import { launchStockOperationsModal } from '../../stock-operation.utils';
13
17
  import { type StockOperationDTO } from '../../../core/api/types/stockOperation/StockOperationDTO';
@@ -34,7 +38,13 @@ const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormSte
34
38
  const { t } = useTranslation();
35
39
  const handleMutate = useHandleMutate();
36
40
  const operationTypePermision = useOperationTypePermisions(stockOperationType);
37
- const editable = useMemo(() => !stockOperation || stockOperation.status === 'NEW', [stockOperation]);
41
+ const editable = useMemo(
42
+ () =>
43
+ !stockOperation ||
44
+ stockOperation.status === StockOperationStatusNew ||
45
+ stockOperation.status === StockOperationStatusReturned,
46
+ [stockOperation],
47
+ );
38
48
  const form = useFormContext<StockOperationItemDtoSchema>();
39
49
  const [approvalRequired, setApprovalRequired] = useState<boolean | null>(stockOperation?.approvalRequired);
40
50
  const isStockIssueOperation = useMemo(
@@ -46,7 +56,7 @@ const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormSte
46
56
  };
47
57
 
48
58
  const handleSave = useCallback(async () => {
49
- let result: StockOperationDTO; // To store the result for returning
59
+ let result: StockOperationDTO | undefined;
50
60
  await form.handleSubmit(async (formData) => {
51
61
  try {
52
62
  // Get deleted items (items in stock operation bt not i form data)
@@ -118,7 +128,6 @@ const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormSte
118
128
  kind: 'error',
119
129
  isLowContrast: true,
120
130
  });
121
- throw error;
122
131
  }
123
132
  })(); // Call handleSubmit to trigger validation and submission
124
133
  return result; // Return the result after handleSubmit completes
@@ -126,16 +135,25 @@ const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormSte
126
135
 
127
136
  const handleComplete = useCallback(() => {
128
137
  handleSave().then((operation) => {
138
+ if (!operation?.uuid?.trim()) {
139
+ return;
140
+ }
129
141
  launchStockOperationsModal('Complete', false, { ...operation, status: 'COMPLETED' });
130
142
  });
131
143
  }, [handleSave]);
132
144
  const handleSubmitForReview = useCallback(() => {
133
145
  handleSave().then((operation) => {
146
+ if (!operation?.uuid?.trim()) {
147
+ return;
148
+ }
134
149
  launchStockOperationsModal('Submit', false, { ...operation, status: 'SUBMITTED' });
135
150
  });
136
151
  }, [handleSave]);
137
152
  const handleDispatch = useCallback(() => {
138
153
  handleSave().then((operation) => {
154
+ if (!operation?.uuid?.trim()) {
155
+ return;
156
+ }
139
157
  launchStockOperationsModal('Dispatch', false, { ...operation, status: 'DISPATCHED' });
140
158
  });
141
159
  }, [handleSave]);