Adds a month navigator and category filter chips to the Тооцоо list, plus a categorize-review flow at /accounting/review for bulk-assigning categories to uncategorized merchants (grouped by matchKey, biggest spend first).
22 lines
1,018 B
TypeScript
22 lines
1,018 B
TypeScript
import { todayLocalDate } from "@/api/hooks/reads";
|
||
|
||
/**
|
||
* Local-calendar [from, to] bounds (`YYYY-MM-DD`, matching `?from=&to=`) for
|
||
* the month `offset` months from `base` — 0 = `base`'s own month, -1 = the
|
||
* month before, +1 = the month after. Powers the Тооцоо month navigator.
|
||
*/
|
||
export function monthRange(offset: number, base: Date = new Date()): { from: string; to: string } {
|
||
const year = base.getFullYear();
|
||
const month = base.getMonth() + offset;
|
||
const first = new Date(year, month, 1);
|
||
const last = new Date(year, month + 1, 0); // day 0 of next month = this month's last day
|
||
return { from: todayLocalDate(first), to: todayLocalDate(last) };
|
||
}
|
||
|
||
/** "2026 оны 8-р сар" for the month `offset` months from `base`. */
|
||
export function monthLabel(offset: number, base: Date = new Date()): string {
|
||
const year = base.getFullYear();
|
||
const month = base.getMonth() + offset;
|
||
const d = new Date(year, month, 1);
|
||
return `${d.getFullYear()} оны ${d.getMonth() + 1}-р сар`;
|
||
}
|