Skip to content

Order from List of Items.

Description

Allow Users to create an Order from a list of selected Items given by their eId identifiers and the values active at the time (Bitemporal Coordinates) of
the PO creation.

Requirement

Given a list of Items given by their eId identifiers and the Bitemporal Coordinates for Order Creation, the system will create an
OrderHeader
and a list of OrderLines (one per Item), persist them and return the Header and Order Lines to the User for further action (e.g. edit, submit, etc.).

Preconditions

Validations (Return error if not met)
  • All selected Items must have not been deleted at the time of Order Creation.
  • All selected Items must have at least one shared Supply as defined by $.primarySupply.supplier or $.secondarySupply.supplier.
Behavior Assumptions
  • If two supplies have the same $.supplier value, they are assumed to be the same supply and one of them will be taken arbitrarily by the system.

Scenario Overview

  1. User selects a set of Items in the Item List view and triggers the Create Order from Items action.
  2. System will verify all selected Items are current and have at least a shared Supply as defined by $.primarySupply.supplier or $.secondarySupply.supplier.
    • If no shared Supply is found, the system will return an error to the User.
  3. If there is more than one shared Supply (at most 2 at this time 20251028), the system selects the Supply with the highest number of mentions as $.primarySupply among the
    selected Items.
  4. System will create and persist:
    • An OrderHeader with the information for the shared Supply selected in step 3, in state OrderStatus.NEW.
    • A list of OrderLines with one line per selected Item.
  5. System returns the created OrderHeader and associated OrderLines to the User for further editing.

PostConditions

OrderHeader

The newly created OrderHeader will have the following values:

  1. eId: Generated by the system using UUID.randomUUID().
  2. status: OrderStatus.NEW
  3. orderNumber: A sequential value generated by the system with the pattern: PO-######, which in the future will be configurable.
  4. orderDate: Set to the current date in the User Preferences Time Zone or the system default Time Zone.
  5. allowPartial: true
  6. expedite: false
  7. deliverBy: orderDate + 1 week
  8. deliveryAddress: null
  9. procurement: null
  10. supplierName: The name of the selected shared Supply.supplier within the list of Items, or null if no supplier is available.
  11. supplierAddress: null
  12. orderMethod: The assigned Supply’s order method if it is common across all items, OrderMethod.UNKNOWN otherwise.
  13. sales: null
  14. goodsValue: Calculated as the sum of the cost field of all created Order Lines with null values considered 0.
    If the currency fields of the cost values are not the same for all lines, this value will be null.
  15. taxesAndFees: empty map.
  16. termsAndConditions: null
  17. notes: null
  18. privateNotes: null

Note

The deliverBy date could be computed based on the lines effectiveSupply.leadTime values
for simplicity of first implementation, it is set to a constant 1 Week delay.

Supplier Selection for OrderLines and OrderHeader

Each OrderLine has a preferredSupply that is determined as:

  1. The Supply whose supplier field matches the defaultSupply field of the Item.
  2. If no Supply matches the defaultSupply, the primarySupply if not null.
  3. If primarySupply is null, the secondarySupply if not null.
  4. null

The supplierName in the Header is selected as:

  1. If there is a single Supply that is shared across all Items with non-null preferredSupply, that Supply’s supplierName is assigned.
  2. If there are multiple shared Supplies, the one with the highest nummber of appearances as preferredSupply is selected.
  3. If no shared Supply is found, the supplierName is set to null if all Items have preferredSupply as null. Otherwise, an error is returned.

The Values selected for each Order Line are based on the ItemSupply that corresponds to the selected Supply for the OrderHeader.

Order Lines

Order Lines will be created with the following field values:

  1. eId: Generated by the system using UUID.randomUUID().
  2. title: The name or the sku of the Item based on the preferred vendor selected in the OrderHeader.
  3. description: the description of the associated Item.
  4. status: OrderLineStatus.BLANK
  5. item: An ItemReference from the associated item.
  6. supplierSku: The sku of the selected Supply for the Item.
  7. quantity: The orderQuantity of the selected Supply for the Item.
  8. unitCost: The unitCost of the selected Supply for the Item.
  9. cost: Calculated as quantity.amount * unitCost in the currency of the unitCost. null if either quantity or unitCost are null.
  10. received: 0 with units equal to the `quantity.unit.
  11. notes: null
  12. privateNotes: null

Comments