Generic sales order header and lines
A two-file sales order import: an order header table and its line items, related by an explicit foreign key.
- Languages
eng- Formats
csv
Recipe
gbddl 1
language eng
table sales_orders rows 12 (
id int64 autoincrement primarykey
order_no text unique pattern(pattern: "SO-######")
customer text same(person) fullName()
customer_email text same(person) email()
order_date date date(min: "2024-01-01", max: "2025-12-31")
currency text same(geo) currency()
country text same(geo) country()
city text same(geo) city()
postal_code text same(geo) postcode()
status text enum(values: ["draft", "confirmed", "picking", "shipped", "cancelled"])
)
table sales_order_lines rows 36 per(sales_orders, 1, 5) (
id int64 autoincrement primarykey
order_id int64 fk(sales_orders.id)
product_code text pattern(pattern: "SKU-#####")
description text words(maxWords: 4)
quantity int64 integer(min: 1, max: 20)
unit text unitOfMeasure()
unit_price decimal(10, 2) decimal(min: 0.01, max: 2500)
)
output csv
This is the exact recipe.gbddl committed to the repository. Copy it, or download the raw source.
About this recipe
Sales order import
A two-table recipe that generates a generic sales order import: an order header file and a matching line-items file, shaped like the interchange CSV an integration tool or a target system would hand over. It demonstrates a common order-header-and-lines shape, not compliance with any named ERP.
What it demonstrates
- Order header —
sales_ordersis the header table: one row per order, with a source-system order number (SO-######) that is unique, the way an import file carries its own key instead of relying on an internal id. - Order lines —
sales_order_linesis the line-items table, related tosales_ordersthroughorder_id(fk(sales_orders.id)) and grouped byper(sales_orders, 1, 5), so every header has at least one line and at most five. - Customer reference —
customerandcustomer_emailshare asame(person)group, so both describe one coherent contact person. - Shipping geography —
currency,country,cityandpostal_codeshare asame(geo)group, so they all describe one place; the currency follows the country. - Line details — each line carries a
product_code, a fillerdescription, aquantity, aunitof measure and a boundedunit_price.
Run it
Submit the recipe body to POST /api/v1/jobs?input_format=gbddl, or paste it
into Chef, to generate the data. The repository's local runner (run by
task test) also generates it and verifies its output.
The recipe outputs two CSV table files: sales_orders.csv (twelve header rows)
and sales_order_lines.csv (thirty-six line rows).
Table relationships
sales_order_lines.order_idreferencessales_orders.id; every line names a header, and theperrule keeps the lines grouped within one to five per header.
Adapt it
- Change the
order_noandproduct_codemasks to match your source system's reference formats. - Add or drop columns to mirror the exact columns of your import template.
- Replace the
statusvalues with the states your target system accepts. - Raise the header
rowsand widen theper(sales_orders, 1, 5)bounds to produce a larger import.
Guarantees and limitations
Every header has a unique id and a unique order_no, every line references
an existing header through order_id, and the geography and person columns stay
coherent per row. Values are synthetic and do not reference real people,
companies or products. The recipe does not compute line totals or order
balances; it only shapes the import relationship.
Tested features
Smart types, physical types, rules and formats this recipe exercises and verifies.
patternfullNameemaildatecurrencycountrycitypostcodeenumwordsintegerunitOfMeasuredecimaluniquefkperautoincrementprimary-keysame:personsame:geography