{
  "schema": "leumas.docs.page/1",
  "id": "adapter:domain/finance",
  "slug": "adapters/domain/finance",
  "kind": "capabilities",
  "bucket": "package",
  "title": "finance (adapter system)",
  "name": "finance",
  "eyebrow": "adapter system",
  "chip": null,
  "summary": "Money-math capability pack: compound interest, loan amortization + full schedules, mortgage breakdown, time-value-of-money (present/future value, NPV, IRR via Newton's method, PMT), business ratios...",
  "keywords": [
    "finance",
    "money-math",
    "mortgage",
    "newton",
    "cagr",
    "straight-line",
    "double-declining",
    "depreciation"
  ],
  "audience": "both",
  "funnel": {
    "product": null,
    "cta": null
  },
  "body": "# finance (adapter system)\n\nMoney-math capability pack — Studio-aligned, monetizable business tools. Pure JS, **zero deps**.\nEverything a small-business / CRM surface needs to quote loans, price products, model investments,\nand format money correctly.\n\nRates are **decimals** everywhere (`0.06` = 6%), never percents. Money outputs round to 2 decimals\n(via integer cents to avoid float drift). Amortization/depreciation schedules keep running balances\nconsistent — the final payment is trued-up so the balance lands exactly on `0`.\n\n## Tools (`adapters`)\n\n| tool | args | result |\n|------|------|--------|\n| `compoundInterest` | `{ principal, rate, times=12, years, schedule? }` | `{ futureValue, interestEarned, periods, schedule? }` |\n| `loanAmortization` | `{ principal, annualRate, termMonths }` | `{ monthlyPayment, totalInterest, totalPaid, schedule:[{month,payment,principal,interest,balance}] }` |\n| `mortgage` | `{ price, downPayment?, annualRate, termYears, taxRate?, insurance? }` | `{ loanAmount, monthly:{principalAndInterest,tax,insurance,total}, totalPaid, totalInterest }` |\n| `presentValue` | `{ futureValue, rate, periods }` | `{ presentValue }` |\n| `futureValue` | `{ presentValue, rate, periods }` | `{ futureValue }` |\n| `npv` | `{ rate, cashflows:[] }` | `{ npv }` |\n| `irr` | `{ cashflows:[], guess? }` | `{ irr, iterations, method }` (Newton + bisection fallback) |\n| `pmt` | `{ rate, periods, presentValue, futureValue? }` | `{ payment }` |\n| `roi` | `{ gain, cost }` | `{ roi, roiPercent, netProfit }` |\n| `cagr` | `{ begin, end, years }` | `{ cagr, cagrPercent }` |\n| `breakEven` | `{ fixedCosts, pricePerUnit, variableCostPerUnit }` | `{ breakEvenUnits, breakEvenRevenue, contributionMargin }` |\n| `depreciation` | `{ cost, salvage?, life, method? }` | `{ method, schedule:[{year,expense,accumulated,bookValue}] }` |\n| `currencyFormat` | `{ amount, currency='USD', locale='en-US' }` | `{ formatted, amount, currency, locale }` |\n| `tip` | `{ amount, percent, split=1 }` | `{ tip, total, perPersonTip, perPersonTotal }` |\n\n`depreciation.method` accepts `'straight-line'` (default) or `'double-declining'`.\n`cashflows` are ordered `[t0, t1, ...]`; negatives are outflows. `taxRate` in `mortgage` is an annual\nproperty-tax rate (decimal) applied to the home price.\n\n## Usage\n\n```js\nconst m = await import('./index.js');\nconst finance = m.default.adapters;\n\nfinance.loanAmortization({ principal: 10000, annualRate: 0.06, termMonths: 12 });\n// → { monthlyPayment: 860.66, totalInterest: 327.9, totalPaid: 10327.9, schedule: [...] }\n\nfinance.currencyFormat({ amount: 1234.5 }); // → { formatted: '$1,234.50', ... }\n```\n\n## DRY boundary\n\nThe **`numbers`** pack owns generic numeric-series analytics (running average, percentile insights,\nanomaly detection, unit/base conversion). **`finance`** owns money math (interest, loans, TVM,\ndepreciation, currency formatting). They do not overlap — keep money math here.\n",
  "source": {
    "path": "shared/engines/adapters/domain/finance/README.md",
    "blobSha": "",
    "commit": "",
    "committedAt": "",
    "provenance": "no-git",
    "bytes": 3146,
    "hash": "a381a478e89ffe95d918f78947a9b76687f8a9f7"
  },
  "urls": {
    "html": "/p/adapters/domain/finance",
    "json": "/docs/adapters/domain/finance.json",
    "md": "/docs/adapters/domain/finance.md"
  },
  "links": {
    "composes": [],
    "usedBy": [],
    "product": [],
    "howTo": [],
    "skills": []
  }
}
