From 0f435049cb3cc6900d881c5dce43bec3a1e60e2e Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Mon, 13 Oct 2025 01:32:27 +0530 Subject: added item variants --- item/item.go | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'item/item.go') 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 + * Copyright (C) 2023-2025 Vidhu Kant Sharma * * 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 } -- cgit v1.2.3