Add Lines from Items.
Description¶
The user can select a set of Items from the Item List and create a Purchase Order with PoLines for each selected item. The user can then edit the Order as in the previous cases.
- The creation will fail if the selected items don’t have a shared vendor (blank primary and secondary suppliers is considered a match with any other item).
- The Quantities of the
PoLineswill be set to theminQuantityof the item if available or0 eachesotherwise.
Requirement¶
Create an order (header + lines) from a caller-supplied list of Item identifiers.
Implementation entry point: OrderFromItemsService.addOrderFromItems (operations/src/main/kotlin/cards/arda/operations/procurement/orders/service/OrderFromItemsService.kt).
Preconditions¶
- The
itemscollection must contain at least one entry and cannot exceedLineUniverse.MAX_PAGE_SIZE(currently1000); otherwise anArgumentValidationerror is returned (OrderFromItemsService.kt:29-33,60-73). - Every requested Item must exist at
TimeCoordinates.now(effectiveTime); missing items result in aNotFounderror before any persistence (OrderFromItemsService.kt:74-84). - Items must share a compatible supplier according to
OrderHelper.selectCompatibleSupply; if no shared supplier exists among items that have a preferred supply, the call fails withIllegalArgumentException(operations/src/main/kotlin/cards/arda/operations/procurement/orders/service/OrderHelper.kt:134-147).
Scenario Overview¶
- Load all requested Items via
ItemService.listEntities. Items are processed as of the effective timestamp specified (OrderFromItemsService.kt:74-84). - Build draft order lines by calling
OrderHelper.composeLinefor each item, producing placeholder lines with generatedeIds (OrderFromItemsService.kt:85-87). - Compose a provisional header with defaults (
OrderStatus.NEW,allowPartial=true,deliverBy = now + 7 days, etc.) usingOrderHelper.composeHeader(operations/src/main/kotlin/cards/arda/operations/procurement/orders/service/OrderHelper.kt:261-283). - Enrich every line with supplier-driven details (title, quantity, unit cost) via
OrderHelper.adjustLine, and recompute the header (supplier, goods value) throughOrderHelper.adjustHeader(OrderFromItemsService.kt:88-91). - Persist the header and lines in a single transaction with
OrderHelper.addOrderWithLines, invoking any suppliedpostProcesscallback after persistence (OrderFromItemsService.kt:92-93).
PostConditions¶
- A new
OrderRecord(header plus paginated lines) is stored and returned on success. - Goods value is derived from the enriched line costs when supplier data is available; otherwise it remains
null. - No Kanban card associations are created by this flow.
Creation of Order Lines¶
- Each line references the selected item through
ItemReference.Value.fromItem. - Quantities default to the supplier’s reorder quantity when available; when not, they remain
null. The implementation does not useItem.minQuantity, contrary to earlier plans. - Unit cost is copied from the effective supply without verifying unit compatibility (the service assumes
OrderHelper.adjustLineproduced a coherent quantity).
Changes to Order Header¶
supplierNameis derived from the compatible supplier returned byselectCompatibleSupply; if none is found the field remainsnull.orderMethodreflects the shared effective supply method when consistent, orOrderMethod.UNKNOWNotherwise (OrderHelper.kt:165-176).goodsValueis recomputed from enriched lines duringadjustHeader; if any line references an item missing supply data, the goods value may remainnull.