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:
2026-05-27 16:41:26 -03:00
co-authored by Claude Sonnet 4.6
parent 0507d7bff3
commit 88461a4aea
6 changed files with 50 additions and 5 deletions
+15 -1
View File
@@ -60,7 +60,7 @@ func (h *TransactionHandler) Update(w http.ResponseWriter, r *http.Request) {
}
t.ID = id
out, err := h.svc.Update(r.Context(), t)
if errors.Is(err, repository.ErrNotFound) || errors.Is(err, service.ErrCannotEditImported) {
if errors.Is(err, repository.ErrNotFound) {
respondError(w, http.StatusNotFound, err.Error())
return
}
@@ -83,3 +83,17 @@ func (h *TransactionHandler) Delete(w http.ResponseWriter, r *http.Request) {
}
w.WriteHeader(http.StatusNoContent)
}
func (h *TransactionHandler) DeleteByMonth(w http.ResponseWriter, r *http.Request) {
month := r.URL.Query().Get("month")
if len(month) != 7 {
respondError(w, http.StatusBadRequest, "month required (YYYY-MM)")
return
}
count, err := h.svc.DeleteByMonth(r.Context(), month)
if err != nil {
respondError(w, http.StatusInternalServerError, err.Error())
return
}
respondJSON(w, http.StatusOK, map[string]int{"deleted": count})
}