Docs: backfill JSDoc, utility docs, and CLAUDE.md API/schema sections
- Add JSDoc to paychecks.js helpers: buildVirtualPaychecks, generatePaychecks, fetchPaychecksForMonth - Add JSDoc to financing.js helpers: remainingPeriods, calcPaymentAmount, enrichPlan - Add JSDoc to validateBillFields (bills.js) and getAllConfig (config.js) - Add JSDoc to ThemeProvider and useTheme in ThemeContext.jsx - Add Database Schema reference table to CLAUDE.md - Add complete API Endpoints reference section to CLAUDE.md covering all routes Nightshift-Task: docs-backfill Nightshift-Ref: https://github.com/marcus/nightshift
This commit is contained in:
84
CLAUDE.md
84
CLAUDE.md
@@ -94,3 +94,87 @@ The default route `/` renders the paycheck-centric main view (`client/src/pages/
|
||||
**Financing:** `GET/POST /api/financing`, `PUT/DELETE /api/financing/:id`, `PATCH /api/financing-payments/:id/paid`. Plans track a total amount, payoff due date, and `start_date`. Payment per period is auto-calculated as `(remaining balance) / (remaining periods)`. Split plans (`assigned_paycheck = null`) divide each period's payment across both paychecks. Plans auto-close when fully paid. Financing payments are included in the paycheck remaining balance. `start_date` prevents a plan from appearing on paycheck months before it was created — both virtual previews and `generate` respect this guard.
|
||||
|
||||
**Migrations:** SQL files in `db/migrations/` are applied in filename order on server startup. Add new migrations as `00N_description.sql` — they run once and are tracked in the `migrations` table.
|
||||
|
||||
## Database Schema
|
||||
|
||||
Full DDL lives in `db/migrations/`. Key tables:
|
||||
|
||||
| Table | Description |
|
||||
|---|---|
|
||||
| `config` | Key/value store for app settings (paycheck days, gross/net amounts). |
|
||||
| `bills` | Bill definitions: name, amount, due day, assigned paycheck, category, active flag. |
|
||||
| `paychecks` | One row per paycheck per period (year + month + paycheck_number 1 or 2). |
|
||||
| `paycheck_bills` | Junction between a paycheck instance and its bills; tracks paid status and amount_override. |
|
||||
| `one_time_expenses` | Ad-hoc expenses attached to a specific paycheck instance. |
|
||||
| `financing_plans` | Financing plans: total amount, due date, start_date, optional assigned_paycheck. |
|
||||
| `financing_payments` | One payment record per plan per paycheck; tracks paid status. |
|
||||
| `expense_categories` | Lookup table for variable-expense categories (Groceries, Gas, Dining, …). |
|
||||
| `actuals` | Actual spending log entries linked to a paycheck, category, or bill. |
|
||||
| `migrations` | Internal table tracking which migration files have been applied. |
|
||||
|
||||
## API Endpoints
|
||||
|
||||
All routes are prefixed with `/api`.
|
||||
|
||||
### Paychecks
|
||||
| Method | Path | Description |
|
||||
|---|---|---|
|
||||
| `GET` | `/paychecks?year=&month=` | Return both paychecks for a month. Returns virtual data (id: null) when no DB record exists. |
|
||||
| `POST` | `/paychecks/generate?year=&month=` | Upsert paycheck records and sync bills/financing for the month. |
|
||||
| `GET` | `/paychecks/months` | List all months that have generated paycheck records, newest first. |
|
||||
| `PATCH` | `/paychecks/:id` | Update gross and net for a specific paycheck. |
|
||||
| `PATCH` | `/paycheck-bills/:id/paid` | Toggle paid status; locks amount_override on pay. |
|
||||
| `PATCH` | `/paycheck-bills/:id/amount` | Set amount_override for a variable-amount bill. |
|
||||
|
||||
### Bills
|
||||
| Method | Path | Description |
|
||||
|---|---|---|
|
||||
| `GET` | `/bills` | List all bills ordered by assigned_paycheck, name. |
|
||||
| `POST` | `/bills` | Create a bill. |
|
||||
| `GET` | `/bills/:id` | Fetch a single bill. |
|
||||
| `PUT` | `/bills/:id` | Replace a bill's fields. |
|
||||
| `DELETE` | `/bills/:id` | Hard-delete a bill. |
|
||||
| `PATCH` | `/bills/:id/toggle` | Toggle the active flag. |
|
||||
|
||||
### Config
|
||||
| Method | Path | Description |
|
||||
|---|---|---|
|
||||
| `GET` | `/config` | Return all config values as a flat object with numeric values. |
|
||||
| `PUT` | `/config` | Upsert one or more config keys. Unknown keys are silently ignored. |
|
||||
|
||||
### One-Time Expenses
|
||||
| Method | Path | Description |
|
||||
|---|---|---|
|
||||
| `POST` | `/one-time-expenses` | Add a one-time expense to a paycheck. |
|
||||
| `DELETE` | `/one-time-expenses/:id` | Remove a one-time expense. |
|
||||
| `PATCH` | `/one-time-expenses/:id/paid` | Toggle paid status. |
|
||||
|
||||
### Financing
|
||||
| Method | Path | Description |
|
||||
|---|---|---|
|
||||
| `GET` | `/financing` | List all financing plans with enriched progress fields. |
|
||||
| `POST` | `/financing` | Create a financing plan. |
|
||||
| `GET` | `/financing/:id` | Fetch a plan with its full payment history. |
|
||||
| `PUT` | `/financing/:id` | Update a financing plan. |
|
||||
| `DELETE` | `/financing/:id` | Delete a financing plan and its payments. |
|
||||
| `PATCH` | `/financing-payments/:id/paid` | Toggle a payment's paid status; auto-closes the plan when fully paid. |
|
||||
|
||||
### Actuals & Categories
|
||||
| Method | Path | Description |
|
||||
|---|---|---|
|
||||
| `GET` | `/expense-categories` | List all expense categories. |
|
||||
| `POST` | `/expense-categories` | Create a new expense category. |
|
||||
| `GET` | `/actuals?paycheckId=` | List actual spending entries for a paycheck. |
|
||||
| `POST` | `/actuals` | Log an actual spending entry. |
|
||||
| `DELETE` | `/actuals/:id` | Remove an actual spending entry. |
|
||||
|
||||
### Summary
|
||||
| Method | Path | Description |
|
||||
|---|---|---|
|
||||
| `GET` | `/summary/monthly?year=&month=` | Spending breakdown and category totals for a single month. |
|
||||
| `GET` | `/summary/annual?year=` | Income vs. spending, surplus/deficit trend, and stacked variable spending for a full year. |
|
||||
|
||||
### Health
|
||||
| Method | Path | Description |
|
||||
|---|---|---|
|
||||
| `GET` | `/health` | Returns `{ ok: true }`. Used by Docker healthcheck. |
|
||||
|
||||
Reference in New Issue
Block a user