Skip to content

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:

    1. 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.
    2. 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)
    3. The user can either select an item from the list (via up/down arrows and enter or mouse click), or continue typing the name of the item until it is complete and press enter.
    4. If the item name matches an existing item, the line is filled with the values of the current version of the item.
    5. 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 INVALID and 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 + asOf or by rId) must exist; otherwise the service replies with ArgumentValidation (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

  1. The service loads the parent order snapshot for the provided coordinates.
  2. If the incoming line references an Item, the latest version is fetched and OrderHelper.adjustLine enriches missing fields such as title, quantity, unitCost, and received using the order’s supplierName (operations/src/main/kotlin/cards/arda/operations/procurement/orders/service/OrderHelper.kt:354-374).
  3. The adjusted (or original) payload is inserted through OrderLineUniverse.add, respecting the optional insertion index (OrderHelper.kt:381-394).
  4. The caller-provided postProcess callback is invoked; its failure halts the transaction (OrderHelper.kt:392-393).

PostConditions

  • The new OrderLine version is persisted and returned to the caller wrapped in an EntityRecord.
  • The parent OrderHeader is not automatically rebalanced (e.g. goods value, supplier) by this operation; additional orchestration must be invoked when needed.
  • When postProcess raises 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.

Comments