feat(budget): aylık bütçe motoru, limitler ve ay sonu tahmini

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-06 00:58:51 +03:00
parent 6de6d07c66
commit 3fa1e949e2
10 changed files with 1179 additions and 1 deletions
+29
View File
@@ -0,0 +1,29 @@
import { z } from "zod";
import { tr } from "../../i18n/tr";
import { nonNegativeMoneySchema } from "./account";
/** Bütçe ayı "YYYY-MM". */
export const budgetMonthSchema = z
.string()
.regex(/^\d{4}-(0[1-9]|1[0-2])$/, tr.budget.validation.month);
/**
* Limit formu: kategori → tutar metni. Boş veya 0 limit kaldırılır (kategori bütçesiz olur).
*/
export const budgetLimitsSchema = z.object({
month: budgetMonthSchema,
limits: z
.array(
z.object({
categoryId: z.string().regex(/^[a-f0-9]{24}$/i, tr.budget.validation.category),
amount: nonNegativeMoneySchema,
}),
)
.max(500)
.transform((list) =>
list
.filter((l) => l.amount > 0)
.map((l) => ({ categoryId: l.categoryId, amountMinor: l.amount })),
),
});
export type BudgetLimitsForm = z.output<typeof budgetLimitsSchema>;