Add per-account historical bank imports without resetting sync cursors

This commit is contained in:
Lars Nolden
2026-09-10 17:02:17 +02:00
parent f4c7d54575
commit 2259db3e85
7 changed files with 561 additions and 8 deletions
+13
View File
@@ -41,6 +41,7 @@ func New(a *app.App, assets fs.FS, publicURL string) (http.Handler, error) {
s.mux.HandleFunc("POST /api/transactions/{id}", s.transaction)
s.mux.HandleFunc("POST /api/manage", s.manage)
s.mux.HandleFunc("POST /api/import", s.importCSV)
s.mux.HandleFunc("POST /api/backfill", s.backfill)
s.mux.HandleFunc("POST /api/rebuild", func(w http.ResponseWriter, r *http.Request) { v, e := a.Rebuild(r.Context()); respond(w, v, e) })
s.mux.HandleFunc("POST /api/sync", func(w http.ResponseWriter, r *http.Request) { v, e := a.Sync(r.Context()); respond(w, v, e) })
s.mux.HandleFunc("POST /api/settings", s.settings)
@@ -281,6 +282,18 @@ func (s *Server) importCSV(w http.ResponseWriter, r *http.Request) {
v, e := s.app.ImportCSV(r.Context(), r.FormValue("revision"), r.FormValue("account_id"), f)
respond(w, v, e)
}
func (s *Server) backfill(w http.ResponseWriter, r *http.Request) {
var b struct {
Revision string `json:"revision"`
AccountID string `json:"account_id"`
HistoryMonths int `json:"history_months"`
}
if !decode(w, r, &b) {
return
}
v, e := s.app.Backfill(r.Context(), b.Revision, b.AccountID, b.HistoryMonths)
respond(w, v, e)
}
func (s *Server) settings(w http.ResponseWriter, r *http.Request) {
var b app.Settings
if !decode(w, r, &b) {