Outsourced purchase orders

An outsourced purchase order (PO) buys products a subcontractor makes from your own ingredients. Its recipe rows say which ingredients the subcontractor uses; assign them batches, serial numbers and bins, and receiving the products takes exactly those out of stock.

This guide continues the bike workshop from Receiving purchase orders. The workshop orders 5 Wheel kits (variant 24890301) from a subcontractor. Each kit is assembled from 1 Hub motor and 1 Chain, taken from the parts the workshop has in stock in the Main warehouse.

Before you start

  • The Wheel kit has a recipe: 1 Hub motor and 1 Chain per kit.
  • The ingredients are in stock at the location that tracks them: hub motors HM-0001 to HM-0006 and chain batch CH-2610 (3871301) in the Main warehouse.

Create the order

Create the PO with entity_type: "outsourced". tracking_location_id is the location the ingredients are taken from:

curl -X POST https://api.katanamrp.com/v1/purchase_orders \
  -H "Authorization: Bearer $KATANA_API_KEY" -H "Content-Type: application/json" \
  -d '{"order_no": "PO-1043", "entity_type": "outsourced", "supplier_id": 2210452, "status": "NOT_RECEIVED",
       "location_id": 160012, "tracking_location_id": 160012,
       "purchase_order_rows": [{"variant_id": 24890301, "quantity": 5, "price_per_unit": 40}]}'

Katana adds a recipe row per ingredient from the Wheel kit's recipe. List them:

curl "https://api.katanamrp.com/v1/outsourced_purchase_order_recipe_rows?purchase_order_id=3120416" \
  -H "Authorization: Bearer $KATANA_API_KEY"
{
  "data": [
    {
      "id": 9930101,
      "purchase_order_id": 3120416,
      "purchase_order_row_id": 46012020,
      "ingredient_variant_id": 24890221,
      "planned_quantity_per_unit": 1,
      "traceability": [{"batch_id": null, "serial_number_id": null, "bin_location_id": null, "quantity": "5"}]
    },
    {
      "id": 9930102,
      "purchase_order_id": 3120416,
      "purchase_order_row_id": 46012020,
      "ingredient_variant_id": 24890211,
      "planned_quantity_per_unit": 1,
      "traceability": [{"batch_id": null, "serial_number_id": null, "bin_location_id": null, "quantity": "5"}]
    }
  ]
}

Each row covers planned_quantity_per_unit times the ordered quantity: 5 hub motors and 5 pcs of chain, still untraced.

Assign the ingredients

Recipe rows have no purchase unit: their quantities are in the ingredient's default unit. Send which hub motors go to the subcontractor, by serial_number_id, one entry each, with the bin each is taken from:

curl -X PATCH https://api.katanamrp.com/v1/outsourced_purchase_order_recipe_rows/9930101 \
  -H "Authorization: Bearer $KATANA_API_KEY" -H "Content-Type: application/json" \
  -d '{"traceability": [
        {"serial_number_id": 7710001, "bin_location_id": 512001}, {"serial_number_id": 7710002, "bin_location_id": 512001},
        {"serial_number_id": 7710003, "bin_location_id": 512001}, {"serial_number_id": 7710004, "bin_location_id": 512001},
        {"serial_number_id": 7710005, "bin_location_id": 512002}
      ]}'

And the chain, 5 pcs of batch CH-2610 from A-01:

curl -X PATCH https://api.katanamrp.com/v1/outsourced_purchase_order_recipe_rows/9930102 \
  -H "Authorization: Bearer $KATANA_API_KEY" -H "Content-Type: application/json" \
  -d '{"traceability": [{"batch_id": 3871301, "bin_location_id": 512001, "quantity": "5"}]}'

The response returns the row with its traceability; each serial entry has a quantity of "1". Batch and bin entries need a positive quantity; any quantity they leave uncovered stays untraced. Serial numbers on recipe rows are not available on every account; where they are not, serial entries are refused with 422.

traceability works on the whole row, on create (POST /outsourced_purchase_order_recipe_rows) and update alike: entries replace the row's assignments, [] clears them, and leaving it out of a PATCH keeps them. batch_transactions is deprecated: use traceability. When both are sent, traceability is used.

Receive the kits

When the subcontractor delivers, receive the PO row as in Receiving purchase orders:

curl -X POST https://api.katanamrp.com/v1/purchase_order_receive \
  -H "Authorization: Bearer $KATANA_API_KEY" -H "Content-Type: application/json" \
  -d '{"purchase_order_row_id": 46012020, "quantity": 5}'

The kits go into stock and each recipe row consumes planned_quantity_per_unit times the received quantity, taken from its assignments:

ItemChangeFrom
Wheel kit+5 pcs
Hub motor−5 pcsHM-0001 to HM-0004 in A-01, HM-0005 in A-02
Chain−5 pcsCH-2610 in A-01, leaving 10 pcs

HM-0006 stays in A-02 and batch CH-2611 is untouched. Receiving the kits in parts consumes each recipe row's share for the kits received, assigned batches and serial numbers first.


Did this page help you?