Add coa purchase and vendors
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type IngredientUnitConverter struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
OrganizationID uuid.UUID `gorm:"type:uuid;not null" json:"organization_id"`
|
||||
IngredientID uuid.UUID `gorm:"type:uuid;not null" json:"ingredient_id"`
|
||||
FromUnitID uuid.UUID `gorm:"type:uuid;not null" json:"from_unit_id"`
|
||||
ToUnitID uuid.UUID `gorm:"type:uuid;not null" json:"to_unit_id"`
|
||||
ConversionFactor float64 `gorm:"type:decimal(15,6);not null" json:"conversion_factor"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
CreatedBy uuid.UUID `gorm:"type:uuid;not null" json:"created_by"`
|
||||
UpdatedBy uuid.UUID `gorm:"type:uuid;not null" json:"updated_by"`
|
||||
|
||||
// Relationships
|
||||
Organization *Organization `gorm:"foreignKey:OrganizationID" json:"organization,omitempty"`
|
||||
Ingredient *Ingredient `gorm:"foreignKey:IngredientID" json:"ingredient,omitempty"`
|
||||
FromUnit *Unit `gorm:"foreignKey:FromUnitID" json:"from_unit,omitempty"`
|
||||
ToUnit *Unit `gorm:"foreignKey:ToUnitID" json:"to_unit,omitempty"`
|
||||
CreatedByUser *User `gorm:"foreignKey:CreatedBy" json:"created_by_user,omitempty"`
|
||||
UpdatedByUser *User `gorm:"foreignKey:UpdatedBy" json:"updated_by_user,omitempty"`
|
||||
}
|
||||
|
||||
func (IngredientUnitConverter) TableName() string {
|
||||
return "ingredient_unit_converters"
|
||||
}
|
||||
|
||||
// BeforeCreate hook to set default values
|
||||
func (iuc *IngredientUnitConverter) BeforeCreate() error {
|
||||
if iuc.ID == uuid.Nil {
|
||||
iuc.ID = uuid.New()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user