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
|
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 {
|
func (s *RecurringService) ConfirmIncome(ctx context.Context, id int, month string) error {
|
||||||
re, err := s.repo.GetByID(ctx, id)
|
re, err := s.repo.GetByID(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if re.Type != "income" {
|
txType := re.Type
|
||||||
return ErrRecurringNotIncome
|
if txType == "" {
|
||||||
|
txType = "expense"
|
||||||
}
|
}
|
||||||
today := time.Now().Format("2006-01-02")
|
today := time.Now().Format("2006-01-02")
|
||||||
tx := model.Transaction{
|
tx := model.Transaction{
|
||||||
Date: today,
|
Date: today,
|
||||||
Amount: re.ExpectedAmount,
|
Amount: re.ExpectedAmount,
|
||||||
Description: re.Name,
|
Description: re.Name,
|
||||||
Type: "income",
|
Type: txType,
|
||||||
CategoryID: re.CategoryID,
|
CategoryID: re.CategoryID,
|
||||||
}
|
}
|
||||||
_, err = s.txRepo.Create(ctx, tx)
|
_, err = s.txRepo.Create(ctx, tx)
|
||||||
|
|||||||
@@ -163,8 +163,8 @@ function getStatus(id: number) {
|
|||||||
</div>
|
</div>
|
||||||
<div class="rec-item__right">
|
<div class="rec-item__right">
|
||||||
<template v-if="getStatus(item.id)">
|
<template v-if="getStatus(item.id)">
|
||||||
<span v-if="getStatus(item.id)!.covered" class="fc-chip chip--ok fc-pixel">OK</span>
|
<span v-if="getStatus(item.id)!.covered" class="fc-chip chip--ok fc-pixel">CONFIRMADO</span>
|
||||||
<span v-else class="fc-chip chip--pending fc-pixel">PENDENTE</span>
|
<button v-else class="fc-btn fc-btn--sm fc-btn--primary" @click="confirmIncome(item.id)">CONFIRMAR</button>
|
||||||
</template>
|
</template>
|
||||||
<div class="rec-item__actions">
|
<div class="rec-item__actions">
|
||||||
<button class="fc-btn fc-btn--sm fc-btn--ghost" @click="startEdit(item.id)">EDITAR</button>
|
<button class="fc-btn fc-btn--sm fc-btn--ghost" @click="startEdit(item.id)">EDITAR</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user