mirror of
https://github.com/Komediruzecki/token-circles.git
synced 2026-10-20 09:46:43 +02:00
Slice 3 of the form-errors work. The goal dialog and Add Funds, the Bills dialog, and Allocate and Set Budget say what is wrong under the field that is wrong, in the same words in cloud and local-first, through the form kit from #602. - shared/budgetSchema.ts, goalSchema.ts and billSchema.ts hold the rules and words both runtimes and the forms use, read through shared/fieldReaders.ts; money is kept to the cent with shared/money.ts. - One rule for when a bill falls due next (shared/billSchedule.ts), used by the Bills list, its calendar, the Dashboard, /api/bills/upcoming, mark-paid, the reminder email and the MCP tools. Weekly and biweekly bills fall due on their own schedule, a bill due on the 31st falls on a shorter month's last day, and local-first's Dashboard lists upcoming bills. - The Bills dialog saves its category, Set Budget changes the month's budget instead of adding one, Allocate sets the month on screen, budget alerts measure a month against that month's budgets, the sankey counts uncategorised spending, and setting a month from last month's spending fills only the categories without a budget. - A budget stored with a float error opens and saves unchanged, and Backfill from Spending stores sums to the cent. MCP upsert_budget checks a budget as the app does. - Seven contract pins are settled: both runtimes give one answer.
11 lines
423 B
TypeScript
11 lines
423 B
TypeScript
/**
|
|
* An amount to the cent.
|
|
*
|
|
* Amounts exact to the cent do not stay exact in floating point once they are added up or taken
|
|
* away: 10.3 - 0.1 - 0.2 is 10.000000000000002, and 1000.1 - 260.45 is 739.6500000000001. A figure
|
|
* a person reads as money, or compares with another, is worked out to the cent, as they would.
|
|
*/
|
|
export function toCents(amount: number): number {
|
|
return Math.round(amount * 100) / 100;
|
|
}
|