diff options
author | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-06-26 03:18:55 +0530 |
---|---|---|
committer | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-06-26 03:18:55 +0530 |
commit | ce832a0bddc02a21d9c382f46b81dd6c114f35f9 (patch) | |
tree | 96d22a4307573b9f4f82abae5486c8baa8678332 | |
parent | e59c4dee0ab213c2e1f93b494a09fcd3810d7f10 (diff) |
Storing HSN as string now
-rw-r--r-- | server/database/database.go | 2 | ||||
-rw-r--r-- | server/database/items.go | 4 | ||||
-rw-r--r-- | server/router/items.go | 3 | ||||
-rw-r--r-- | src/components/Form/Items/AddNewItemForm.tsx | 9 |
4 files changed, 7 insertions, 11 deletions
diff --git a/server/database/database.go b/server/database/database.go index f8d9092..2339d29 100644 --- a/server/database/database.go +++ b/server/database/database.go @@ -23,7 +23,7 @@ func InitDB() { Model TEXT NOT NULL, Desc TEXT, UnitPrice REAL, - HSN BLOB, + HSN TEXT, TotalGST REAL, Category TEXT, Brand TEXT)`, diff --git a/server/database/items.go b/server/database/items.go index 059f5e6..5a637cd 100644 --- a/server/database/items.go +++ b/server/database/items.go @@ -17,7 +17,7 @@ type Item struct { Model string Description string UnitPrice float64 - HSN int + HSN string TotalGST float64 Category string Brand string @@ -32,7 +32,7 @@ func GetAllItems() []Item { var ( model, desc, cat, brand string unitPrice, GST float64 - HSN int + HSN string ) for rows.Next() { diff --git a/server/router/items.go b/server/router/items.go index 684d1d8..540fdf3 100644 --- a/server/router/items.go +++ b/server/router/items.go @@ -25,7 +25,6 @@ func getAllItems(ctx *gin.Context) { func registerItem(ctx *gin.Context) { // extract data not string price, _ := strconv.ParseFloat(ctx.Query("price"), 64) - hsn, _ := strconv.Atoi(ctx.Query("hsn")) gst, _ := strconv.ParseFloat(ctx.Query("gst"), 64) cat := "cat coming soon" brand := "brand coming soon" @@ -34,7 +33,7 @@ func registerItem(ctx *gin.Context) { Model: ctx.Query("model"), Description: ctx.Query("desc"), UnitPrice: price, - HSN: hsn, + HSN: ctx.Query("hsn"), TotalGST: gst, Category: cat, Brand: brand, diff --git a/src/components/Form/Items/AddNewItemForm.tsx b/src/components/Form/Items/AddNewItemForm.tsx index 48ca4b2..2c4669d 100644 --- a/src/components/Form/Items/AddNewItemForm.tsx +++ b/src/components/Form/Items/AddNewItemForm.tsx @@ -25,7 +25,7 @@ const AddNewItemForm: React.FC<props> = (props) => { const [itemDiscountPercentage, setItemDiscountPercentage] = useState<number>(0.00); const [itemGSTPercentage, setItemGSTValue] = useState<number>(props.defGSTValue); const [itemQTYValue, setItemQTYValue] = useState<number>(1); - const [itemHSNValue, setItemHSNValue] = useState<number>(0); + const [itemHSNValue, setItemHSNValue] = useState<string>(""); // to be handled by DocumentInfo // check if client is in same state @@ -57,7 +57,7 @@ const AddNewItemForm: React.FC<props> = (props) => { setItemQTYValue(1); setItemPriceValue(1); setItemDiscountPercentage(0); - setItemHSNValue(0); + setItemHSNValue(""); setItemGSTValue(props.defGSTValue); } @@ -157,10 +157,7 @@ const AddNewItemForm: React.FC<props> = (props) => { <label> HSN: <input className={"smallInputBox"} type="number" min="0" value={itemHSNValue} - onInput={ - (event: React.FormEvent<HTMLInputElement>) => - setItemHSNValue(parseInt(event.currentTarget.value)) - } + onChange={(event) => setItemHSNValue(event.target.value)} required /> </label> |