feat: confirmar despesas recorrentes cria transação manual
Botão CONFIRMAR para despesas pendentes, igual ao fluxo de receitas. Backend remove guard income-only no ConfirmIncome. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
@@ -110,21 +110,22 @@ func (s *RecurringService) MonthlyStatus(ctx context.Context, month string) ([]m
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ConfirmIncome creates an income transaction confirming receipt of this recurring income.
|
||||
// ConfirmIncome creates a transaction (income or expense) confirming this recurring item for the month.
|
||||
func (s *RecurringService) ConfirmIncome(ctx context.Context, id int, month string) error {
|
||||
re, err := s.repo.GetByID(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if re.Type != "income" {
|
||||
return ErrRecurringNotIncome
|
||||
txType := re.Type
|
||||
if txType == "" {
|
||||
txType = "expense"
|
||||
}
|
||||
today := time.Now().Format("2006-01-02")
|
||||
tx := model.Transaction{
|
||||
Date: today,
|
||||
Amount: re.ExpectedAmount,
|
||||
Description: re.Name,
|
||||
Type: "income",
|
||||
Type: txType,
|
||||
CategoryID: re.CategoryID,
|
||||
}
|
||||
_, err = s.txRepo.Create(ctx, tx)
|
||||
|
||||
Reference in New Issue
Block a user