You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ims/app/models/purchase_order.go

58 lines
3.7 KiB

2 months ago
package models
import (
"ims/util/db/dts"
"time"
"github.com/shopspring/decimal"
"gorm.io/gorm"
)
type PurchaseOrderType int8
const (
PlannedOrder PurchaseOrderType = iota + 1 // 计划订单
PurchaseStorage // 采购入库
PurchaseReturn // 采购退货
)
// PurchaseOrder 采购订单
type PurchaseOrder struct {
// 采购订单基础信息
ID uint `json:"id" gorm:"primaryKey"` // 审核ID
Code string `json:"code"` // 采购订单编号
RequisitionID uint `json:"requisition_id"` // 采购单ID
Name string `json:"name"` // 采购订单名称
Type PurchaseOrderType `json:"type"` // 订单类型
ContractDate dts.Date `json:"contract_date"` // 订单签订日期
DeliveryDate dts.Date `json:"delivery_date"` // 订单交付日期
PurchaserID uint `json:"purchaser_id"` // 采购负责人ID
DepartmentID uint `json:"department_id"` // 采购归属部门ID
WarehouseID uint `json:"warehouse_id"` // 入库仓库ID
PreferentialPrice decimal.Decimal `json:"preferential_price"` // 优惠金额/元
RemittanceID uint `json:"remittance_id"` // 财务信息
SettlementMethodID uint `json:"settlement_method_id"` // 结算方式
//Attachments []types.File `json:"attachments"` // 合同附件上传
Products []PurchaseProduct `json:"products,omitempty" gorm:"foreignKey:OrderID"` // 采购产品明细
Requisition *PurchaseRequisition `json:"requisition,omitempty" gorm:"foreignKey:RequisitionID"` // 所属采购请求
Purchaser *Employee `json:"purchaser,omitempty" gorm:"foreignKey:PurchaserID"` // 采购负责人
Department *Department `json:"department,omitempty" gorm:"foreignKey:DepartmentID"` // 采购归属部门
Warehouse *Warehouse `json:"warehouse,omitempty" gorm:"foreignKey:WarehouseID"` // 入库仓库
DistributionPlans []DistributionPlan `json:"distribution_plans" gorm:"polymorphic:Owner;polymorphicValue:purchase"` // 到货计划
PaymentPlans []PaymentPlan `json:"payment_plans" gorm:"polymorphic:Owner;polymorphicValue:purchase"` // 付款计划
Remittance *Remittance `json:"remittance,omitempty" gorm:"foreignKey:RemittanceID"` // 财务信息
SettlementMethod *Tag `json:"settlement_method" gorm:"foreignKey:SettlementMethodID"` // 结算方式
CreatedBy uint `json:"created_by"` // 创建者(员工编号)
CreatedAt time.Time `json:"created_at"` // 创建时间
UpdatedBy dts.NullUint `json:"updated_by"` // 创建者(员工编号)
UpdatedAt dts.NullTime `json:"updated_at" gorm:"autoUpdateTime:false"` // 上次操作时间
DeletedBy dts.NullUint `json:"deleted_by"` // 删除者(员工编号)
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` // 删除数据时间
Creator *Employee `json:"creator,omitempty" gorm:"foreignKey:CreatedBy"` // 创建数据的员工
Updater *Employee `json:"updater,omitempty" gorm:"foreignKey:UpdatedBy"` // 上次更新数据的员工
Deleter *Employee `json:"deleter,omitempty" gorm:"foreignKey:DeletedBy"` // 删除数据的员工
}