diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2025-10-14 07:35:05 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2025-10-14 07:35:05 +0530 |
commit | 9de7dcb3b45a86ee0de0e2b6f3044a859ed5ea08 (patch) | |
tree | 0968c46e2d6f28c38e2f6fa0e946ca03404a9bb2 | |
parent | 0f435049cb3cc6900d881c5dce43bec3a1e60e2e (diff) |
moved item's gst % to item not its variantv0.23.0
-rw-r--r-- | item/item.go | 2 | ||||
-rw-r--r-- | item/validators.go | 14 | ||||
-rw-r--r-- | main.go | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/item/item.go b/item/item.go index 05ca8f6..f161f78 100644 --- a/item/item.go +++ b/item/item.go @@ -40,7 +40,6 @@ type ItemVariant struct { SavedItemID uint `gorm:"index"` VariantName string // "red color", "large size", "red color large size", etc UnitPrice string // float - GSTPercentage string // float QuantityInStock string // float } @@ -52,5 +51,6 @@ type SavedItem struct { Description string HSN string UnitOfMeasure string + GSTPercentage string // float Variants []ItemVariant } diff --git a/item/validators.go b/item/validators.go index 3541acb..1fba170 100644 --- a/item/validators.go +++ b/item/validators.go @@ -31,6 +31,13 @@ func (i *SavedItem) validate() error { i.Description = strings.TrimSpace(i.Description) i.HSN = strings.TrimSpace(i.HSN) i.UnitOfMeasure = strings.TrimSpace(i.UnitOfMeasure) + i.GSTPercentage = strings.TrimSpace(i.GSTPercentage) + + // check if GSTPercentage is float + _, err := strconv.ParseFloat(i.GSTPercentage, 64) + if err != nil && i.GSTPercentage != "" { + return errors.ErrInvalidGSTPercentage + } if len(i.Variants) == 0 { return errors.ErrNoItemVariants @@ -54,7 +61,6 @@ func (i *SavedItem) validate() error { func (v *ItemVariant) validate() error { v.VariantName = strings.TrimSpace(v.VariantName) v.UnitPrice = strings.TrimSpace(v.UnitPrice) - v.GSTPercentage = strings.TrimSpace(v.GSTPercentage) v.QuantityInStock = strings.TrimSpace(v.QuantityInStock) var err error @@ -65,12 +71,6 @@ func (v *ItemVariant) validate() error { return errors.ErrInvalidUnitPrice } - // check if GSTPercentage is float - _, err = strconv.ParseFloat(v.GSTPercentage, 64) - if err != nil && v.GSTPercentage != "" { - return errors.ErrInvalidGSTPercentage - } - // check if QuantityInStock is float _, err = strconv.ParseFloat(v.QuantityInStock, 64) if err != nil && v.QuantityInStock != "" { @@ -38,7 +38,7 @@ import ( "log" ) -const OPENBILLS_VERSION = "v0.22.0" +const OPENBILLS_VERSION = "v0.23.0" func init() { if !viper.GetBool("debug_mode") { |