diff options
author | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-06-24 20:00:10 +0530 |
---|---|---|
committer | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-06-24 20:00:10 +0530 |
commit | 5d2222d9fa782b94ba6787e5c6b23aab1e468308 (patch) | |
tree | 6bfd4a98ae121c3ce109510021ead96e1b2fa0cd /server/database | |
parent | 5329b1fd16d0b8940f9526b523676dfb1cdbf317 (diff) |
Multiple minor bug fixes and convert more compnents to TS
Diffstat (limited to 'server/database')
-rw-r--r-- | server/database/database.go | 14 | ||||
-rw-r--r-- | server/database/items.go | 30 |
2 files changed, 21 insertions, 23 deletions
diff --git a/server/database/database.go b/server/database/database.go index c2c0dfe..f8d9092 100644 --- a/server/database/database.go +++ b/server/database/database.go @@ -20,13 +20,13 @@ func InitDB() { init_items, _ := myDatabase.Prepare( `CREATE TABLE IF NOT EXISTS Items (id INTEGER PRIMARY KEY AUTOINCREMENT, - Model TEXT NOT NULL, - Desc TEXT, - Price REAL, - Hsn BLOB, - Gst REAL, - Category TEXT, - Brand TEXT)`, + Model TEXT NOT NULL, + Desc TEXT, + UnitPrice REAL, + HSN BLOB, + TotalGST REAL, + Category TEXT, + Brand TEXT)`, ) init_items.Exec() diff --git a/server/database/items.go b/server/database/items.go index 325b7c1..059f5e6 100644 --- a/server/database/items.go +++ b/server/database/items.go @@ -14,30 +14,30 @@ import ( ) type Item struct { - Model string - Desc string `json:"Description"` - Price float64 - HSN int - GST float64 - Cat string `json:"Category"` - Brand string + Model string + Description string + UnitPrice float64 + HSN int + TotalGST float64 + Category string + Brand string } func GetAllItems() []Item { var allItems []Item rows, _ := myDatabase.Query( - `SELECT Model, Desc, Price, Hsn, Gst, Category, Brand FROM Items`, + `SELECT Model, Desc, UnitPrice, HSN, TotalGST, Category, Brand FROM Items`, ) var ( model, desc, cat, brand string - price, GST float64 + unitPrice, GST float64 HSN int ) for rows.Next() { - rows.Scan(&model, &desc, &price, &HSN, &GST, &cat, &brand) - allItems = append(allItems, Item{model, desc, price, HSN, GST, cat, brand}) + rows.Scan(&model, &desc, &unitPrice, &HSN, &GST, &cat, &brand) + allItems = append(allItems, Item{model, desc, unitPrice, HSN, GST, cat, brand}) } return allItems @@ -48,7 +48,7 @@ func RegisterItem(item Item) bool { register_item, _ := myDatabase.Prepare( `INSERT INTO Items - (Model, Desc, Price, Hsn, Gst, Category, Brand) + (Model, Desc, UnitPrice, HSN, TotalGST, Category, Brand) VALUES (?, ?, ?, ?, ?, ?, ?)`, ) @@ -64,10 +64,8 @@ func RegisterItem(item Item) bool { } register_item.Exec( - item.Model, item.Desc, - item.Price, item.HSN, - item.GST, item.Cat, - item.Brand, + item.Model, item.Description, item.UnitPrice, item.HSN, + item.TotalGST, item.Category, item.Brand, ) return true |