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:
@@ -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})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user