Exemple API: același scenariu ca în manual

Flux curl pe datele din Exemple practice (Cafea / RoastCo / CafeBar). Înlocuiți ID-urile și token-ul cu valorile dvs.

Premisă. Partenerii (furnizor/client) și depozitul se creează în UI - API-ul REST le listează, dar nu oferă creare partener/depozit. Articolul, PO, recepția și SO se pot crea din API.

0. Token și context

export APP="https://www.flowscmc.ro"
export TOKEN="1|tokenul-dvs"
export COMPANY=123

curl -s "$APP/api/companies" \
  -H "Authorization: Bearer $TOKEN" -H "Accept: application/json"

1. ID-uri existente (parteneri, depozit)

curl -s "$APP/api/partners?per_page=50" \
  -H "Authorization: Bearer $TOKEN" \
  -H "X-Company-Id: $COMPANY" -H "Accept: application/json"

curl -s "$APP/api/warehouses" \
  -H "Authorization: Bearer $TOKEN" \
  -H "X-Company-Id: $COMPANY" -H "Accept: application/json"

# Notați: PARTNER_FURN, PARTNER_CLI, WAREHOUSE

2. Creare articol

curl -s -X POST "$APP/api/articles" \
  -H "Authorization: Bearer $TOKEN" \
  -H "X-Company-Id: $COMPANY" \
  -H "Content-Type: application/json" -H "Accept: application/json" \
  -d '{"article_code":"SKU-CAFEA-1KG","name":"Cafea boabe 1 kg","description":"Cafea boabe 1 kg","um3pl":"buc","integer_only":true,"um3pl_barcode":"5940123456789","active":true}'

# → ARTICLE_ID

3. Comandă de achiziție (PO)

curl -s -X POST "$APP/api/purchase-orders" \
  -H "Authorization: Bearer $TOKEN" \
  -H "X-Company-Id: $COMPANY" \
  -H "Content-Type: application/json" -H "Accept: application/json" \
  -d '{"partner_id":11,"internal_code":"PO-DEMO-CAFEA","items":[{"article_id":55,"um3pl":"buc","quantity_um3pl":100}]}'

# Înlocuiți 11 și 55 cu ID-urile reale. → PO_ID, PO_ITEM_ID

4. Recepție (stoc ↑)

curl -s -X POST "$APP/api/receptions" \
  -H "Authorization: Bearer $TOKEN" \
  -H "X-Company-Id: $COMPANY" \
  -H "Content-Type: application/json" -H "Accept: application/json" \
  -d '{"purchase_order_id":77,"warehouse_id":3,"selected_items":[{"po_item_id":88,"quantity_um3pl":100}]}'

curl -s "$APP/api/stock?per_page=50" \
  -H "Authorization: Bearer $TOKEN" \
  -H "X-Company-Id: $COMPANY" -H "Accept: application/json"

5. Comandă de vânzare (SO)

curl -s -X POST "$APP/api/sales-orders" \
  -H "Authorization: Bearer $TOKEN" \
  -H "X-Company-Id: $COMPANY" \
  -H "Content-Type: application/json" -H "Accept: application/json" \
  -d '{"partner_id":12,"source_warehouse_id":3,"stock_type":"STOC_OK","internal_code":"SO-DEMO-CAFEBAR","items":[{"article_id":55,"um3pl":"buc","quantity_um3pl":40}]}'
Status / livrare. Picking și status „livrat” se fac de obicei din UI (sau update/status din REST). Stocul scade la livrarea confirmată.

Sfaturi