diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2025-10-13 01:32:27 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2025-10-13 01:32:27 +0530 |
commit | 0f435049cb3cc6900d881c5dce43bec3a1e60e2e (patch) | |
tree | 374950fba5605ea8411da428ac94b1deef4e2809 /item/item.go | |
parent | fb9ba155438100f295fdb563ad955151ee038ad3 (diff) |
Diffstat (limited to 'item/item.go')
-rw-r--r-- | item/item.go | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/item/item.go b/item/item.go index 108187a..05ca8f6 100644 --- a/item/item.go +++ b/item/item.go @@ -1,5 +1,5 @@ /* openbills - Server for web based Libre Billing Software - * Copyright (C) 2023 Vidhu Kant Sharma <vidhukant@vidhukant.com> + * Copyright (C) 2023-2025 Vidhu Kant Sharma <vidhukant@vidhukant.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,21 +27,30 @@ var db *gorm.DB func init() { db = d.DB - db.AutoMigrate(&SavedItem{}) + db.AutoMigrate(&SavedItem{}, &ItemVariant{}) } -type Item struct { +type ItemVariant struct { + // if the item has only one variant and showing it on + // the UI side (or when printing) isn't really necessary + // just set it as ".default" on the UI side so it can be + // optionally ignored. it's just a standard I'm setting + // here, the server gives no shit + ID uint `gorm:"primaryKey"` + SavedItemID uint `gorm:"index"` + VariantName string // "red color", "large size", "red color large size", etc + UnitPrice string // float + GSTPercentage string // float + QuantityInStock string // float +} + +type SavedItem struct { + ID uint `gorm:"primaryKey"` Name string BrandName string Category string Description string HSN string UnitOfMeasure string - UnitPrice string // float - GSTPercentage string // float -} - -type SavedItem struct { - gorm.Model - Item + Variants []ItemVariant } |