Home›Blog›Larzscript
Larzscript

Building a Budget Tracker in Larzscript, Part 3: Reports and Bills

2026-08-01 · Larzscript

Part 1 built accounts and expenses; Part 2 added spending limits. This last part covers larzscript-budget's report command and monthly recurring bills - the pieces that make the transaction log from the first two parts actually useful to look at.

A report is just aggregation plus a bar

Nothing exotic - filter this month's expense transactions into a dict keyed by category, then print each with a proportional # bar (scaled against whichever category spent the most):

let totals = {}
for t in ledger["transactions"] {
  if t["date"][0:7] == month and t["amount"] < 0 {
    let cat = t["category"]
    totals[cat] = totals.get(cat, 0) + (-t["amount"])
  }
}
...
let max_cents = 1
for cat in keys(totals) { if totals[cat] > max_cents { max_cents = totals[cat] } }
for cat in sorted(keys(totals)) {
  let bar_len = int((totals[cat] / max_cents) * 30)
  let bar = "#" * (bar_len < 1 ? 1 : bar_len)
  print("  " + cat.ljust(14) + fmt_cents(totals[cat]).rjust(11) + "  " + bar)
}
$ larzscript budget.lz report

Report for 2026-08

  food                $4.50 / $300.00 limit  #
  housing          $1200.00  ##############################

Total across accounts: $5795.50

Recurring bills, and an honest scope limit

recurring-add rent -1200.00 housing stores a bill; recurring-run processes anything not yet run this calendar month, reusing the exact same record_expense() function add uses - a recurring bill is not a separate code path, it's the same real pay/limit-check/ledger-write, just triggered on a schedule instead of by hand:

for item in ledger["recurring"] {
  if item["last_run_month"] == month {
    print("skipped '" + item["name"] + "' - already ran this month")
    continue
  }
  record_expense(ledger, path, item["name"], item["amount"], item["account"], item["category"], date())
  item["last_run_month"] = month
  ...
}

Worth being direct about a real constraint here: recurring items compare against the *current calendar month* (date()[0:7]), not an exact day interval, because Larzscript doesn't have a string-to-epoch date parser yet - there's date()/datetime() to go *from* a timestamp to a string, but nothing to go the other way. That makes "monthly" easy to get right and "every 10 days" impossible to get right, so this project only supports monthly bills. That's a real gap in the language today, not a design preference - worth knowing if you're planning your own date-heavy Larzscript project.

The whole project

That's the full arc: Part 1 (accounts, pay, the persistence pattern), Part 2 (require/unless as a real guardrail), and reports/bills here. The full source is one file, budget.lz, with a test suite and CI - clone it, read it end to end, or use it for real.

Ready to get started?

See the full source on GitHub →

Explore the apps