Skip to content
Snippets Groups Projects
Commit b663177c authored by meskio's avatar meskio :tent:
Browse files

Don't make the total negative

parent 140c4c55
No related branches found
No related tags found
No related merge requests found
...@@ -56,7 +56,7 @@ func (a *api) AddPurchase(num int, w http.ResponseWriter, req *http.Request) { ...@@ -56,7 +56,7 @@ func (a *api) AddPurchase(num int, w http.ResponseWriter, req *http.Request) {
Date: time.Now(), Date: time.Now(),
Purchase: purchase, Purchase: purchase,
Type: "purchase", Type: "purchase",
Total: -total, Total: total,
} }
err = a.db.Create(&transaction).Error err = a.db.Create(&transaction).Error
if err != nil { if err != nil {
......
...@@ -30,7 +30,7 @@ func TestPurchaseAddListMine(t *testing.T) { ...@@ -30,7 +30,7 @@ func TestPurchaseAddListMine(t *testing.T) {
if len(transactions) != 1 { if len(transactions) != 1 {
t.Fatal("Wrong number of transactions", len(transactions), transactions) t.Fatal("Wrong number of transactions", len(transactions), transactions)
} }
if transactions[0].Total != -testProduct.Price*products[0].Ammount { if transactions[0].Total != testProduct.Price*products[0].Ammount {
t.Error("Wrong total:", transactions[0].Total) t.Error("Wrong total:", transactions[0].Total)
} }
if len(transactions[0].Purchase) != 1 { if len(transactions[0].Purchase) != 1 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment