Refactor partnumber book catalog storage
This commit is contained in:
@@ -57,11 +57,11 @@ func (StockLog) TableName() string {
|
||||
|
||||
// LotPartnumber maps external part numbers to internal lots.
|
||||
type LotPartnumber struct {
|
||||
Vendor string `gorm:"column:vendor;size:255;primaryKey" json:"vendor"`
|
||||
Partnumber string `gorm:"column:partnumber;size:255;primaryKey" json:"partnumber"`
|
||||
LotName string `gorm:"column:lot_name;size:255" json:"lot_name"`
|
||||
Description *string `gorm:"column:description;size:10000" json:"description,omitempty"`
|
||||
IsPrimaryPN bool `gorm:"column:is_primary_pn;not null;default:true" json:"is_primary_pn"`
|
||||
Vendor string `gorm:"column:vendor;size:255;primaryKey" json:"vendor"`
|
||||
Partnumber string `gorm:"column:partnumber;size:255;primaryKey" json:"partnumber"`
|
||||
LotName string `gorm:"column:lot_name;size:255" json:"lot_name"`
|
||||
Description *string `gorm:"column:description;size:10000" json:"description,omitempty"`
|
||||
IsPrimaryPN bool `gorm:"column:is_primary_pn;not null;default:true" json:"is_primary_pn"`
|
||||
}
|
||||
|
||||
func (LotPartnumber) TableName() string {
|
||||
@@ -71,24 +71,29 @@ func (LotPartnumber) TableName() string {
|
||||
// PartnumberBook is a versioned snapshot of the partnumber→LOT mapping.
|
||||
// Written by PriceForge; QuoteForge reads via SELECT only.
|
||||
type PartnumberBook struct {
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
Version string `gorm:"column:version;size:30;not null;uniqueIndex:uq_qt_partnumber_books_version" json:"version"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`
|
||||
CreatedBy string `gorm:"column:created_by;size:100;not null;default:''" json:"created_by"`
|
||||
IsActive bool `gorm:"column:is_active;not null;default:false" json:"is_active"`
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
Version string `gorm:"column:version;size:30;not null;uniqueIndex:uq_qt_partnumber_books_version" json:"version"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`
|
||||
CreatedBy string `gorm:"column:created_by;size:100;not null;default:''" json:"created_by"`
|
||||
IsActive bool `gorm:"column:is_active;not null;default:false" json:"is_active"`
|
||||
PartnumbersJSON string `gorm:"column:partnumbers_json;type:longtext;not null" json:"partnumbers_json"`
|
||||
}
|
||||
|
||||
func (PartnumberBook) TableName() string {
|
||||
return "qt_partnumber_books"
|
||||
}
|
||||
|
||||
// PartnumberBookItem is one mapping row in a PartnumberBook snapshot.
|
||||
// Bundles are expanded: a single partnumber may have multiple rows (one per LOT component).
|
||||
type PartnumberBookLot struct {
|
||||
LotName string `json:"lot_name"`
|
||||
Qty float64 `json:"qty"`
|
||||
}
|
||||
|
||||
// PartnumberBookItem is the current source-of-truth row for one partnumber.
|
||||
// lots_json stores the resolved LOT composition with quantities.
|
||||
type PartnumberBookItem struct {
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
BookID uint64 `gorm:"column:book_id;not null" json:"book_id"`
|
||||
Partnumber string `gorm:"column:partnumber;size:255;not null" json:"partnumber"`
|
||||
LotName string `gorm:"column:lot_name;size:255;not null" json:"lot_name"`
|
||||
Partnumber string `gorm:"column:partnumber;size:255;not null;uniqueIndex:uq_qt_partnumber_book_items_partnumber" json:"partnumber"`
|
||||
LotsJSON string `gorm:"column:lots_json;type:longtext;not null" json:"lots_json"`
|
||||
IsPrimaryPN bool `gorm:"column:is_primary_pn;not null;default:true" json:"is_primary_pn"`
|
||||
Description *string `gorm:"column:description;size:10000" json:"description,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user