feat: extract into remaining packages
All checks were successful
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 1m19s

There has been a cyclic dependency.
transaction
	-> treasure_chest
	-> transaction_recurring
	-> transaction

This has been temporarily solved by moving the GenerateTransactions
function into the transaction package. In the future, this function has
to be rewritten to use a proper Service insteas of direct DB access or
replaced with a different system entirely.
This commit is contained in:
2025-12-31 22:24:21 +01:00
parent 6de8d8fb10
commit 1be46780bb
29 changed files with 230 additions and 251 deletions

View File

@@ -4,7 +4,6 @@ import (
"net/http"
"spend-sparrow/internal/auth_types"
"spend-sparrow/internal/core"
"spend-sparrow/internal/utils"
)
type Handler interface {
@@ -35,7 +34,7 @@ func (h HandlerImpl) handleTransactionRecurringItemComp() http.HandlerFunc {
user := core.GetUser(r)
if user == nil {
utils.DoRedirect(w, r, "/auth/signin")
core.DoRedirect(w, r, "/auth/signin")
return
}
@@ -52,7 +51,7 @@ func (h HandlerImpl) handleUpdateTransactionRecurring() http.HandlerFunc {
user := core.GetUser(r)
if user == nil {
utils.DoRedirect(w, r, "/auth/signin")
core.DoRedirect(w, r, "/auth/signin")
return
}
@@ -91,7 +90,7 @@ func (h HandlerImpl) handleDeleteTransactionRecurring() http.HandlerFunc {
user := core.GetUser(r)
if user == nil {
utils.DoRedirect(w, r, "/auth/signin")
core.DoRedirect(w, r, "/auth/signin")
return
}
@@ -113,7 +112,7 @@ func (h HandlerImpl) renderItems(w http.ResponseWriter, r *http.Request, user *a
var transactionsRecurring []*TransactionRecurring
var err error
if accountId == "" && treasureChestId == "" {
utils.TriggerToastWithStatus(r.Context(), w, r, "error", "Please select an account or treasure chest", http.StatusBadRequest)
core.TriggerToastWithStatus(r.Context(), w, r, "error", "Please select an account or treasure chest", http.StatusBadRequest)
}
if accountId != "" {
transactionsRecurring, err = h.s.GetAllByAccount(r.Context(), user, accountId)