Receiving flows

A receiving flow describes the stages merchandise goes through before it is sellable. While merchandise sits in a HOLD stage it cannot be sold or transferred: it counts as inProcess in the branch's inventory. When it reaches an AVAILABLE stage, stock goes up and the channels are updated.

Each flow applies to one entry type: purchase_order (purchase), transfer (transfer) or return (customer return). When merchandise is received, Fenicia looks for the flow in this order: the branch's flow for that entry type, the tenant's flow, and if there is none, the merchandise goes straight into stock.

A branch whose stock is governed by an ERP does not use a flow

If an ERP or an external system governs the branch's stock, receiving does not change inventory and does not enter any flow.

List flows

Lists the tenant's receiving flows, with optional filters.

200Flows of the tenant, of the requested branch, or both.
{
  "data": [
    {
      "id": "flw_01J8Z",
      "tenantId": "69db07c8bce4d49b18c42a49",
      "entryType": "purchase_order",
      "name": "Recepción estándar",
      "initialStageId": "st_recepcion",
      "stages": [
        { "id": "st_recepcion", "name": "Recepción", "disposition": "HOLD", "transitions": [{ "toStageId": "st_calidad" }] },
        { "id": "st_calidad", "name": "Control de calidad", "disposition": "HOLD", "transitions": [{ "toStageId": "st_piso", "label": "Aprobada" }, { "toStageId": "st_merma", "label": "Rechazada" }] },
        { "id": "st_piso", "name": "Piso de venta", "disposition": "AVAILABLE", "transitions": [] },
        { "id": "st_merma", "name": "Merma", "disposition": "SCRAP", "transitions": [] }
      ],
      "active": true,
      "isDefault": true
    }
  ]
}
403The inventory:read permission is missing.
{ "code": "forbidden", "message": "Permission denied: requires 'inventory:read'" }

Returns the flows that match the filters, inside data.

Required permission: inventory:read

Parameters

entryTypestring

Filter by entry type. Accepted values: purchase_order, transfer, return.

locationIdstring

Returns that branch's flows. Without this parameter the tenant's flows are returned.

activeboolean

Filter by active (true) or inactive (false) flows.

Templates

Lists the templates a flow can be created from.

200Available templates.
{
  "templates": [
    {
      "id": "standard-receiving",
      "name": "Recepción estándar",
      "stages": [
        { "id": "st_recepcion", "name": "Recepción", "disposition": "HOLD", "transitions": [{ "toStageId": "st_calidad" }] },
        { "id": "st_calidad", "name": "Control de calidad", "disposition": "HOLD", "transitions": [{ "toStageId": "st_piso", "label": "Aprobada" }, { "toStageId": "st_merma", "label": "Rechazada" }] },
        { "id": "st_piso", "name": "Piso de venta", "disposition": "AVAILABLE", "transitions": [] },
        { "id": "st_merma", "name": "Merma", "disposition": "SCRAP", "transitions": [] }
      ]
    }
  ]
}

Returns the templates. The Recepción estándar template has the stages Recepción (HOLD), Control de calidad (HOLD), Piso de venta (AVAILABLE) and Merma (SCRAP), with one branch from Control de calidad to each final destination.

Required permission: inventory:read

Create a flow

Creates a receiving flow for an entry type, for the tenant or for a branch.

{
  "entryType": "purchase_order",
  "locationId": "670a1b2c3d4e5f6a7b8c9d01",
  "name": "Compra nacional",
  "initialStageId": "st_recepcion",
  "stages": [
    { "id": "st_recepcion", "name": "Recepción", "disposition": "HOLD", "placeId": "plc_recepcion", "transitions": [{ "toStageId": "st_calidad" }] },
    { "id": "st_calidad", "name": "Control de calidad", "disposition": "HOLD", "placeId": "plc_calidad", "transitions": [{ "toStageId": "st_piso", "label": "Aprobada" }, { "toStageId": "st_merma", "label": "Rechazada" }] },
    { "id": "st_piso", "name": "Piso de venta", "disposition": "AVAILABLE", "transitions": [] },
    { "id": "st_merma", "name": "Merma", "disposition": "SCRAP", "transitions": [] }
  ],
  "active": true,
  "isDefault": true
}
201Flow created.
{
  "id": "flw_01J8Z",
  "tenantId": "69db07c8bce4d49b18c42a49",
  "locationId": "670a1b2c3d4e5f6a7b8c9d01",
  "entryType": "purchase_order",
  "name": "Compra nacional",
  "initialStageId": "st_recepcion",
  "active": true,
  "isDefault": true
}
400The flow breaks one of the save rules.
{ "code": "bad-request", "message": "Desde la etapa inicial no se llega a una etapa AVAILABLE ni SCRAP" }

