Skip to main content
Version: v1.0.0(int)

W117: Add item to purchase order

Appends a new line to an existing PO. Triggered from the Purchase Order Detail items section.

Steps

  1. Load the PO. Call PurchaseOrders.getPoById to confirm existence and read targetType and status.

  2. Assert editable. 409 when any receipt exists against the PO — line items are locked once goods have been received (same rule as WO items, W134-W136).

  3. Validate the catalog reference. Confirm the referenced material or SKU exists in this org, matches targetType, and is active.

  4. Insert the line. Call PurchaseOrders.addItem with quantity and unit cost.

  5. Project the new line. Run the status → ledger reconciliation projector for just this line — past Planning it books the line's ORDER; Planning/Cancelled book nothing.

Returns

The new line.

Business rules

  • Items are locked once a receipt exists. Receipts roll header costs up from the lines; editing partly-received orders would corrupt the math.
  • Catalog must match targetType. A materials PO accepts only materials; an FG PO accepts only SKUs.
  • Active references only. Soft-deleted materials or SKUs cannot be added.

Errors

  • NotFoundError. The PO, material, or SKU was not found.
  • ConflictError. A receipt exists against the PO.
  • ValidationError. The referenced catalog mismatches the PO's target type.