Skip to content
View as Markdown

Data model ​

The main entities an integration sees and the fields that link them. Every _id is a 24-character string. How the terms differ: glossary.

text
organization ── warehouse ──┐
                            ├── stock (product × warehouse)
product ────────────────────┘
product × price list × organization ── price

customer ── order (sale-order) ── sale (trade) ── invoice ── transaction

Organization and warehouse ​

EntityReferencesRead
Organization (organization)currency_id — its accounting currencyGET /organization/get-all
Warehouse (warehouse)organization_id — belongs to one organization; is_main — the main warehousePOST /warehouse/get-all

warehouse/get-paging returns an organization object instead of organization_id.

Product, price, stock ​

EntityReferencesRead
Product (product)category, measure; organizations[] — where it is available; parent_id on a variantPOST /product/get-paging
Price list (price)currency_id; type — sale or incomeGET /price/get-all
Product priceproduct × price_id × organization → amountPOST /price/items/get-paging
Stock (product-warehouse)product_id × warehouse_id, organization_idPOST /product-warehouse/get-paging
Batch (product-stock)product, warehouse, cost and its currencyPOST /product-stock/get-paging

A product does not belong to a single organization: the catalog is shared, while availability, prices and stock are per organization. How to read stock: stock and prices; what changes it: warehouse documents.

Customer, order, sale, transaction ​

EntityReferencesRead
Customer (customer)organization_ids, category_idPOST /customer/get-paging
Order (sale-order)organization_id, customer_id, price_id; on a line product_id, price_id, warehouse_idGET /sale-order/get-by-id/{id}
Sale (trade)organization, customer_id, warehouse_id, price_id; order_id — the order it came from; refund_id — the original sale of a refundGET /trade/get-by-id/{id}
Sale line_id — the product, item_id — the line, warehouseGET /trade/get-items/{id}
Transaction (transaction)organization_id, cashbox_id, payment_method, payment_type; customer_id, trade_id, invoice_idPOST /transaction/get-paging
  • sale-order is a customer's order, trade is the sale itself. How one becomes the other: the sale lifecycle.
  • A transaction is a movement of money. On a credit sale the payment can arrive later or in parts, so count sale totals and cash movement separately.

Storing it in your system ​

  • Link records by _id. Names and numbers (number, uuid) are for display.
  • Deletes are soft: a stored _id can point at a deleted record. Products, warehouses, customers and orders have a get-deleted method.
  • Track changes with the updated_at filter (where a method has it) and webhooks.

Bito 2.0 Integration API