From 1f99413f2235d0206e0d13c22d5ae80b26431c2d Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Tue, 12 Apr 2022 15:07:38 -0800 Subject: [PATCH] Check for barcode instead of id when adding item --- internal/postgres/items.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/postgres/items.go b/internal/postgres/items.go index 19331c2..4c3fbeb 100644 --- a/internal/postgres/items.go +++ b/internal/postgres/items.go @@ -42,7 +42,7 @@ func (s itemService) Item(id int, user *quartermaster.User) (*quartermaster.Item func (s itemService) AddItem(i *quartermaster.Item, l *quartermaster.Location, user *quartermaster.User) (*quartermaster.Item, error) { var err error - if i.ID == 0 { + if ib, _ := s.GetItemByBarcode(i.Barcode, user); ib == nil { if i.Nutrition != nil { i.Nutrition, err = NutritionService.AddNutrition(i.Nutrition) if err != nil {