Added start of balances

This commit is contained in:
2026-03-01 13:07:22 +01:00
parent 54a8292234
commit ddf06554f8
3 changed files with 21 additions and 3 deletions

View File

@@ -45,18 +45,23 @@ func Expenses(w http.ResponseWriter, r *http.Request) {
share.ID = utils.GenerateUUID()
err := storage.AddShare(&share)
if err != nil {
println(err.Error())
http.Error(w, "Error adding expense", http.StatusBadRequest) // Should never happen
return
}
}
err := storage.AddExpense(&body.Expense)
if err != nil {
println(err.Error())
http.Error(w, "Error adding expense", http.StatusBadRequest)
return
}
w.WriteHeader(http.StatusCreated)
err = json.NewEncoder(w).Encode(map[string]interface{}{
"expense": body.Expense,
"shares": body.Shares,
})
if err != nil {
println(err.Error())
return
}
break
case http.MethodPut: // -> Update Expense
break