Implement global vendor mappings with bundle support and seen-based ignore
This commit is contained in:
@@ -57,8 +57,9 @@ 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;primaryKey" json:"lot_name"`
|
||||
LotName string `gorm:"column:lot_name;size:255" json:"lot_name"`
|
||||
Description *string `gorm:"column:description;size:10000" json:"description,omitempty"`
|
||||
}
|
||||
|
||||
@@ -66,11 +67,67 @@ func (LotPartnumber) TableName() string {
|
||||
return "lot_partnumbers"
|
||||
}
|
||||
|
||||
// StockIgnoreRule contains import ignore pattern rules.
|
||||
type LotBundle struct {
|
||||
BundleLotName string `gorm:"column:bundle_lot_name;size:255;primaryKey" json:"bundle_lot_name"`
|
||||
IsActive bool `gorm:"column:is_active;default:true" json:"is_active"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (LotBundle) TableName() string {
|
||||
return "qt_lot_bundles"
|
||||
}
|
||||
|
||||
type LotBundleItem struct {
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
BundleLotName string `gorm:"column:bundle_lot_name;size:255;not null;index:uq_qt_lot_bundle_items_bundle_lot,unique" json:"bundle_lot_name"`
|
||||
LotName string `gorm:"column:lot_name;size:255;not null;index:uq_qt_lot_bundle_items_bundle_lot,unique" json:"lot_name"`
|
||||
Qty float64 `gorm:"column:qty;not null" json:"qty"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (LotBundleItem) TableName() string {
|
||||
return "qt_lot_bundle_items"
|
||||
}
|
||||
|
||||
type VendorPartnumberSeen struct {
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
SourceType string `gorm:"column:source_type;size:32;not null;index:uq_qt_vendor_partnumber_seen_source_key,unique" json:"source_type"`
|
||||
Vendor string `gorm:"column:vendor;size:255;not null;default:'';index:uq_qt_vendor_partnumber_seen_source_key,unique;index:idx_qt_vendor_partnumber_seen_vendor_partnumber" json:"vendor"`
|
||||
Partnumber string `gorm:"column:partnumber;size:255;not null;index:uq_qt_vendor_partnumber_seen_source_key,unique;index:idx_qt_vendor_partnumber_seen_vendor_partnumber" json:"partnumber"`
|
||||
Description *string `gorm:"column:description;size:10000" json:"description,omitempty"`
|
||||
LastSeenAt time.Time `gorm:"column:last_seen_at;not null" json:"last_seen_at"`
|
||||
IsIgnored bool `gorm:"column:is_ignored;not null;default:false;index:idx_qt_vendor_partnumber_seen_ignored" json:"is_ignored"`
|
||||
IgnoredAt *time.Time `gorm:"column:ignored_at" json:"ignored_at,omitempty"`
|
||||
IgnoredBy *string `gorm:"column:ignored_by;size:100" json:"ignored_by,omitempty"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (VendorPartnumberSeen) TableName() string {
|
||||
return "qt_vendor_partnumber_seen"
|
||||
}
|
||||
|
||||
type BOM struct {
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
ExternalBOMID string `gorm:"column:external_bom_id;size:255;not null;index:uq_qt_bom_source_external,unique" json:"external_bom_id"`
|
||||
SourceSystem string `gorm:"column:source_system;size:100;not null;index:uq_qt_bom_source_external,unique" json:"source_system"`
|
||||
Payload *string `gorm:"column:payload;type:json" json:"payload,omitempty"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (BOM) TableName() string {
|
||||
return "qt_bom"
|
||||
}
|
||||
|
||||
// StockIgnoreRule is deprecated and kept for backward compatibility only.
|
||||
// New logic uses VendorPartnumberSeen.is_ignored.
|
||||
type StockIgnoreRule struct {
|
||||
ID uint `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
Target string `gorm:"column:target;size:20;not null" json:"target"` // partnumber|description
|
||||
MatchType string `gorm:"column:match_type;size:20;not null" json:"match_type"` // exact|prefix|suffix
|
||||
Target string `gorm:"column:target;size:20;not null" json:"target"`
|
||||
MatchType string `gorm:"column:match_type;size:20;not null" json:"match_type"`
|
||||
Pattern string `gorm:"column:pattern;size:500;not null" json:"pattern"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user