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