Baseleg Docs

Billing

Status: v1 lite — scaffolded, not a primary v1 delivery focus
Packages: packages/domain/billing, packages/application/billing

Purpose

The Billing context tracks the financial relationship between the organisation and its members. It records billable activity as Charge Items, compiles them into Invoice Drafts, and manages the invoice lifecycle through to issuance.

In v1, Billing covers charge tracking and draft invoicing. Payment processing, accounting system integration, and automated fee calculation come later.

Key entities

Charge item (aggregate root or entity)

A single billable line item against a Member. The atomic unit of billing.

Key attributes:

  • id — unique identifier
  • memberId — the member being charged (MemberId)
  • bookingId — optional reference to the Booking that generated the charge (BookingId | null)
  • description — human-readable description (e.g. C172 ZK-ABC — 1.2 hrs at $150/hr)
  • quantity — amount or duration (e.g. hours flown)
  • unitPrice — price per unit in cents (avoids floating-point currency issues)
  • total — computed: quantity × unitPrice
  • invoiceId — null until added to an Invoice Draft
  • createdAt — when the charge was recorded

Invoice draft

An un-issued invoice accumulating Charge Items for a Member.

Key attributes:

  • id — unique identifier
  • memberId — the invoice recipient (MemberId)
  • lineItems — list of ChargeItemId references
  • subtotal — sum of all line item totals
  • statusdraft | issued | void
  • createdAt — draft creation timestamp
  • issuedAt — null until issued

Domain rules

  1. A Charge Item must reference an active Member.
  2. Charge Items cannot be modified once added to an issued Invoice.
  3. An Invoice Draft may be edited freely before issuance.
  4. Once issued, an Invoice transitions to issued and is immutable; corrections require a new invoice or credit note.
  5. All monetary values are stored in the smallest currency unit (e.g. cents).

Key use cases

  • recordChargeItem — create a Charge Item against a Member (optionally linked to a Booking).
  • createInvoiceDraft — create a new draft Invoice for a Member.
  • addChargeToInvoice — attach a Charge Item to an existing Invoice Draft.
  • issueInvoice — finalise and issue an Invoice Draft.
  • voidInvoice — void a draft or issued invoice.

Cross-context relationships

ContextUsage
PeopleReferences MemberId for the charge/invoice recipient
SchedulingCharge Items may reference BookingId to link charges to bookings
NotificationsInvoice issuance triggers a notification to the Member