Territorial product

Territorial Invoices

The system that runs Territorial's billing: calendar-based time tracking, contracts with deterministic billing math, and invoices generated in minutes.

1/2Dashboard: hours, revenue, daily distribution by client and alerts

Territorial bills several clients against different contract types every month. This internal platform tracks time on a drag-to-create calendar, rolls hours up against contracts and milestones, and generates a full batch of invoices with PDFs. Billing that took an afternoon now takes under fifteen minutes.

At a glance

  • Time is logged on a calendar the way you create Google Calendar events: drag, resize, move
  • Three contract types with pure, testable billing math: hourly, hourly with a base retainer, and hourly with rollover credit
  • Draft invoices are live projections; issued invoices are immutable snapshots with frozen FX rates and A4 PDFs
  • An MCP server lets Territorial Assistant register time entries automatically from my own activity

The problem

Consulting billing is simple until it is not: one client on plain hourly, another on a retainer with overtime, a third on a base that rolls unused hours forward, all in different currencies, all needing a document that looks final. I wanted the whole month to close in minutes and the numbers to be reproducible.

What it does

Clients, contracts, projects and milestones form the model; time entries attach to a project and milestone and inherit the contract's rate. The calendar is the fast path for logging, with client, project and milestone filters and project-based colouring. When a period closes, the system computes each contract's billable hours: plain hourly bills what was worked; hourly-with-base bills the floor plus overtime at its own rate; hourly-with-rollover bills the base, defers overage to a one-cycle buffer, and uses carried-in credit to cover shortfalls before expiring it. Every rule is a pure function with worked examples in the docs and tests.

Invoices start as drafts projected live from time entries and become immutable when issued, with lines, totals and the FX rate frozen. PDFs are rendered with Playwright from the same HTML the web app shows, in English or Portuguese, with structured issuer and client addresses and per-currency payment instructions. A dashboard gives hours, revenue, per-client distribution and alerts for orphan entries and base-hours risk.

Automation and fiscal integration

Over time I got lazy about logging, so Territorial Assistant now proposes time entries from git history, Claude Code transcripts and window activity and registers them here through a personal-access-token MCP endpoint, with the same role model as the web app. Fiscal integration with Brazil's NF-e system is in progress: today the platform prepares everything the fiscal system asks for so that issuing the nota is a copy-and-paste task instead of a reconstruction.

The stack is a pnpm monorepo with a Fastify API (Zod validation, Prisma, PostgreSQL) and a Next.js App Router frontend that keeps all business logic on the server.

More projects

All projects