@open-mercato/core 0.6.7-develop.6669.1.40b669666b → 0.6.7-develop.6671.1.4b925c5096

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 (473) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/dist/generated/entities/inventory_balance/index.js +21 -0
  3. package/dist/generated/entities/inventory_balance/index.js.map +7 -0
  4. package/dist/generated/entities/inventory_lot/index.js +19 -0
  5. package/dist/generated/entities/inventory_lot/index.js.map +7 -0
  6. package/dist/generated/entities/inventory_movement/index.js +35 -0
  7. package/dist/generated/entities/inventory_movement/index.js.map +7 -0
  8. package/dist/generated/entities/inventory_reservation/index.js +23 -0
  9. package/dist/generated/entities/inventory_reservation/index.js.map +7 -0
  10. package/dist/generated/entities/product_inventory_profile/index.js +21 -0
  11. package/dist/generated/entities/product_inventory_profile/index.js.map +7 -0
  12. package/dist/generated/entities/sales_order_warehouse_assignment/index.js +11 -0
  13. package/dist/generated/entities/sales_order_warehouse_assignment/index.js.map +7 -0
  14. package/dist/generated/entities/warehouse/index.js +25 -0
  15. package/dist/generated/entities/warehouse/index.js.map +7 -0
  16. package/dist/generated/entities/warehouse_location/index.js +21 -0
  17. package/dist/generated/entities/warehouse_location/index.js.map +7 -0
  18. package/dist/generated/entities/warehouse_zone/index.js +11 -0
  19. package/dist/generated/entities/warehouse_zone/index.js.map +7 -0
  20. package/dist/generated/entities.ids.generated.js +12 -0
  21. package/dist/generated/entities.ids.generated.js.map +2 -2
  22. package/dist/generated/entity-fields-registry.js +98 -0
  23. package/dist/generated/entity-fields-registry.js.map +2 -2
  24. package/dist/modules/auth/backend/roles/page.js +12 -4
  25. package/dist/modules/auth/backend/roles/page.js.map +2 -2
  26. package/dist/modules/auth/lib/backendChrome.js +1 -0
  27. package/dist/modules/auth/lib/backendChrome.js.map +2 -2
  28. package/dist/modules/auth/services/rbacService.js +16 -17
  29. package/dist/modules/auth/services/rbacService.js.map +2 -2
  30. package/dist/modules/catalog/api/products/route.js +3 -0
  31. package/dist/modules/catalog/api/products/route.js.map +2 -2
  32. package/dist/modules/catalog/api/variants/route.js +3 -0
  33. package/dist/modules/catalog/api/variants/route.js.map +2 -2
  34. package/dist/modules/query_index/lib/engine.js +6 -6
  35. package/dist/modules/query_index/lib/engine.js.map +2 -2
  36. package/dist/modules/sales/api/documents/factory.js +1 -0
  37. package/dist/modules/sales/api/documents/factory.js.map +2 -2
  38. package/dist/modules/sales/commands/documents.js +53 -0
  39. package/dist/modules/sales/commands/documents.js.map +2 -2
  40. package/dist/modules/sales/components/documents/ItemsSection.js +51 -2
  41. package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
  42. package/dist/modules/sales/events.js +2 -0
  43. package/dist/modules/sales/events.js.map +2 -2
  44. package/dist/modules/sales/widgets/injection/order-items-context.js +11 -0
  45. package/dist/modules/sales/widgets/injection/order-items-context.js.map +7 -0
  46. package/dist/modules/wms/acl.js +18 -0
  47. package/dist/modules/wms/acl.js.map +7 -0
  48. package/dist/modules/wms/analytics.js +11 -0
  49. package/dist/modules/wms/analytics.js.map +7 -0
  50. package/dist/modules/wms/api/dashboard/operational/route.js +80 -0
  51. package/dist/modules/wms/api/dashboard/operational/route.js.map +7 -0
  52. package/dist/modules/wms/api/interceptors.js +90 -0
  53. package/dist/modules/wms/api/interceptors.js.map +7 -0
  54. package/dist/modules/wms/api/inventory/adjust/route.js +51 -0
  55. package/dist/modules/wms/api/inventory/adjust/route.js.map +7 -0
  56. package/dist/modules/wms/api/inventory/allocate/route.js +51 -0
  57. package/dist/modules/wms/api/inventory/allocate/route.js.map +7 -0
  58. package/dist/modules/wms/api/inventory/balances/route.js +172 -0
  59. package/dist/modules/wms/api/inventory/balances/route.js.map +7 -0
  60. package/dist/modules/wms/api/inventory/cycle-count/route.js +52 -0
  61. package/dist/modules/wms/api/inventory/cycle-count/route.js.map +7 -0
  62. package/dist/modules/wms/api/inventory/helpers.js +113 -0
  63. package/dist/modules/wms/api/inventory/helpers.js.map +7 -0
  64. package/dist/modules/wms/api/inventory/import/apply/route.js +46 -0
  65. package/dist/modules/wms/api/inventory/import/apply/route.js.map +7 -0
  66. package/dist/modules/wms/api/inventory/import/helpers.js +195 -0
  67. package/dist/modules/wms/api/inventory/import/helpers.js.map +7 -0
  68. package/dist/modules/wms/api/inventory/import/template/route.js +32 -0
  69. package/dist/modules/wms/api/inventory/import/template/route.js.map +7 -0
  70. package/dist/modules/wms/api/inventory/import/validate/route.js +54 -0
  71. package/dist/modules/wms/api/inventory/import/validate/route.js.map +7 -0
  72. package/dist/modules/wms/api/inventory/move/route.js +51 -0
  73. package/dist/modules/wms/api/inventory/move/route.js.map +7 -0
  74. package/dist/modules/wms/api/inventory/movements/route.js +164 -0
  75. package/dist/modules/wms/api/inventory/movements/route.js.map +7 -0
  76. package/dist/modules/wms/api/inventory/receive/route.js +50 -0
  77. package/dist/modules/wms/api/inventory/receive/route.js.map +7 -0
  78. package/dist/modules/wms/api/inventory/release/route.js +44 -0
  79. package/dist/modules/wms/api/inventory/release/route.js.map +7 -0
  80. package/dist/modules/wms/api/inventory/reservations/route.js +128 -0
  81. package/dist/modules/wms/api/inventory/reservations/route.js.map +7 -0
  82. package/dist/modules/wms/api/inventory/reserve/route.js +59 -0
  83. package/dist/modules/wms/api/inventory/reserve/route.js.map +7 -0
  84. package/dist/modules/wms/api/inventory-profiles/route.js +178 -0
  85. package/dist/modules/wms/api/inventory-profiles/route.js.map +7 -0
  86. package/dist/modules/wms/api/listEnrichers.js +181 -0
  87. package/dist/modules/wms/api/listEnrichers.js.map +7 -0
  88. package/dist/modules/wms/api/listSearch.js +77 -0
  89. package/dist/modules/wms/api/listSearch.js.map +7 -0
  90. package/dist/modules/wms/api/locations/route.js +172 -0
  91. package/dist/modules/wms/api/locations/route.js.map +7 -0
  92. package/dist/modules/wms/api/lots/route.js +204 -0
  93. package/dist/modules/wms/api/lots/route.js.map +7 -0
  94. package/dist/modules/wms/api/openapi.js +27 -0
  95. package/dist/modules/wms/api/openapi.js.map +7 -0
  96. package/dist/modules/wms/api/sales-orders/[salesOrderId]/re-run-reservation/route.js +54 -0
  97. package/dist/modules/wms/api/sales-orders/[salesOrderId]/re-run-reservation/route.js.map +7 -0
  98. package/dist/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.js +279 -0
  99. package/dist/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.js.map +7 -0
  100. package/dist/modules/wms/api/sales-orders/assign-warehouse/route.js +56 -0
  101. package/dist/modules/wms/api/sales-orders/assign-warehouse/route.js.map +7 -0
  102. package/dist/modules/wms/api/sales-orders/unassign-warehouse/route.js +43 -0
  103. package/dist/modules/wms/api/sales-orders/unassign-warehouse/route.js.map +7 -0
  104. package/dist/modules/wms/api/warehouses/route.js +181 -0
  105. package/dist/modules/wms/api/warehouses/route.js.map +7 -0
  106. package/dist/modules/wms/api/zones/route.js +159 -0
  107. package/dist/modules/wms/api/zones/route.js.map +7 -0
  108. package/dist/modules/wms/backend/config/wms/page.js +9 -0
  109. package/dist/modules/wms/backend/config/wms/page.js.map +7 -0
  110. package/dist/modules/wms/backend/config/wms/page.meta.js +18 -0
  111. package/dist/modules/wms/backend/config/wms/page.meta.js.map +7 -0
  112. package/dist/modules/wms/backend/page.js +9 -0
  113. package/dist/modules/wms/backend/page.js.map +7 -0
  114. package/dist/modules/wms/backend/page.meta.js +16 -0
  115. package/dist/modules/wms/backend/page.meta.js.map +7 -0
  116. package/dist/modules/wms/backend/wms/inventory/page.js +9 -0
  117. package/dist/modules/wms/backend/wms/inventory/page.js.map +7 -0
  118. package/dist/modules/wms/backend/wms/inventory/page.meta.js +18 -0
  119. package/dist/modules/wms/backend/wms/inventory/page.meta.js.map +7 -0
  120. package/dist/modules/wms/backend/wms/location/[id]/page.js +9 -0
  121. package/dist/modules/wms/backend/wms/location/[id]/page.js.map +7 -0
  122. package/dist/modules/wms/backend/wms/location/[id]/page.meta.js +18 -0
  123. package/dist/modules/wms/backend/wms/location/[id]/page.meta.js.map +7 -0
  124. package/dist/modules/wms/backend/wms/locations/page.js +10 -0
  125. package/dist/modules/wms/backend/wms/locations/page.js.map +7 -0
  126. package/dist/modules/wms/backend/wms/locations/page.meta.js +18 -0
  127. package/dist/modules/wms/backend/wms/locations/page.meta.js.map +7 -0
  128. package/dist/modules/wms/backend/wms/lot/[id]/page.js +9 -0
  129. package/dist/modules/wms/backend/wms/lot/[id]/page.js.map +7 -0
  130. package/dist/modules/wms/backend/wms/lot/[id]/page.meta.js +18 -0
  131. package/dist/modules/wms/backend/wms/lot/[id]/page.meta.js.map +7 -0
  132. package/dist/modules/wms/backend/wms/lots/page.js +9 -0
  133. package/dist/modules/wms/backend/wms/lots/page.js.map +7 -0
  134. package/dist/modules/wms/backend/wms/lots/page.meta.js +18 -0
  135. package/dist/modules/wms/backend/wms/lots/page.meta.js.map +7 -0
  136. package/dist/modules/wms/backend/wms/movements/page.js +22 -0
  137. package/dist/modules/wms/backend/wms/movements/page.js.map +7 -0
  138. package/dist/modules/wms/backend/wms/movements/page.meta.js +18 -0
  139. package/dist/modules/wms/backend/wms/movements/page.meta.js.map +7 -0
  140. package/dist/modules/wms/backend/wms/reservations/page.js +23 -0
  141. package/dist/modules/wms/backend/wms/reservations/page.js.map +7 -0
  142. package/dist/modules/wms/backend/wms/reservations/page.meta.js +18 -0
  143. package/dist/modules/wms/backend/wms/reservations/page.meta.js.map +7 -0
  144. package/dist/modules/wms/backend/wms/sku/[id]/page.js +9 -0
  145. package/dist/modules/wms/backend/wms/sku/[id]/page.js.map +7 -0
  146. package/dist/modules/wms/backend/wms/sku/[id]/page.meta.js +18 -0
  147. package/dist/modules/wms/backend/wms/sku/[id]/page.meta.js.map +7 -0
  148. package/dist/modules/wms/backend/wms/warehouses/page.js +10 -0
  149. package/dist/modules/wms/backend/wms/warehouses/page.js.map +7 -0
  150. package/dist/modules/wms/backend/wms/warehouses/page.meta.js +18 -0
  151. package/dist/modules/wms/backend/wms/warehouses/page.meta.js.map +7 -0
  152. package/dist/modules/wms/backend/wms/zones/page.js +10 -0
  153. package/dist/modules/wms/backend/wms/zones/page.js.map +7 -0
  154. package/dist/modules/wms/backend/wms/zones/page.meta.js +18 -0
  155. package/dist/modules/wms/backend/wms/zones/page.meta.js.map +7 -0
  156. package/dist/modules/wms/ce.js +80 -0
  157. package/dist/modules/wms/ce.js.map +7 -0
  158. package/dist/modules/wms/cli.js +83 -0
  159. package/dist/modules/wms/cli.js.map +7 -0
  160. package/dist/modules/wms/commands/configuration.js +1519 -0
  161. package/dist/modules/wms/commands/configuration.js.map +7 -0
  162. package/dist/modules/wms/commands/index.js +4 -0
  163. package/dist/modules/wms/commands/index.js.map +7 -0
  164. package/dist/modules/wms/commands/inventory-actions.js +1539 -0
  165. package/dist/modules/wms/commands/inventory-actions.js.map +7 -0
  166. package/dist/modules/wms/commands/sales-order-assignment.js +277 -0
  167. package/dist/modules/wms/commands/sales-order-assignment.js.map +7 -0
  168. package/dist/modules/wms/commands/shared.js +82 -0
  169. package/dist/modules/wms/commands/shared.js.map +7 -0
  170. package/dist/modules/wms/components/backend/AdjustInventoryDialog.js +755 -0
  171. package/dist/modules/wms/components/backend/AdjustInventoryDialog.js.map +7 -0
  172. package/dist/modules/wms/components/backend/ChangeLotStatusDialog.js +269 -0
  173. package/dist/modules/wms/components/backend/ChangeLotStatusDialog.js.map +7 -0
  174. package/dist/modules/wms/components/backend/CycleCountWizardDialog.js +1783 -0
  175. package/dist/modules/wms/components/backend/CycleCountWizardDialog.js.map +7 -0
  176. package/dist/modules/wms/components/backend/ImportInventoryDialog.js +766 -0
  177. package/dist/modules/wms/components/backend/ImportInventoryDialog.js.map +7 -0
  178. package/dist/modules/wms/components/backend/InventoryOperationsSection.js +119 -0
  179. package/dist/modules/wms/components/backend/InventoryOperationsSection.js.map +7 -0
  180. package/dist/modules/wms/components/backend/LocationEditDialog.js +140 -0
  181. package/dist/modules/wms/components/backend/LocationEditDialog.js.map +7 -0
  182. package/dist/modules/wms/components/backend/MoveInventoryDialog.js +791 -0
  183. package/dist/modules/wms/components/backend/MoveInventoryDialog.js.map +7 -0
  184. package/dist/modules/wms/components/backend/ReceiveInventoryDialog.js +656 -0
  185. package/dist/modules/wms/components/backend/ReceiveInventoryDialog.js.map +7 -0
  186. package/dist/modules/wms/components/backend/ReleaseReservationDialog.js +344 -0
  187. package/dist/modules/wms/components/backend/ReleaseReservationDialog.js.map +7 -0
  188. package/dist/modules/wms/components/backend/ReserveInventoryDialog.js +475 -0
  189. package/dist/modules/wms/components/backend/ReserveInventoryDialog.js.map +7 -0
  190. package/dist/modules/wms/components/backend/WmsConfigurationPage.js +1112 -0
  191. package/dist/modules/wms/components/backend/WmsConfigurationPage.js.map +7 -0
  192. package/dist/modules/wms/components/backend/WmsInventoryConsolePage.js +908 -0
  193. package/dist/modules/wms/components/backend/WmsInventoryConsolePage.js.map +7 -0
  194. package/dist/modules/wms/components/backend/WmsLocationDetailPage.js +1015 -0
  195. package/dist/modules/wms/components/backend/WmsLocationDetailPage.js.map +7 -0
  196. package/dist/modules/wms/components/backend/WmsLotDetailPage.js +1049 -0
  197. package/dist/modules/wms/components/backend/WmsLotDetailPage.js.map +7 -0
  198. package/dist/modules/wms/components/backend/WmsLotsListPage.js +297 -0
  199. package/dist/modules/wms/components/backend/WmsLotsListPage.js.map +7 -0
  200. package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js +757 -0
  201. package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js.map +7 -0
  202. package/dist/modules/wms/components/backend/WmsSkuDetailPage.js +975 -0
  203. package/dist/modules/wms/components/backend/WmsSkuDetailPage.js.map +7 -0
  204. package/dist/modules/wms/components/backend/inventoryMutationLoaders.js +710 -0
  205. package/dist/modules/wms/components/backend/inventoryMutationLoaders.js.map +7 -0
  206. package/dist/modules/wms/components/backend/useWmsInventoryMutationAccess.js +79 -0
  207. package/dist/modules/wms/components/backend/useWmsInventoryMutationAccess.js.map +7 -0
  208. package/dist/modules/wms/components/backend/useWmsInventoryScopeFromSearchParams.js +24 -0
  209. package/dist/modules/wms/components/backend/useWmsInventoryScopeFromSearchParams.js.map +7 -0
  210. package/dist/modules/wms/components/backend/wmsLookupLoaders.js +55 -0
  211. package/dist/modules/wms/components/backend/wmsLookupLoaders.js.map +7 -0
  212. package/dist/modules/wms/data/enrichers.js +501 -0
  213. package/dist/modules/wms/data/enrichers.js.map +7 -0
  214. package/dist/modules/wms/data/entities.js +467 -0
  215. package/dist/modules/wms/data/entities.js.map +7 -0
  216. package/dist/modules/wms/data/validators.js +399 -0
  217. package/dist/modules/wms/data/validators.js.map +7 -0
  218. package/dist/modules/wms/di.js +27 -0
  219. package/dist/modules/wms/di.js.map +7 -0
  220. package/dist/modules/wms/events.js +42 -0
  221. package/dist/modules/wms/events.js.map +7 -0
  222. package/dist/modules/wms/index.js +17 -0
  223. package/dist/modules/wms/index.js.map +7 -0
  224. package/dist/modules/wms/lib/catalogInventoryProfileIntent.js +54 -0
  225. package/dist/modules/wms/lib/catalogInventoryProfileIntent.js.map +7 -0
  226. package/dist/modules/wms/lib/catalogInventoryProfileSync.js +144 -0
  227. package/dist/modules/wms/lib/catalogInventoryProfileSync.js.map +7 -0
  228. package/dist/modules/wms/lib/expiry.js +29 -0
  229. package/dist/modules/wms/lib/expiry.js.map +7 -0
  230. package/dist/modules/wms/lib/flashMutationError.js +51 -0
  231. package/dist/modules/wms/lib/flashMutationError.js.map +7 -0
  232. package/dist/modules/wms/lib/inventoryDisplayUi.js +188 -0
  233. package/dist/modules/wms/lib/inventoryDisplayUi.js.map +7 -0
  234. package/dist/modules/wms/lib/inventoryIdempotency.js +37 -0
  235. package/dist/modules/wms/lib/inventoryIdempotency.js.map +7 -0
  236. package/dist/modules/wms/lib/inventoryImportCsv.js +173 -0
  237. package/dist/modules/wms/lib/inventoryImportCsv.js.map +7 -0
  238. package/dist/modules/wms/lib/inventoryImportService.js +468 -0
  239. package/dist/modules/wms/lib/inventoryImportService.js.map +7 -0
  240. package/dist/modules/wms/lib/inventoryMutationUi.js +25 -0
  241. package/dist/modules/wms/lib/inventoryMutationUi.js.map +7 -0
  242. package/dist/modules/wms/lib/inventoryPolicy.js +61 -0
  243. package/dist/modules/wms/lib/inventoryPolicy.js.map +7 -0
  244. package/dist/modules/wms/lib/inventoryReconciliation.js +193 -0
  245. package/dist/modules/wms/lib/inventoryReconciliation.js.map +7 -0
  246. package/dist/modules/wms/lib/inventoryTrackingValidation.js +13 -0
  247. package/dist/modules/wms/lib/inventoryTrackingValidation.js.map +7 -0
  248. package/dist/modules/wms/lib/loadOperationalDashboard.js +580 -0
  249. package/dist/modules/wms/lib/loadOperationalDashboard.js.map +7 -0
  250. package/dist/modules/wms/lib/lowStockBalanceFilter.js +49 -0
  251. package/dist/modules/wms/lib/lowStockBalanceFilter.js.map +7 -0
  252. package/dist/modules/wms/lib/primaryWarehousePolicy.js +32 -0
  253. package/dist/modules/wms/lib/primaryWarehousePolicy.js.map +7 -0
  254. package/dist/modules/wms/lib/roleFeatures.js +30 -0
  255. package/dist/modules/wms/lib/roleFeatures.js.map +7 -0
  256. package/dist/modules/wms/lib/salesOrderInventoryAutomation.js +291 -0
  257. package/dist/modules/wms/lib/salesOrderInventoryAutomation.js.map +7 -0
  258. package/dist/modules/wms/lib/salesOrderWarehouseAssignment.js +54 -0
  259. package/dist/modules/wms/lib/salesOrderWarehouseAssignment.js.map +7 -0
  260. package/dist/modules/wms/lib/wmsIntegrationToggles.js +71 -0
  261. package/dist/modules/wms/lib/wmsIntegrationToggles.js.map +7 -0
  262. package/dist/modules/wms/migrations/Migration20260428110546.js +78 -0
  263. package/dist/modules/wms/migrations/Migration20260428110546.js.map +7 -0
  264. package/dist/modules/wms/migrations/Migration20260527120000.js +15 -0
  265. package/dist/modules/wms/migrations/Migration20260527120000.js.map +7 -0
  266. package/dist/modules/wms/migrations/Migration20260527140000.js +37 -0
  267. package/dist/modules/wms/migrations/Migration20260527140000.js.map +7 -0
  268. package/dist/modules/wms/migrations/Migration20260613120000.js +23 -0
  269. package/dist/modules/wms/migrations/Migration20260613120000.js.map +7 -0
  270. package/dist/modules/wms/migrations/Migration20260616090000.js +13 -0
  271. package/dist/modules/wms/migrations/Migration20260616090000.js.map +7 -0
  272. package/dist/modules/wms/migrations/Migration20260707180000.js +15 -0
  273. package/dist/modules/wms/migrations/Migration20260707180000.js.map +7 -0
  274. package/dist/modules/wms/notifications.client.js +18 -0
  275. package/dist/modules/wms/notifications.client.js.map +7 -0
  276. package/dist/modules/wms/notifications.js +53 -0
  277. package/dist/modules/wms/notifications.js.map +7 -0
  278. package/dist/modules/wms/search.js +196 -0
  279. package/dist/modules/wms/search.js.map +7 -0
  280. package/dist/modules/wms/setup.js +30 -0
  281. package/dist/modules/wms/setup.js.map +7 -0
  282. package/dist/modules/wms/subscribers/low-stock-notification.js +40 -0
  283. package/dist/modules/wms/subscribers/low-stock-notification.js.map +7 -0
  284. package/dist/modules/wms/subscribers/reservation-shortfall-notification.js +69 -0
  285. package/dist/modules/wms/subscribers/reservation-shortfall-notification.js.map +7 -0
  286. package/dist/modules/wms/subscribers/sales-order-cancelled-release.js +14 -0
  287. package/dist/modules/wms/subscribers/sales-order-cancelled-release.js.map +7 -0
  288. package/dist/modules/wms/subscribers/sales-order-confirmed-reserve.js +14 -0
  289. package/dist/modules/wms/subscribers/sales-order-confirmed-reserve.js.map +7 -0
  290. package/dist/modules/wms/translations.js +10 -0
  291. package/dist/modules/wms/translations.js.map +7 -0
  292. package/dist/modules/wms/vector.js +9 -0
  293. package/dist/modules/wms/vector.js.map +7 -0
  294. package/dist/modules/wms/widgets/injection/catalog-inventory-profile/widget.js +200 -0
  295. package/dist/modules/wms/widgets/injection/catalog-inventory-profile/widget.js.map +7 -0
  296. package/dist/modules/wms/widgets/injection/order-items-stock-column/widget.js +104 -0
  297. package/dist/modules/wms/widgets/injection/order-items-stock-column/widget.js.map +7 -0
  298. package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.client.js +389 -0
  299. package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.client.js.map +7 -0
  300. package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.js +16 -0
  301. package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.js.map +7 -0
  302. package/dist/modules/wms/widgets/injection-table.js +36 -0
  303. package/dist/modules/wms/widgets/injection-table.js.map +7 -0
  304. package/dist/modules/wms/widgets/notifications/WmsLowStockRenderer.js +150 -0
  305. package/dist/modules/wms/widgets/notifications/WmsLowStockRenderer.js.map +7 -0
  306. package/dist/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.js +186 -0
  307. package/dist/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.js.map +7 -0
  308. package/dist/modules/wms/widgets/notifications/index.js +7 -0
  309. package/dist/modules/wms/widgets/notifications/index.js.map +7 -0
  310. package/generated/entities/inventory_balance/index.ts +9 -0
  311. package/generated/entities/inventory_lot/index.ts +8 -0
  312. package/generated/entities/inventory_movement/index.ts +16 -0
  313. package/generated/entities/inventory_reservation/index.ts +10 -0
  314. package/generated/entities/product_inventory_profile/index.ts +9 -0
  315. package/generated/entities/sales_order_warehouse_assignment/index.ts +4 -0
  316. package/generated/entities/warehouse/index.ts +11 -0
  317. package/generated/entities/warehouse_location/index.ts +9 -0
  318. package/generated/entities/warehouse_zone/index.ts +4 -0
  319. package/generated/entities.ids.generated.ts +12 -0
  320. package/generated/entity-fields-registry.ts +98 -0
  321. package/package.json +7 -7
  322. package/src/modules/auth/backend/roles/page.tsx +13 -4
  323. package/src/modules/auth/i18n/de.json +2 -0
  324. package/src/modules/auth/i18n/en.json +2 -0
  325. package/src/modules/auth/i18n/es.json +2 -0
  326. package/src/modules/auth/i18n/pl.json +2 -0
  327. package/src/modules/auth/lib/backendChrome.tsx +1 -0
  328. package/src/modules/auth/services/rbacService.ts +25 -21
  329. package/src/modules/catalog/api/products/route.ts +3 -0
  330. package/src/modules/catalog/api/variants/route.ts +3 -0
  331. package/src/modules/query_index/lib/engine.ts +18 -6
  332. package/src/modules/sales/api/documents/factory.ts +1 -0
  333. package/src/modules/sales/commands/documents.ts +71 -0
  334. package/src/modules/sales/components/documents/ItemsSection.tsx +58 -0
  335. package/src/modules/sales/events.ts +2 -0
  336. package/src/modules/sales/widgets/injection/order-items-context.ts +15 -0
  337. package/src/modules/wms/acl.ts +14 -0
  338. package/src/modules/wms/analytics.ts +9 -0
  339. package/src/modules/wms/api/dashboard/operational/route.ts +83 -0
  340. package/src/modules/wms/api/interceptors.ts +108 -0
  341. package/src/modules/wms/api/inventory/adjust/route.ts +50 -0
  342. package/src/modules/wms/api/inventory/allocate/route.ts +50 -0
  343. package/src/modules/wms/api/inventory/balances/route.ts +178 -0
  344. package/src/modules/wms/api/inventory/cycle-count/route.ts +51 -0
  345. package/src/modules/wms/api/inventory/helpers.ts +128 -0
  346. package/src/modules/wms/api/inventory/import/apply/route.ts +47 -0
  347. package/src/modules/wms/api/inventory/import/helpers.ts +223 -0
  348. package/src/modules/wms/api/inventory/import/template/route.ts +31 -0
  349. package/src/modules/wms/api/inventory/import/validate/route.ts +56 -0
  350. package/src/modules/wms/api/inventory/move/route.ts +50 -0
  351. package/src/modules/wms/api/inventory/movements/route.ts +164 -0
  352. package/src/modules/wms/api/inventory/receive/route.ts +49 -0
  353. package/src/modules/wms/api/inventory/release/route.ts +43 -0
  354. package/src/modules/wms/api/inventory/reservations/route.ts +128 -0
  355. package/src/modules/wms/api/inventory/reserve/route.ts +59 -0
  356. package/src/modules/wms/api/inventory-profiles/route.ts +177 -0
  357. package/src/modules/wms/api/listEnrichers.ts +312 -0
  358. package/src/modules/wms/api/listSearch.ts +121 -0
  359. package/src/modules/wms/api/locations/route.ts +171 -0
  360. package/src/modules/wms/api/lots/route.ts +205 -0
  361. package/src/modules/wms/api/openapi.ts +28 -0
  362. package/src/modules/wms/api/sales-orders/[salesOrderId]/re-run-reservation/route.ts +58 -0
  363. package/src/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.ts +306 -0
  364. package/src/modules/wms/api/sales-orders/assign-warehouse/route.ts +57 -0
  365. package/src/modules/wms/api/sales-orders/unassign-warehouse/route.ts +43 -0
  366. package/src/modules/wms/api/warehouses/route.ts +181 -0
  367. package/src/modules/wms/api/zones/route.ts +158 -0
  368. package/src/modules/wms/backend/config/wms/page.meta.ts +14 -0
  369. package/src/modules/wms/backend/config/wms/page.tsx +5 -0
  370. package/src/modules/wms/backend/page.meta.ts +12 -0
  371. package/src/modules/wms/backend/page.tsx +5 -0
  372. package/src/modules/wms/backend/wms/inventory/page.meta.ts +14 -0
  373. package/src/modules/wms/backend/wms/inventory/page.tsx +5 -0
  374. package/src/modules/wms/backend/wms/location/[id]/page.meta.ts +14 -0
  375. package/src/modules/wms/backend/wms/location/[id]/page.tsx +5 -0
  376. package/src/modules/wms/backend/wms/locations/page.meta.ts +14 -0
  377. package/src/modules/wms/backend/wms/locations/page.tsx +12 -0
  378. package/src/modules/wms/backend/wms/lot/[id]/page.meta.ts +14 -0
  379. package/src/modules/wms/backend/wms/lot/[id]/page.tsx +5 -0
  380. package/src/modules/wms/backend/wms/lots/page.meta.ts +14 -0
  381. package/src/modules/wms/backend/wms/lots/page.tsx +5 -0
  382. package/src/modules/wms/backend/wms/movements/page.meta.ts +14 -0
  383. package/src/modules/wms/backend/wms/movements/page.tsx +23 -0
  384. package/src/modules/wms/backend/wms/reservations/page.meta.ts +14 -0
  385. package/src/modules/wms/backend/wms/reservations/page.tsx +24 -0
  386. package/src/modules/wms/backend/wms/sku/[id]/page.meta.ts +14 -0
  387. package/src/modules/wms/backend/wms/sku/[id]/page.tsx +5 -0
  388. package/src/modules/wms/backend/wms/warehouses/page.meta.ts +14 -0
  389. package/src/modules/wms/backend/wms/warehouses/page.tsx +12 -0
  390. package/src/modules/wms/backend/wms/zones/page.meta.ts +14 -0
  391. package/src/modules/wms/backend/wms/zones/page.tsx +12 -0
  392. package/src/modules/wms/ce.ts +76 -0
  393. package/src/modules/wms/cli.ts +96 -0
  394. package/src/modules/wms/commands/configuration.ts +1844 -0
  395. package/src/modules/wms/commands/index.ts +3 -0
  396. package/src/modules/wms/commands/inventory-actions.ts +1866 -0
  397. package/src/modules/wms/commands/sales-order-assignment.ts +346 -0
  398. package/src/modules/wms/commands/shared.ts +90 -0
  399. package/src/modules/wms/components/backend/AdjustInventoryDialog.tsx +820 -0
  400. package/src/modules/wms/components/backend/ChangeLotStatusDialog.tsx +312 -0
  401. package/src/modules/wms/components/backend/CycleCountWizardDialog.tsx +2007 -0
  402. package/src/modules/wms/components/backend/ImportInventoryDialog.tsx +1018 -0
  403. package/src/modules/wms/components/backend/InventoryOperationsSection.tsx +159 -0
  404. package/src/modules/wms/components/backend/LocationEditDialog.tsx +185 -0
  405. package/src/modules/wms/components/backend/MoveInventoryDialog.tsx +907 -0
  406. package/src/modules/wms/components/backend/ReceiveInventoryDialog.tsx +695 -0
  407. package/src/modules/wms/components/backend/ReleaseReservationDialog.tsx +424 -0
  408. package/src/modules/wms/components/backend/ReserveInventoryDialog.tsx +511 -0
  409. package/src/modules/wms/components/backend/WmsConfigurationPage.tsx +1340 -0
  410. package/src/modules/wms/components/backend/WmsInventoryConsolePage.tsx +1132 -0
  411. package/src/modules/wms/components/backend/WmsLocationDetailPage.tsx +1310 -0
  412. package/src/modules/wms/components/backend/WmsLotDetailPage.tsx +1355 -0
  413. package/src/modules/wms/components/backend/WmsLotsListPage.tsx +359 -0
  414. package/src/modules/wms/components/backend/WmsOperationalDashboardPage.tsx +958 -0
  415. package/src/modules/wms/components/backend/WmsSkuDetailPage.tsx +1245 -0
  416. package/src/modules/wms/components/backend/inventoryMutationLoaders.ts +960 -0
  417. package/src/modules/wms/components/backend/useWmsInventoryMutationAccess.ts +89 -0
  418. package/src/modules/wms/components/backend/useWmsInventoryScopeFromSearchParams.ts +32 -0
  419. package/src/modules/wms/components/backend/wmsLookupLoaders.ts +78 -0
  420. package/src/modules/wms/data/enrichers.ts +718 -0
  421. package/src/modules/wms/data/entities.ts +436 -0
  422. package/src/modules/wms/data/validators.ts +463 -0
  423. package/src/modules/wms/di.ts +25 -0
  424. package/src/modules/wms/events.ts +41 -0
  425. package/src/modules/wms/i18n/de.json +1051 -0
  426. package/src/modules/wms/i18n/en.json +1051 -0
  427. package/src/modules/wms/i18n/es.json +1051 -0
  428. package/src/modules/wms/i18n/pl.json +1051 -0
  429. package/src/modules/wms/index.ts +15 -0
  430. package/src/modules/wms/lib/catalogInventoryProfileIntent.ts +65 -0
  431. package/src/modules/wms/lib/catalogInventoryProfileSync.ts +199 -0
  432. package/src/modules/wms/lib/expiry.ts +30 -0
  433. package/src/modules/wms/lib/flashMutationError.ts +74 -0
  434. package/src/modules/wms/lib/inventoryDisplayUi.ts +249 -0
  435. package/src/modules/wms/lib/inventoryIdempotency.ts +54 -0
  436. package/src/modules/wms/lib/inventoryImportCsv.ts +212 -0
  437. package/src/modules/wms/lib/inventoryImportService.ts +629 -0
  438. package/src/modules/wms/lib/inventoryMutationUi.ts +21 -0
  439. package/src/modules/wms/lib/inventoryPolicy.ts +111 -0
  440. package/src/modules/wms/lib/inventoryReconciliation.ts +263 -0
  441. package/src/modules/wms/lib/inventoryTrackingValidation.ts +23 -0
  442. package/src/modules/wms/lib/loadOperationalDashboard.ts +776 -0
  443. package/src/modules/wms/lib/lowStockBalanceFilter.ts +74 -0
  444. package/src/modules/wms/lib/primaryWarehousePolicy.ts +46 -0
  445. package/src/modules/wms/lib/roleFeatures.ts +32 -0
  446. package/src/modules/wms/lib/salesOrderInventoryAutomation.ts +390 -0
  447. package/src/modules/wms/lib/salesOrderWarehouseAssignment.ts +78 -0
  448. package/src/modules/wms/lib/wmsIntegrationToggles.ts +81 -0
  449. package/src/modules/wms/migrations/.snapshot-open-mercato.json +2880 -0
  450. package/src/modules/wms/migrations/Migration20260428110546.ts +91 -0
  451. package/src/modules/wms/migrations/Migration20260527120000.ts +15 -0
  452. package/src/modules/wms/migrations/Migration20260527140000.ts +35 -0
  453. package/src/modules/wms/migrations/Migration20260613120000.ts +21 -0
  454. package/src/modules/wms/migrations/Migration20260616090000.ts +11 -0
  455. package/src/modules/wms/migrations/Migration20260707180000.ts +13 -0
  456. package/src/modules/wms/notifications.client.ts +18 -0
  457. package/src/modules/wms/notifications.ts +51 -0
  458. package/src/modules/wms/search.ts +230 -0
  459. package/src/modules/wms/setup.ts +29 -0
  460. package/src/modules/wms/subscribers/low-stock-notification.ts +54 -0
  461. package/src/modules/wms/subscribers/reservation-shortfall-notification.ts +98 -0
  462. package/src/modules/wms/subscribers/sales-order-cancelled-release.ts +21 -0
  463. package/src/modules/wms/subscribers/sales-order-confirmed-reserve.ts +21 -0
  464. package/src/modules/wms/translations.ts +6 -0
  465. package/src/modules/wms/vector.ts +7 -0
  466. package/src/modules/wms/widgets/injection/catalog-inventory-profile/widget.ts +238 -0
  467. package/src/modules/wms/widgets/injection/order-items-stock-column/widget.tsx +153 -0
  468. package/src/modules/wms/widgets/injection/sales-order-stock-context/widget.client.tsx +476 -0
  469. package/src/modules/wms/widgets/injection/sales-order-stock-context/widget.ts +15 -0
  470. package/src/modules/wms/widgets/injection-table.ts +34 -0
  471. package/src/modules/wms/widgets/notifications/WmsLowStockRenderer.tsx +153 -0
  472. package/src/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.tsx +194 -0
  473. package/src/modules/wms/widgets/notifications/index.ts +2 -0
