Months that start on payday
A profile setting ("A month starts: on payday") runs each month from one
salary to the day before the next, named after the calendar month it
mostly covers. Salary is money in under Income of at least half a usual
paycheck, found within 12 days of the usual pay day; until it arrives the
running month goes on. The months are worked out on each request and kept
in pay_periods, which money_by_month now groups by, so every monthly
total follows. Spending, Home, Budgets, the typical month and the plan
use them; Charts, check-ins and onboarding stay on calendar months.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1bdcc57c2f
commit
9d42d52e4d
12 files changed
+269
-39
No files matched your search
@@ -11,8 +11,8 @@ import { PayQuestion } from "@/components/PayQuestion";
|
||||
import { SyncButton } from "@/components/PlaidButtons";
|
||||
import { TxnList } from "@/components/TxnList";
|
||||
import { WeekCard } from "@/components/WeekCard";
|
||||
import { categories, getUser, moneyByMonth, today, TXN_SELECT, withAccountNames, type Txn } from "@/lib/data";
|
||||
import { dateLabel, money0, monthStart, ymd } from "@/lib/format";
|
||||
import { categories, getUser, moneyByMonth, months, today, TXN_SELECT, withAccountNames, type Txn } from "@/lib/data";
|
||||
import { dateLabel, money0, ymd } from "@/lib/format";
|
||||
import { deterministicMoves, ladder } from "@/lib/plan";
|
||||
import { myPlanFacts } from "@/lib/plan-facts";
|
||||
import { payGuess } from "@/lib/pay";
|
||||
@@ -66,6 +66,8 @@ export default async function Dashboard() {
|
||||
const now = await today(); // the user's date at UTC midnight: read it with getUTC* and ymd
|
||||
const day = ymd(now), soon = ymd(new Date(now.getTime() + 14 * 864e5));
|
||||
const checks = (fetchChecks(supabase, uid, day) as Promise<Checks>).catch(() => ({ rows: [], total: 0 })); // starts now, beside the queries below
|
||||
// Pay months on: "this month" is the pay month today is in, named after the calendar month it mostly covers.
|
||||
const thisMonth = await (await months()).current();
|
||||
|
||||
// Own rows only: an account a partner shares is on the Accounts page, not in your totals.
|
||||
const [{ data: recent }, { data: accounts }, { data: noRate }, { data: bills }, rows, cats] = await Promise.all([
|
||||
@@ -73,7 +75,7 @@ export default async function Dashboard() {
|
||||
supabase.from("accounts").select("type, subtype, current_balance:home_balance, included").eq("user_id", uid),
|
||||
supabase.rpc("fx_missing"),
|
||||
supabase.from("recurring").select("id, merchant_name, logo_url, average_amount:home_average, next_date").eq("user_id", uid).eq("active", true).eq("is_income", false).neq("status", "TOMBSTONED").gte("next_date", day).lte("next_date", soon).order("next_date").limit(4),
|
||||
moneyByMonth(supabase, ymd(monthStart(now))),
|
||||
moneyByMonth(supabase, `${thisMonth}-01`),
|
||||
categories(),
|
||||
]);
|
||||
|
||||
@@ -93,8 +95,8 @@ export default async function Dashboard() {
|
||||
{ label: "You owe", value: owed == null ? null : Math.abs(owed), href: "/debt" },
|
||||
].filter((t) => t.value != null);
|
||||
|
||||
const pic = moneyPicture(rows, cats, ymd(monthStart(now)).slice(0, 7), null);
|
||||
const monthName = dateLabel(day, { month: "long" });
|
||||
const pic = moneyPicture(rows, cats, thisMonth, null);
|
||||
const monthName = dateLabel(`${thisMonth}-01`, { month: "long" });
|
||||
|
||||
return (
|
||||
<div className="space-y-4 max-w-4xl">
|
||||
|
||||
Reference in new issue
Block a user