@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,346 @@
|
|
|
1
|
+
import type { CommandHandler } from '@open-mercato/shared/lib/commands'
|
|
2
|
+
import { registerCommand } from '@open-mercato/shared/lib/commands'
|
|
3
|
+
import type { CommandRuntimeContext } from '@open-mercato/shared/lib/commands'
|
|
4
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
5
|
+
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
6
|
+
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
7
|
+
import { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'
|
|
8
|
+
import { extractUndoPayload } from '@open-mercato/shared/lib/commands/undo'
|
|
9
|
+
import { SalesOrderWarehouseAssignment, Warehouse } from '../data/entities'
|
|
10
|
+
import type { SalesOrderWarehouseAssignInput, SalesOrderWarehouseUnassignInput } from '../data/validators'
|
|
11
|
+
import { z } from 'zod'
|
|
12
|
+
import { reserveInventoryForConfirmedOrder } from '../lib/salesOrderInventoryAutomation'
|
|
13
|
+
import { ensureOrganizationScope, ensureTenantScope } from './shared'
|
|
14
|
+
|
|
15
|
+
type AssignmentSnapshot = {
|
|
16
|
+
id: string
|
|
17
|
+
salesOrderId: string
|
|
18
|
+
warehouseId: string
|
|
19
|
+
notes: string | null
|
|
20
|
+
organizationId: string
|
|
21
|
+
tenantId: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type AssignWarehouseUndoPayload = {
|
|
25
|
+
before: AssignmentSnapshot | null
|
|
26
|
+
after: AssignmentSnapshot | null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type UnassignWarehouseUndoPayload = {
|
|
30
|
+
before: AssignmentSnapshot | null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function resolveScope(
|
|
34
|
+
ctx: CommandRuntimeContext,
|
|
35
|
+
fallback?: { tenantId?: string | null; organizationId?: string | null },
|
|
36
|
+
) {
|
|
37
|
+
return {
|
|
38
|
+
tenantId: fallback?.tenantId ?? ctx.auth?.tenantId ?? null,
|
|
39
|
+
organizationId: fallback?.organizationId ?? ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null,
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function resolveEm(ctx: CommandRuntimeContext): EntityManager {
|
|
44
|
+
return (ctx.container.resolve('em') as EntityManager).fork()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function loadAssignment(
|
|
48
|
+
em: EntityManager,
|
|
49
|
+
salesOrderId: string,
|
|
50
|
+
scope: ReturnType<typeof resolveScope>,
|
|
51
|
+
): Promise<SalesOrderWarehouseAssignment | null> {
|
|
52
|
+
if (!scope.organizationId || !scope.tenantId) return null
|
|
53
|
+
return findOneWithDecryption(
|
|
54
|
+
em,
|
|
55
|
+
SalesOrderWarehouseAssignment,
|
|
56
|
+
{
|
|
57
|
+
salesOrderId,
|
|
58
|
+
organizationId: scope.organizationId,
|
|
59
|
+
tenantId: scope.tenantId,
|
|
60
|
+
deletedAt: null,
|
|
61
|
+
},
|
|
62
|
+
undefined,
|
|
63
|
+
scope as { organizationId: string; tenantId: string },
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function snapshotAssignment(
|
|
68
|
+
assignment: SalesOrderWarehouseAssignment | null,
|
|
69
|
+
): AssignmentSnapshot | null {
|
|
70
|
+
if (!assignment) return null
|
|
71
|
+
const warehouseRel = assignment.warehouse as { id?: string } | undefined
|
|
72
|
+
const warehouseId = warehouseRel?.id ?? ''
|
|
73
|
+
return {
|
|
74
|
+
id: assignment.id,
|
|
75
|
+
salesOrderId: assignment.salesOrderId,
|
|
76
|
+
warehouseId,
|
|
77
|
+
notes: assignment.notes ?? null,
|
|
78
|
+
organizationId: assignment.organizationId,
|
|
79
|
+
tenantId: assignment.tenantId,
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const assignWarehouseHandler: CommandHandler<
|
|
84
|
+
SalesOrderWarehouseAssignInput,
|
|
85
|
+
{ assignmentId: string; warehouseId: string }
|
|
86
|
+
> = {
|
|
87
|
+
id: 'wms.sales-order.assign-warehouse',
|
|
88
|
+
|
|
89
|
+
prepare: async (input, ctx) => {
|
|
90
|
+
const scope = resolveScope(ctx, input)
|
|
91
|
+
const em = resolveEm(ctx)
|
|
92
|
+
const existing = await loadAssignment(em, input.salesOrderId, scope)
|
|
93
|
+
return { before: snapshotAssignment(existing) }
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
execute: async (input, ctx) => {
|
|
97
|
+
const scope = resolveScope(ctx, input)
|
|
98
|
+
if (!scope.tenantId || !scope.organizationId) {
|
|
99
|
+
throw new CrudHttpError(401, { error: 'Unauthorized' })
|
|
100
|
+
}
|
|
101
|
+
const em = resolveEm(ctx)
|
|
102
|
+
|
|
103
|
+
const warehouse = await findOneWithDecryption(
|
|
104
|
+
em,
|
|
105
|
+
Warehouse,
|
|
106
|
+
{
|
|
107
|
+
id: input.warehouseId,
|
|
108
|
+
organizationId: scope.organizationId,
|
|
109
|
+
tenantId: scope.tenantId,
|
|
110
|
+
deletedAt: null,
|
|
111
|
+
},
|
|
112
|
+
undefined,
|
|
113
|
+
scope as { organizationId: string; tenantId: string },
|
|
114
|
+
)
|
|
115
|
+
if (!warehouse) throw new CrudHttpError(404, { error: 'Warehouse not found.' })
|
|
116
|
+
ensureTenantScope(ctx, warehouse.tenantId)
|
|
117
|
+
ensureOrganizationScope(ctx, warehouse.organizationId)
|
|
118
|
+
if (!warehouse.isActive) throw new CrudHttpError(422, { error: 'Warehouse is inactive.' })
|
|
119
|
+
|
|
120
|
+
const existing = await loadAssignment(em, input.salesOrderId, scope)
|
|
121
|
+
|
|
122
|
+
if (existing) {
|
|
123
|
+
existing.warehouse = warehouse
|
|
124
|
+
existing.notes = input.notes ?? null
|
|
125
|
+
existing.assignedBy = ctx.auth?.sub ?? null
|
|
126
|
+
existing.updatedAt = new Date()
|
|
127
|
+
await em.flush()
|
|
128
|
+
return { assignmentId: existing.id, warehouseId: warehouse.id }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const assignment = em.create(SalesOrderWarehouseAssignment, {
|
|
132
|
+
salesOrderId: input.salesOrderId,
|
|
133
|
+
warehouse,
|
|
134
|
+
organizationId: scope.organizationId,
|
|
135
|
+
tenantId: scope.tenantId,
|
|
136
|
+
assignedBy: ctx.auth?.sub ?? null,
|
|
137
|
+
notes: input.notes ?? null,
|
|
138
|
+
})
|
|
139
|
+
em.persist(assignment)
|
|
140
|
+
await em.flush()
|
|
141
|
+
return { assignmentId: assignment.id, warehouseId: warehouse.id }
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
captureAfter: async (input, _result, ctx) => {
|
|
145
|
+
const scope = resolveScope(ctx, input)
|
|
146
|
+
const em = resolveEm(ctx)
|
|
147
|
+
const updated = await loadAssignment(em, input.salesOrderId, scope)
|
|
148
|
+
return { after: snapshotAssignment(updated) }
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
buildLog: async ({ input, result, ctx, snapshots }) => {
|
|
152
|
+
const { translate } = await resolveTranslations()
|
|
153
|
+
return {
|
|
154
|
+
actionLabel: translate('wms.audit.salesOrder.assignWarehouse', 'Assign warehouse to order'),
|
|
155
|
+
resourceKind: 'wms.sales_order_warehouse_assignment',
|
|
156
|
+
resourceId: result?.assignmentId ?? null,
|
|
157
|
+
tenantId: input?.tenantId ?? ctx.auth?.tenantId ?? null,
|
|
158
|
+
organizationId: input?.organizationId ?? ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null,
|
|
159
|
+
payload: {
|
|
160
|
+
undo: {
|
|
161
|
+
before: (snapshots as { before?: AssignmentSnapshot | null })?.before ?? null,
|
|
162
|
+
after: (snapshots as { after?: AssignmentSnapshot | null })?.after ?? null,
|
|
163
|
+
} satisfies AssignWarehouseUndoPayload,
|
|
164
|
+
},
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
undo: async ({ logEntry, ctx }) => {
|
|
169
|
+
const payload = extractUndoPayload<AssignWarehouseUndoPayload>(logEntry)
|
|
170
|
+
if (!payload) return
|
|
171
|
+
const em = resolveEm(ctx)
|
|
172
|
+
|
|
173
|
+
const after = payload.after
|
|
174
|
+
const before = payload.before
|
|
175
|
+
|
|
176
|
+
if (after) {
|
|
177
|
+
const scope = { tenantId: after.tenantId, organizationId: after.organizationId }
|
|
178
|
+
const assignment = await findOneWithDecryption(
|
|
179
|
+
em,
|
|
180
|
+
SalesOrderWarehouseAssignment,
|
|
181
|
+
{ id: after.id, organizationId: after.organizationId, tenantId: after.tenantId },
|
|
182
|
+
undefined,
|
|
183
|
+
scope,
|
|
184
|
+
)
|
|
185
|
+
if (!assignment) return
|
|
186
|
+
|
|
187
|
+
if (!before) {
|
|
188
|
+
assignment.deletedAt = new Date()
|
|
189
|
+
await em.flush()
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const previousWarehouse = await findOneWithDecryption(
|
|
194
|
+
em,
|
|
195
|
+
Warehouse,
|
|
196
|
+
{
|
|
197
|
+
id: before.warehouseId,
|
|
198
|
+
organizationId: scope.organizationId,
|
|
199
|
+
tenantId: scope.tenantId,
|
|
200
|
+
deletedAt: null,
|
|
201
|
+
},
|
|
202
|
+
undefined,
|
|
203
|
+
scope,
|
|
204
|
+
)
|
|
205
|
+
if (!previousWarehouse) {
|
|
206
|
+
assignment.deletedAt = new Date()
|
|
207
|
+
await em.flush()
|
|
208
|
+
return
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
assignment.warehouse = previousWarehouse
|
|
212
|
+
assignment.notes = before.notes ?? null
|
|
213
|
+
await em.flush()
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const unassignWarehouseHandler: CommandHandler<
|
|
219
|
+
SalesOrderWarehouseUnassignInput,
|
|
220
|
+
{ ok: true }
|
|
221
|
+
> = {
|
|
222
|
+
id: 'wms.sales-order.unassign-warehouse',
|
|
223
|
+
|
|
224
|
+
prepare: async (input, ctx) => {
|
|
225
|
+
const scope = resolveScope(ctx, input)
|
|
226
|
+
const em = resolveEm(ctx)
|
|
227
|
+
const existing = await loadAssignment(em, input.salesOrderId, scope)
|
|
228
|
+
return { before: snapshotAssignment(existing) }
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
execute: async (input, ctx) => {
|
|
232
|
+
const scope = resolveScope(ctx, input)
|
|
233
|
+
if (!scope.tenantId || !scope.organizationId) {
|
|
234
|
+
throw new CrudHttpError(401, { error: 'Unauthorized' })
|
|
235
|
+
}
|
|
236
|
+
const em = resolveEm(ctx)
|
|
237
|
+
const existing = await loadAssignment(em, input.salesOrderId, scope)
|
|
238
|
+
|
|
239
|
+
if (existing) {
|
|
240
|
+
existing.deletedAt = new Date()
|
|
241
|
+
await em.flush()
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return { ok: true as const }
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
buildLog: async ({ input, ctx, snapshots }) => {
|
|
248
|
+
const { translate } = await resolveTranslations()
|
|
249
|
+
const before = (snapshots as { before?: AssignmentSnapshot | null })?.before ?? null
|
|
250
|
+
return {
|
|
251
|
+
actionLabel: translate('wms.audit.salesOrder.unassignWarehouse', 'Remove warehouse assignment from order'),
|
|
252
|
+
resourceKind: 'wms.sales_order_warehouse_assignment',
|
|
253
|
+
resourceId: before?.id ?? null,
|
|
254
|
+
tenantId: input?.tenantId ?? ctx.auth?.tenantId ?? null,
|
|
255
|
+
organizationId: input?.organizationId ?? ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null,
|
|
256
|
+
payload: {
|
|
257
|
+
undo: { before } satisfies UnassignWarehouseUndoPayload,
|
|
258
|
+
},
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
undo: async ({ logEntry, ctx }) => {
|
|
263
|
+
const payload = extractUndoPayload<UnassignWarehouseUndoPayload>(logEntry)
|
|
264
|
+
const before = payload?.before
|
|
265
|
+
if (!before?.salesOrderId || !before.warehouseId) return
|
|
266
|
+
|
|
267
|
+
const scope = { tenantId: before.tenantId, organizationId: before.organizationId }
|
|
268
|
+
const em = resolveEm(ctx)
|
|
269
|
+
|
|
270
|
+
const existingDeleted = await findOneWithDecryption(
|
|
271
|
+
em,
|
|
272
|
+
SalesOrderWarehouseAssignment,
|
|
273
|
+
{ id: before.id, organizationId: before.organizationId, tenantId: before.tenantId },
|
|
274
|
+
undefined,
|
|
275
|
+
scope,
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
if (existingDeleted) {
|
|
279
|
+
existingDeleted.deletedAt = null
|
|
280
|
+
await em.flush()
|
|
281
|
+
return
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const warehouse = await findOneWithDecryption(
|
|
285
|
+
em,
|
|
286
|
+
Warehouse,
|
|
287
|
+
{
|
|
288
|
+
id: before.warehouseId,
|
|
289
|
+
organizationId: before.organizationId,
|
|
290
|
+
tenantId: before.tenantId,
|
|
291
|
+
deletedAt: null,
|
|
292
|
+
},
|
|
293
|
+
undefined,
|
|
294
|
+
scope,
|
|
295
|
+
)
|
|
296
|
+
if (!warehouse) return
|
|
297
|
+
|
|
298
|
+
const restored = em.create(SalesOrderWarehouseAssignment, {
|
|
299
|
+
salesOrderId: before.salesOrderId,
|
|
300
|
+
warehouse,
|
|
301
|
+
organizationId: before.organizationId,
|
|
302
|
+
tenantId: before.tenantId,
|
|
303
|
+
notes: before.notes ?? null,
|
|
304
|
+
})
|
|
305
|
+
em.persist(restored)
|
|
306
|
+
await em.flush()
|
|
307
|
+
},
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
registerCommand(assignWarehouseHandler)
|
|
311
|
+
registerCommand(unassignWarehouseHandler)
|
|
312
|
+
|
|
313
|
+
export const reRunReservationInputSchema = z.object({
|
|
314
|
+
salesOrderId: z.string().uuid(),
|
|
315
|
+
organizationId: z.string().uuid(),
|
|
316
|
+
tenantId: z.string().uuid(),
|
|
317
|
+
})
|
|
318
|
+
export type ReRunReservationInput = z.infer<typeof reRunReservationInputSchema>
|
|
319
|
+
|
|
320
|
+
const reRunReservationHandler: CommandHandler<ReRunReservationInput, { ok: boolean }> = {
|
|
321
|
+
id: 'wms.sales-order.re-run-reservation',
|
|
322
|
+
isUndoable: false,
|
|
323
|
+
async execute(rawInput, ctx) {
|
|
324
|
+
const input = reRunReservationInputSchema.parse(rawInput)
|
|
325
|
+
const eventCtx = {
|
|
326
|
+
resolve: <T>(name: string) => ctx.container.resolve<T>(name),
|
|
327
|
+
}
|
|
328
|
+
await reserveInventoryForConfirmedOrder(
|
|
329
|
+
{ orderId: input.salesOrderId, tenantId: input.tenantId, organizationId: input.organizationId },
|
|
330
|
+
eventCtx,
|
|
331
|
+
)
|
|
332
|
+
return { ok: true }
|
|
333
|
+
},
|
|
334
|
+
async buildLog({ input, ctx }) {
|
|
335
|
+
const { translate } = await resolveTranslations()
|
|
336
|
+
return {
|
|
337
|
+
actionLabel: translate('wms.audit.salesOrder.reRunReservation', 'Re-run reservation for order'),
|
|
338
|
+
resourceKind: 'wms.sales_order_reservation',
|
|
339
|
+
resourceId: input?.salesOrderId ?? null,
|
|
340
|
+
tenantId: input?.tenantId ?? ctx.auth?.tenantId ?? null,
|
|
341
|
+
organizationId: input?.organizationId ?? ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null,
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
registerCommand(reRunReservationHandler)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { CommandRuntimeContext } from '@open-mercato/shared/lib/commands'
|
|
2
|
+
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
3
|
+
import { ensureOrganizationScope } from '@open-mercato/shared/lib/commands/scope'
|
|
4
|
+
import type { CrudIndexerConfig, CrudEventsConfig } from '@open-mercato/shared/lib/crud/types'
|
|
5
|
+
import { E } from '#generated/entities.ids.generated'
|
|
6
|
+
import {
|
|
7
|
+
InventoryBalance,
|
|
8
|
+
InventoryMovement,
|
|
9
|
+
InventoryReservation,
|
|
10
|
+
} from '../data/entities'
|
|
11
|
+
|
|
12
|
+
export function ensureTenantScope(ctx: CommandRuntimeContext, tenantId: string): void {
|
|
13
|
+
const currentTenant = ctx.auth?.tenantId ?? null
|
|
14
|
+
if (currentTenant && currentTenant !== tenantId) {
|
|
15
|
+
throw new CrudHttpError(403, { error: 'Forbidden' })
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function requireId(id: string | null | undefined, label: string): string {
|
|
20
|
+
if (typeof id === 'string' && id.trim().length > 0) return id.trim()
|
|
21
|
+
throw new CrudHttpError(400, { error: `${label} id is required.` })
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function normalizeOptionalString(value: string | null | undefined): string | null {
|
|
25
|
+
if (typeof value !== 'string') return null
|
|
26
|
+
const trimmed = value.trim()
|
|
27
|
+
return trimmed.length > 0 ? trimmed : null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function toNumericString(value: number | string | null | undefined, fallback = '0'): string {
|
|
31
|
+
if (typeof value === 'string' && value.trim().length > 0) return value.trim()
|
|
32
|
+
if (typeof value === 'number' && Number.isFinite(value)) return String(value)
|
|
33
|
+
return fallback
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// CRUD indexer configs — used by emitCrudSideEffects to drive query_index updates.
|
|
37
|
+
// Cache invalidation cross-aliases (e.g. balance lists invalidated when a reservation mutates)
|
|
38
|
+
// are declared in command-level metadata.context.cacheAliases so the command bus picks them up.
|
|
39
|
+
export const inventoryBalanceCrudIndexer: CrudIndexerConfig<InventoryBalance> = {
|
|
40
|
+
entityType: E.wms.inventory_balance,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const inventoryReservationCrudIndexer: CrudIndexerConfig<InventoryReservation> = {
|
|
44
|
+
entityType: E.wms.inventory_reservation,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const inventoryMovementCrudIndexer: CrudIndexerConfig<InventoryMovement> = {
|
|
48
|
+
entityType: E.wms.inventory_movement,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const inventoryBalanceCrudEvents: CrudEventsConfig<InventoryBalance> = {
|
|
52
|
+
module: 'wms',
|
|
53
|
+
entity: 'inventory_balance',
|
|
54
|
+
persistent: true,
|
|
55
|
+
buildPayload: (ctx) => ({
|
|
56
|
+
id: ctx.identifiers.id,
|
|
57
|
+
organizationId: ctx.identifiers.organizationId,
|
|
58
|
+
tenantId: ctx.identifiers.tenantId,
|
|
59
|
+
}),
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const inventoryReservationCrudEvents: CrudEventsConfig<InventoryReservation> = {
|
|
63
|
+
module: 'wms',
|
|
64
|
+
entity: 'inventory_reservation',
|
|
65
|
+
persistent: true,
|
|
66
|
+
buildPayload: (ctx) => ({
|
|
67
|
+
id: ctx.identifiers.id,
|
|
68
|
+
organizationId: ctx.identifiers.organizationId,
|
|
69
|
+
tenantId: ctx.identifiers.tenantId,
|
|
70
|
+
}),
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const inventoryMovementCrudEvents: CrudEventsConfig<InventoryMovement> = {
|
|
74
|
+
module: 'wms',
|
|
75
|
+
entity: 'inventory_movement',
|
|
76
|
+
persistent: true,
|
|
77
|
+
buildPayload: (ctx) => ({
|
|
78
|
+
id: ctx.identifiers.id,
|
|
79
|
+
organizationId: ctx.identifiers.organizationId,
|
|
80
|
+
tenantId: ctx.identifiers.tenantId,
|
|
81
|
+
}),
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Cache alias resource kinds used to extend command-level cache invalidation
|
|
85
|
+
// when a single mutation impacts multiple list resources.
|
|
86
|
+
export const WMS_INVENTORY_BALANCE_RESOURCE = 'wms.inventoryBalance'
|
|
87
|
+
export const WMS_INVENTORY_RESERVATION_RESOURCE = 'wms.inventoryReservation'
|
|
88
|
+
export const WMS_INVENTORY_MOVEMENT_RESOURCE = 'wms.inventoryMovement'
|
|
89
|
+
|
|
90
|
+
export { ensureOrganizationScope }
|