Returns the created flow, with its id.

Required permission: inventory:manage

Parameters

entryTypestringrequired

Entry type the flow applies to. Accepted values: purchase_order, transfer, return.

namestringrequired

Flow name.

locationIdstring

Branch the flow applies to. Without a value, the flow belongs to the tenant. A tenant flow carries no placeId on its stages: areas belong to each branch.

initialStageIdstringrequired

ID of the stage where merchandise enters. It must exist in stages.

stagesarrayrequired

Flow stages.

stages.idstringrequired

Stage identifier within the flow.

stages.namestringrequired

Display name, for example Control de calidad.

stages.dispositionstringrequired

What the stage means for stock. Accepted values: HOLD (in process, not sold), AVAILABLE (sellable: merchandise that gets here raises stock), SCRAP (scrap, merchandise is written off with its loss).

stages.placeIdstring

Area of the branch where the stage is. It must exist in the branch. Several stages can share an area.

stages.transitionsarrayrequired

Stages merchandise can move to from this one. AVAILABLE and SCRAP stages have no exits.

stages.transitions.toStageIdstringrequired

Destination stage. It must exist in stages.

stages.transitions.labelstring

Branch label, for example Aprobada or Rechazada.

activeboolean

Whether the flow applies to new receipts.

isDefaultboolean

Marks the tenant's (or branch's) default flow for that entry type. A branch can have several active flows per entry type, with one default.

Save rules

  1. The initial stage and every transition destination exist.
  2. From the initial stage you can reach an AVAILABLE or SCRAP stage.
  3. AVAILABLE and SCRAP stages have no exits.
  4. If a stage carries placeId, the area exists in the branch.
  5. A stage cannot be deleted, nor its disposition changed, while it holds merchandise in process. The response says how many pieces, and from which receipts, must be moved first.

Get a flow

Gets a receiving flow by its identifier.

200The flow with all its stages.
{
  "id": "flw_01J8Z",
  "tenantId": "69db07c8bce4d49b18c42a49",
  "entryType": "purchase_order",
  "name": "Compra nacional",
  "initialStageId": "st_recepcion",
  "stages": [
    { "id": "st_recepcion", "name": "Recepción", "disposition": "HOLD", "transitions": [{ "toStageId": "st_piso" }] },
    { "id": "st_piso", "name": "Piso de venta", "disposition": "AVAILABLE", "transitions": [] }
  ],
  "active": true,
  "isDefault": true
}
404The flow does not exist in your tenant.
{ "code": "not-found", "message": "Flow not found" }

Returns the flow.

Required permission: inventory:read

Parameters

idstringrequired

Flow identifier.

Update a flow

Replaces a flow's definition. It applies the same save rules as creation.

{
  "name": "Compra nacional",
  "initialStageId": "st_recepcion",
  "stages": [
    { "id": "st_recepcion", "name": "Recepción", "disposition": "HOLD", "transitions": [{ "toStageId": "st_piso" }] },
    { "id": "st_piso", "name": "Piso de venta", "disposition": "AVAILABLE", "transitions": [] }
  ],
  "active": true
}
200Flow updated.
{ "id": "flw_01J8Z", "name": "Compra nacional", "initialStageId": "st_recepcion", "active": true }
400A stage that holds merchandise in process was removed, or its disposition changed.
{ "code": "bad-request", "message": "La etapa st_calidad tiene 47 piezas en proceso" }

Returns the updated flow. Merchandise already in process stays in the flow it entered with: each position stores its flowId, and editing a flow does not move it. The flow has no versions.

Required permission: inventory:manage

Parameters

idstringrequired

Flow identifier.

stagesarrayrequired

Flow stages, with the same shape as on creation.

stages.idstringrequired

Stage identifier.

stages.namestringrequired

Display name.

stages.dispositionstringrequired

Accepted values: HOLD, AVAILABLE, SCRAP.

stages.transitionsarrayrequired

Destination stages, with toStageId and an optional label.

stages.transitions.toStageIdstringrequired

Destination stage.

namestring

Flow name.

initialStageIdstring

Initial stage. It must exist in stages.

activeboolean

Whether the flow applies to new receipts.

Delete a flow

Deletes a receiving flow that has no merchandise in process.

200Flow deleted.
{ "deleted": true }
400The flow has merchandise in process.
{ "code": "bad-request", "message": "El flujo flw_01J8Z tiene piezas en proceso" }

Returns the deletion confirmation.

Required permission: inventory:manage

Parameters

idstringrequired

Flow identifier.

Examples

curl -G https://api.fenicia.io/inventory/flows \
  -H "Authorization: Bearer fkapi_tu_api_key" \
  --data-urlencode "entryType=purchase_order"

Next steps