@open-mercato/core 0.6.7-develop.6669.1.40b669666b → 0.6.7-develop.6671.1.4b925c5096
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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/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/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/query_index/lib/engine.ts +18 -6
- package/src/modules/sales/api/documents/factory.ts +1 -0
- 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/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,718 @@
|
|
|
1
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
2
|
+
import type { ResponseEnricher, EnricherContext } from '@open-mercato/shared/lib/crud/response-enricher'
|
|
3
|
+
import { findWithDecryption } from '@open-mercato/shared/lib/encryption/find'
|
|
4
|
+
import type { FeatureTogglesService } from '@open-mercato/core/modules/feature_toggles/lib/feature-flag-check'
|
|
5
|
+
import type { QueryEngine } from '@open-mercato/shared/lib/query/types'
|
|
6
|
+
import { E } from '#generated/entities.ids.generated'
|
|
7
|
+
import { InventoryBalance, InventoryReservation, ProductInventoryProfile, SalesOrderWarehouseAssignment, Warehouse } from './entities'
|
|
8
|
+
import { resolvePrimaryWarehouseId } from '../lib/primaryWarehousePolicy'
|
|
9
|
+
|
|
10
|
+
type SalesOrderRecord = Record<string, unknown> & { id?: string }
|
|
11
|
+
type CatalogProductRecord = Record<string, unknown> & { id?: string }
|
|
12
|
+
type CatalogVariantRecord = Record<string, unknown> & { id?: string; product_id?: string; productId?: string }
|
|
13
|
+
|
|
14
|
+
type SalesOrderLineRow = {
|
|
15
|
+
id?: string
|
|
16
|
+
order_id?: string | null
|
|
17
|
+
product_variant_id?: string | null
|
|
18
|
+
quantity?: string | number | null
|
|
19
|
+
line_number?: number | null
|
|
20
|
+
status?: string | null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type CatalogVariantRow = {
|
|
24
|
+
id?: string
|
|
25
|
+
product_id?: string | null
|
|
26
|
+
}
|
|
27
|
+
type ReservationStatus = 'unreserved' | 'partially_reserved' | 'fully_reserved'
|
|
28
|
+
type ReorderState = 'no_profile' | 'healthy' | 'below_reorder_point' | 'below_safety_stock'
|
|
29
|
+
|
|
30
|
+
type InventoryProfileSummary = {
|
|
31
|
+
profileId: string
|
|
32
|
+
catalogProductId: string
|
|
33
|
+
catalogVariantId: string | null
|
|
34
|
+
defaultUom: string
|
|
35
|
+
defaultStrategy: string
|
|
36
|
+
trackLot: boolean
|
|
37
|
+
trackSerial: boolean
|
|
38
|
+
trackExpiration: boolean
|
|
39
|
+
reorderPoint: string
|
|
40
|
+
safetyStock: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type StockSummaryItem = {
|
|
44
|
+
catalogVariantId: string
|
|
45
|
+
onHand: string
|
|
46
|
+
reserved: string
|
|
47
|
+
allocated: string
|
|
48
|
+
available: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type ReorderStatus = {
|
|
52
|
+
state: ReorderState
|
|
53
|
+
available: string
|
|
54
|
+
reorderPoint: string
|
|
55
|
+
safetyStock: string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type SalesOrderWmsEnrichment = {
|
|
59
|
+
_wms: {
|
|
60
|
+
assignedWarehouseId: string | null
|
|
61
|
+
assignedWarehouseName: string | null
|
|
62
|
+
isExplicitlyAssigned: boolean
|
|
63
|
+
stockSummary: Array<{
|
|
64
|
+
catalogVariantId: string
|
|
65
|
+
available: string
|
|
66
|
+
reserved: string
|
|
67
|
+
}>
|
|
68
|
+
reservationSummary: {
|
|
69
|
+
status: ReservationStatus
|
|
70
|
+
reservationIds: string[]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type CatalogWmsEnrichment = {
|
|
76
|
+
_wms: {
|
|
77
|
+
inventoryProfile: InventoryProfileSummary | null
|
|
78
|
+
stockSummary: StockSummaryItem[]
|
|
79
|
+
reorderStatus: ReorderStatus
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
type EnricherScope = EnricherContext & { em: EntityManager }
|
|
84
|
+
type Scope = { organizationId: string; tenantId: string }
|
|
85
|
+
type BalanceAggregate = { onHand: number; reserved: number; allocated: number; available: number }
|
|
86
|
+
|
|
87
|
+
import { resolveWmsIntegrationToggleEnabled } from '../lib/wmsIntegrationToggles'
|
|
88
|
+
const EMPTY_ENRICHMENT: SalesOrderWmsEnrichment = {
|
|
89
|
+
_wms: {
|
|
90
|
+
assignedWarehouseId: null,
|
|
91
|
+
assignedWarehouseName: null,
|
|
92
|
+
isExplicitlyAssigned: false,
|
|
93
|
+
stockSummary: [],
|
|
94
|
+
reservationSummary: {
|
|
95
|
+
status: 'unreserved',
|
|
96
|
+
reservationIds: [],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const EMPTY_CATALOG_ENRICHMENT: CatalogWmsEnrichment = {
|
|
102
|
+
_wms: {
|
|
103
|
+
inventoryProfile: null,
|
|
104
|
+
stockSummary: [],
|
|
105
|
+
reorderStatus: {
|
|
106
|
+
state: 'no_profile',
|
|
107
|
+
available: '0',
|
|
108
|
+
reorderPoint: '0',
|
|
109
|
+
safetyStock: '0',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function extractRecordId(record: SalesOrderRecord): string | null {
|
|
115
|
+
return typeof record.id === 'string' && record.id.trim().length > 0 ? record.id : null
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function extractOrderIdFromLine(line: SalesOrderLineRow): string | null {
|
|
119
|
+
return typeof line.order_id === 'string' && line.order_id.length > 0 ? line.order_id : null
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function extractProductIdFromVariant(variant: CatalogVariantRow): string | null {
|
|
123
|
+
return typeof variant.product_id === 'string' && variant.product_id.length > 0
|
|
124
|
+
? variant.product_id
|
|
125
|
+
: null
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function extractWarehouseId(reservation: InventoryReservation): string | null {
|
|
129
|
+
const relation = reservation.warehouse as { id?: string } | undefined
|
|
130
|
+
return typeof relation?.id === 'string' ? relation.id : null
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function addToMap(map: Map<string, number>, key: string, value: string | number | null | undefined) {
|
|
134
|
+
const numeric = typeof value === 'number' ? value : Number(value ?? 0)
|
|
135
|
+
map.set(key, (map.get(key) ?? 0) + numeric)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function formatQuantity(value: number): string {
|
|
139
|
+
if (!Number.isFinite(value) || value === 0) return '0'
|
|
140
|
+
const normalized = value.toFixed(4).replace(/\.?0+$/, '')
|
|
141
|
+
return normalized.length > 0 ? normalized : '0'
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function toInventoryProfileSummary(profile: ProductInventoryProfile): InventoryProfileSummary {
|
|
145
|
+
return {
|
|
146
|
+
profileId: profile.id,
|
|
147
|
+
catalogProductId: profile.catalogProductId,
|
|
148
|
+
catalogVariantId: profile.catalogVariantId ?? null,
|
|
149
|
+
defaultUom: profile.defaultUom,
|
|
150
|
+
defaultStrategy: profile.defaultStrategy,
|
|
151
|
+
trackLot: profile.trackLot,
|
|
152
|
+
trackSerial: profile.trackSerial,
|
|
153
|
+
trackExpiration: profile.trackExpiration,
|
|
154
|
+
reorderPoint: profile.reorderPoint,
|
|
155
|
+
safetyStock: profile.safetyStock,
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function resolveReservationStatus(requiredQuantity: number, reservedQuantity: number): ReservationStatus {
|
|
160
|
+
if (requiredQuantity <= 0 || reservedQuantity <= 0) return 'unreserved'
|
|
161
|
+
if (reservedQuantity + 0.0001 < requiredQuantity) return 'partially_reserved'
|
|
162
|
+
return 'fully_reserved'
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function resolveReorderStatus(
|
|
166
|
+
availableQuantity: number,
|
|
167
|
+
profile: ProductInventoryProfile | null | undefined,
|
|
168
|
+
): ReorderStatus {
|
|
169
|
+
if (!profile) {
|
|
170
|
+
return {
|
|
171
|
+
state: 'no_profile',
|
|
172
|
+
available: formatQuantity(availableQuantity),
|
|
173
|
+
reorderPoint: '0',
|
|
174
|
+
safetyStock: '0',
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const reorderPoint = Number(profile.reorderPoint)
|
|
179
|
+
const safetyStock = Number(profile.safetyStock)
|
|
180
|
+
let state: ReorderState = 'healthy'
|
|
181
|
+
|
|
182
|
+
if (availableQuantity <= safetyStock) {
|
|
183
|
+
state = 'below_safety_stock'
|
|
184
|
+
} else if (availableQuantity <= reorderPoint) {
|
|
185
|
+
state = 'below_reorder_point'
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
state,
|
|
190
|
+
available: formatQuantity(availableQuantity),
|
|
191
|
+
reorderPoint: profile.reorderPoint,
|
|
192
|
+
safetyStock: profile.safetyStock,
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function buildBalanceSummaryByVariant(
|
|
197
|
+
balances: InventoryBalance[],
|
|
198
|
+
): Map<string, BalanceAggregate> {
|
|
199
|
+
const byVariant = new Map<string, BalanceAggregate>()
|
|
200
|
+
|
|
201
|
+
for (const balance of balances) {
|
|
202
|
+
const current = byVariant.get(balance.catalogVariantId) ?? {
|
|
203
|
+
onHand: 0,
|
|
204
|
+
reserved: 0,
|
|
205
|
+
allocated: 0,
|
|
206
|
+
available: 0,
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
current.onHand += Number(balance.quantityOnHand)
|
|
210
|
+
current.reserved += Number(balance.quantityReserved)
|
|
211
|
+
current.allocated += Number(balance.quantityAllocated)
|
|
212
|
+
current.available +=
|
|
213
|
+
Number(balance.quantityOnHand) - Number(balance.quantityReserved) - Number(balance.quantityAllocated)
|
|
214
|
+
|
|
215
|
+
byVariant.set(balance.catalogVariantId, current)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return byVariant
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function buildStockSummaryItem(
|
|
222
|
+
catalogVariantId: string,
|
|
223
|
+
aggregate: BalanceAggregate | undefined,
|
|
224
|
+
): StockSummaryItem {
|
|
225
|
+
return {
|
|
226
|
+
catalogVariantId,
|
|
227
|
+
onHand: formatQuantity(aggregate?.onHand ?? 0),
|
|
228
|
+
reserved: formatQuantity(aggregate?.reserved ?? 0),
|
|
229
|
+
allocated: formatQuantity(aggregate?.allocated ?? 0),
|
|
230
|
+
available: formatQuantity(aggregate?.available ?? 0),
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
async function isSalesOrderInventoryEnabled(context: EnricherContext): Promise<boolean> {
|
|
235
|
+
const container = context.container as { resolve?: (name: string) => unknown } | undefined
|
|
236
|
+
if (!container?.resolve) return true
|
|
237
|
+
try {
|
|
238
|
+
const featureTogglesService = container.resolve('featureTogglesService') as FeatureTogglesService | undefined
|
|
239
|
+
const em = container.resolve('em') as EntityManager | undefined
|
|
240
|
+
if (!featureTogglesService || !em) return true
|
|
241
|
+
return resolveWmsIntegrationToggleEnabled(
|
|
242
|
+
featureTogglesService,
|
|
243
|
+
em,
|
|
244
|
+
'wms_integration_sales_order_inventory',
|
|
245
|
+
context.tenantId,
|
|
246
|
+
)
|
|
247
|
+
} catch {
|
|
248
|
+
return true
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
async function loadExplicitAssignments(
|
|
253
|
+
em: EntityManager,
|
|
254
|
+
orderIds: string[],
|
|
255
|
+
scope: Scope,
|
|
256
|
+
): Promise<SalesOrderWarehouseAssignment[]> {
|
|
257
|
+
if (orderIds.length === 0) return []
|
|
258
|
+
return findWithDecryption(
|
|
259
|
+
em,
|
|
260
|
+
SalesOrderWarehouseAssignment,
|
|
261
|
+
{
|
|
262
|
+
salesOrderId: { $in: orderIds },
|
|
263
|
+
organizationId: scope.organizationId,
|
|
264
|
+
tenantId: scope.tenantId,
|
|
265
|
+
deletedAt: null,
|
|
266
|
+
},
|
|
267
|
+
undefined,
|
|
268
|
+
scope,
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async function loadWarehousesByIds(
|
|
273
|
+
em: EntityManager,
|
|
274
|
+
warehouseIds: string[],
|
|
275
|
+
scope: Scope,
|
|
276
|
+
): Promise<Warehouse[]> {
|
|
277
|
+
if (warehouseIds.length === 0) return []
|
|
278
|
+
return findWithDecryption(
|
|
279
|
+
em,
|
|
280
|
+
Warehouse,
|
|
281
|
+
{
|
|
282
|
+
id: { $in: warehouseIds },
|
|
283
|
+
organizationId: scope.organizationId,
|
|
284
|
+
tenantId: scope.tenantId,
|
|
285
|
+
deletedAt: null,
|
|
286
|
+
},
|
|
287
|
+
undefined,
|
|
288
|
+
scope,
|
|
289
|
+
)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
async function loadOrderLines(
|
|
293
|
+
context: EnricherContext,
|
|
294
|
+
orderIds: string[],
|
|
295
|
+
scope: Scope,
|
|
296
|
+
): Promise<SalesOrderLineRow[]> {
|
|
297
|
+
if (orderIds.length === 0) return []
|
|
298
|
+
// Read sales order lines via QueryEngine instead of importing the sales ORM
|
|
299
|
+
// entity. Keeps the WMS module decoupled from sales internals; queryEngine
|
|
300
|
+
// resolves the base table via Mikro-ORM metadata.
|
|
301
|
+
const container = context.container as { resolve: (name: string) => unknown }
|
|
302
|
+
const queryEngine = container.resolve('queryEngine') as QueryEngine
|
|
303
|
+
const result = await queryEngine.query<SalesOrderLineRow>(E.sales.sales_order_line, {
|
|
304
|
+
tenantId: scope.tenantId,
|
|
305
|
+
organizationId: scope.organizationId,
|
|
306
|
+
filters: { order_id: { $in: orderIds } },
|
|
307
|
+
fields: ['id', 'order_id', 'product_variant_id', 'quantity', 'line_number', 'status'],
|
|
308
|
+
sort: [{ field: 'line_number', dir: 'asc' as never }],
|
|
309
|
+
page: { page: 1, pageSize: 5000 },
|
|
310
|
+
})
|
|
311
|
+
return result.items
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
async function loadReservations(
|
|
315
|
+
em: EntityManager,
|
|
316
|
+
orderIds: string[],
|
|
317
|
+
scope: Scope,
|
|
318
|
+
): Promise<InventoryReservation[]> {
|
|
319
|
+
if (orderIds.length === 0) return []
|
|
320
|
+
return findWithDecryption(
|
|
321
|
+
em,
|
|
322
|
+
InventoryReservation,
|
|
323
|
+
{
|
|
324
|
+
sourceType: 'order',
|
|
325
|
+
sourceId: { $in: orderIds },
|
|
326
|
+
organizationId: scope.organizationId,
|
|
327
|
+
tenantId: scope.tenantId,
|
|
328
|
+
deletedAt: null,
|
|
329
|
+
},
|
|
330
|
+
{ orderBy: { createdAt: 'asc' } },
|
|
331
|
+
scope,
|
|
332
|
+
)
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
async function loadBalances(
|
|
336
|
+
em: EntityManager,
|
|
337
|
+
variantIds: string[],
|
|
338
|
+
scope: Scope,
|
|
339
|
+
): Promise<InventoryBalance[]> {
|
|
340
|
+
if (variantIds.length === 0) return []
|
|
341
|
+
return findWithDecryption(
|
|
342
|
+
em,
|
|
343
|
+
InventoryBalance,
|
|
344
|
+
{
|
|
345
|
+
catalogVariantId: { $in: variantIds },
|
|
346
|
+
organizationId: scope.organizationId,
|
|
347
|
+
tenantId: scope.tenantId,
|
|
348
|
+
deletedAt: null,
|
|
349
|
+
},
|
|
350
|
+
undefined,
|
|
351
|
+
scope,
|
|
352
|
+
)
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
async function loadCatalogVariants(
|
|
356
|
+
context: EnricherContext,
|
|
357
|
+
productIds: string[],
|
|
358
|
+
scope: Scope,
|
|
359
|
+
): Promise<CatalogVariantRow[]> {
|
|
360
|
+
if (productIds.length === 0) return []
|
|
361
|
+
const container = context.container as { resolve: (name: string) => unknown }
|
|
362
|
+
const queryEngine = container.resolve('queryEngine') as QueryEngine
|
|
363
|
+
const result = await queryEngine.query<CatalogVariantRow>(E.catalog.catalog_product_variant, {
|
|
364
|
+
tenantId: scope.tenantId,
|
|
365
|
+
organizationId: scope.organizationId,
|
|
366
|
+
filters: { product_id: { $in: productIds } },
|
|
367
|
+
fields: ['id', 'product_id'],
|
|
368
|
+
sort: [{ field: 'created_at', dir: 'asc' as never }],
|
|
369
|
+
page: { page: 1, pageSize: 5000 },
|
|
370
|
+
})
|
|
371
|
+
return result.items
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
async function loadProductInventoryProfiles(
|
|
375
|
+
em: EntityManager,
|
|
376
|
+
productIds: string[],
|
|
377
|
+
scope: Scope,
|
|
378
|
+
): Promise<ProductInventoryProfile[]> {
|
|
379
|
+
if (productIds.length === 0) return []
|
|
380
|
+
return findWithDecryption(
|
|
381
|
+
em,
|
|
382
|
+
ProductInventoryProfile,
|
|
383
|
+
{
|
|
384
|
+
catalogProductId: { $in: productIds },
|
|
385
|
+
catalogVariantId: null,
|
|
386
|
+
organizationId: scope.organizationId,
|
|
387
|
+
tenantId: scope.tenantId,
|
|
388
|
+
deletedAt: null,
|
|
389
|
+
},
|
|
390
|
+
undefined,
|
|
391
|
+
scope,
|
|
392
|
+
)
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
async function loadVariantInventoryProfiles(
|
|
396
|
+
em: EntityManager,
|
|
397
|
+
variantIds: string[],
|
|
398
|
+
scope: Scope,
|
|
399
|
+
): Promise<ProductInventoryProfile[]> {
|
|
400
|
+
if (variantIds.length === 0) return []
|
|
401
|
+
return findWithDecryption(
|
|
402
|
+
em,
|
|
403
|
+
ProductInventoryProfile,
|
|
404
|
+
{
|
|
405
|
+
catalogVariantId: { $in: variantIds },
|
|
406
|
+
organizationId: scope.organizationId,
|
|
407
|
+
tenantId: scope.tenantId,
|
|
408
|
+
deletedAt: null,
|
|
409
|
+
},
|
|
410
|
+
undefined,
|
|
411
|
+
scope,
|
|
412
|
+
)
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const salesOrderInventoryEnricher: ResponseEnricher<SalesOrderRecord, SalesOrderWmsEnrichment> = {
|
|
416
|
+
id: 'wms.sales-order-inventory',
|
|
417
|
+
targetEntity: E.sales.sales_order,
|
|
418
|
+
features: ['wms.view'],
|
|
419
|
+
priority: 40,
|
|
420
|
+
timeout: 2000,
|
|
421
|
+
fallback: EMPTY_ENRICHMENT,
|
|
422
|
+
|
|
423
|
+
async enrichOne(record, context: EnricherScope) {
|
|
424
|
+
return (await this.enrichMany!([record], context))[0]
|
|
425
|
+
},
|
|
426
|
+
|
|
427
|
+
async enrichMany(records, context: EnricherScope) {
|
|
428
|
+
if (records.length === 0) return records as Array<SalesOrderRecord & SalesOrderWmsEnrichment>
|
|
429
|
+
const enabled = await isSalesOrderInventoryEnabled(context)
|
|
430
|
+
if (!enabled) return records as Array<SalesOrderRecord & SalesOrderWmsEnrichment>
|
|
431
|
+
|
|
432
|
+
const orderIds = records
|
|
433
|
+
.map(extractRecordId)
|
|
434
|
+
.filter((value): value is string => Boolean(value))
|
|
435
|
+
|
|
436
|
+
if (orderIds.length === 0) {
|
|
437
|
+
return records.map((record) => ({ ...record, ...EMPTY_ENRICHMENT }))
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const em = context.em.fork()
|
|
441
|
+
const scope = { organizationId: context.organizationId, tenantId: context.tenantId }
|
|
442
|
+
|
|
443
|
+
const lines = await loadOrderLines(context, orderIds, scope)
|
|
444
|
+
|
|
445
|
+
const variantIds = Array.from(
|
|
446
|
+
new Set(
|
|
447
|
+
lines
|
|
448
|
+
.map((line) => line.product_variant_id)
|
|
449
|
+
.filter((value): value is string => typeof value === 'string' && value.length > 0),
|
|
450
|
+
),
|
|
451
|
+
)
|
|
452
|
+
|
|
453
|
+
const [reservations, balances, primaryWarehouseId, explicitAssignments] = await Promise.all([
|
|
454
|
+
loadReservations(em, orderIds, scope),
|
|
455
|
+
loadBalances(em, variantIds, scope),
|
|
456
|
+
resolvePrimaryWarehouseId(em, scope),
|
|
457
|
+
loadExplicitAssignments(em, orderIds, scope),
|
|
458
|
+
])
|
|
459
|
+
|
|
460
|
+
const explicitWarehouseIdsByOrder = new Map<string, string>()
|
|
461
|
+
for (const assignment of explicitAssignments) {
|
|
462
|
+
const warehouseRel = assignment.warehouse as { id?: string } | undefined
|
|
463
|
+
const warehouseId = warehouseRel?.id
|
|
464
|
+
if (warehouseId) {
|
|
465
|
+
explicitWarehouseIdsByOrder.set(assignment.salesOrderId, warehouseId)
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const reservationWarehouseIds = reservations
|
|
470
|
+
.map(extractWarehouseId)
|
|
471
|
+
.filter((value): value is string => typeof value === 'string' && value.length > 0)
|
|
472
|
+
const allRelevantWarehouseIds = Array.from(
|
|
473
|
+
new Set([
|
|
474
|
+
...Array.from(explicitWarehouseIdsByOrder.values()),
|
|
475
|
+
...reservationWarehouseIds,
|
|
476
|
+
...(primaryWarehouseId ? [primaryWarehouseId] : []),
|
|
477
|
+
]),
|
|
478
|
+
)
|
|
479
|
+
const warehouses = await loadWarehousesByIds(em, allRelevantWarehouseIds, scope)
|
|
480
|
+
const warehouseNamesById = new Map(warehouses.map((w) => [w.id, w.name]))
|
|
481
|
+
|
|
482
|
+
const variantAvailability = new Map<string, number>()
|
|
483
|
+
const variantReserved = new Map<string, number>()
|
|
484
|
+
for (const balance of balances) {
|
|
485
|
+
addToMap(
|
|
486
|
+
variantAvailability,
|
|
487
|
+
balance.catalogVariantId,
|
|
488
|
+
Number(balance.quantityOnHand) - Number(balance.quantityReserved) - Number(balance.quantityAllocated),
|
|
489
|
+
)
|
|
490
|
+
addToMap(variantReserved, balance.catalogVariantId, balance.quantityReserved)
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
const variantOrderBySalesOrder = new Map<string, string[]>()
|
|
494
|
+
const requiredBySalesOrder = new Map<string, number>()
|
|
495
|
+
|
|
496
|
+
for (const line of lines) {
|
|
497
|
+
const orderId = extractOrderIdFromLine(line)
|
|
498
|
+
const variantId = line.product_variant_id ?? null
|
|
499
|
+
if (!orderId || !variantId) continue
|
|
500
|
+
|
|
501
|
+
const variantOrder = variantOrderBySalesOrder.get(orderId) ?? []
|
|
502
|
+
if (!variantOrder.includes(variantId)) {
|
|
503
|
+
variantOrder.push(variantId)
|
|
504
|
+
variantOrderBySalesOrder.set(orderId, variantOrder)
|
|
505
|
+
}
|
|
506
|
+
requiredBySalesOrder.set(orderId, (requiredBySalesOrder.get(orderId) ?? 0) + Number(line.quantity))
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
const activeReservationsBySalesOrder = new Map<string, InventoryReservation[]>()
|
|
510
|
+
const reservedBySalesOrder = new Map<string, number>()
|
|
511
|
+
|
|
512
|
+
for (const reservation of reservations) {
|
|
513
|
+
if (reservation.status !== 'active') continue
|
|
514
|
+
const orderId = reservation.sourceId
|
|
515
|
+
const activeReservations = activeReservationsBySalesOrder.get(orderId) ?? []
|
|
516
|
+
activeReservations.push(reservation)
|
|
517
|
+
activeReservationsBySalesOrder.set(orderId, activeReservations)
|
|
518
|
+
reservedBySalesOrder.set(orderId, (reservedBySalesOrder.get(orderId) ?? 0) + Number(reservation.quantity))
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return records.map((record) => {
|
|
522
|
+
const orderId = extractRecordId(record)
|
|
523
|
+
if (!orderId) {
|
|
524
|
+
return { ...record, ...EMPTY_ENRICHMENT }
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
const reservationsForOrder = activeReservationsBySalesOrder.get(orderId) ?? []
|
|
528
|
+
const warehouseIds = Array.from(
|
|
529
|
+
new Set(
|
|
530
|
+
reservationsForOrder
|
|
531
|
+
.map(extractWarehouseId)
|
|
532
|
+
.filter((value): value is string => typeof value === 'string' && value.length > 0),
|
|
533
|
+
),
|
|
534
|
+
)
|
|
535
|
+
const variantIdsForOrder = variantOrderBySalesOrder.get(orderId) ?? []
|
|
536
|
+
|
|
537
|
+
const explicitWarehouseId = explicitWarehouseIdsByOrder.get(orderId) ?? null
|
|
538
|
+
const isExplicitlyAssigned = explicitWarehouseId !== null
|
|
539
|
+
|
|
540
|
+
let assignedWarehouseId: string | null
|
|
541
|
+
if (isExplicitlyAssigned) {
|
|
542
|
+
assignedWarehouseId = explicitWarehouseId
|
|
543
|
+
} else if (warehouseIds.length === 1) {
|
|
544
|
+
assignedWarehouseId = warehouseIds[0]
|
|
545
|
+
} else if (warehouseIds.length === 0 && primaryWarehouseId) {
|
|
546
|
+
assignedWarehouseId = primaryWarehouseId
|
|
547
|
+
} else {
|
|
548
|
+
assignedWarehouseId = null
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
const assignedWarehouseName = assignedWarehouseId
|
|
552
|
+
? (warehouseNamesById.get(assignedWarehouseId) ?? null)
|
|
553
|
+
: null
|
|
554
|
+
|
|
555
|
+
return {
|
|
556
|
+
...record,
|
|
557
|
+
_wms: {
|
|
558
|
+
assignedWarehouseId,
|
|
559
|
+
assignedWarehouseName,
|
|
560
|
+
isExplicitlyAssigned,
|
|
561
|
+
stockSummary: variantIdsForOrder.map((catalogVariantId) => ({
|
|
562
|
+
catalogVariantId,
|
|
563
|
+
available: formatQuantity(variantAvailability.get(catalogVariantId) ?? 0),
|
|
564
|
+
reserved: formatQuantity(variantReserved.get(catalogVariantId) ?? 0),
|
|
565
|
+
})),
|
|
566
|
+
reservationSummary: {
|
|
567
|
+
status: resolveReservationStatus(
|
|
568
|
+
requiredBySalesOrder.get(orderId) ?? 0,
|
|
569
|
+
reservedBySalesOrder.get(orderId) ?? 0,
|
|
570
|
+
),
|
|
571
|
+
reservationIds: reservationsForOrder.map((reservation) => reservation.id),
|
|
572
|
+
},
|
|
573
|
+
},
|
|
574
|
+
}
|
|
575
|
+
})
|
|
576
|
+
},
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
const catalogProductInventoryEnricher: ResponseEnricher<CatalogProductRecord, CatalogWmsEnrichment> = {
|
|
580
|
+
id: 'wms.catalog-product-inventory',
|
|
581
|
+
targetEntity: E.catalog.catalog_product,
|
|
582
|
+
features: ['wms.view'],
|
|
583
|
+
priority: 40,
|
|
584
|
+
timeout: 2000,
|
|
585
|
+
fallback: EMPTY_CATALOG_ENRICHMENT,
|
|
586
|
+
|
|
587
|
+
async enrichOne(record, context: EnricherScope) {
|
|
588
|
+
return (await this.enrichMany!([record], context))[0]
|
|
589
|
+
},
|
|
590
|
+
|
|
591
|
+
async enrichMany(records, context: EnricherScope) {
|
|
592
|
+
if (records.length === 0) return records as Array<CatalogProductRecord & CatalogWmsEnrichment>
|
|
593
|
+
|
|
594
|
+
const productIds = records
|
|
595
|
+
.map(extractRecordId)
|
|
596
|
+
.filter((value): value is string => Boolean(value))
|
|
597
|
+
|
|
598
|
+
if (productIds.length === 0) {
|
|
599
|
+
return records.map((record) => ({ ...record, ...EMPTY_CATALOG_ENRICHMENT }))
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
const em = context.em.fork()
|
|
603
|
+
const scope = { organizationId: context.organizationId, tenantId: context.tenantId }
|
|
604
|
+
|
|
605
|
+
const variants = await loadCatalogVariants(context, productIds, scope)
|
|
606
|
+
const variantIds = variants
|
|
607
|
+
.map((variant) => variant.id)
|
|
608
|
+
.filter((value): value is string => typeof value === 'string' && value.length > 0)
|
|
609
|
+
const [productProfiles, balances] = await Promise.all([
|
|
610
|
+
loadProductInventoryProfiles(em, productIds, scope),
|
|
611
|
+
loadBalances(em, variantIds, scope),
|
|
612
|
+
])
|
|
613
|
+
|
|
614
|
+
const profileByProductId = new Map(
|
|
615
|
+
productProfiles.map((profile) => [profile.catalogProductId, profile] as const),
|
|
616
|
+
)
|
|
617
|
+
const balanceByVariantId = buildBalanceSummaryByVariant(balances)
|
|
618
|
+
const variantIdsByProductId = new Map<string, string[]>()
|
|
619
|
+
|
|
620
|
+
for (const variant of variants) {
|
|
621
|
+
const productId = extractProductIdFromVariant(variant)
|
|
622
|
+
if (!productId || typeof variant.id !== 'string') continue
|
|
623
|
+
const entries = variantIdsByProductId.get(productId) ?? []
|
|
624
|
+
entries.push(variant.id)
|
|
625
|
+
variantIdsByProductId.set(productId, entries)
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
return records.map((record) => {
|
|
629
|
+
const productId = extractRecordId(record)
|
|
630
|
+
if (!productId) {
|
|
631
|
+
return { ...record, ...EMPTY_CATALOG_ENRICHMENT }
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
const profile = profileByProductId.get(productId) ?? null
|
|
635
|
+
const stockSummary = (variantIdsByProductId.get(productId) ?? []).map((variantId) =>
|
|
636
|
+
buildStockSummaryItem(variantId, balanceByVariantId.get(variantId)),
|
|
637
|
+
)
|
|
638
|
+
const totalAvailable = stockSummary.reduce(
|
|
639
|
+
(sum, item) => sum + Number(item.available),
|
|
640
|
+
0,
|
|
641
|
+
)
|
|
642
|
+
|
|
643
|
+
return {
|
|
644
|
+
...record,
|
|
645
|
+
_wms: {
|
|
646
|
+
inventoryProfile: profile ? toInventoryProfileSummary(profile) : null,
|
|
647
|
+
stockSummary,
|
|
648
|
+
reorderStatus: resolveReorderStatus(totalAvailable, profile),
|
|
649
|
+
},
|
|
650
|
+
}
|
|
651
|
+
})
|
|
652
|
+
},
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
const catalogVariantInventoryEnricher: ResponseEnricher<CatalogVariantRecord, CatalogWmsEnrichment> = {
|
|
656
|
+
id: 'wms.catalog-variant-inventory',
|
|
657
|
+
targetEntity: E.catalog.catalog_product_variant,
|
|
658
|
+
features: ['wms.view'],
|
|
659
|
+
priority: 40,
|
|
660
|
+
timeout: 2000,
|
|
661
|
+
fallback: EMPTY_CATALOG_ENRICHMENT,
|
|
662
|
+
|
|
663
|
+
async enrichOne(record, context: EnricherScope) {
|
|
664
|
+
return (await this.enrichMany!([record], context))[0]
|
|
665
|
+
},
|
|
666
|
+
|
|
667
|
+
async enrichMany(records, context: EnricherScope) {
|
|
668
|
+
if (records.length === 0) return records as Array<CatalogVariantRecord & CatalogWmsEnrichment>
|
|
669
|
+
|
|
670
|
+
const variantIds = records
|
|
671
|
+
.map(extractRecordId)
|
|
672
|
+
.filter((value): value is string => Boolean(value))
|
|
673
|
+
|
|
674
|
+
if (variantIds.length === 0) {
|
|
675
|
+
return records.map((record) => ({ ...record, ...EMPTY_CATALOG_ENRICHMENT }))
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
const em = context.em.fork()
|
|
679
|
+
const scope = { organizationId: context.organizationId, tenantId: context.tenantId }
|
|
680
|
+
|
|
681
|
+
const [profiles, balances] = await Promise.all([
|
|
682
|
+
loadVariantInventoryProfiles(em, variantIds, scope),
|
|
683
|
+
loadBalances(em, variantIds, scope),
|
|
684
|
+
])
|
|
685
|
+
|
|
686
|
+
const profileByVariantId = new Map(
|
|
687
|
+
profiles
|
|
688
|
+
.filter((profile): profile is ProductInventoryProfile & { catalogVariantId: string } => typeof profile.catalogVariantId === 'string')
|
|
689
|
+
.map((profile) => [profile.catalogVariantId, profile] as const),
|
|
690
|
+
)
|
|
691
|
+
const balanceByVariantId = buildBalanceSummaryByVariant(balances)
|
|
692
|
+
|
|
693
|
+
return records.map((record) => {
|
|
694
|
+
const variantId = extractRecordId(record)
|
|
695
|
+
if (!variantId) {
|
|
696
|
+
return { ...record, ...EMPTY_CATALOG_ENRICHMENT }
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
const profile = profileByVariantId.get(variantId) ?? null
|
|
700
|
+
const stockSummary = [buildStockSummaryItem(variantId, balanceByVariantId.get(variantId))]
|
|
701
|
+
|
|
702
|
+
return {
|
|
703
|
+
...record,
|
|
704
|
+
_wms: {
|
|
705
|
+
inventoryProfile: profile ? toInventoryProfileSummary(profile) : null,
|
|
706
|
+
stockSummary,
|
|
707
|
+
reorderStatus: resolveReorderStatus(Number(stockSummary[0]?.available ?? 0), profile),
|
|
708
|
+
},
|
|
709
|
+
}
|
|
710
|
+
})
|
|
711
|
+
},
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
export const enrichers: ResponseEnricher[] = [
|
|
715
|
+
salesOrderInventoryEnricher,
|
|
716
|
+
catalogProductInventoryEnricher,
|
|
717
|
+
catalogVariantInventoryEnricher,
|
|
718
|
+
]
|