| | |
| | | ) |
| | | |
| | | type Purchase struct { |
| | | global.GVA_MODEL |
| | | PurchaseTypeId int `json:"purchaseTypeId" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"` // 采购类型id |
| | | global.GVA_MODEL_INT |
| | | PurchaseTypeId int `json:"purchaseTypeId,string" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"` // 采购类型id |
| | | PurchaseType PurchaseType `json:"purchaseType" gorm:"foreignKey:PurchaseTypeId"` |
| | | OrderSource string `json:"orderSource" gorm:"type:varchar(255);not null;default '';comment:单据来源"` // 单据来源 |
| | | SupplierId int `json:"supplierId" form:"supplierId" gorm:"type:int(11);not null;default 0;comment:供应商id"` // 供应商id |
| | | OrderSource string `json:"orderSource" gorm:"type:varchar(255);not null;default '';comment:单据来源"` // 单据来源 |
| | | SupplierId int `json:"supplierId,string" form:"supplierId" gorm:"type:int(11);not null;default 0;comment:供应商id"` // 供应商id |
| | | Supplier test.Supplier `json:"supplier" gorm:"foreignKey:SupplierId"` |
| | | Number string `json:"number" form:"number" gorm:"unique;type:varchar(255);not null;default '';comment:采购编号"` // 采购编号 |
| | | Name string `json:"name" form:"name" gorm:"type:varchar(255);not null;default '';comment:采购名称"` // 采购名称 |
| | |
| | | PaidAmount decimal.Decimal `json:"paidAmount" form:"paidAmount" gorm:"type:decimal(12,2);not null;default '';comment:已付金额"` //已付金额 |
| | | } |
| | | |
| | | func (Purchase) TableName() string { |
| | | return "srm_purchase" |
| | | } |
| | | |
| | | type OrderStatus int |
| | | |
| | | const ( |
| | | OrderStatusConfirmed OrderStatus = 1 //已下单 |
| | | OrderStatusReceived OrderStatus = 2 //已到货 |
| | | OrderStatusConfirmed OrderStatus = 1 //待确认 |
| | | OrderStatusReceived OrderStatus = 2 //待入库 |
| | | OrderStatusStored OrderStatus = 3 //已入库 |
| | | OrderStatusCompleted OrderStatus = 4 //已完成 |
| | | OrderStatusCanceled OrderStatus = 5 //已取消 |
| | | ) |
| | | |
| | | type WholeDiscountType int |
| | |
| | | func (slf Purchase) CalcRealTotalPrice() decimal.Decimal { |
| | | totalPrice := slf.TotalPrice |
| | | if slf.WholeDiscountType == WholeDiscountTypePercent { |
| | | totalPrice = totalPrice.Mul(slf.WholeDiscount).Div(decimal.NewFromInt(100)) |
| | | totalPrice = totalPrice.Mul(decimal.NewFromInt(1).Sub(slf.WholeDiscount.Div(decimal.NewFromInt(100)))) |
| | | } else if slf.WholeDiscountType == WholeDiscountTypeDiscount { |
| | | totalPrice = totalPrice.Sub(slf.WholeDiscount) |
| | | } |