dodil/erp-method

starters/uk-wholesale.calls.yaml

# Starter: a UK wholesaler (one company, GBP, VAT registered) — the rows a small trading business starts from.
#
#   erp-compose init --starter uk-wholesale            (writes this file to config/starter.calls.yaml)
#   erp-compose migrate --local compose.yaml
#   erp-compose seed --local compose.yaml config/starter.calls.yaml
#   erp-compose serve --local compose.yaml            (seeded today: the business clock starts tomorrow)
#
# Each call is one use case of a brick, replayed through its route (erp-platform >= 0.9.10, `erp-compose seed`):
# never an INSERT. `as: name` saves a call's answer; "$name.field" reads it back (the ledger mints account ids, so the
# account maps read them from the account's own answer). "$today" / "$year" are the business day. A row a brick takes
# only from a later day is dated "$tomorrow"; `serve --local` on the day of the seed starts the clock there, so the
# first sale runs straight away. Re-running skips what is there.
#
# PLACEHOLDER marks every value that is the customer's own: their company name, address, VAT number and bank account number.
# Nothing here is a real company or a real VAT number. No sample customer, product or stock: those are the OPTIONAL
# starters/uk-wholesale-sample.calls.yaml, seeded after this one, only when the business has no products of its own yet.
modules: [sales-order, product, business-partner, ar, gl, tax, payments, inventory]
calls:
  # ── the books (gl): a UK chart, the company UK1 in GBP, an open year ─────────────────────────────────────────────
  - {use_case: keep_chart, args: {chart_id: UK, name: UK standard chart, kind: operational, country: GB}}
  - {use_case: keep_company, args: {company_code: UK1, name: "PLACEHOLDER Wholesale Ltd", country: GB, functional_currency: GBP,
                                    chart_id: UK, financial_year_end_month: 12, is_default: true}}
  - {use_case: keep_account, as: a0030, args: {chart_id: UK, code: "0030", name: Office equipment, type: asset, subtype: other}}
  - {use_case: keep_account, as: a0031, args: {chart_id: UK, code: "0031", name: Office equipment depreciation, type: asset, subtype: other}}
  - {use_case: keep_account, as: a1001, args: {chart_id: UK, code: "1001", name: Stock, type: asset, subtype: other}}
  - {use_case: keep_account, as: a1100, args: {chart_id: UK, code: "1100", name: Trade debtors, type: asset, subtype: receivable}}
  - {use_case: keep_account, as: a1200, args: {chart_id: UK, code: "1200", name: Bank current account, type: asset, subtype: bank}}
  - {use_case: keep_account, as: a1230, args: {chart_id: UK, code: "1230", name: Petty cash, type: asset, subtype: bank}}
  - {use_case: keep_account, as: a2100, args: {chart_id: UK, code: "2100", name: Trade creditors, type: liability, subtype: payable}}
  - {use_case: keep_account, as: a2109, args: {chart_id: UK, code: "2109", name: Goods received not invoiced, type: liability, subtype: other}}
  - {use_case: keep_account, as: a2110, args: {chart_id: UK, code: "2110", name: Customer deposits, type: liability, subtype: other}}
  - {use_case: keep_account, as: a2200, args: {chart_id: UK, code: "2200", name: VAT on sales, type: liability, subtype: tax}}
  - {use_case: keep_account, as: a2201, args: {chart_id: UK, code: "2201", name: VAT on purchases, type: liability, subtype: tax}}
  - {use_case: keep_account, as: a2202, args: {chart_id: UK, code: "2202", name: VAT liability, type: liability, subtype: tax}}
  - {use_case: keep_account, as: a2210, args: {chart_id: UK, code: "2210", name: PAYE and NI, type: liability, subtype: other}}
  - {use_case: keep_account, as: a3000, args: {chart_id: UK, code: "3000", name: Share capital, type: equity, subtype: other}}
  - {use_case: keep_account, as: a3200, args: {chart_id: UK, code: "3200", name: Retained earnings, type: equity, subtype: retained_earnings}}
  - {use_case: keep_account, as: a4000, args: {chart_id: UK, code: "4000", name: Sales, type: income, subtype: other}}
  - {use_case: keep_account, as: a4900, args: {chart_id: UK, code: "4900", name: Other income, type: income, subtype: other}}
  - {use_case: keep_account, as: a4920, args: {chart_id: UK, code: "4920", name: Exchange gains, type: income, subtype: other}}
  - {use_case: keep_account, as: a5000, args: {chart_id: UK, code: "5000", name: Cost of goods sold, type: expense, subtype: other}}
  - {use_case: keep_account, as: a5100, args: {chart_id: UK, code: "5100", name: Stock adjustments, type: expense, subtype: other}}
  - {use_case: keep_account, as: a5200, args: {chart_id: UK, code: "5200", name: Purchase price variance, type: expense, subtype: other}}
  - {use_case: keep_account, as: a7900, args: {chart_id: UK, code: "7900", name: Bank charges, type: expense, subtype: other}}
  - {use_case: keep_account, as: a7906, args: {chart_id: UK, code: "7906", name: Exchange losses, type: expense, subtype: other}}
  - {use_case: keep_account, as: a7907, args: {chart_id: UK, code: "7907", name: Rounding differences, type: expense, subtype: other}}
  - {use_case: keep_account, as: a8100, args: {chart_id: UK, code: "8100", name: Bad debt write off, type: expense, subtype: other}}
  # where each posting purpose lands in this chart (the first row of a purpose is in force today)
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: receivable, account_id: $a1100.account_id}}
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: payable, account_id: $a2100.account_id}}
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: revenue, account_id: $a4000.account_id}}
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: bank, account_id: $a1200.account_id}}
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: tax, account_id: $a2200.account_id}}
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: vat_control, account_id: $a2202.account_id}}
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: retained_earnings, account_id: $a3200.account_id}}
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: fx_gain, account_id: $a4920.account_id}}
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: fx_loss, account_id: $a7906.account_id}}
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: rounding, account_id: $a7907.account_id}}
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: tax_rounding, account_id: $a7907.account_id}}
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: bad_debt, account_id: $a8100.account_id}}
  - {use_case: set_gl_account_map, args: {chart_id: UK, purpose: deposit, account_id: $a2110.account_id}}
  - {use_case: open_year, args: {fiscal_year: "FY$year", company_code: UK1}}

  # ── VAT (tax): the UK pack, standard 20% / reduced / zero / exempt, VAT registered ───────────────────────────────
  - {use_case: load_pack, args: {}}
  - {use_case: activate_code, args: {tax_code: S}}
  - {use_case: activate_code, args: {tax_code: R}}
  - {use_case: activate_code, args: {tax_code: Z}}
  - {use_case: activate_code, args: {tax_code: E}}
  - {use_case: record_registered, args: {vat_number: "GB000000000", effective_from: $today}}     # PLACEHOLDER: the customer's VAT number
  - {use_case: set_rule, args: {category_code: standard, treatment_code: uk_business, tax_code: S}}
  - {use_case: set_rule, args: {category_code: standard, treatment_code: uk_consumer, tax_code: S}}
  - {use_case: set_rule, args: {category_code: reduced, treatment_code: any, tax_code: R}}
  - {use_case: set_rule, args: {category_code: zero, treatment_code: any, tax_code: Z}}
  - {use_case: set_rule, args: {category_code: exempt, treatment_code: any, tax_code: E}}

  # ── invoicing (ar): its account map, our details on a VAT invoice, 30 days, the number range ───────────────────────
  - {use_case: set_ar_account_map, args: {purpose: receivable, account_id: $a1100.account_id}}
  - {use_case: set_ar_account_map, args: {purpose: revenue, account_id: $a4000.account_id}}
  - {use_case: set_ar_account_map, args: {purpose: tax, tax_code: S, account_id: $a2200.account_id}}
  - {use_case: set_ar_account_map, args: {purpose: tax, tax_code: R, account_id: $a2200.account_id}}
  - {use_case: set_ar_account_map, args: {purpose: tax, tax_code: Z, account_id: $a2200.account_id}}
  - {use_case: set_ar_account_map, args: {purpose: tax, tax_code: E, account_id: $a2200.account_id}}
  - {use_case: set_ar_account_map, args: {purpose: deposit, account_id: $a2110.account_id}}
  - {use_case: set_ar_account_map, args: {purpose: bad_debt, account_id: $a8100.account_id}}
  - {use_case: set_ar_account_map, args: {purpose: fx_gain, account_id: $a4920.account_id}}
  - {use_case: set_ar_account_map, args: {purpose: fx_loss, account_id: $a7906.account_id}}
  - {use_case: set_setting, args: {key: supplier_name, value: "PLACEHOLDER Wholesale Ltd"}}
  - {use_case: set_setting, args: {key: supplier_address, value: "PLACEHOLDER 1 Example Street, Exampletown EX1 1AA"}}
  - {use_case: set_terms, args: {terms_id: NET30, days: 30, basis: invoice_date, description: 30 days from the invoice date}}
  - {use_case: set_control, args: {key: invoice_number_format, value: "INV-{yyyy}-{seq:4}"}}

  # ── stock (inventory): one warehouse with a bin, its account map ──────────────────────────────────────────────────
  - {use_case: add_warehouse, args: {warehouse_id: MAIN, company_code: UK1, name: Main warehouse}}
  - {use_case: add_location, args: {location_id: MAIN/A, kind: view, name: Zone A}}
  - {use_case: add_location, args: {location_id: MAIN/A/01, kind: internal, name: Bin A-01}}
  - {use_case: set_inventory_account_map, args: {company_code: UK1, purpose: stock_valuation, account_id: $a1001.account_id}}
  - {use_case: set_inventory_account_map, args: {company_code: UK1, purpose: cost_of_goods_sold, account_id: $a5000.account_id}}
  - {use_case: set_inventory_account_map, args: {company_code: UK1, purpose: stock_received_not_billed, account_id: $a2109.account_id}}
  - {use_case: set_inventory_account_map, args: {company_code: UK1, purpose: inventory_loss, account_id: $a5100.account_id}}
  - {use_case: set_inventory_account_map, args: {company_code: UK1, purpose: price_difference, account_id: $a5200.account_id}}

  # ── sales orders (sales-order): deliver from MAIN, the number range ───────────────────────────────────────────────
  - {use_case: set_so_setting, args: {setting_key: default_warehouse_id, value: MAIN, valid_from: $tomorrow}}
  - {use_case: set_so_setting, args: {setting_key: order_number_format, value: "SO-{yyyy}-{seq:4}", valid_from: $tomorrow}}

  # ── cash (payments): the bank account on the ledger's 1200, the default for GBP ───────────────────────────────────
  - {use_case: put_bank_account, args: {bank_account_id: BANK1, name: Business current account, currency: GBP, company_code: UK1,
                                        gl_account_id: $a1200.account_id, account_number: "00000000", purposes: "receive,pay"}}   # PLACEHOLDER account number
  - {use_case: set_default_bank_account, args: {company_code: UK1, currency: GBP, bank_account_id: BANK1, valid_from: $tomorrow}}

  # ── prices (product): the default GBP price list, prices excluding VAT ────────────────────────────────────────────
  - {use_case: open_price_list, args: {price_list_id: LIST-GBP, name: Wholesale GBP (ex VAT), currency: GBP, prices_include_tax: false,
                                       default_from: $today}}