feat: categoria is_tax exclui impostos do denominador do savings_pct

savings_pct = (receita - despesas) / (receita - impostos).
Toggle IMPOSTO no CRUD de categorias; badge dourado na lista.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
2026-05-27 15:53:53 -03:00
co-authored by Claude Sonnet 4.6
parent 2cf6d94a03
commit 7dae05cabf
10 changed files with 90 additions and 35 deletions
+10 -2
View File
@@ -8,6 +8,7 @@ import (
type DashboardRepo interface {
MonthlySummary(ctx context.Context, month string) (income, expenses float64, err error)
TotalTaxes(ctx context.Context, month string) (float64, error)
ByCategory(ctx context.Context, month string) ([]model.CategoryTotal, error)
MonthlyEvolution(ctx context.Context, month string) ([]model.MonthEvolution, error)
RecentTransactions(ctx context.Context, month string) ([]model.RecentTransaction, error)
@@ -34,6 +35,11 @@ func (s *DashboardService) Get(ctx context.Context, month string) (*model.Dashbo
return nil, err
}
taxes, err := s.repo.TotalTaxes(ctx, month)
if err != nil {
return nil, err
}
byCategory, err := s.repo.ByCategory(ctx, month)
if err != nil {
return nil, err
@@ -49,9 +55,11 @@ func (s *DashboardService) Get(ctx context.Context, month string) (*model.Dashbo
return nil, err
}
// savings_pct uses net income (gross - taxes) as denominator (Option B)
var savingsPct float64
if income > 0 {
savingsPct = (income - expenses) / income * 100
netIncome := income - taxes
if netIncome > 0 {
savingsPct = (income - expenses) / netIncome * 100
}
statuses, err := s.recurrSvc.MonthlyStatus(ctx, month)