From b663177c052fd5ef4ff829456061903a78106ef2 Mon Sep 17 00:00:00 2001 From: meskio <meskio@sindominio.net> Date: Mon, 28 Sep 2020 19:33:28 +0200 Subject: [PATCH] Don't make the total negative --- api/purchase.go | 2 +- api/purchase_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/purchase.go b/api/purchase.go index d57b024..86b3b25 100644 --- a/api/purchase.go +++ b/api/purchase.go @@ -56,7 +56,7 @@ func (a *api) AddPurchase(num int, w http.ResponseWriter, req *http.Request) { Date: time.Now(), Purchase: purchase, Type: "purchase", - Total: -total, + Total: total, } err = a.db.Create(&transaction).Error if err != nil { diff --git a/api/purchase_test.go b/api/purchase_test.go index 3e979cb..e176e19 100644 --- a/api/purchase_test.go +++ b/api/purchase_test.go @@ -30,7 +30,7 @@ func TestPurchaseAddListMine(t *testing.T) { if len(transactions) != 1 { 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) } if len(transactions[0].Purchase) != 1 { -- GitLab