Skip to content

Accounts receivable

Customers, invoices and payments related by foreign keys, written as XML.

related volume small AccountingInvoicesPaymentsRelationships
Languages
eng
Formats
xml

Recipe

recipe.gbddl
gbddl 1
language eng

table customers rows 8 (
  id    int64 autoincrement primarykey
  name  text same(person) fullName()
  email text same(person) email()
)

table invoices rows 12 per(customers, 1, 2) (
  id          int64 autoincrement primarykey
  customer_id int64 fk(customers.id)
  number      text unique pattern(pattern: "INV-#####")
  amount      decimal(10, 2) decimal(min: 50, max: 20000)
  issued_on   date date(min: "2023-01-01", max: "2024-12-31")
)

table payments rows 18 per(invoices, 0, 2) (
  id         int64 autoincrement primarykey
  invoice_id int64 fk(invoices.id)
  amount     decimal(10, 2) decimal(min: 10, max: 10000)
  paid_on    date date(min: "2023-01-01", max: "2025-01-31")
  method     text enum(values: ["card", "bank_transfer", "cash"])
)

output xml (rootElement: "records", recordElement: "record", maxRowsPerFile: 10)

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

About this recipe

Accounts receivable

A multi-table recipe that generates receivables: customers, invoices and payments, related by foreign keys.

What it demonstrates

  • Relationships — invoices references customers, and payments references invoices.
  • Row distribution — per(...) groups each customer's invoices (1 to 2) and each invoice's payments (0 to 2, so some invoices are unpaid).
  • XML output — each table is written as an XML 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 XML files: customers.xml, invoices.xml and payments.xml.

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.

fullNameemailpatterndecimaldateenumuniquefkpersame:personautoincrementprimary-keyxml.rootElementxml.recordElementxml.maxRowsPerFile