fix(budget): sabit gider ayrımı ve taban hızlı ay sonu tahmini
$ne ile eksik alan yolu her işlemi sabit sayıyordu; $ifNull ile düzeltildi. Tahmin, bu ayın hızını önceki dönemin değişken hızıyla karıştırır. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -206,6 +206,30 @@ describe("aylık bütçe", () => {
|
||||
expect((await line("aidat", shiftMonth(M, 1)))!.actualMinor).toBe(1_000_00);
|
||||
});
|
||||
|
||||
it("tahmin: değişken gider tempoyla, sabit gider olduğu gibi (gelecek ayda değişken sayılmaz)", async () => {
|
||||
const F = shiftMonth(todayIstanbul().slice(0, 7), 24);
|
||||
const f = budgetPeriod(F);
|
||||
await expense({ date: f.from, amountMinor: 900_00, category: cat.keyif });
|
||||
await expense({ date: f.from, amountMinor: 4_000_00, category: cat.kira, recurring: true });
|
||||
const keyif = (await line("keyif", F))!;
|
||||
expect(keyif.actualMinor).toBe(900_00);
|
||||
// Henüz başlamamış dönem, geçmiş yok: gerçekleşen değişken olduğu gibi, tempo eklenmez.
|
||||
expect(keyif.forecastMinor).toBe(900_00);
|
||||
expect((await line("kira", F))!.forecastMinor).toBe(4_000_00);
|
||||
});
|
||||
|
||||
it("içinde bulunulan ayda değişken gider tempoyla büyür, sabit gider büyümez", async () => {
|
||||
const today = todayIstanbul();
|
||||
const cur = today.slice(0, 7);
|
||||
if (budgetPeriod(cur).to === today) return; // ayın son günü: kalan gün yok
|
||||
await expense({ date: today, amountMinor: 1_000_00, category: cat.keyif });
|
||||
await expense({ date: today, amountMinor: 2_000_00, category: cat.kira, recurring: true });
|
||||
const keyif = (await line("keyif", cur))!;
|
||||
expect(keyif.actualMinor).toBe(1_000_00);
|
||||
expect(keyif.forecastMinor).toBeGreaterThan(1_000_00);
|
||||
expect((await line("kira", cur))!.forecastMinor).toBe(2_000_00);
|
||||
});
|
||||
|
||||
it("bütçe ayı başlangıç günü dönemi kaydırır", async () => {
|
||||
await HouseholdModel.updateOne(
|
||||
{ _id: cakir },
|
||||
|
||||
Reference in New Issue
Block a user