aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-06-24 20:00:10 +0530
committerMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-06-24 20:00:10 +0530
commit5d2222d9fa782b94ba6787e5c6b23aab1e468308 (patch)
tree6bfd4a98ae121c3ce109510021ead96e1b2fa0cd /server
parent5329b1fd16d0b8940f9526b523676dfb1cdbf317 (diff)
Multiple minor bug fixes and convert more compnents to TS
Diffstat (limited to 'server')
-rw-r--r--server/database/database.go14
-rw-r--r--server/database/items.go30
-rw-r--r--server/filled.dbbin57344 -> 0 bytes
-rw-r--r--server/router/items.go14
4 files changed, 28 insertions, 30 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
diff --git a/server/filled.db b/server/filled.db
deleted file mode 100644
index d9258ed..0000000
--- a/server/filled.db
+++ /dev/null
Binary files differ
diff --git a/server/router/items.go b/server/router/items.go
index c71fac6..684d1d8 100644
--- a/server/router/items.go
+++ b/server/router/items.go
@@ -31,13 +31,13 @@ func registerItem(ctx *gin.Context) {
brand := "brand coming soon"
item := db.Item {
- Model: ctx.Query("model"),
- Desc: ctx.Query("desc"),
- Price: price,
- HSN: hsn,
- GST: gst,
- Cat: cat,
- Brand: brand,
+ Model: ctx.Query("model"),
+ Description: ctx.Query("desc"),
+ UnitPrice: price,
+ HSN: hsn,
+ TotalGST: gst,
+ Category: cat,
+ Brand: brand,
}
db.RegisterItem(item)