97 lines
4.0 KiB
Go
97 lines
4.0 KiB
Go
package view
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
type ProductAttribute struct {
|
|
IDProductAttribute uint `gorm:"column:id_product_attribute" json:"id_product_attribute"`
|
|
Reference string `gorm:"column:reference" json:"reference"`
|
|
BasePrice float64 `gorm:"column:base_price" json:"base_price"`
|
|
PriceTaxExcl float64 `gorm:"column:price_tax_excl" json:"price_tax_excl"`
|
|
PriceTaxIncl float64 `gorm:"column:price_tax_incl" json:"price_tax_incl"`
|
|
Quantity int64 `gorm:"column:quantity" json:"quantity"`
|
|
Attributes json.RawMessage `gorm:"column:attributes" json:"attributes"`
|
|
}
|
|
|
|
type Price struct {
|
|
Base float64 `json:"base"`
|
|
FinalTaxExcl float64 `json:"final_tax_excl"`
|
|
FinalTaxIncl float64 `json:"final_tax_incl"`
|
|
TaxRate float64 `json:"tax_rate"`
|
|
Priority int `json:"priority"` // or string
|
|
}
|
|
|
|
type Variant struct {
|
|
ID uint `json:"id_product_attribute"`
|
|
Reference string `json:"reference"`
|
|
|
|
BasePrice float64 `json:"base_price"`
|
|
FinalExcl float64 `json:"final_tax_excl"`
|
|
FinalIncl float64 `json:"final_tax_incl"`
|
|
|
|
Stock int `json:"stock"`
|
|
}
|
|
type ProductFull struct {
|
|
Product Product `json:"product"`
|
|
Price Price `json:"price"`
|
|
Variants []ProductAttribute `json:"variants,omitempty"`
|
|
}
|
|
|
|
type Product struct {
|
|
ID uint `gorm:"column:id" json:"id"`
|
|
Reference string `gorm:"column:reference" json:"reference"`
|
|
SupplierReference string `gorm:"column:supplier_reference" json:"supplier_reference,omitempty"`
|
|
EAN13 string `gorm:"column:ean13" json:"ean13,omitempty"`
|
|
UPC string `gorm:"column:upc" json:"upc,omitempty"`
|
|
ISBN string `gorm:"column:isbn" json:"isbn,omitempty"`
|
|
|
|
// Basic Price (from product table)
|
|
BasePrice float64 `gorm:"column:base_price" json:"base_price"`
|
|
WholesalePrice float64 `gorm:"column:wholesale_price" json:"wholesale_price,omitempty"`
|
|
Unity string `gorm:"column:unity" json:"unity,omitempty"`
|
|
UnitPriceRatio float64 `gorm:"column:unit_price_ratio" json:"unit_price_ratio,omitempty"`
|
|
|
|
// Stock & Availability
|
|
Quantity int `gorm:"column:quantity" json:"quantity"`
|
|
MinimalQuantity int `gorm:"column:minimal_quantity" json:"minimal_quantity"`
|
|
AvailableForOrder bool `gorm:"column:available_for_order" json:"available_for_order"`
|
|
AvailableDate string `gorm:"column:available_date" json:"available_date,omitempty"`
|
|
OutOfStockBehavior int `gorm:"column:out_of_stock_behavior" json:"out_of_stock_behavior"`
|
|
|
|
// Flags
|
|
OnSale bool `gorm:"column:on_sale" json:"on_sale"`
|
|
ShowPrice bool `gorm:"column:show_price" json:"show_price"`
|
|
Condition string `gorm:"column:condition" json:"condition"`
|
|
IsVirtual bool `gorm:"column:is_virtual" json:"is_virtual"`
|
|
|
|
// Physical
|
|
Weight float64 `gorm:"column:weight" json:"weight"`
|
|
Width float64 `gorm:"column:width" json:"width"`
|
|
Height float64 `gorm:"column:height" json:"height"`
|
|
Depth float64 `gorm:"column:depth" json:"depth"`
|
|
AdditionalShippingCost float64 `gorm:"column:additional_shipping_cost" json:"additional_shipping_cost,omitempty"`
|
|
|
|
// Delivery
|
|
DeliveryDays int `gorm:"column:delivery_days" json:"delivery_days,omitempty"`
|
|
|
|
// Status
|
|
Active bool `gorm:"column:active" json:"active"`
|
|
Visibility string `gorm:"column:visibility" json:"visibility"`
|
|
Indexed bool `gorm:"column:indexed" json:"indexed"`
|
|
|
|
// Timestamps
|
|
DateAdd time.Time `gorm:"column:date_add" json:"date_add"`
|
|
DateUpd time.Time `gorm:"column:date_upd" json:"date_upd"`
|
|
|
|
// Language fields
|
|
Name string `gorm:"column:name" json:"name"`
|
|
Description string `gorm:"column:description" json:"description"`
|
|
DescriptionShort string `gorm:"column:description_short" json:"description_short"`
|
|
|
|
// Relations
|
|
Manufacturer string `gorm:"column:manufacturer" json:"manufacturer"`
|
|
Category string `gorm:"column:category" json:"category"`
|
|
}
|