feat: excluir transações de extrato + delete em lote por mês
Remove restrição que bloqueava delete de transações importadas. Adiciona DELETE /transactions?month=YYYY-MM para exclusão em lote e botão "EXCLUIR MÊS" na view de transações. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
var (
|
||||
ErrInvalidTransactionType = errors.New("type must be 'income' or 'expense'")
|
||||
ErrCannotEditImported = errors.New("imported transactions cannot be edited or deleted")
|
||||
ErrTransactionEmptyDesc = errors.New("description is required")
|
||||
ErrTransactionInvalidAmount = errors.New("amount must be greater than zero")
|
||||
)
|
||||
@@ -55,11 +54,15 @@ func (s *TransactionService) Update(ctx context.Context, t model.Transaction) (*
|
||||
func (s *TransactionService) Delete(ctx context.Context, id int) error {
|
||||
err := s.repo.Delete(ctx, id)
|
||||
if errors.Is(err, repository.ErrNotFound) {
|
||||
return ErrCannotEditImported
|
||||
return errors.New("transaction not found")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TransactionService) DeleteByMonth(ctx context.Context, month string) (int, error) {
|
||||
return s.repo.DeleteByMonth(ctx, month)
|
||||
}
|
||||
|
||||
func validateTransaction(t model.Transaction) error {
|
||||
if strings.TrimSpace(t.Description) == "" {
|
||||
return ErrTransactionEmptyDesc
|
||||
|
||||
Reference in New Issue
Block a user