Fluent Commerce Logo
Docs

Fulfillment Options Utils

Essential knowledge

Intended Audience:

Technical User

Author:

Kirill Gaiduk

Changed on:

9 July 2026

Overview

The `FulfilmentOptionsUtils` class in the `util-sourcing` library creates `FulfilmentPlan` records for Fulfillment Options from a `SourcingPlan`It captures the proposed fulfillment options, available quantities, and optional ETA values, helping rules present calculated sourcing outcomes without recreating fulfillment-plan mapping logic.

Key points

  • Fulfillment Plan Creation: Persists a `SourcingPlan` as a `FulfilmentPlan` under the fulfillment option entity
  • ETA Calculation: Accepts an optional `EtaCalculator` to calculate and set ETA on the plan and on each individual fulfillment. When no `EtaCalculator` is provided, ETA fields are omitted
  • Available Quantity: Each `FulfilmentItem` in the plan records the available quantity at the sourcing location at the time of plan generation

Core Methods

`createFulfilmentPlan()`
Persists a `SourcingPlan` as a `FulfilmentPlan` under the fulfillment option entity.
  • Returns early without action if `context`, `plan`, or `sourcingContext` is `null`, or if the plan contains no fulfillments
  • Each item includes `productRef`, `requestedQuantity`, and `availableQuantity`
  • If an `EtaCalculator` is provided, ETA is calculated and set for the plan and for each fulfillment separately
1// With ETA calculation
2EtaCalculator etaCalculator = (sourcingPlan, fulfilment) -> {
3    // Calculate and return ETA for the given fulfilment
4    return ZonedDateTime.now().plusDays(3);
5};
6
7FulfilmentOptionsUtils.createFulfilmentPlan(context, sourcingPlan, sourcingContext, etaCalculator);
8
9// Without ETA calculation
10FulfilmentOptionsUtils.createFulfilmentPlan(context, sourcingPlan, sourcingContext, null);