@open-mercato/core 0.6.7-develop.6669.1.40b669666b → 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/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,98 @@
|
|
|
1
|
+
import type { QueryEngine } from '@open-mercato/shared/lib/query/types'
|
|
2
|
+
import { E } from '#generated/entities.ids.generated'
|
|
3
|
+
import { resolveNotificationService } from '../../notifications/lib/notificationService'
|
|
4
|
+
import { buildFeatureNotificationFromType } from '../../notifications/lib/notificationBuilder'
|
|
5
|
+
import { notificationTypes } from '../notifications'
|
|
6
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
7
|
+
|
|
8
|
+
const logger = createLogger('wms')
|
|
9
|
+
|
|
10
|
+
export const metadata = {
|
|
11
|
+
event: 'wms.inventory.reservation_shortfall',
|
|
12
|
+
persistent: true,
|
|
13
|
+
id: 'wms:reservation-shortfall-notification',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type ShortfallLine = {
|
|
17
|
+
catalogVariantId: string
|
|
18
|
+
requiredQuantity: number
|
|
19
|
+
reservedQuantity: number
|
|
20
|
+
shortfallQuantity: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type ShortfallPayload = {
|
|
24
|
+
orderId: string
|
|
25
|
+
orderNumber?: string | null
|
|
26
|
+
shortfalls: ShortfallLine[]
|
|
27
|
+
tenantId: string
|
|
28
|
+
organizationId?: string | null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type ResolverContext = {
|
|
32
|
+
resolve: <T = unknown>(name: string) => T
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function resolveShortfallSku(
|
|
36
|
+
ctx: ResolverContext,
|
|
37
|
+
catalogVariantId: string,
|
|
38
|
+
organizationId: string | null | undefined,
|
|
39
|
+
tenantId: string,
|
|
40
|
+
): Promise<string> {
|
|
41
|
+
try {
|
|
42
|
+
const queryEngine = ctx.resolve<QueryEngine>('queryEngine')
|
|
43
|
+
const result = await queryEngine.query(E.catalog.catalog_product_variant, {
|
|
44
|
+
tenantId,
|
|
45
|
+
organizationId: organizationId ?? undefined,
|
|
46
|
+
filters: { id: { $eq: catalogVariantId } },
|
|
47
|
+
fields: ['id', 'sku', 'name'],
|
|
48
|
+
page: { page: 1, pageSize: 1 },
|
|
49
|
+
})
|
|
50
|
+
const row = result.items?.[0] as { sku?: string | null; name?: string | null } | undefined
|
|
51
|
+
const sku = typeof row?.sku === 'string' ? row.sku.trim() : ''
|
|
52
|
+
if (sku) return sku
|
|
53
|
+
const name = typeof row?.name === 'string' ? row.name.trim() : ''
|
|
54
|
+
if (name) return name
|
|
55
|
+
} catch {
|
|
56
|
+
// fall through to variant id
|
|
57
|
+
}
|
|
58
|
+
return catalogVariantId
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default async function handle(payload: ShortfallPayload, ctx: ResolverContext) {
|
|
62
|
+
try {
|
|
63
|
+
const notificationService = resolveNotificationService(ctx)
|
|
64
|
+
const typeDef = notificationTypes.find((type) => type.type === 'wms.inventory.reservation_shortfall')
|
|
65
|
+
if (!typeDef) return
|
|
66
|
+
|
|
67
|
+
const primaryShortfall = payload.shortfalls[0]
|
|
68
|
+
const shortfallSku = primaryShortfall
|
|
69
|
+
? await resolveShortfallSku(
|
|
70
|
+
ctx,
|
|
71
|
+
primaryShortfall.catalogVariantId,
|
|
72
|
+
payload.organizationId,
|
|
73
|
+
payload.tenantId,
|
|
74
|
+
)
|
|
75
|
+
: ''
|
|
76
|
+
const shortfallQuantity = primaryShortfall ? String(primaryShortfall.shortfallQuantity) : '0'
|
|
77
|
+
const notificationInput = buildFeatureNotificationFromType(typeDef, {
|
|
78
|
+
requiredFeature: 'wms.view',
|
|
79
|
+
bodyVariables: {
|
|
80
|
+
orderNumber: payload.orderNumber ?? payload.orderId,
|
|
81
|
+
shortfallCount: String(payload.shortfalls.length),
|
|
82
|
+
shortfallSku,
|
|
83
|
+
shortfallQuantity,
|
|
84
|
+
shortfallVariantId: primaryShortfall?.catalogVariantId ?? '',
|
|
85
|
+
},
|
|
86
|
+
sourceEntityType: 'sales:order',
|
|
87
|
+
sourceEntityId: payload.orderId,
|
|
88
|
+
linkHref: `/backend/sales/orders/${encodeURIComponent(payload.orderId)}`,
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
await notificationService.createForFeature(notificationInput, {
|
|
92
|
+
tenantId: payload.tenantId,
|
|
93
|
+
organizationId: payload.organizationId ?? null,
|
|
94
|
+
})
|
|
95
|
+
} catch (error) {
|
|
96
|
+
logger.error('Failed to create notification', { subscriber: 'reservation-shortfall-notification', err: error })
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { releaseInventoryForCancelledOrder } from '../lib/salesOrderInventoryAutomation'
|
|
2
|
+
|
|
3
|
+
export const metadata = {
|
|
4
|
+
event: 'sales.order.cancelled',
|
|
5
|
+
persistent: true,
|
|
6
|
+
id: 'wms:sales-order-cancelled-release',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type SubscriberContext = {
|
|
10
|
+
resolve: <T = unknown>(name: string) => T
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type SalesOrderCancelledPayload = {
|
|
14
|
+
orderId?: string | null
|
|
15
|
+
tenantId?: string | null
|
|
16
|
+
organizationId?: string | null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default async function handle(payload: SalesOrderCancelledPayload, ctx: SubscriberContext) {
|
|
20
|
+
await releaseInventoryForCancelledOrder(payload, ctx)
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { reserveInventoryForConfirmedOrder } from '../lib/salesOrderInventoryAutomation'
|
|
2
|
+
|
|
3
|
+
export const metadata = {
|
|
4
|
+
event: 'sales.order.confirmed',
|
|
5
|
+
persistent: true,
|
|
6
|
+
id: 'wms:sales-order-confirmed-reserve',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type SubscriberContext = {
|
|
10
|
+
resolve: <T = unknown>(name: string) => T
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type SalesOrderConfirmedPayload = {
|
|
14
|
+
orderId?: string | null
|
|
15
|
+
tenantId?: string | null
|
|
16
|
+
organizationId?: string | null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default async function handle(payload: SalesOrderConfirmedPayload, ctx: SubscriberContext) {
|
|
20
|
+
await reserveInventoryForConfirmedOrder(payload, ctx)
|
|
21
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import type { InjectionFieldWidget } from '@open-mercato/shared/modules/widgets/injection'
|
|
2
|
+
import {
|
|
3
|
+
encodeCatalogInventoryProfileIntent,
|
|
4
|
+
WMS_CATALOG_PROFILE_HEADER,
|
|
5
|
+
type CatalogInventoryProfileIntent,
|
|
6
|
+
} from '../../../lib/catalogInventoryProfileIntent'
|
|
7
|
+
|
|
8
|
+
type RecordLike = Record<string, unknown>
|
|
9
|
+
|
|
10
|
+
function asRecord(value: unknown): RecordLike | null {
|
|
11
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return null
|
|
12
|
+
return value as RecordLike
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function readString(value: unknown): string {
|
|
16
|
+
return typeof value === 'string' ? value : ''
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function readBoolean(value: unknown): boolean {
|
|
20
|
+
return value === true
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function readNumber(value: unknown): number | undefined {
|
|
24
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value
|
|
25
|
+
if (typeof value === 'string' && value.trim().length > 0) {
|
|
26
|
+
const parsed = Number(value)
|
|
27
|
+
if (Number.isFinite(parsed)) return parsed
|
|
28
|
+
}
|
|
29
|
+
return undefined
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function buildIntent(data: RecordLike): CatalogInventoryProfileIntent {
|
|
33
|
+
return {
|
|
34
|
+
manageInventory: readBoolean(data['wms.manageInventory']),
|
|
35
|
+
defaultUom: readString(data['wms.defaultUom']).trim() || null,
|
|
36
|
+
defaultStrategy: (() => {
|
|
37
|
+
const strategy = readString(data['wms.defaultStrategy']).trim()
|
|
38
|
+
return strategy === 'fifo' || strategy === 'lifo' || strategy === 'fefo'
|
|
39
|
+
? strategy
|
|
40
|
+
: undefined
|
|
41
|
+
})(),
|
|
42
|
+
trackLot: readBoolean(data['wms.trackLot']),
|
|
43
|
+
trackSerial: readBoolean(data['wms.trackSerial']),
|
|
44
|
+
trackExpiration: readBoolean(data['wms.trackExpiration']),
|
|
45
|
+
reorderPoint: readNumber(data['wms.reorderPoint']) ?? 0,
|
|
46
|
+
safetyStock: readNumber(data['wms.safetyStock']) ?? 0,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function buildDisplayState(data: RecordLike): RecordLike {
|
|
51
|
+
const wms = asRecord(data._wms)
|
|
52
|
+
const inventoryProfile = asRecord(wms?.inventoryProfile)
|
|
53
|
+
const fallbackDefaultUom = readString(data.defaultUnit).trim()
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
...data,
|
|
57
|
+
'wms.manageInventory': Boolean(inventoryProfile),
|
|
58
|
+
'wms.defaultUom':
|
|
59
|
+
readString(inventoryProfile?.defaultUom).trim() ||
|
|
60
|
+
fallbackDefaultUom,
|
|
61
|
+
'wms.defaultStrategy':
|
|
62
|
+
readString(inventoryProfile?.defaultStrategy).trim() || 'fifo',
|
|
63
|
+
'wms.trackLot': readBoolean(inventoryProfile?.trackLot),
|
|
64
|
+
'wms.trackSerial': readBoolean(inventoryProfile?.trackSerial),
|
|
65
|
+
'wms.trackExpiration': readBoolean(inventoryProfile?.trackExpiration),
|
|
66
|
+
'wms.reorderPoint':
|
|
67
|
+
readNumber(inventoryProfile?.reorderPoint) ?? 0,
|
|
68
|
+
'wms.safetyStock':
|
|
69
|
+
readNumber(inventoryProfile?.safetyStock) ?? 0,
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const visibleWhenManaged = {
|
|
74
|
+
field: 'wms.manageInventory',
|
|
75
|
+
operator: 'eq' as const,
|
|
76
|
+
value: true,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const widget: InjectionFieldWidget = {
|
|
80
|
+
metadata: {
|
|
81
|
+
id: 'wms.injection.catalog-inventory-profile',
|
|
82
|
+
priority: 120,
|
|
83
|
+
features: ['wms.manage_inventory'],
|
|
84
|
+
},
|
|
85
|
+
fields: [
|
|
86
|
+
{
|
|
87
|
+
id: 'wms.manageInventory',
|
|
88
|
+
label: 'Manage inventory with WMS',
|
|
89
|
+
labelKey: 'wms.widgets.catalog.inventoryProfile.manageInventory',
|
|
90
|
+
type: 'boolean',
|
|
91
|
+
group: 'wms.inventoryProfile',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: 'wms.defaultUom',
|
|
95
|
+
label: 'Default UOM',
|
|
96
|
+
labelKey: 'wms.widgets.catalog.inventoryProfile.defaultUom',
|
|
97
|
+
type: 'text',
|
|
98
|
+
group: 'wms.inventoryProfile',
|
|
99
|
+
visibleWhen: visibleWhenManaged,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: 'wms.defaultStrategy',
|
|
103
|
+
label: 'Rotation strategy',
|
|
104
|
+
labelKey: 'wms.widgets.catalog.inventoryProfile.defaultStrategy',
|
|
105
|
+
type: 'select',
|
|
106
|
+
group: 'wms.inventoryProfile',
|
|
107
|
+
visibleWhen: visibleWhenManaged,
|
|
108
|
+
options: [
|
|
109
|
+
{
|
|
110
|
+
value: 'fifo',
|
|
111
|
+
label: 'FIFO',
|
|
112
|
+
labelKey: 'wms.widgets.catalog.inventoryProfile.strategy.fifo',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
value: 'lifo',
|
|
116
|
+
label: 'LIFO',
|
|
117
|
+
labelKey: 'wms.widgets.catalog.inventoryProfile.strategy.lifo',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
value: 'fefo',
|
|
121
|
+
label: 'FEFO',
|
|
122
|
+
labelKey: 'wms.widgets.catalog.inventoryProfile.strategy.fefo',
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: 'wms.trackLot',
|
|
128
|
+
label: 'Track lots',
|
|
129
|
+
labelKey: 'wms.widgets.catalog.inventoryProfile.trackLot',
|
|
130
|
+
type: 'boolean',
|
|
131
|
+
group: 'wms.inventoryProfile',
|
|
132
|
+
visibleWhen: visibleWhenManaged,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: 'wms.trackSerial',
|
|
136
|
+
label: 'Track serials',
|
|
137
|
+
labelKey: 'wms.widgets.catalog.inventoryProfile.trackSerial',
|
|
138
|
+
type: 'boolean',
|
|
139
|
+
group: 'wms.inventoryProfile',
|
|
140
|
+
visibleWhen: visibleWhenManaged,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: 'wms.trackExpiration',
|
|
144
|
+
label: 'Track expiration',
|
|
145
|
+
labelKey: 'wms.widgets.catalog.inventoryProfile.trackExpiration',
|
|
146
|
+
type: 'boolean',
|
|
147
|
+
group: 'wms.inventoryProfile',
|
|
148
|
+
visibleWhen: visibleWhenManaged,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: 'wms.reorderPoint',
|
|
152
|
+
label: 'Reorder point',
|
|
153
|
+
labelKey: 'wms.widgets.catalog.inventoryProfile.reorderPoint',
|
|
154
|
+
type: 'number',
|
|
155
|
+
group: 'wms.inventoryProfile',
|
|
156
|
+
visibleWhen: visibleWhenManaged,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: 'wms.safetyStock',
|
|
160
|
+
label: 'Safety stock',
|
|
161
|
+
labelKey: 'wms.widgets.catalog.inventoryProfile.safetyStock',
|
|
162
|
+
type: 'number',
|
|
163
|
+
group: 'wms.inventoryProfile',
|
|
164
|
+
visibleWhen: visibleWhenManaged,
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
eventHandlers: {
|
|
168
|
+
async transformDisplayData(data) {
|
|
169
|
+
const source = asRecord(data)
|
|
170
|
+
if (!source) return data
|
|
171
|
+
return buildDisplayState(source) as typeof data
|
|
172
|
+
},
|
|
173
|
+
async onBeforeSave(data) {
|
|
174
|
+
const source = asRecord(data)
|
|
175
|
+
if (!source) return { ok: true }
|
|
176
|
+
|
|
177
|
+
const intent = buildIntent(source)
|
|
178
|
+
if (!intent.manageInventory) {
|
|
179
|
+
return {
|
|
180
|
+
ok: true,
|
|
181
|
+
requestHeaders: {
|
|
182
|
+
[WMS_CATALOG_PROFILE_HEADER]:
|
|
183
|
+
encodeCatalogInventoryProfileIntent(intent),
|
|
184
|
+
},
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const fieldErrors: Record<string, string> = {}
|
|
189
|
+
if (!intent.defaultUom) {
|
|
190
|
+
fieldErrors['wms.defaultUom'] =
|
|
191
|
+
'wms.widgets.catalog.inventoryProfile.errors.defaultUomRequired'
|
|
192
|
+
}
|
|
193
|
+
if (!intent.defaultStrategy) {
|
|
194
|
+
fieldErrors['wms.defaultStrategy'] =
|
|
195
|
+
'wms.widgets.catalog.inventoryProfile.errors.strategyRequired'
|
|
196
|
+
}
|
|
197
|
+
if (
|
|
198
|
+
intent.trackExpiration &&
|
|
199
|
+
intent.defaultStrategy &&
|
|
200
|
+
intent.defaultStrategy !== 'fefo'
|
|
201
|
+
) {
|
|
202
|
+
fieldErrors['wms.defaultStrategy'] =
|
|
203
|
+
'wms.widgets.catalog.inventoryProfile.errors.fefoRequired'
|
|
204
|
+
}
|
|
205
|
+
if (
|
|
206
|
+
typeof intent.reorderPoint === 'number' &&
|
|
207
|
+
intent.reorderPoint < 0
|
|
208
|
+
) {
|
|
209
|
+
fieldErrors['wms.reorderPoint'] =
|
|
210
|
+
'wms.widgets.catalog.inventoryProfile.errors.nonNegative'
|
|
211
|
+
}
|
|
212
|
+
if (
|
|
213
|
+
typeof intent.safetyStock === 'number' &&
|
|
214
|
+
intent.safetyStock < 0
|
|
215
|
+
) {
|
|
216
|
+
fieldErrors['wms.safetyStock'] =
|
|
217
|
+
'wms.widgets.catalog.inventoryProfile.errors.nonNegative'
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (Object.keys(fieldErrors).length > 0) {
|
|
221
|
+
return {
|
|
222
|
+
ok: false,
|
|
223
|
+
fieldErrors,
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return {
|
|
228
|
+
ok: true,
|
|
229
|
+
requestHeaders: {
|
|
230
|
+
[WMS_CATALOG_PROFILE_HEADER]:
|
|
231
|
+
encodeCatalogInventoryProfileIntent(intent),
|
|
232
|
+
},
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export default widget
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import type { InjectionColumnWidget } from '@open-mercato/shared/modules/widgets/injection'
|
|
5
|
+
import { apiCall } from '@open-mercato/ui/backend/utils/apiCall'
|
|
6
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
7
|
+
import { useOrderItemsInjectionContext } from '@open-mercato/core/modules/sales/widgets/injection/order-items-context'
|
|
8
|
+
|
|
9
|
+
type WmsStockEntry = {
|
|
10
|
+
catalogVariantId: string
|
|
11
|
+
available: string
|
|
12
|
+
reserved: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type WmsOrderListResponse = {
|
|
16
|
+
items?: Array<{
|
|
17
|
+
_wms?: {
|
|
18
|
+
stockSummary?: WmsStockEntry[]
|
|
19
|
+
}
|
|
20
|
+
}>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const CACHE_TTL_MS = 60_000
|
|
24
|
+
|
|
25
|
+
type CacheEntry = {
|
|
26
|
+
data: WmsStockEntry[]
|
|
27
|
+
fetchedAt: number
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const orderStockCache = new Map<string, CacheEntry>()
|
|
31
|
+
const pendingFetches = new Map<string, Promise<void>>()
|
|
32
|
+
|
|
33
|
+
function getCachedStock(documentId: string): WmsStockEntry[] | null {
|
|
34
|
+
const entry = orderStockCache.get(documentId)
|
|
35
|
+
if (!entry) return null
|
|
36
|
+
if (Date.now() - entry.fetchedAt > CACHE_TTL_MS) {
|
|
37
|
+
orderStockCache.delete(documentId)
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
40
|
+
return entry.data
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function fetchOrderStock(documentId: string): Promise<void> {
|
|
44
|
+
if (getCachedStock(documentId) !== null) return
|
|
45
|
+
if (pendingFetches.has(documentId)) return pendingFetches.get(documentId)
|
|
46
|
+
|
|
47
|
+
const promise = apiCall<WmsOrderListResponse>(`/api/sales/orders?id=${documentId}`)
|
|
48
|
+
.then((res) => {
|
|
49
|
+
const summary = res.result?.items?.[0]?._wms?.stockSummary ?? []
|
|
50
|
+
orderStockCache.set(documentId, { data: summary, fetchedAt: Date.now() })
|
|
51
|
+
})
|
|
52
|
+
.catch(() => {
|
|
53
|
+
orderStockCache.set(documentId, { data: [], fetchedAt: Date.now() })
|
|
54
|
+
})
|
|
55
|
+
.finally(() => {
|
|
56
|
+
pendingFetches.delete(documentId)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
pendingFetches.set(documentId, promise)
|
|
60
|
+
return promise
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function WmsOrderItemStockCell({ getValue }: { getValue: () => unknown }) {
|
|
64
|
+
const t = useT()
|
|
65
|
+
const ctx = useOrderItemsInjectionContext()
|
|
66
|
+
const variantId = getValue() as string | null
|
|
67
|
+
|
|
68
|
+
const [stock, setStock] = React.useState<WmsStockEntry | null | undefined>(
|
|
69
|
+
() => {
|
|
70
|
+
if (!variantId || !ctx?.documentId) return undefined
|
|
71
|
+
const summary = getCachedStock(ctx.documentId)
|
|
72
|
+
if (!summary) return undefined
|
|
73
|
+
return summary.find((e) => e.catalogVariantId === variantId) ?? null
|
|
74
|
+
},
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
React.useEffect(() => {
|
|
78
|
+
if (!variantId || !ctx?.documentId) return
|
|
79
|
+
const documentId = ctx.documentId
|
|
80
|
+
|
|
81
|
+
const cached = getCachedStock(documentId)
|
|
82
|
+
if (cached) {
|
|
83
|
+
setStock(cached.find((e) => e.catalogVariantId === variantId) ?? null)
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let cancelled = false
|
|
88
|
+
void fetchOrderStock(documentId).then(() => {
|
|
89
|
+
if (cancelled) return
|
|
90
|
+
const summary = getCachedStock(documentId) ?? []
|
|
91
|
+
setStock(summary.find((e) => e.catalogVariantId === variantId) ?? null)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
return () => {
|
|
95
|
+
cancelled = true
|
|
96
|
+
}
|
|
97
|
+
}, [variantId, ctx?.documentId])
|
|
98
|
+
|
|
99
|
+
if (!variantId || ctx?.kind !== 'order') return null
|
|
100
|
+
|
|
101
|
+
if (stock === undefined) {
|
|
102
|
+
return (
|
|
103
|
+
<span className="text-xs text-muted-foreground">
|
|
104
|
+
{t('wms.widgets.sales.orderItems.stockColumn.loading', '…')}
|
|
105
|
+
</span>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (stock === null) {
|
|
110
|
+
return (
|
|
111
|
+
<span className="text-xs text-muted-foreground">
|
|
112
|
+
{t('wms.widgets.sales.orderItems.stockColumn.noData', '—')}
|
|
113
|
+
</span>
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<div className="flex flex-col gap-0.5 text-xs">
|
|
119
|
+
<span className="font-medium tabular-nums">
|
|
120
|
+
{stock.available}{' '}
|
|
121
|
+
<span className="font-normal text-muted-foreground">
|
|
122
|
+
{t('wms.widgets.sales.orderItems.stockColumn.available', 'avail.')}
|
|
123
|
+
</span>
|
|
124
|
+
</span>
|
|
125
|
+
{Number(stock.reserved) > 0 && (
|
|
126
|
+
<span className="text-muted-foreground tabular-nums">
|
|
127
|
+
{stock.reserved}{' '}
|
|
128
|
+
{t('wms.widgets.sales.orderItems.stockColumn.reserved', 'reserved')}
|
|
129
|
+
</span>
|
|
130
|
+
)}
|
|
131
|
+
</div>
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const widget: InjectionColumnWidget = {
|
|
136
|
+
metadata: {
|
|
137
|
+
id: 'wms.injection.order-items-stock-column',
|
|
138
|
+
priority: 50,
|
|
139
|
+
features: ['wms.view'],
|
|
140
|
+
},
|
|
141
|
+
columns: [
|
|
142
|
+
{
|
|
143
|
+
id: 'wms_warehouse_stock',
|
|
144
|
+
headerKey: 'wms.widgets.sales.orderItems.stockColumn.header',
|
|
145
|
+
header: 'Warehouse Stock',
|
|
146
|
+
accessorKey: 'productVariantId',
|
|
147
|
+
sortable: false,
|
|
148
|
+
cell: WmsOrderItemStockCell,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default widget
|