Add Line to Order.
Description¶
- When an order line is added to an order from a Kanban Card, The Line takes the values of the current version of the Item referenced by the Kanban Card.
-
When an order line is added as a blank line, the UI will present the user with an editable field to select the Item:
- The selector shows a list, alphabetically ordered by the name of the items for the tenant that have the same vendor (matching by supplier name) as the order. If no vendor is specified for the order, all items are shown.
- The user can start typing the name of the item and the list will be filtered to match the text at the start of the item name ignoring the spelling case. (in a future version, a more flexible matching mechanism will be supported)
- The user can either select an item from the list (via up/down arrows and
enteror mouse click), or continue typing the name of the item until it is complete and pressenter. - If the item name matches an existing item, the line is filled with the values of the current version of the item.
- If the item name does not match any existing item, a modal allows the user to confirm the creation of a new item with that name and optionally other values provided by the user. If the user cancels out of this modal, the system should revert to the field being edited to allow the user to make changes to the name or select another existing item.
- Line Order items can also be uploaded in bulk from a CSV file. In this case, if the Item name provided matches exactly (up to case insensitivity) the name of an item in the tenant, then that item will be selected. Otherwise, the line will be marked as
INVALIDand must be edited by the user before approval or submission of the order, resulting in either adding a new item to the system or assigning an existing item to the line.
Requirement¶
Provide an API that appends a single OrderLine to an existing order, updating the persisted record and invoking any supplied post-processing callbacks.
Implementation entry point: OrderRecordService.addLine (operations/src/main/kotlin/cards/arda/operations/procurement/orders/service/OrderRecordService.kt).
Preconditions¶
- The target order (identified either by
eId+asOfor byrId) must exist; otherwise the service replies withArgumentValidation(OrderRecordService.kt:152-167,173-186). - When the incoming line references an Item (
linePayload.item.eId), the item lookup must succeed at the requested coordinates; if it no longer exists the system keeps the original payload but does not fail (OrderRecordService.kt:156-164). - There is no explicit validation of supplier compatibility in this operation; incompatible data is left to downstream validation or workflow steps.
Scenario Overview¶
- The service loads the parent order snapshot for the provided coordinates.
- If the incoming line references an Item, the latest version is fetched and
OrderHelper.adjustLineenriches missing fields such astitle,quantity,unitCost, andreceivedusing the order’ssupplierName(operations/src/main/kotlin/cards/arda/operations/procurement/orders/service/OrderHelper.kt:354-374). - The adjusted (or original) payload is inserted through
OrderLineUniverse.add, respecting the optionalinsertionindex (OrderHelper.kt:381-394). - The caller-provided
postProcesscallback is invoked; its failure halts the transaction (OrderHelper.kt:392-393).
PostConditions¶
- The new
OrderLineversion is persisted and returned to the caller wrapped in anEntityRecord. - The parent
OrderHeaderis not automatically rebalanced (e.g. goods value, supplier) by this operation; additional orchestration must be invoked when needed. - When
postProcessraises an error, the transaction aborts and the error is propagated without committing the line.
Creation of Order Lines¶
Lines are persisted exactly as supplied (after optional enrichment via adjustLine). Bulk CSV handling and item name matching described in legacy UI flows are not implemented at the service layer.
Changes to Order Header¶
None. Header adjustments (supplier selection, goods value recomputation, etc.) remain the responsibility of higher-level orchestration such as OrderHelper.adjustHeader.