variants units

This commit is contained in:
2026-09-02 16:01:24 +05:30
parent 09efc5403f
commit e45da9f7df
8 changed files with 374 additions and 61 deletions

View File

@@ -63,9 +63,14 @@ type Productvariant struct {
// why a variant does not need to duplicate any of them.
Variantproductid int `json:"variantproductid"`
Variantname string `json:"variantname"`
Varianttype string `json:"varianttype,omitempty"`
Price float64 `json:"price,omitempty"`
Variantname string `json:"variantname"`
Varianttype string `json:"varianttype,omitempty"`
// A per-variant price override. 0 means "no override, use the product’s
// own price" — which is a real answer, so it is always emitted. With
// omitempty the key vanished at 0 and a client reading `price` got
// undefined, then rendered it.
Price float64 `json:"price"`
Categoryid int `json:"categoryid" gorm:"default:0"`
Categoryname string `json:"categoryname" gorm:"-"`
@@ -78,6 +83,12 @@ type Productvariant struct {
Variantproductname string `json:"variantproductname" gorm:"->"`
Variantprice float64 `json:"variantprice" gorm:"->"`
Variantstock int `json:"variantstock" gorm:"->"`
// The size, as the product itself records it. Without these the only way to
// label a size was to join the parent’s unit fields to the variant’s name,
// which is how "null kg" reaches a screen.
Variantunitvalue string `json:"variantunitvalue" gorm:"->"`
Variantproductunit string `json:"variantproductunit" gorm:"->"`
}
type Products struct {
@@ -131,8 +142,8 @@ type Products struct {
Productsku string `json:"productsku,omitempty"`
Brandid int `json:"brandid,omitempty"`
Productbrand string `json:"productbrand,omitempty"`
Productunit string `json:"productunit,omitempty"`
Unitvalue string `json:"unitvalue,omitempty"`
Productunit string `json:"productunit"`
Unitvalue string `json:"unitvalue"`
Toppicks string `json:"toppicks,omitempty"`
Productcost float64 `json:"productcost,omitempty"`
Taxamount float64 `json:"taxamount,omitempty"`
@@ -163,7 +174,7 @@ type Products struct {
// returned only Retailprice, which the admin catalogue never writes.
// Same meaning as Locationproducts.Price, so both product feeds agree.
Price float64 `json:"price" gorm:"->"`
Retailprice float64 `json:"retailprice,omitempty"`
Retailprice float64 `json:"retailprice"`
Diffprice float64 `json:"diffprice,omitempty"`
Diffpercent float64 `json:"diffpercent,omitempty"`
Othercost float64 `json:"othercost,omitempty"`
@@ -199,8 +210,8 @@ type Locationproducts struct {
Productsku string `json:"productsku,omitempty"`
Brandid int `json:"brandid,omitempty"`
Productbrand string `json:"productbrand,omitempty"`
Productunit string `json:"productunit,omitempty"`
Unitvalue string `json:"unitvalue,omitempty"`
Productunit string `json:"productunit"`
Unitvalue string `json:"unitvalue"`
Toppicks string `json:"toppicks,omitempty"`
Productcost float64 `json:"productcost,omitempty"`
Taxamount float64 `json:"taxamount,omitempty"`
@@ -215,7 +226,7 @@ type Locationproducts struct {
// productlocations row, not from products. Without it a store could set a
// price and never read it back, so the UI always showed the master price.
Price float64 `json:"price" gorm:"->"`
Retailprice float64 `json:"retailprice,omitempty"`
Retailprice float64 `json:"retailprice"`
Diffprice float64 `json:"diffprice,omitempty"`
Diffpercent float64 `json:"diffpercent,omitempty"`
Othercost float64 `json:"othercost,omitempty"`