feat(panel): özet kartları, anlık durum ve hızlı harcama ekleme
- Gelir, sabit gider, toplam birikim, devreden borç kartları - Anlık durum: kalan harcanabilir ve günlük harcama önerisi - Grup planlanan/gerçekleşen (Haftalık/Aylık) - "Harcama Ekle": masaüstünde başlıkta, mobilde yüzen düğme - Yükleniyor iskeleti, boş durumlar, açık dönem yokken son dönem özeti Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { Period } from '@/types/Period'
|
||||
import { dailyAllowance, dashboardPeriod } from './dashboard'
|
||||
|
||||
const nov = { start_date: '2026-11-01', last_date: '2026-11-30', days: 30 }
|
||||
|
||||
describe('dashboard', () => {
|
||||
it('picks the open period, else the latest one', () => {
|
||||
const open = { id: 'o' } as Period
|
||||
const last = { id: 'l' } as Period
|
||||
expect(dashboardPeriod([last], open)).toBe(open)
|
||||
expect(dashboardPeriod([last, { id: 'x' } as Period], null)).toBe(last)
|
||||
expect(dashboardPeriod([], null)).toBeNull()
|
||||
})
|
||||
|
||||
it('splits what is left over the remaining days', () => {
|
||||
// 12.11 dahil 19 gün; 19.000 ₺ → günde 1.000 ₺
|
||||
expect(dailyAllowance(1_900_000, nov, '2026-11-12')).toEqual({ daysLeft: 19, perDay: 100_000 })
|
||||
expect(dailyAllowance(1_000, nov, '2026-11-30')).toEqual({ daysLeft: 1, perDay: 1_000 })
|
||||
// kuruş aşağı yuvarlanır (önerilen tutar kalanı aşmasın)
|
||||
expect(dailyAllowance(1_000, nov, '2026-11-28')).toEqual({ daysLeft: 3, perDay: 333 })
|
||||
})
|
||||
|
||||
it('has no daily suggestion when over budget or the period has ended', () => {
|
||||
expect(dailyAllowance(-5_000, nov, '2026-11-12').perDay).toBeNull()
|
||||
expect(dailyAllowance(0, nov, '2026-11-12').perDay).toBeNull()
|
||||
expect(dailyAllowance(5_000, nov, '2026-12-01')).toEqual({ daysLeft: 0, perDay: null })
|
||||
expect(dailyAllowance(3_000, nov, '2026-10-20')).toEqual({ daysLeft: 30, perDay: 100 })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user