# ExpenseTracker

> Spend by category on three bases. Polarity derived per row from the sign convention.

Source: https://lopifi.com/components/expense-tracker
Part of: Lopifi — US GAAP books on autopilot, reviewed by a CPA (https://lopifi.com)

---

- **Family:** Metrics & analysis — ---
- **Status:** Implemented
- **Spec:** https://lopifi.com/docs/catalog/13-metrics-and-analysis

## Install

```bash
npx shadcn@latest add @lopifi/theme
npx shadcn@latest add @lopifi/expense-tracker
```

## Specification

Spend by category on three bases — actual, budget, variance — because they are the same
categories asked three questions, and a nine-column grid of all of them is one nobody reads past
the third column.

**Every row carries a polarity, and the component derives it.** An increase in spend is not good
news; under budget is favourable and over budget is not. A grid that paints a rising cost green
has told the reader the opposite of the truth.

Polarity describes the figure *as stored*, not the concept behind it, and that is the easiest
thing here to get backwards: this system holds costs as negatives, so a heavier month is a figure
moving **down** and the row wants `standard`. A model holding the same costs as positive
magnitudes wants `inverted`. `ExpenseTracker` takes a `sign` and works it out itself rather than
asking its caller to reason about a storage convention to get the colours the right way round.

Committed-but-unbilled is shown beside the total, never folded into it. A purchase order is not
an expense — accruing it silently is a cutoff error, and showing it nowhere is how a category
with six figures of open POs looks under budget right up until the invoices land.

The movers list ranks by amount, not by percentage. A line that doubled from 400 to 800 is not
the story of a month in which another went from 180,000 to 240,000.

## Rules this component obeys

Money is minor units, never floats. `null` is not `0` and neither is redacted. Negatives render in accounting parentheses with the parenthesis column reserved on both sides. Debit and credit are two columns. Per-currency decimal places. Polarity is explicit — up is not always good. Every figure states its period, entity, currency, basis and as-of.
