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.supplieror$.secondarySupply.supplier.
Behavior Assumptions¶
- If two supplies have the same
$.suppliervalue, they are assumed to be the same supply and one of them will be taken arbitrarily by the system.
Scenario Overview¶
- User selects a set of
Itemsin the Item List view and triggers theCreate Order from Itemsaction. - System will verify all selected Items are current and have at least a shared Supply as defined by
$.primarySupply.supplieror$.secondarySupply.supplier.- If no shared Supply is found, the system will return an error to the User.
- 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
$.primarySupplyamong the
selected Items. - System will create and persist:
- An
OrderHeaderwith the information for the shared Supply selected in step 3, in stateOrderStatus.NEW. - A list of
OrderLineswith one line per selected Item.
- An
- System returns the created
OrderHeaderand associatedOrderLinesto the User for further editing.
PostConditions¶
OrderHeader¶
The newly created OrderHeader will have the following values:
eId: Generated by the system usingUUID.randomUUID().status:OrderStatus.NEWorderNumber: A sequential value generated by the system with the pattern:PO-######, which in the future will be configurable.orderDate: Set to the current date in the User Preferences Time Zone or the system default Time Zone.allowPartial: trueexpedite: falsedeliverBy:orderDate+ 1 weekdeliveryAddress:nullprocurement:nullsupplierName: The name of the selected sharedSupply.supplierwithin the list of Items, or null if no supplier is available.supplierAddress: nullorderMethod: The assigned Supply’s order method if it is common across all items,OrderMethod.UNKNOWNotherwise.sales: nullgoodsValue: Calculated as the sum of thecostfield of all created Order Lines withnullvalues considered0.
If thecurrencyfields of thecostvalues are not the same for all lines, this value will benull.taxesAndFees: empty map.termsAndConditions: nullnotes: nullprivateNotes: 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:
- The Supply whose
supplierfield matches thedefaultSupplyfield of the Item. - If no Supply matches the
defaultSupply, theprimarySupplyif notnull. - If
primarySupplyisnull, thesecondarySupplyif notnull. null
The supplierName in the Header is selected as:
- If there is a single Supply that is shared across all Items with
non-nullpreferredSupply, that Supply’ssupplierNameis assigned. - If there are multiple shared Supplies, the one with the highest nummber of appearances as
preferredSupplyis selected. - If no shared Supply is found, the
supplierNameis set to null if all Items havepreferredSupplyasnull. 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:
eId: Generated by the system usingUUID.randomUUID().title: Thenameor theskuof the Item based on the preferred vendor selected in the OrderHeader.description: thedescriptionof the associated Item.status: OrderLineStatus.BLANKitem: AnItemReferencefrom the associated item.supplierSku: Theskuof the selected Supply for the Item.quantity: TheorderQuantityof the selected Supply for the Item.unitCost: TheunitCostof the selected Supply for the Item.cost: Calculated asquantity.amount * unitCostin the currency of theunitCost.nullif eitherquantityorunitCostare null.received: 0 with units equal to the `quantity.unit.notes: nullprivateNotes: null