Skip to content

Supplier invoices and lines

Suppliers, invoices and lines related by foreign keys, written as YAML.

related volume small InvoicesSuppliersRelationships
Languages
eng
Formats
yaml

Recipe

recipe.gbddl
gbddl 1
language eng

table suppliers rows 6 (
  id     int64 autoincrement primarykey
  name   text company()
  vat_id text unique vatId()
)

table supplier_invoices rows 12 per(suppliers, 1, 3) (
  id          int64 autoincrement primarykey
  supplier_id int64 fk(suppliers.id)
  number      text unique pattern(pattern: "SINV-#####")
  issued_on   date date(min: "2023-01-01", max: "2024-12-31")
  incoterm    text enum(values: ["EXW", "FCA", "CPT", "CIP", "DAP", "DPU", "DDP", "FAS", "FOB", "CFR", "CIF"])
  amount      decimal(10, 2) decimal(min: 100, max: 50000)
)

table supplier_invoice_lines rows 24 per(supplier_invoices, 1, 3) (
  id          int64 autoincrement primarykey
  invoice_id  int64 fk(supplier_invoices.id)
  description text enum(values: ["Office supplies", "Freight and handling", "Software licence", "Maintenance service", "Raw materials", "Consulting hours", "Packaging materials", "Equipment rental"])
  line_total  decimal(10, 2) decimal(min: 10, max: 5000)
)

output yaml (maxRowsPerFile: 8)

This is the exact recipe.gbddl committed to the repository. Copy it, or download the raw source.

About this recipe

Supplier invoices

A multi-table recipe that generates supplier invoices: suppliers, invoices and lines, related by foreign keys.

What it demonstrates

  • Relationships — supplier_invoices references suppliers, and supplier_invoice_lines references supplier_invoices.
  • Row distribution — per(...) groups each supplier's invoices and each invoice's lines.
  • Identity — vat_id is a check-digit-valid vatId and number a unique pattern mask.
  • Delivery terms — incoterm is an enum of the eleven Incoterms 2020 codes (codes only, no rule text).
  • YAML output — each table is written as a YAML document.

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 YAML files: suppliers.yaml, supplier_invoices.yaml and supplier_invoice_lines.yaml.

Guarantees

Every primary key is unique, every foreign key names an existing parent row, and per(...) grouping holds. Values are synthetic and not a balanced ledger.

Tested features

Smart types, physical types, rules and formats this recipe exercises and verifies.

companyvatIdpatterndatedecimalenumuniquefkperautoincrementprimary-keyyaml.maxRowsPerFile