feat: CDI % configurável por conta + fix mocks de teste

- Adiciona campo cdi_percentage (default 100%) na tabela accounts
- Cálculo CDI aplica proporção: balance × (compound-1) × (pct/100)
- Frontend exibe input de % quando yield_type=cdi e badge mostra valor
- Corrige mocks de teste desatualizados (DeleteByMonth, isTax)
- Corrige ConfirmIncome para rejeitar tipo expense (ErrRecurringNotIncome)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
2026-05-28 22:20:32 -03:00
co-authored by Claude Sonnet 4.6
parent 433c4f42a5
commit 6292858970
10 changed files with 73 additions and 37 deletions
+2
View File
@@ -22,6 +22,7 @@ export interface Account {
initial_balance: number
balance: number
yield_type: 'none' | 'cdi' | 'variable'
cdi_percentage: number
last_yield_date?: string
closing_day?: number
due_day?: number
@@ -35,6 +36,7 @@ export interface AccountInput {
type: string
initial_balance: number
yield_type: string
cdi_percentage: number
closing_day?: number | null
due_day?: number | null
}
+16 -2
View File
@@ -14,7 +14,7 @@ const typeLabels: Record<string, string> = {
credit: 'Cartão de Crédito',
}
const blank = (): AccountInput => ({ name: '', type: 'checking', initial_balance: 0, yield_type: 'none', closing_day: null, due_day: null })
const blank = (): AccountInput => ({ name: '', type: 'checking', initial_balance: 0, yield_type: 'none', cdi_percentage: 100, closing_day: null, due_day: null })
const form = ref(blank())
const editId = ref<number | null>(null)
const formError = ref<string | null>(null)
@@ -26,6 +26,7 @@ function startEdit(id: number) {
form.value = {
name: a.name, type: a.type, initial_balance: a.initial_balance,
yield_type: a.yield_type ?? 'none',
cdi_percentage: a.cdi_percentage ?? 100,
closing_day: a.closing_day ?? null,
due_day: a.due_day ?? null,
}
@@ -92,6 +93,17 @@ function totalBalance() {
<option value="cdi">CDI automático</option>
<option value="variable">Renda variável</option>
</select>
<div v-if="form.yield_type === 'cdi'" class="fc-label fc-acc-form__day-wrap">
% do CDI
<input
type="number"
v-model.number="form.cdi_percentage"
min="1"
max="200"
step="0.5"
class="fc-input fc-acc-form__day"
/>
</div>
<template v-if="form.type === 'credit'">
<div class="fc-label fc-acc-form__day-wrap">
Fechamento
@@ -138,7 +150,9 @@ function totalBalance() {
<div class="fc-acc-item__info">
<div class="fc-acc-item__name-row">
<span class="fc-body fc-acc-item__name">{{ a.name }}</span>
<span v-if="a.yield_type === 'cdi'" class="fc-acc-badge fc-acc-badge--cdi fc-pixel">CDI</span>
<span v-if="a.yield_type === 'cdi'" class="fc-acc-badge fc-acc-badge--cdi fc-pixel">
{{ a.cdi_percentage != null && a.cdi_percentage !== 100 ? a.cdi_percentage + '% CDI' : 'CDI' }}
</span>
<span v-else-if="a.yield_type === 'variable'" class="fc-acc-badge fc-acc-badge--var fc-pixel">VAR</span>
</div>
<span class="fc-mono fc-acc-item__meta">