@open-mercato/core 0.6.7-develop.6661.1.0043ed1d03 → 0.6.7-develop.6670.1.4efa7961c6

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