mirror of
https://github.com/gabehf/BudgetBuddy.git
synced 2026-03-07 21:48:14 -08:00
Bug Fix: Category case is normalized
This commit is contained in:
parent
8cbb8ee963
commit
6c55e37f20
2 changed files with 6 additions and 4 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/jacobmveber-01839764/BudgetBuddy/db"
|
||||
"github.com/jacobmveber-01839764/BudgetBuddy/money"
|
||||
|
|
@ -94,7 +95,7 @@ func SetCategoryBudget(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// get form values
|
||||
r.ParseForm()
|
||||
cat := r.FormValue("category")
|
||||
cat := strings.ToLower(r.FormValue("category"))
|
||||
if cat == "" {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
fmt.Fprintf(w, "{\"error\":\"category must be specified\"}")
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jacobmveber-01839764/BudgetBuddy/db"
|
||||
|
|
@ -113,7 +114,7 @@ func NewTransaction(w http.ResponseWriter, r *http.Request) {
|
|||
if r.FormValue("category") == "" {
|
||||
cat = "uncategorized"
|
||||
} else {
|
||||
cat = r.FormValue("category")
|
||||
cat = strings.ToLower(r.FormValue("category"))
|
||||
}
|
||||
|
||||
newT := db.Transaction{
|
||||
|
|
@ -129,10 +130,10 @@ func NewTransaction(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
var newArr []db.Transaction
|
||||
var success bool
|
||||
if r.FormValue("type") == "income" {
|
||||
if strings.ToLower(r.FormValue("type")) == "income" {
|
||||
newArr = append(user.Income, newT)
|
||||
success = addToBalance(user, newT.Amount)
|
||||
} else if r.FormValue("type") == "expenses" {
|
||||
} else if strings.ToLower(r.FormValue("type")) == "expenses" {
|
||||
newArr = append(user.Expenses, newT)
|
||||
success = subtractFromBalance(user, newT.Amount)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue