@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,710 @@
|
|
|
1
|
+
import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
|
|
2
|
+
import {
|
|
3
|
+
buildQuery,
|
|
4
|
+
loadCatalogVariantOptions,
|
|
5
|
+
loadWarehouseOptions
|
|
6
|
+
} from "./wmsLookupLoaders.js";
|
|
7
|
+
async function loadCrudOptionsByIds(endpoint, ids, mapItem) {
|
|
8
|
+
const normalizedIds = [...new Set(ids.map((id) => id.trim()).filter(Boolean))];
|
|
9
|
+
if (normalizedIds.length === 0) return [];
|
|
10
|
+
const params = buildQuery({
|
|
11
|
+
page: 1,
|
|
12
|
+
pageSize: normalizedIds.length,
|
|
13
|
+
ids: normalizedIds.join(",")
|
|
14
|
+
});
|
|
15
|
+
const call = await apiCall(`${endpoint}?${params}`);
|
|
16
|
+
if (!call.ok) return [];
|
|
17
|
+
return (call.result?.items ?? []).map(mapItem).filter((option) => option !== null);
|
|
18
|
+
}
|
|
19
|
+
async function resolveCatalogVariantLabel(catalogVariantId) {
|
|
20
|
+
const id = catalogVariantId.trim();
|
|
21
|
+
if (!id) return null;
|
|
22
|
+
const params = buildQuery({ page: 1, pageSize: 1, id });
|
|
23
|
+
const call = await apiCall(
|
|
24
|
+
`/api/catalog/variants?${params}`
|
|
25
|
+
);
|
|
26
|
+
if (!call.ok) return null;
|
|
27
|
+
const item = call.result?.items?.[0];
|
|
28
|
+
if (!item) return null;
|
|
29
|
+
return item.sku?.trim() || item.name?.trim() || id;
|
|
30
|
+
}
|
|
31
|
+
async function resolveWarehouseLabel(warehouseId) {
|
|
32
|
+
const [option] = await loadCrudOptionsByIds(
|
|
33
|
+
"/api/wms/warehouses",
|
|
34
|
+
[warehouseId],
|
|
35
|
+
(item) => {
|
|
36
|
+
const value = typeof item.id === "string" ? item.id : null;
|
|
37
|
+
if (!value) return null;
|
|
38
|
+
return { value, label: item.name || item.code || value };
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
return option?.label ?? null;
|
|
42
|
+
}
|
|
43
|
+
async function resolveLocationLabel(locationId) {
|
|
44
|
+
const [option] = await loadCrudOptionsByIds(
|
|
45
|
+
"/api/wms/locations",
|
|
46
|
+
[locationId],
|
|
47
|
+
(item) => {
|
|
48
|
+
const value = typeof item.id === "string" ? item.id : null;
|
|
49
|
+
if (!value) return null;
|
|
50
|
+
return { value, label: item.code || value };
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
return option?.label ?? null;
|
|
54
|
+
}
|
|
55
|
+
async function resolveLotLabel(lotId) {
|
|
56
|
+
const [option] = await loadCrudOptionsByIds(
|
|
57
|
+
"/api/wms/lots",
|
|
58
|
+
[lotId],
|
|
59
|
+
(item) => {
|
|
60
|
+
const value = typeof item.id === "string" ? item.id : null;
|
|
61
|
+
if (!value) return null;
|
|
62
|
+
const lotNumber = item.lot_number?.trim() || value;
|
|
63
|
+
const expiresAt = item.expires_at?.trim();
|
|
64
|
+
const label = expiresAt ? `${lotNumber} \xB7 exp ${expiresAt.slice(0, 10)}` : lotNumber;
|
|
65
|
+
return { value, label };
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
return option?.label ?? null;
|
|
69
|
+
}
|
|
70
|
+
async function resolveLotNumberFromId(lotId) {
|
|
71
|
+
const [option] = await loadCrudOptionsByIds(
|
|
72
|
+
"/api/wms/lots",
|
|
73
|
+
[lotId],
|
|
74
|
+
(item) => {
|
|
75
|
+
const value = typeof item.id === "string" ? item.id : null;
|
|
76
|
+
const lotNumber = item.lot_number?.trim();
|
|
77
|
+
if (!value || !lotNumber) return null;
|
|
78
|
+
return { value, label: lotNumber };
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
return option?.label ?? null;
|
|
82
|
+
}
|
|
83
|
+
async function resolveCatalogVariantSku(catalogVariantId) {
|
|
84
|
+
const id = catalogVariantId.trim();
|
|
85
|
+
if (!id) return null;
|
|
86
|
+
const params = buildQuery({ page: 1, pageSize: 1, id });
|
|
87
|
+
const call = await apiCall(
|
|
88
|
+
`/api/catalog/variants?${params}`
|
|
89
|
+
);
|
|
90
|
+
if (!call.ok) return null;
|
|
91
|
+
const sku = call.result?.items?.[0]?.sku?.trim();
|
|
92
|
+
return sku || null;
|
|
93
|
+
}
|
|
94
|
+
async function loadInventoryProfileForVariant(catalogVariantId) {
|
|
95
|
+
const variantId = catalogVariantId.trim();
|
|
96
|
+
if (!variantId) return null;
|
|
97
|
+
const params = buildQuery({ page: 1, pageSize: 1, catalogVariantId: variantId });
|
|
98
|
+
const call = await apiCall(
|
|
99
|
+
`/api/wms/inventory-profiles?${params}`
|
|
100
|
+
);
|
|
101
|
+
if (!call.ok) return null;
|
|
102
|
+
return call.result?.items?.[0] ?? null;
|
|
103
|
+
}
|
|
104
|
+
async function findLotIdByNumber(catalogVariantId, lotNumber) {
|
|
105
|
+
const variantId = catalogVariantId.trim();
|
|
106
|
+
const normalizedLotNumber = lotNumber.trim();
|
|
107
|
+
if (!variantId || !normalizedLotNumber) return null;
|
|
108
|
+
const params = buildQuery({
|
|
109
|
+
page: 1,
|
|
110
|
+
pageSize: 20,
|
|
111
|
+
catalogVariantId: variantId,
|
|
112
|
+
search: normalizedLotNumber
|
|
113
|
+
});
|
|
114
|
+
const call = await apiCall(`/api/wms/lots?${params}`);
|
|
115
|
+
if (!call.ok) return null;
|
|
116
|
+
const match = (call.result?.items ?? []).find(
|
|
117
|
+
(item) => item.lot_number?.trim().toLowerCase() === normalizedLotNumber.toLowerCase()
|
|
118
|
+
);
|
|
119
|
+
return typeof match?.id === "string" ? match.id : null;
|
|
120
|
+
}
|
|
121
|
+
class InventoryLotMutationError extends Error {
|
|
122
|
+
constructor(message = "Failed to resolve inventory lot.") {
|
|
123
|
+
super(message);
|
|
124
|
+
this.name = "InventoryLotMutationError";
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async function ensureLotIdForInventoryMutation(input) {
|
|
128
|
+
const lotNumber = input.lotNumber.trim();
|
|
129
|
+
if (!lotNumber) {
|
|
130
|
+
throw new InventoryLotMutationError("Lot number is required.");
|
|
131
|
+
}
|
|
132
|
+
const existingId = await findLotIdByNumber(input.catalogVariantId, lotNumber);
|
|
133
|
+
if (existingId) return existingId;
|
|
134
|
+
const sku = await resolveCatalogVariantSku(input.catalogVariantId);
|
|
135
|
+
if (!sku) {
|
|
136
|
+
throw new InventoryLotMutationError("Could not resolve SKU for the selected variant.");
|
|
137
|
+
}
|
|
138
|
+
const call = await apiCall("/api/wms/lots", {
|
|
139
|
+
method: "POST",
|
|
140
|
+
headers: { "content-type": "application/json" },
|
|
141
|
+
body: JSON.stringify({
|
|
142
|
+
organizationId: input.organizationId,
|
|
143
|
+
tenantId: input.tenantId,
|
|
144
|
+
catalogVariantId: input.catalogVariantId,
|
|
145
|
+
sku,
|
|
146
|
+
lotNumber,
|
|
147
|
+
status: "available"
|
|
148
|
+
})
|
|
149
|
+
});
|
|
150
|
+
if (!call.ok) {
|
|
151
|
+
const racedId = await findLotIdByNumber(input.catalogVariantId, lotNumber);
|
|
152
|
+
if (racedId) return racedId;
|
|
153
|
+
throw new InventoryLotMutationError("Failed to create inventory lot.");
|
|
154
|
+
}
|
|
155
|
+
const createdId = call.result?.id?.trim();
|
|
156
|
+
if (createdId) return createdId;
|
|
157
|
+
const resolvedId = await findLotIdByNumber(input.catalogVariantId, lotNumber);
|
|
158
|
+
if (resolvedId) return resolvedId;
|
|
159
|
+
throw new InventoryLotMutationError("Failed to resolve created inventory lot.");
|
|
160
|
+
}
|
|
161
|
+
function readZoneWarehouseId(item) {
|
|
162
|
+
if (typeof item.warehouse_id === "string" && item.warehouse_id.trim()) {
|
|
163
|
+
return item.warehouse_id.trim();
|
|
164
|
+
}
|
|
165
|
+
if (typeof item.warehouseId === "string" && item.warehouseId.trim()) {
|
|
166
|
+
return item.warehouseId.trim();
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
class BalanceLookupError extends Error {
|
|
171
|
+
constructor(message = "Failed to load inventory balance.", code = "LOOKUP_FAILED", candidateLotIds = []) {
|
|
172
|
+
super(message);
|
|
173
|
+
this.name = "BalanceLookupError";
|
|
174
|
+
this.code = code;
|
|
175
|
+
this.candidateLotIds = candidateLotIds;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
class ScopeEstimateError extends Error {
|
|
179
|
+
constructor(message = "Failed to estimate cycle count scope.") {
|
|
180
|
+
super(message);
|
|
181
|
+
this.name = "ScopeEstimateError";
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function compareLocationCodes(left, right) {
|
|
185
|
+
return left.localeCompare(right, void 0, { numeric: true, sensitivity: "base" });
|
|
186
|
+
}
|
|
187
|
+
function isLocationCodeWithinRange(code, fromCode, toCode) {
|
|
188
|
+
const from = fromCode?.trim();
|
|
189
|
+
const to = toCode?.trim();
|
|
190
|
+
if (from && compareLocationCodes(code, from) < 0) return false;
|
|
191
|
+
if (to && compareLocationCodes(code, to) > 0) return false;
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
function formatCycleCountZoneLabel(baseLabel, stats) {
|
|
195
|
+
const trimmed = baseLabel.trim();
|
|
196
|
+
if (!trimmed || !stats) return trimmed;
|
|
197
|
+
return `${trimmed} \xB7 ${stats.expectedSkus} SKUs \xB7 ${stats.binCount} bins`;
|
|
198
|
+
}
|
|
199
|
+
function mapLocationOptions(items) {
|
|
200
|
+
return items.map((item) => {
|
|
201
|
+
const value = typeof item.id === "string" ? item.id : null;
|
|
202
|
+
if (!value) return null;
|
|
203
|
+
const label = item.code || value;
|
|
204
|
+
return { value, label };
|
|
205
|
+
}).filter((option) => option !== null);
|
|
206
|
+
}
|
|
207
|
+
async function loadAllLocations(warehouseId, filters) {
|
|
208
|
+
const items = [];
|
|
209
|
+
let page = 1;
|
|
210
|
+
let totalPages = 1;
|
|
211
|
+
while (page <= totalPages && page <= 10) {
|
|
212
|
+
const params = buildQuery({
|
|
213
|
+
page,
|
|
214
|
+
pageSize: 100,
|
|
215
|
+
warehouseId,
|
|
216
|
+
type: filters.type,
|
|
217
|
+
search: filters.search?.trim() || void 0
|
|
218
|
+
});
|
|
219
|
+
const call = await apiCall(`/api/wms/locations?${params}`);
|
|
220
|
+
if (!call.ok) break;
|
|
221
|
+
items.push(...call.result?.items ?? []);
|
|
222
|
+
totalPages = call.result?.totalPages ?? 1;
|
|
223
|
+
page += 1;
|
|
224
|
+
}
|
|
225
|
+
return items;
|
|
226
|
+
}
|
|
227
|
+
function filterLocationsByCodeRange(locations, fromCode, toCode) {
|
|
228
|
+
const from = fromCode?.trim();
|
|
229
|
+
const to = toCode?.trim();
|
|
230
|
+
if (!from && !to) return locations;
|
|
231
|
+
return locations.filter((location) => {
|
|
232
|
+
const code = location.code?.trim();
|
|
233
|
+
if (!code) return false;
|
|
234
|
+
return isLocationCodeWithinRange(code, from, to);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
async function loadLocationPage(warehouseId, filters) {
|
|
238
|
+
const params = buildQuery({
|
|
239
|
+
page: filters.page ?? 1,
|
|
240
|
+
pageSize: filters.pageSize ?? 50,
|
|
241
|
+
warehouseId,
|
|
242
|
+
type: filters.type,
|
|
243
|
+
search: filters.search?.trim() || void 0
|
|
244
|
+
});
|
|
245
|
+
const call = await apiCall(`/api/wms/locations?${params}`);
|
|
246
|
+
if (!call.ok) {
|
|
247
|
+
throw new BalanceLookupError("Failed to load warehouse locations.");
|
|
248
|
+
}
|
|
249
|
+
return call.result ?? { items: [], total: 0, totalPages: 0 };
|
|
250
|
+
}
|
|
251
|
+
async function loadLocationOptions(warehouseId, query) {
|
|
252
|
+
if (!warehouseId) return [];
|
|
253
|
+
try {
|
|
254
|
+
const page = await loadLocationPage(warehouseId, { search: query });
|
|
255
|
+
return mapLocationOptions(page.items ?? []);
|
|
256
|
+
} catch {
|
|
257
|
+
return [];
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async function loadBinLocationOptions(warehouseId, query) {
|
|
261
|
+
if (!warehouseId) return [];
|
|
262
|
+
try {
|
|
263
|
+
const page = await loadLocationPage(warehouseId, { type: "bin", search: query });
|
|
264
|
+
return mapLocationOptions(page.items ?? []);
|
|
265
|
+
} catch {
|
|
266
|
+
return [];
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
async function loadZoneOptions(warehouseId, query) {
|
|
270
|
+
const scopedWarehouseId = warehouseId.trim();
|
|
271
|
+
if (!scopedWarehouseId) return [];
|
|
272
|
+
const params = buildQuery({
|
|
273
|
+
page: 1,
|
|
274
|
+
pageSize: 50,
|
|
275
|
+
warehouseId: scopedWarehouseId,
|
|
276
|
+
search: query?.trim() || void 0
|
|
277
|
+
});
|
|
278
|
+
const call = await apiCall(`/api/wms/zones?${params}`);
|
|
279
|
+
if (!call.ok) return [];
|
|
280
|
+
return (call.result?.items ?? []).map((item) => {
|
|
281
|
+
const value = typeof item.id === "string" ? item.id : null;
|
|
282
|
+
if (!value) return null;
|
|
283
|
+
const label = item.name?.trim() || item.code?.trim() || value;
|
|
284
|
+
const zoneWarehouseId = readZoneWarehouseId(item);
|
|
285
|
+
return {
|
|
286
|
+
value,
|
|
287
|
+
label,
|
|
288
|
+
...zoneWarehouseId ? { warehouseId: zoneWarehouseId } : {}
|
|
289
|
+
};
|
|
290
|
+
}).filter((option) => option !== null);
|
|
291
|
+
}
|
|
292
|
+
async function resolveZoneLabel(zoneId) {
|
|
293
|
+
const [option] = await loadCrudOptionsByIds(
|
|
294
|
+
"/api/wms/zones",
|
|
295
|
+
[zoneId],
|
|
296
|
+
(item) => {
|
|
297
|
+
const value = typeof item.id === "string" ? item.id : null;
|
|
298
|
+
if (!value) return null;
|
|
299
|
+
return { value, label: item.name?.trim() || item.code?.trim() || value };
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
return option?.label ?? null;
|
|
303
|
+
}
|
|
304
|
+
async function resolveZoneWarehouseId(zoneId) {
|
|
305
|
+
const id = zoneId.trim();
|
|
306
|
+
if (!id) return null;
|
|
307
|
+
const [option] = await loadCrudOptionsByIds(
|
|
308
|
+
"/api/wms/zones",
|
|
309
|
+
[id],
|
|
310
|
+
(item) => {
|
|
311
|
+
const value = typeof item.id === "string" ? item.id : null;
|
|
312
|
+
const warehouseId = readZoneWarehouseId(item);
|
|
313
|
+
if (!value || !warehouseId) return null;
|
|
314
|
+
return { value, label: warehouseId };
|
|
315
|
+
}
|
|
316
|
+
);
|
|
317
|
+
return option?.label ?? null;
|
|
318
|
+
}
|
|
319
|
+
async function loadAssigneeOptions(query, fallback) {
|
|
320
|
+
const fallbackUserId = fallback?.userId.trim();
|
|
321
|
+
const fallbackLabel = fallback?.label.trim();
|
|
322
|
+
const fallbackOption = fallbackUserId && fallbackLabel ? [{ value: fallbackUserId, label: fallbackLabel }] : [];
|
|
323
|
+
const params = buildQuery({
|
|
324
|
+
page: 1,
|
|
325
|
+
pageSize: 50,
|
|
326
|
+
search: query?.trim() || void 0
|
|
327
|
+
});
|
|
328
|
+
const call = await apiCall(`/api/auth/users?${params}`);
|
|
329
|
+
if (!call.ok) {
|
|
330
|
+
return {
|
|
331
|
+
options: fallbackOption,
|
|
332
|
+
canListUsers: false
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
const options = (call.result?.items ?? []).map((item) => {
|
|
336
|
+
const value = typeof item.id === "string" ? item.id : null;
|
|
337
|
+
if (!value) return null;
|
|
338
|
+
const email = item.email?.trim() || value;
|
|
339
|
+
const role = item.roles?.find((entry) => entry.trim().length > 0)?.trim();
|
|
340
|
+
const label = role ? `${email} (${role})` : email;
|
|
341
|
+
return { value, label };
|
|
342
|
+
}).filter((option) => option !== null);
|
|
343
|
+
return {
|
|
344
|
+
options,
|
|
345
|
+
canListUsers: true
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
async function resolveAssigneeLabel(userId) {
|
|
349
|
+
const params = buildQuery({ page: 1, pageSize: 1, id: userId.trim() });
|
|
350
|
+
const call = await apiCall(`/api/auth/users?${params}`);
|
|
351
|
+
if (!call.ok) return null;
|
|
352
|
+
const item = call.result?.items?.[0];
|
|
353
|
+
if (!item?.id) return null;
|
|
354
|
+
const email = item.email?.trim() || item.id;
|
|
355
|
+
const role = item.roles?.find((entry) => entry.trim().length > 0)?.trim();
|
|
356
|
+
return role ? `${email} (${role})` : email;
|
|
357
|
+
}
|
|
358
|
+
async function fetchCycleCountScopeEstimate(input) {
|
|
359
|
+
const warehouseId = input.warehouseId.trim();
|
|
360
|
+
if (!warehouseId) return { expectedSkus: 0, binCount: 0 };
|
|
361
|
+
const bins = await loadAllLocations(warehouseId, { type: "bin" });
|
|
362
|
+
const locationById = new Map(
|
|
363
|
+
bins.map((location) => {
|
|
364
|
+
const id = location.id?.trim();
|
|
365
|
+
return id ? [id, location] : null;
|
|
366
|
+
}).filter((entry) => entry !== null)
|
|
367
|
+
);
|
|
368
|
+
const fromCode = input.fromLocationId ? locationById.get(input.fromLocationId.trim())?.code : void 0;
|
|
369
|
+
const toCode = input.toLocationId ? locationById.get(input.toLocationId.trim())?.code : void 0;
|
|
370
|
+
const scopedBins = filterLocationsByCodeRange(bins, fromCode, toCode);
|
|
371
|
+
const scopedBinIds = new Set(
|
|
372
|
+
scopedBins.map((location) => location.id?.trim()).filter((id) => Boolean(id))
|
|
373
|
+
);
|
|
374
|
+
const binCount = scopedBinIds.size;
|
|
375
|
+
const variantIds = /* @__PURE__ */ new Set();
|
|
376
|
+
let page = 1;
|
|
377
|
+
let totalPages = 1;
|
|
378
|
+
while (page <= totalPages && page <= 10) {
|
|
379
|
+
const params = buildQuery({
|
|
380
|
+
page,
|
|
381
|
+
pageSize: 100,
|
|
382
|
+
warehouseId
|
|
383
|
+
});
|
|
384
|
+
const call = await apiCall(
|
|
385
|
+
`/api/wms/inventory/balances?${params}`
|
|
386
|
+
);
|
|
387
|
+
if (!call.ok) {
|
|
388
|
+
throw new ScopeEstimateError();
|
|
389
|
+
}
|
|
390
|
+
for (const row of call.result?.items ?? []) {
|
|
391
|
+
const locationId = row.location_id?.trim();
|
|
392
|
+
const variantId = row.catalog_variant_id?.trim();
|
|
393
|
+
const onHand = Number(row.quantity_on_hand ?? 0);
|
|
394
|
+
if (!locationId || !variantId || !Number.isFinite(onHand) || onHand <= 0) continue;
|
|
395
|
+
if (scopedBinIds.size > 0 && !scopedBinIds.has(locationId)) continue;
|
|
396
|
+
variantIds.add(variantId);
|
|
397
|
+
}
|
|
398
|
+
totalPages = call.result?.totalPages ?? 1;
|
|
399
|
+
page += 1;
|
|
400
|
+
}
|
|
401
|
+
return { expectedSkus: variantIds.size, binCount };
|
|
402
|
+
}
|
|
403
|
+
function normalizeBalanceLotId(value) {
|
|
404
|
+
const trimmed = value?.trim();
|
|
405
|
+
return trimmed || null;
|
|
406
|
+
}
|
|
407
|
+
function readBalanceAvailable(row) {
|
|
408
|
+
const available = Number(row.quantity_available ?? row.quantity_on_hand ?? 0);
|
|
409
|
+
return Number.isFinite(available) ? available : 0;
|
|
410
|
+
}
|
|
411
|
+
function selectBalanceLookupRow(items, lotId) {
|
|
412
|
+
if (items.length === 0) return null;
|
|
413
|
+
if (items.length === 1) return items[0];
|
|
414
|
+
const normalizedLotId = normalizeBalanceLotId(lotId);
|
|
415
|
+
if (normalizedLotId) {
|
|
416
|
+
const exactMatch = items.find(
|
|
417
|
+
(row) => normalizeBalanceLotId(row.lot_id) === normalizedLotId
|
|
418
|
+
);
|
|
419
|
+
if (exactMatch) return exactMatch;
|
|
420
|
+
throw new BalanceLookupError("No balance bucket matches the selected lot.", "LOT_NOT_FOUND");
|
|
421
|
+
}
|
|
422
|
+
const withoutLot = items.filter((row) => !normalizeBalanceLotId(row.lot_id));
|
|
423
|
+
if (withoutLot.length === 1) return withoutLot[0];
|
|
424
|
+
const candidateLotIds = [
|
|
425
|
+
...new Set(
|
|
426
|
+
items.map((row) => normalizeBalanceLotId(row.lot_id)).filter((id) => Boolean(id))
|
|
427
|
+
)
|
|
428
|
+
];
|
|
429
|
+
throw new BalanceLookupError(
|
|
430
|
+
"Multiple balance buckets match this location; specify a lot.",
|
|
431
|
+
"LOT_REQUIRED",
|
|
432
|
+
candidateLotIds
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
async function fetchBalanceAvailable(input) {
|
|
436
|
+
const params = buildQuery({
|
|
437
|
+
page: 1,
|
|
438
|
+
pageSize: 20,
|
|
439
|
+
warehouseId: input.warehouseId,
|
|
440
|
+
locationId: input.locationId,
|
|
441
|
+
catalogVariantId: input.catalogVariantId,
|
|
442
|
+
lotId: input.lotId?.trim() || void 0
|
|
443
|
+
});
|
|
444
|
+
const call = await apiCall(
|
|
445
|
+
`/api/wms/inventory/balances?${params}`
|
|
446
|
+
);
|
|
447
|
+
if (!call.ok) {
|
|
448
|
+
throw new BalanceLookupError();
|
|
449
|
+
}
|
|
450
|
+
const row = selectBalanceLookupRow(call.result?.items ?? [], input.lotId);
|
|
451
|
+
if (!row) return 0;
|
|
452
|
+
return readBalanceAvailable(row);
|
|
453
|
+
}
|
|
454
|
+
function mapInventoryLotListRowToOption(item) {
|
|
455
|
+
const value = typeof item.id === "string" ? item.id : null;
|
|
456
|
+
if (!value) return null;
|
|
457
|
+
const lotNumber = item.lot_number?.trim() || value;
|
|
458
|
+
const expiresAt = item.expires_at?.trim();
|
|
459
|
+
const label = expiresAt ? `${lotNumber} \xB7 exp ${expiresAt.slice(0, 10)}` : lotNumber;
|
|
460
|
+
return { value, label };
|
|
461
|
+
}
|
|
462
|
+
function mapInventoryLotListRowToLotNumberOption(item) {
|
|
463
|
+
const lotNumber = item.lot_number?.trim();
|
|
464
|
+
if (!lotNumber) return null;
|
|
465
|
+
const expiresAt = item.expires_at?.trim();
|
|
466
|
+
const label = expiresAt ? `${lotNumber} \xB7 exp ${expiresAt.slice(0, 10)}` : lotNumber;
|
|
467
|
+
return { value: lotNumber, label };
|
|
468
|
+
}
|
|
469
|
+
async function loadInventoryLotListOptions(catalogVariantId, query, mapItem) {
|
|
470
|
+
if (!catalogVariantId) return [];
|
|
471
|
+
const params = buildQuery({
|
|
472
|
+
page: 1,
|
|
473
|
+
pageSize: 50,
|
|
474
|
+
catalogVariantId,
|
|
475
|
+
status: "available",
|
|
476
|
+
search: query?.trim() || void 0
|
|
477
|
+
});
|
|
478
|
+
const call = await apiCall(`/api/wms/lots?${params}`);
|
|
479
|
+
if (!call.ok) return [];
|
|
480
|
+
return (call.result?.items ?? []).map(mapItem).filter((option) => option !== null);
|
|
481
|
+
}
|
|
482
|
+
async function loadLotOptions(catalogVariantId, query) {
|
|
483
|
+
return loadInventoryLotListOptions(catalogVariantId, query, mapInventoryLotListRowToOption);
|
|
484
|
+
}
|
|
485
|
+
async function loadLotOptionsByIds(lotIds) {
|
|
486
|
+
return loadCrudOptionsByIds(
|
|
487
|
+
"/api/wms/lots",
|
|
488
|
+
lotIds,
|
|
489
|
+
mapInventoryLotListRowToOption
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
async function loadLotOptionsForBalanceLocation(input) {
|
|
493
|
+
const warehouseId = input.warehouseId.trim();
|
|
494
|
+
const locationId = input.locationId.trim();
|
|
495
|
+
const catalogVariantId = input.catalogVariantId.trim();
|
|
496
|
+
if (!warehouseId || !locationId || !catalogVariantId) return [];
|
|
497
|
+
const params = buildQuery({
|
|
498
|
+
page: 1,
|
|
499
|
+
pageSize: 50,
|
|
500
|
+
warehouseId,
|
|
501
|
+
locationId,
|
|
502
|
+
catalogVariantId
|
|
503
|
+
});
|
|
504
|
+
const call = await apiCall(
|
|
505
|
+
`/api/wms/inventory/balances?${params}`
|
|
506
|
+
);
|
|
507
|
+
if (!call.ok) return [];
|
|
508
|
+
const lotIds = [
|
|
509
|
+
...new Set(
|
|
510
|
+
(call.result?.items ?? []).map((row) => normalizeBalanceLotId(row.lot_id)).filter((id) => Boolean(id))
|
|
511
|
+
)
|
|
512
|
+
];
|
|
513
|
+
if (lotIds.length === 0) return [];
|
|
514
|
+
const options = await loadCrudOptionsByIds(
|
|
515
|
+
"/api/wms/lots",
|
|
516
|
+
lotIds,
|
|
517
|
+
mapInventoryLotListRowToOption
|
|
518
|
+
);
|
|
519
|
+
const query = input.query?.trim().toLowerCase();
|
|
520
|
+
if (!query) return options;
|
|
521
|
+
return options.filter((option) => option.label.toLowerCase().includes(query));
|
|
522
|
+
}
|
|
523
|
+
async function loadLotNumberOptions(catalogVariantId, query) {
|
|
524
|
+
return loadInventoryLotListOptions(catalogVariantId, query, mapInventoryLotListRowToLotNumberOption);
|
|
525
|
+
}
|
|
526
|
+
class ScopeQueueError extends Error {
|
|
527
|
+
constructor(message = "Failed to build cycle count scope queue.") {
|
|
528
|
+
super(message);
|
|
529
|
+
this.name = "ScopeQueueError";
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
async function buildCycleCountScopeQueue(input) {
|
|
533
|
+
const warehouseId = input.warehouseId.trim();
|
|
534
|
+
if (!warehouseId) return [];
|
|
535
|
+
const bins = await loadAllLocations(warehouseId, { type: "bin" });
|
|
536
|
+
const binById = new Map(
|
|
537
|
+
bins.map((b) => {
|
|
538
|
+
const id = b.id?.trim();
|
|
539
|
+
return id ? [id, b] : null;
|
|
540
|
+
}).filter((entry) => entry !== null)
|
|
541
|
+
);
|
|
542
|
+
const fromCode = input.fromLocationId?.trim() ? binById.get(input.fromLocationId.trim())?.code : void 0;
|
|
543
|
+
const toCode = input.toLocationId?.trim() ? binById.get(input.toLocationId.trim())?.code : void 0;
|
|
544
|
+
const scopedBins = filterLocationsByCodeRange(bins, fromCode, toCode);
|
|
545
|
+
const scopedBinIds = new Set(
|
|
546
|
+
scopedBins.map((b) => b.id?.trim()).filter((id) => Boolean(id))
|
|
547
|
+
);
|
|
548
|
+
if (scopedBinIds.size === 0) return [];
|
|
549
|
+
const items = [];
|
|
550
|
+
let page = 1;
|
|
551
|
+
let totalPages = 1;
|
|
552
|
+
while (page <= totalPages && page <= 20) {
|
|
553
|
+
const params = buildQuery({ page, pageSize: 100, warehouseId });
|
|
554
|
+
const call = await apiCall(
|
|
555
|
+
`/api/wms/inventory/balances?${params}`
|
|
556
|
+
);
|
|
557
|
+
if (!call.ok) throw new ScopeQueueError();
|
|
558
|
+
for (const row of call.result?.items ?? []) {
|
|
559
|
+
const locationId = row.location_id?.trim();
|
|
560
|
+
const variantId = row.catalog_variant_id?.trim();
|
|
561
|
+
const lotId = row.lot_id?.trim() || null;
|
|
562
|
+
const onHand = Number(row.quantity_on_hand ?? 0);
|
|
563
|
+
if (!locationId || !variantId) continue;
|
|
564
|
+
if (!scopedBinIds.has(locationId)) continue;
|
|
565
|
+
if (!Number.isFinite(onHand) || onHand <= 0) continue;
|
|
566
|
+
const bin = binById.get(locationId);
|
|
567
|
+
items.push({
|
|
568
|
+
locationId,
|
|
569
|
+
locationCode: bin?.code?.trim() ?? locationId,
|
|
570
|
+
catalogVariantId: variantId,
|
|
571
|
+
lotId,
|
|
572
|
+
expectedOnHand: onHand
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
totalPages = call.result?.totalPages ?? 1;
|
|
576
|
+
page += 1;
|
|
577
|
+
}
|
|
578
|
+
items.sort((a, b) => {
|
|
579
|
+
const cmp = a.locationCode.localeCompare(b.locationCode, void 0, {
|
|
580
|
+
numeric: true,
|
|
581
|
+
sensitivity: "base"
|
|
582
|
+
});
|
|
583
|
+
return cmp !== 0 ? cmp : a.catalogVariantId.localeCompare(b.catalogVariantId);
|
|
584
|
+
});
|
|
585
|
+
return items;
|
|
586
|
+
}
|
|
587
|
+
async function fetchVariantReorderPoint(catalogVariantId) {
|
|
588
|
+
if (!catalogVariantId) return 0;
|
|
589
|
+
const params = buildQuery({
|
|
590
|
+
page: 1,
|
|
591
|
+
pageSize: 1,
|
|
592
|
+
catalogVariantId
|
|
593
|
+
});
|
|
594
|
+
const call = await apiCall(
|
|
595
|
+
`/api/wms/inventory-profiles?${params}`
|
|
596
|
+
);
|
|
597
|
+
if (!call.ok) return 0;
|
|
598
|
+
const row = call.result?.items?.[0];
|
|
599
|
+
if (!row) return 0;
|
|
600
|
+
const reorderPoint = Number(row.reorder_point ?? 0);
|
|
601
|
+
return Number.isFinite(reorderPoint) ? reorderPoint : 0;
|
|
602
|
+
}
|
|
603
|
+
async function fetchLocationCapacityUnits(locationId) {
|
|
604
|
+
const id = locationId.trim();
|
|
605
|
+
if (!id) return null;
|
|
606
|
+
const params = buildQuery({ page: 1, pageSize: 1, ids: id });
|
|
607
|
+
const call = await apiCall(
|
|
608
|
+
`/api/wms/locations?${params}`
|
|
609
|
+
);
|
|
610
|
+
if (!call.ok) return null;
|
|
611
|
+
const raw = call.result?.items?.[0]?.capacity_units;
|
|
612
|
+
if (raw == null) return null;
|
|
613
|
+
const value = Number(raw);
|
|
614
|
+
return Number.isFinite(value) ? value : null;
|
|
615
|
+
}
|
|
616
|
+
const LOCATION_TOTAL_ON_HAND_PAGE_SIZE = 100;
|
|
617
|
+
const LOCATION_TOTAL_ON_HAND_MAX_PAGES = 50;
|
|
618
|
+
async function fetchLocationTotalOnHand(input) {
|
|
619
|
+
const locationId = input.locationId.trim();
|
|
620
|
+
if (!locationId) return 0;
|
|
621
|
+
let sum = 0;
|
|
622
|
+
let page = 1;
|
|
623
|
+
let totalPages = 1;
|
|
624
|
+
do {
|
|
625
|
+
const params = buildQuery({
|
|
626
|
+
page,
|
|
627
|
+
pageSize: LOCATION_TOTAL_ON_HAND_PAGE_SIZE,
|
|
628
|
+
warehouseId: input.warehouseId,
|
|
629
|
+
locationId
|
|
630
|
+
});
|
|
631
|
+
const call = await apiCall(
|
|
632
|
+
`/api/wms/inventory/balances?${params}`
|
|
633
|
+
);
|
|
634
|
+
if (!call.ok) break;
|
|
635
|
+
for (const row of call.result?.items ?? []) {
|
|
636
|
+
const value = Number(row.quantity_on_hand ?? 0);
|
|
637
|
+
if (Number.isFinite(value)) sum += value;
|
|
638
|
+
}
|
|
639
|
+
totalPages = call.result?.totalPages ?? 1;
|
|
640
|
+
page += 1;
|
|
641
|
+
} while (page <= totalPages && page <= LOCATION_TOTAL_ON_HAND_MAX_PAGES);
|
|
642
|
+
return sum;
|
|
643
|
+
}
|
|
644
|
+
async function fetchLocationCapacitySnapshot(input) {
|
|
645
|
+
const [capacityUnits, totalOnHand] = await Promise.all([
|
|
646
|
+
fetchLocationCapacityUnits(input.locationId),
|
|
647
|
+
fetchLocationTotalOnHand(input)
|
|
648
|
+
]);
|
|
649
|
+
return { capacityUnits, totalOnHand };
|
|
650
|
+
}
|
|
651
|
+
async function fetchBalanceOnHand(input) {
|
|
652
|
+
const params = buildQuery({
|
|
653
|
+
page: 1,
|
|
654
|
+
pageSize: 20,
|
|
655
|
+
warehouseId: input.warehouseId,
|
|
656
|
+
locationId: input.locationId,
|
|
657
|
+
catalogVariantId: input.catalogVariantId,
|
|
658
|
+
lotId: input.lotId?.trim() || void 0
|
|
659
|
+
});
|
|
660
|
+
const call = await apiCall(
|
|
661
|
+
`/api/wms/inventory/balances?${params}`
|
|
662
|
+
);
|
|
663
|
+
if (!call.ok) {
|
|
664
|
+
throw new BalanceLookupError();
|
|
665
|
+
}
|
|
666
|
+
const row = selectBalanceLookupRow(call.result?.items ?? [], input.lotId);
|
|
667
|
+
if (!row) return 0;
|
|
668
|
+
const onHand = Number(row.quantity_on_hand ?? 0);
|
|
669
|
+
return Number.isFinite(onHand) ? onHand : 0;
|
|
670
|
+
}
|
|
671
|
+
export {
|
|
672
|
+
BalanceLookupError,
|
|
673
|
+
InventoryLotMutationError,
|
|
674
|
+
ScopeEstimateError,
|
|
675
|
+
ScopeQueueError,
|
|
676
|
+
buildCycleCountScopeQueue,
|
|
677
|
+
buildQuery,
|
|
678
|
+
ensureLotIdForInventoryMutation,
|
|
679
|
+
fetchBalanceAvailable,
|
|
680
|
+
fetchBalanceOnHand,
|
|
681
|
+
fetchCycleCountScopeEstimate,
|
|
682
|
+
fetchLocationCapacitySnapshot,
|
|
683
|
+
fetchVariantReorderPoint,
|
|
684
|
+
filterLocationsByCodeRange,
|
|
685
|
+
findLotIdByNumber,
|
|
686
|
+
formatCycleCountZoneLabel,
|
|
687
|
+
loadAllLocations,
|
|
688
|
+
loadAssigneeOptions,
|
|
689
|
+
loadBinLocationOptions,
|
|
690
|
+
loadCatalogVariantOptions,
|
|
691
|
+
loadInventoryProfileForVariant,
|
|
692
|
+
loadLocationOptions,
|
|
693
|
+
loadLotNumberOptions,
|
|
694
|
+
loadLotOptions,
|
|
695
|
+
loadLotOptionsByIds,
|
|
696
|
+
loadLotOptionsForBalanceLocation,
|
|
697
|
+
loadWarehouseOptions,
|
|
698
|
+
loadZoneOptions,
|
|
699
|
+
mapLocationOptions,
|
|
700
|
+
resolveAssigneeLabel,
|
|
701
|
+
resolveCatalogVariantLabel,
|
|
702
|
+
resolveCatalogVariantSku,
|
|
703
|
+
resolveLocationLabel,
|
|
704
|
+
resolveLotLabel,
|
|
705
|
+
resolveLotNumberFromId,
|
|
706
|
+
resolveWarehouseLabel,
|
|
707
|
+
resolveZoneLabel,
|
|
708
|
+
resolveZoneWarehouseId
|
|
709
|
+
};
|
|
710
|
+
//# sourceMappingURL=inventoryMutationLoaders.js.map
|