@@ -0,0 +1,791 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { z } from "zod";
5
+ import { useQueryClient } from "@tanstack/react-query";
6
+ import { ArrowLeftRight, Package } from "lucide-react";
7
+ import { flash } from "@open-mercato/ui/backend/FlashMessages";
8
+ import { flashMutationError } from "../../lib/flashMutationError.js";
9
+ import { useGuardedMutation } from "@open-mercato/ui/backend/injection/useGuardedMutation";
10
+ import { ComboboxInput } from "@open-mercato/ui/backend/inputs/ComboboxInput";
11
+ import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
12
+ import { raiseCrudError } from "@open-mercato/ui/backend/utils/serverErrors";
13
+ import { Button } from "@open-mercato/ui/primitives/button";
14
+ import {
15
+ Dialog,
16
+ DialogContent,
17
+ DialogDescription,
18
+ DialogFooter,
19
+ DialogHeader,
20
+ DialogTitle
21
+ } from "@open-mercato/ui/primitives/dialog";
22
+ import { FormField } from "@open-mercato/ui/primitives/form-field";
23
+ import { Input } from "@open-mercato/ui/primitives/input";
24
+ import { KbdShortcut } from "@open-mercato/ui/primitives/kbd";
25
+ import {
26
+ Select,
27
+ SelectContent,
28
+ SelectItem,
29
+ SelectTrigger,
30
+ SelectValue
31
+ } from "@open-mercato/ui/primitives/select";
32
+ import { Textarea } from "@open-mercato/ui/primitives/textarea";
33
+ import { useT } from "@open-mercato/shared/lib/i18n/context";
34
+ import { createLogger } from "@open-mercato/shared/lib/logger";
35
+ import { buildInventoryMutationReferenceId, parseInventoryQuantity } from "../../lib/inventoryMutationUi.js";
36
+ import {
37
+ BalanceLookupError,
38
+ fetchBalanceAvailable,
39
+ fetchLocationCapacitySnapshot,
40
+ loadCatalogVariantOptions,
41
+ loadLocationOptions,
42
+ loadWarehouseOptions,
43
+ resolveCatalogVariantLabel,
44
+ resolveLocationLabel,
45
+ resolveWarehouseLabel
46
+ } from "./inventoryMutationLoaders.js";
47
+ const logger = createLogger("wms");
48
+ const MOVE_REASON_CODES = ["transfer", "replenishment", "consolidation", "correction", "other"];
49
+ const EMPTY_FORM = {
50
+ catalogVariantId: "",
51
+ warehouseId: "",
52
+ fromLocationId: "",
53
+ toLocationId: "",
54
+ quantity: 1,
55
+ reasonCode: "",
56
+ notes: ""
57
+ };
58
+ function parseQuantityInputForSubmit(value) {
59
+ const trimmed = value.trim();
60
+ if (!trimmed || trimmed === "-" || trimmed === "+") return null;
61
+ const parsed = Number(trimmed);
62
+ if (!Number.isFinite(parsed) || parsed <= 0) return null;
63
+ return parsed;
64
+ }
65
+ function MoveInventoryDialog({
66
+ open,
67
+ onOpenChange,
68
+ access,
69
+ initialCatalogVariantId,
70
+ initialWarehouseId,
71
+ initialFromLocationId,
72
+ initialLotId,
73
+ initialAvailable,
74
+ lockSourceContext = false,
75
+ movementType = "transfer"
76
+ }) {
77
+ const t = useT();
78
+ const queryClient = useQueryClient();
79
+ const lotIdRef = React.useRef(void 0);
80
+ const { runMutation, retryLastMutation } = useGuardedMutation({
81
+ contextId: "wms-inventory-move"
82
+ });
83
+ const mutationContext = React.useMemo(
84
+ () => ({ retryLastMutation }),
85
+ [retryLastMutation]
86
+ );
87
+ const moveFormSchema = React.useMemo(
88
+ () => z.object({
89
+ catalogVariantId: z.string().uuid(),
90
+ warehouseId: z.string().uuid(),
91
+ fromLocationId: z.string().uuid(),
92
+ toLocationId: z.string().uuid(),
93
+ quantity: z.coerce.number().positive({
94
+ message: t(
95
+ "wms.backend.inventory.move.errors.quantityPositive",
96
+ "Move quantity must be greater than zero."
97
+ )
98
+ }),
99
+ reasonCode: z.enum(MOVE_REASON_CODES),
100
+ notes: z.string().trim().max(500).optional()
101
+ }).superRefine((values, ctx) => {
102
+ if (values.fromLocationId === values.toLocationId) {
103
+ ctx.addIssue({
104
+ code: z.ZodIssueCode.custom,
105
+ path: ["toLocationId"],
106
+ message: t(
107
+ "wms.backend.inventory.move.errors.sameLocation",
108
+ "Destination must differ from the source location."
109
+ )
110
+ });
111
+ }
112
+ }),
113
+ [t]
114
+ );
115
+ const [submitting, setSubmitting] = React.useState(false);
116
+ const [form, setForm] = React.useState(EMPTY_FORM);
117
+ const [quantityInput, setQuantityInput] = React.useState("1");
118
+ const [fieldErrors, setFieldErrors] = React.useState({});
119
+ const [available, setAvailable] = React.useState(null);
120
+ const [previewError, setPreviewError] = React.useState(null);
121
+ const [loadingPreview, setLoadingPreview] = React.useState(false);
122
+ const [destAvailable, setDestAvailable] = React.useState(null);
123
+ const [loadingDestPreview, setLoadingDestPreview] = React.useState(false);
124
+ const [destCapacity, setDestCapacity] = React.useState(null);
125
+ const [loadingDestCapacity, setLoadingDestCapacity] = React.useState(false);
126
+ const [optionLabelByValue, setOptionLabelByValue] = React.useState({});
127
+ const registerOptionLabels = React.useCallback(
128
+ (options) => {
129
+ setOptionLabelByValue((current) => {
130
+ let changed = false;
131
+ const next = { ...current };
132
+ for (const option of options) {
133
+ const value = option.value.trim();
134
+ const label = option.label.trim();
135
+ if (!value || !label || next[value] === label) continue;
136
+ next[value] = label;
137
+ changed = true;
138
+ }
139
+ return changed ? next : current;
140
+ });
141
+ },
142
+ []
143
+ );
144
+ const resolveOptionLabel = React.useCallback(
145
+ (value) => optionLabelByValue[value] ?? value,
146
+ [optionLabelByValue]
147
+ );
148
+ const optionLabelByValueRef = React.useRef(optionLabelByValue);
149
+ optionLabelByValueRef.current = optionLabelByValue;
150
+ const reasonLabel = React.useCallback(
151
+ (code) => {
152
+ const fallbacks = {
153
+ transfer: "Transfer",
154
+ replenishment: "Replenishment",
155
+ consolidation: "Consolidation",
156
+ correction: "Correction",
157
+ other: "Other"
158
+ };
159
+ return t(`wms.backend.inventory.move.reasons.${code}`, fallbacks[code]);
160
+ },
161
+ [t]
162
+ );
163
+ const resetDialog = React.useCallback(() => {
164
+ setForm(EMPTY_FORM);
165
+ setQuantityInput("1");
166
+ setFieldErrors({});
167
+ setAvailable(null);
168
+ setPreviewError(null);
169
+ setLoadingPreview(false);
170
+ setSubmitting(false);
171
+ setOptionLabelByValue({});
172
+ lotIdRef.current = void 0;
173
+ }, []);
174
+ const closeDialog = React.useCallback(() => {
175
+ onOpenChange(false);
176
+ resetDialog();
177
+ }, [onOpenChange, resetDialog]);
178
+ const patchForm = React.useCallback((patch) => {
179
+ setForm((current) => ({ ...current, ...patch }));
180
+ setFieldErrors({});
181
+ }, []);
182
+ React.useEffect(() => {
183
+ if (!open) {
184
+ resetDialog();
185
+ return;
186
+ }
187
+ const catalogVariantId = initialCatalogVariantId?.trim() ?? "";
188
+ const warehouseId = initialWarehouseId?.trim() ?? "";
189
+ const fromLocationId = initialFromLocationId?.trim() ?? "";
190
+ const lotId = initialLotId?.trim();
191
+ lotIdRef.current = lotId || void 0;
192
+ if (!catalogVariantId && !warehouseId && !fromLocationId) return;
193
+ const presetQuantity = initialAvailable != null && initialAvailable > 0 ? Math.min(1, initialAvailable) : 1;
194
+ setForm({
195
+ ...EMPTY_FORM,
196
+ catalogVariantId,
197
+ warehouseId,
198
+ fromLocationId,
199
+ quantity: presetQuantity
200
+ });
201
+ setQuantityInput(String(presetQuantity));
202
+ setFieldErrors({});
203
+ setPreviewError(null);
204
+ if (initialAvailable != null) {
205
+ setAvailable(parseInventoryQuantity(initialAvailable));
206
+ }
207
+ }, [
208
+ initialAvailable,
209
+ initialCatalogVariantId,
210
+ initialFromLocationId,
211
+ initialLotId,
212
+ initialWarehouseId,
213
+ open,
214
+ resetDialog
215
+ ]);
216
+ React.useEffect(() => {
217
+ if (!open) return;
218
+ let cancelled = false;
219
+ const ensureLabel = async (value, resolve) => {
220
+ const id = value.trim();
221
+ if (!id || optionLabelByValueRef.current[id]) return;
222
+ const label = await resolve(id);
223
+ if (cancelled || !label) return;
224
+ registerOptionLabels([{ value: id, label }]);
225
+ };
226
+ void Promise.all([
227
+ ensureLabel(form.catalogVariantId, resolveCatalogVariantLabel),
228
+ ensureLabel(form.warehouseId, resolveWarehouseLabel),
229
+ ensureLabel(form.fromLocationId, resolveLocationLabel),
230
+ ensureLabel(form.toLocationId, resolveLocationLabel)
231
+ ]);
232
+ return () => {
233
+ cancelled = true;
234
+ };
235
+ }, [
236
+ form.catalogVariantId,
237
+ form.fromLocationId,
238
+ form.toLocationId,
239
+ form.warehouseId,
240
+ open,
241
+ registerOptionLabels
242
+ ]);
243
+ const previewContextReady = Boolean(
244
+ form.catalogVariantId.trim() && form.warehouseId.trim() && form.fromLocationId.trim()
245
+ );
246
+ React.useEffect(() => {
247
+ if (!open || !previewContextReady) {
248
+ if (!open) return;
249
+ if (!previewContextReady) {
250
+ setAvailable(null);
251
+ setPreviewError(null);
252
+ setLoadingPreview(false);
253
+ }
254
+ return;
255
+ }
256
+ let cancelled = false;
257
+ setLoadingPreview(true);
258
+ setPreviewError(null);
259
+ void fetchBalanceAvailable({
260
+ warehouseId: form.warehouseId.trim(),
261
+ locationId: form.fromLocationId.trim(),
262
+ catalogVariantId: form.catalogVariantId.trim(),
263
+ lotId: lotIdRef.current
264
+ }).then((value) => {
265
+ if (cancelled) return;
266
+ setAvailable(value);
267
+ setPreviewError(null);
268
+ setForm((current) => {
269
+ const nextQuantity = value > 0 && current.quantity > value ? value : current.quantity > 0 ? current.quantity : 1;
270
+ setQuantityInput(String(nextQuantity));
271
+ return {
272
+ ...current,
273
+ quantity: nextQuantity
274
+ };
275
+ });
276
+ }).catch((error) => {
277
+ if (cancelled) return;
278
+ setAvailable(null);
279
+ if (error instanceof BalanceLookupError) {
280
+ setPreviewError(
281
+ t(
282
+ "wms.backend.inventory.move.errors.previewBalance",
283
+ "Failed to load available quantity."
284
+ )
285
+ );
286
+ return;
287
+ }
288
+ logger.error("fetchBalanceAvailable failed", { component: "MoveInventoryDialog", err: error });
289
+ setPreviewError(
290
+ t(
291
+ "wms.backend.inventory.move.errors.previewBalance",
292
+ "Failed to load available quantity."
293
+ )
294
+ );
295
+ }).finally(() => {
296
+ if (!cancelled) setLoadingPreview(false);
297
+ });
298
+ return () => {
299
+ cancelled = true;
300
+ };
301
+ }, [
302
+ form.catalogVariantId,
303
+ form.fromLocationId,
304
+ form.warehouseId,
305
+ open,
306
+ previewContextReady,
307
+ t
308
+ ]);
309
+ const destPreviewContextReady = Boolean(
310
+ form.catalogVariantId.trim() && form.warehouseId.trim() && form.toLocationId.trim()
311
+ );
312
+ React.useEffect(() => {
313
+ if (!open || !destPreviewContextReady) {
314
+ setDestAvailable(null);
315
+ setLoadingDestPreview(false);
316
+ return;
317
+ }
318
+ let cancelled = false;
319
+ setLoadingDestPreview(true);
320
+ void fetchBalanceAvailable({
321
+ warehouseId: form.warehouseId.trim(),
322
+ locationId: form.toLocationId.trim(),
323
+ catalogVariantId: form.catalogVariantId.trim()
324
+ }).then((value) => {
325
+ if (cancelled) return;
326
+ setDestAvailable(value);
327
+ }).catch(() => {
328
+ if (cancelled) return;
329
+ setDestAvailable(null);
330
+ }).finally(() => {
331
+ if (!cancelled) setLoadingDestPreview(false);
332
+ });
333
+ return () => {
334
+ cancelled = true;
335
+ };
336
+ }, [
337
+ destPreviewContextReady,
338
+ form.catalogVariantId,
339
+ form.toLocationId,
340
+ form.warehouseId,
341
+ open
342
+ ]);
343
+ React.useEffect(() => {
344
+ if (!open || !form.warehouseId.trim() || !form.toLocationId.trim()) {
345
+ setDestCapacity(null);
346
+ setLoadingDestCapacity(false);
347
+ return;
348
+ }
349
+ let cancelled = false;
350
+ setLoadingDestCapacity(true);
351
+ void fetchLocationCapacitySnapshot({
352
+ warehouseId: form.warehouseId.trim(),
353
+ locationId: form.toLocationId.trim()
354
+ }).then((snapshot) => {
355
+ if (cancelled) return;
356
+ setDestCapacity(snapshot);
357
+ }).catch(() => {
358
+ if (cancelled) return;
359
+ setDestCapacity(null);
360
+ }).finally(() => {
361
+ if (!cancelled) setLoadingDestCapacity(false);
362
+ });
363
+ return () => {
364
+ cancelled = true;
365
+ };
366
+ }, [form.toLocationId, form.warehouseId, open]);
367
+ const destCapacityExcess = React.useMemo(() => {
368
+ if (destCapacity?.capacityUnits == null) return 0;
369
+ const quantity = parseQuantityInputForSubmit(quantityInput) ?? 0;
370
+ return Math.max(0, destCapacity.totalOnHand + quantity - destCapacity.capacityUnits);
371
+ }, [destCapacity, quantityInput]);
372
+ const handleSubmit = React.useCallback(
373
+ async (event) => {
374
+ event?.preventDefault();
375
+ const quantity = parseQuantityInputForSubmit(quantityInput);
376
+ if (quantity == null) {
377
+ setFieldErrors({
378
+ quantity: t(
379
+ "wms.backend.inventory.move.errors.quantityPositive",
380
+ "Move quantity must be greater than zero."
381
+ )
382
+ });
383
+ return;
384
+ }
385
+ const parsed = moveFormSchema.safeParse({
386
+ ...form,
387
+ quantity,
388
+ notes: form.notes.trim() || void 0
389
+ });
390
+ if (!parsed.success) {
391
+ const nextErrors = {};
392
+ for (const issue of parsed.error.issues) {
393
+ const key = String(issue.path[0] ?? "form");
394
+ if (!nextErrors[key]) nextErrors[key] = issue.message;
395
+ }
396
+ setFieldErrors(nextErrors);
397
+ return;
398
+ }
399
+ if (available != null && parsed.data.quantity > available + 1e-6) {
400
+ setFieldErrors({
401
+ quantity: t(
402
+ "wms.backend.inventory.move.errors.insufficientAvailable",
403
+ "Quantity exceeds available stock at the source location."
404
+ )
405
+ });
406
+ return;
407
+ }
408
+ if (!access.scopeReady || !access.organizationId || !access.tenantId || !access.userId) {
409
+ flash(
410
+ t(
411
+ "wms.backend.inventory.mutations.errors.scope",
412
+ "Select an organization and sign in before posting inventory changes."
413
+ ),
414
+ "error"
415
+ );
416
+ return;
417
+ }
418
+ setSubmitting(true);
419
+ try {
420
+ const reason = parsed.data.reasonCode;
421
+ const notes = parsed.data.notes?.trim();
422
+ const payload = {
423
+ organizationId: access.organizationId,
424
+ tenantId: access.tenantId,
425
+ warehouseId: parsed.data.warehouseId,
426
+ fromLocationId: parsed.data.fromLocationId,
427
+ toLocationId: parsed.data.toLocationId,
428
+ catalogVariantId: parsed.data.catalogVariantId,
429
+ quantity: parsed.data.quantity,
430
+ reason,
431
+ reasonCode: parsed.data.reasonCode,
432
+ referenceType: "manual",
433
+ referenceId: buildInventoryMutationReferenceId(),
434
+ performedBy: access.userId,
435
+ type: movementType
436
+ };
437
+ if (lotIdRef.current) payload.lotId = lotIdRef.current;
438
+ if (notes) payload.metadata = { notes };
439
+ await runMutation({
440
+ operation: async () => {
441
+ const call = await apiCall(
442
+ "/api/wms/inventory/move",
443
+ {
444
+ method: "POST",
445
+ headers: { "content-type": "application/json" },
446
+ body: JSON.stringify(payload)
447
+ }
448
+ );
449
+ if (!call.ok) {
450
+ await raiseCrudError(
451
+ call.response,
452
+ t("wms.backend.inventory.move.errors.submit", "Failed to move inventory.")
453
+ );
454
+ }
455
+ return call.result ?? {};
456
+ },
457
+ context: mutationContext,
458
+ mutationPayload: payload
459
+ });
460
+ flash(t("wms.backend.inventory.move.flash.success", "Inventory moved"), "success");
461
+ await queryClient.invalidateQueries({ queryKey: ["wms-inventory-console"] });
462
+ await queryClient.invalidateQueries({ queryKey: ["wms-sku-detail"] });
463
+ await queryClient.invalidateQueries({ queryKey: ["wms-location-detail"] });
464
+ await queryClient.invalidateQueries({ queryKey: ["wms-lot-detail"] });
465
+ closeDialog();
466
+ } catch (error) {
467
+ flashMutationError(error, t("wms.backend.inventory.move.errors.submit", "Failed to move inventory."), t);
468
+ } finally {
469
+ setSubmitting(false);
470
+ }
471
+ },
472
+ [
473
+ access,
474
+ available,
475
+ closeDialog,
476
+ form,
477
+ moveFormSchema,
478
+ quantityInput,
479
+ mutationContext,
480
+ movementType,
481
+ queryClient,
482
+ runMutation,
483
+ t
484
+ ]
485
+ );
486
+ const sourceLocked = lockSourceContext;
487
+ const submitDisabled = submitting || access.loading || !access.scopeReady;
488
+ const handleDialogKeyDown = React.useCallback(
489
+ (event) => {
490
+ if (event.key === "Escape") {
491
+ event.preventDefault();
492
+ closeDialog();
493
+ return;
494
+ }
495
+ if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
496
+ event.preventDefault();
497
+ if (!submitDisabled) void handleSubmit();
498
+ }
499
+ },
500
+ [closeDialog, handleSubmit, submitDisabled]
501
+ );
502
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (next) => next ? onOpenChange(true) : closeDialog(), children: /* @__PURE__ */ jsxs(
503
+ DialogContent,
504
+ {
505
+ className: "max-w-lg gap-0 overflow-hidden p-0",
506
+ onKeyDown: handleDialogKeyDown,
507
+ children: [
508
+ /* @__PURE__ */ jsx("div", { className: "border-b px-6 py-4 pr-12", children: /* @__PURE__ */ jsxs(DialogHeader, { className: "space-y-1 text-left", children: [
509
+ /* @__PURE__ */ jsx(DialogTitle, { children: movementType === "putaway" ? t("wms.backend.inventory.move.dialog.titlePutaway", "Put away to final bin") : t("wms.backend.inventory.move.dialog.title", "Move inventory") }),
510
+ /* @__PURE__ */ jsx(DialogDescription, { children: t(
511
+ "wms.backend.inventory.move.dialog.description",
512
+ "Transfer available stock between locations within the same warehouse."
513
+ ) })
514
+ ] }) }),
515
+ /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "flex min-h-0 flex-1 flex-col", children: [
516
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5 overflow-y-auto px-6 py-6", children: [
517
+ /* @__PURE__ */ jsx(
518
+ FormField,
519
+ {
520
+ label: t("wms.backend.inventory.move.form.variant", "Variant"),
521
+ required: true,
522
+ error: fieldErrors.catalogVariantId,
523
+ children: /* @__PURE__ */ jsxs("div", { className: "relative [&_input]:pl-9", children: [
524
+ /* @__PURE__ */ jsx(
525
+ Package,
526
+ {
527
+ className: "pointer-events-none absolute left-3 top-1/2 z-10 size-4 -translate-y-1/2 text-muted-foreground",
528
+ "aria-hidden": "true"
529
+ }
530
+ ),
531
+ /* @__PURE__ */ jsx(
532
+ ComboboxInput,
533
+ {
534
+ value: form.catalogVariantId,
535
+ onChange: (next) => patchForm({ catalogVariantId: next.trim() }),
536
+ loadSuggestions: async (query) => {
537
+ const options = await loadCatalogVariantOptions(query);
538
+ registerOptionLabels(options);
539
+ return options.map((option) => ({
540
+ value: option.value,
541
+ label: option.label,
542
+ description: option.description
543
+ }));
544
+ },
545
+ resolveLabel: resolveOptionLabel,
546
+ placeholder: t(
547
+ "wms.backend.inventory.move.form.variantPlaceholder",
548
+ "Search variant or SKU"
549
+ ),
550
+ allowCustomValues: false,
551
+ disabled: submitting || sourceLocked
552
+ }
553
+ )
554
+ ] })
555
+ }
556
+ ),
557
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-5 sm:grid-cols-2", children: [
558
+ /* @__PURE__ */ jsx(
559
+ FormField,
560
+ {
561
+ label: t("wms.backend.inventory.move.form.warehouse", "Warehouse"),
562
+ required: true,
563
+ error: fieldErrors.warehouseId,
564
+ children: /* @__PURE__ */ jsx(
565
+ ComboboxInput,
566
+ {
567
+ value: form.warehouseId,
568
+ onChange: (next) => {
569
+ patchForm({
570
+ warehouseId: next.trim(),
571
+ fromLocationId: "",
572
+ toLocationId: ""
573
+ });
574
+ },
575
+ loadSuggestions: async (query) => {
576
+ const options = await loadWarehouseOptions(query);
577
+ registerOptionLabels(options);
578
+ return options.map((option) => ({
579
+ value: option.value,
580
+ label: option.label
581
+ }));
582
+ },
583
+ resolveLabel: resolveOptionLabel,
584
+ placeholder: t(
585
+ "wms.backend.inventory.move.form.warehousePlaceholder",
586
+ "Select warehouse"
587
+ ),
588
+ allowCustomValues: false,
589
+ disabled: submitting || sourceLocked
590
+ }
591
+ )
592
+ }
593
+ ),
594
+ /* @__PURE__ */ jsx(
595
+ FormField,
596
+ {
597
+ label: t("wms.backend.inventory.move.form.fromLocation", "From location"),
598
+ required: true,
599
+ error: fieldErrors.fromLocationId,
600
+ children: /* @__PURE__ */ jsx(
601
+ ComboboxInput,
602
+ {
603
+ value: form.fromLocationId,
604
+ onChange: (next) => patchForm({ fromLocationId: next.trim() }),
605
+ loadSuggestions: async (query) => {
606
+ const options = await loadLocationOptions(form.warehouseId, query);
607
+ registerOptionLabels(options);
608
+ return options.map((option) => ({
609
+ value: option.value,
610
+ label: option.label
611
+ }));
612
+ },
613
+ resolveLabel: resolveOptionLabel,
614
+ placeholder: t(
615
+ "wms.backend.inventory.move.form.fromLocationPlaceholder",
616
+ "Select source location"
617
+ ),
618
+ allowCustomValues: false,
619
+ disabled: submitting || !form.warehouseId || sourceLocked
620
+ }
621
+ )
622
+ }
623
+ )
624
+ ] }),
625
+ /* @__PURE__ */ jsx(
626
+ FormField,
627
+ {
628
+ label: t("wms.backend.inventory.move.form.toLocation", "To location"),
629
+ required: true,
630
+ error: fieldErrors.toLocationId,
631
+ children: /* @__PURE__ */ jsx(
632
+ ComboboxInput,
633
+ {
634
+ value: form.toLocationId,
635
+ onChange: (next) => patchForm({ toLocationId: next.trim() }),
636
+ loadSuggestions: async (query) => {
637
+ const scopedWarehouseId = form.warehouseId.trim() || initialWarehouseId?.trim() || "";
638
+ const options = await loadLocationOptions(scopedWarehouseId, query);
639
+ registerOptionLabels(options);
640
+ return options.filter((option) => option.value !== form.fromLocationId).map((option) => ({
641
+ value: option.value,
642
+ label: option.label
643
+ }));
644
+ },
645
+ resolveLabel: resolveOptionLabel,
646
+ placeholder: t(
647
+ "wms.backend.inventory.move.form.toLocationPlaceholder",
648
+ "Select destination location"
649
+ ),
650
+ allowCustomValues: false,
651
+ disabled: submitting || !form.warehouseId
652
+ }
653
+ )
654
+ }
655
+ ),
656
+ /* @__PURE__ */ jsx(
657
+ FormField,
658
+ {
659
+ label: t("wms.backend.inventory.move.form.quantity", "Quantity"),
660
+ required: true,
661
+ error: fieldErrors.quantity,
662
+ children: /* @__PURE__ */ jsx(
663
+ Input,
664
+ {
665
+ type: "number",
666
+ inputMode: "decimal",
667
+ min: "0.001",
668
+ step: "any",
669
+ value: quantityInput,
670
+ onChange: (event) => {
671
+ setQuantityInput(event.target.value);
672
+ setFieldErrors((current) => {
673
+ if (!current.quantity) return current;
674
+ const next = { ...current };
675
+ delete next.quantity;
676
+ return next;
677
+ });
678
+ },
679
+ disabled: submitting
680
+ }
681
+ )
682
+ }
683
+ ),
684
+ /* @__PURE__ */ jsx(
685
+ FormField,
686
+ {
687
+ label: t("wms.backend.inventory.move.form.reason", "Reason"),
688
+ required: true,
689
+ error: fieldErrors.reasonCode,
690
+ children: /* @__PURE__ */ jsxs(
691
+ Select,
692
+ {
693
+ value: form.reasonCode || void 0,
694
+ onValueChange: (next) => patchForm({ reasonCode: next }),
695
+ disabled: submitting,
696
+ children: [
697
+ /* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(
698
+ SelectValue,
699
+ {
700
+ placeholder: t(
701
+ "wms.backend.inventory.move.form.reasonPlaceholder",
702
+ "Select reason"
703
+ )
704
+ }
705
+ ) }),
706
+ /* @__PURE__ */ jsx(SelectContent, { children: MOVE_REASON_CODES.map((code) => /* @__PURE__ */ jsx(SelectItem, { value: code, children: reasonLabel(code) }, code)) })
707
+ ]
708
+ }
709
+ )
710
+ }
711
+ ),
712
+ /* @__PURE__ */ jsx(FormField, { label: t("wms.backend.inventory.move.form.notes", "Notes"), children: /* @__PURE__ */ jsx(
713
+ Textarea,
714
+ {
715
+ value: form.notes,
716
+ onChange: (event) => patchForm({ notes: event.target.value }),
717
+ placeholder: t(
718
+ "wms.backend.inventory.move.form.notesPlaceholder",
719
+ "Optional \u2014 context for auditors"
720
+ ),
721
+ rows: 3,
722
+ disabled: submitting
723
+ }
724
+ ) }),
725
+ previewContextReady ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-muted/40 px-4 py-3.5", children: [
726
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: t("wms.backend.inventory.move.preview.title", "Source availability") }),
727
+ /* @__PURE__ */ jsxs("div", { className: "mt-2 flex items-center gap-2", children: [
728
+ /* @__PURE__ */ jsx(ArrowLeftRight, { className: "size-4 text-muted-foreground", "aria-hidden": "true" }),
729
+ previewError ? /* @__PURE__ */ jsx("p", { className: "text-sm text-status-warning-fg", children: previewError }) : loadingPreview && available == null ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("wms.backend.inventory.move.preview.loading", "Refreshing availability\u2026") }) : available != null ? /* @__PURE__ */ jsxs("p", { className: "text-sm font-semibold tabular-nums text-foreground", children: [
730
+ t("wms.backend.inventory.move.preview.availableLabel", "Available"),
731
+ " ",
732
+ available
733
+ ] }) : null
734
+ ] }),
735
+ destPreviewContextReady && form.toLocationId !== form.fromLocationId ? /* @__PURE__ */ jsxs("div", { className: "mt-2 border-t pt-2", children: [
736
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mb-1", children: t("wms.backend.inventory.move.preview.destTitle", "Destination current stock") }),
737
+ loadingDestPreview && destAvailable == null ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("wms.backend.inventory.move.preview.destLoading", "Loading destination\u2026") }) : destAvailable != null ? /* @__PURE__ */ jsxs("p", { className: "text-sm tabular-nums text-muted-foreground", children: [
738
+ destAvailable,
739
+ " ",
740
+ t("wms.backend.inventory.move.preview.destUnit", "units already here")
741
+ ] }) : /* @__PURE__ */ jsx("p", { className: "text-sm tabular-nums text-muted-foreground", children: t("wms.backend.inventory.move.preview.destEmpty", "0 units (empty bin)") }),
742
+ loadingDestCapacity && destCapacity == null ? /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: t(
743
+ "wms.backend.inventory.move.preview.capacityLoading",
744
+ "Loading destination capacity\u2026"
745
+ ) }) : destCapacity?.capacityUnits != null ? /* @__PURE__ */ jsx(
746
+ "p",
747
+ {
748
+ className: `mt-1 text-sm tabular-nums ${destCapacityExcess > 0 ? "text-status-warning-fg" : "text-muted-foreground"}`,
749
+ children: t(
750
+ "wms.backend.inventory.move.preview.capacity",
751
+ "{used} / {capacity} units used \xB7 {remaining} remaining",
752
+ {
753
+ used: destCapacity.totalOnHand,
754
+ capacity: destCapacity.capacityUnits,
755
+ remaining: destCapacity.capacityUnits - destCapacity.totalOnHand
756
+ }
757
+ )
758
+ }
759
+ ) : destCapacity ? /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: t(
760
+ "wms.backend.inventory.move.preview.capacityUnset",
761
+ "No capacity limit set for this location."
762
+ ) }) : null,
763
+ destCapacityExcess > 0 ? /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-status-warning-fg", children: t(
764
+ "wms.backend.inventory.move.preview.capacityExceeded",
765
+ "This move would exceed the destination capacity by {quantity} unit(s).",
766
+ { quantity: destCapacityExcess }
767
+ ) }) : null
768
+ ] }) : null
769
+ ] }) : null
770
+ ] }),
771
+ /* @__PURE__ */ jsxs(DialogFooter, { bordered: false, className: "border-t px-6 py-4 sm:justify-between", children: [
772
+ /* @__PURE__ */ jsxs("p", { className: "hidden text-xs text-muted-foreground sm:inline-flex sm:items-center sm:gap-1.5", children: [
773
+ /* @__PURE__ */ jsx(KbdShortcut, { keys: ["\u2318", "Enter"] }),
774
+ /* @__PURE__ */ jsx("span", { children: "/" }),
775
+ /* @__PURE__ */ jsx(KbdShortcut, { keys: ["Ctrl", "Enter"] }),
776
+ /* @__PURE__ */ jsx("span", { children: t("wms.backend.inventory.move.dialog.shortcutSave", "to save") })
777
+ ] }),
778
+ /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col-reverse gap-2 sm:w-auto sm:flex-row", children: [
779
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: closeDialog, disabled: submitting, children: t("common.cancel", "Cancel") }),
780
+ /* @__PURE__ */ jsx(Button, { type: "submit", disabled: submitDisabled, "data-testid": "wms-inventory-move-submit", children: t("wms.backend.inventory.move.dialog.submit", "Move stock") })
781
+ ] })
782
+ ] })
783
+ ] })
784
+ ]
785
+ }
786
+ ) });
787
+ }
788
+ export {
789
+ MoveInventoryDialog
790
+ };
791
+ //# sourceMappingURL=MoveInventoryDialog.js.map