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)
|
||||
|
||||
@@ -163,8 +163,8 @@ function getStatus(id: number) {
|
||||
</div>
|
||||
<div class="rec-item__right">
|
||||
<template v-if="getStatus(item.id)">
|
||||
<span v-if="getStatus(item.id)!.covered" class="fc-chip chip--ok fc-pixel">OK</span>
|
||||
<span v-else class="fc-chip chip--pending fc-pixel">PENDENTE</span>
|
||||
<span v-if="getStatus(item.id)!.covered" class="fc-chip chip--ok fc-pixel">CONFIRMADO</span>
|
||||
<button v-else class="fc-btn fc-btn--sm fc-btn--primary" @click="confirmIncome(item.id)">CONFIRMAR</button>
|
||||
</template>
|
||||
<div class="rec-item__actions">
|
||||
<button class="fc-btn fc-btn--sm fc-btn--ghost" @click="startEdit(item.id)">EDITAR</button>
|
||||
|
||||
Reference in New Issue
Block a user