# RatioAnalysis

> Liquidity, leverage and efficiency ratios, each with its formula and inputs.

Source: https://lopifi.com/components/ratio-analysis
Part of: Lopifi — US GAAP books on autopilot, checked 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/ratio-analysis
```

## Specification

Liquidity, leverage, coverage, efficiency and profitability ratios in one table, grouped in that
order. Each row carries the ratio's name, its formula in words, and **the two figures that produced
it**, so the value can be checked without opening the ledger.

The value is **computed from its inputs**, never passed in beside them. A ratio whose own formula
line contradicts it is worse than no ratio.

- **Kind is explicit:** `times` (1.84×), `percent` (34.2%) or `days` (47 days). A `days` ratio
  takes the length of the period its denominator covers — DSO on a quarter's revenue is × 91, not
  × 365 — so the component never guesses a year.
- **Polarity is required**, no default. A current ratio rising is good; DSO or debt to equity
  rising is not.
- **Change is in the ratio's own unit.** A percent ratio moves in points, not percent of itself.
  The change is computed on the displayed precision, so it never shows a move where both readings
  print the same.
- **Three gaps, three sentences, none of them zero:** an input missing ("Input not available"), a
  zero denominator ("Not meaningful" — never Infinity), and inputs in two currencies ("Inputs in
  two currencies" — a ratio across currencies needs a rate nobody passed).
- **Thresholds name their source** — the credit agreement section, the board policy. A breach is
  stated in words with an icon; the `--negative` color repeats it, never replaces it.
- **The basis is a required prop:** period, entity, currency, accounting basis. Ratios computed
  mid-close inherit the provisional state of their inputs; pass it in the basis line.

Not a covenant monitor: `CovenantMonitor` carries the contractual definition and the test date.
Use this for analysis and the covenant card for compliance.

## 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.
