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_requisition.go

54 lines
3.5 KiB

2 months ago
package models
import (
"ims/util/db/dts"
"time"
"gorm.io/gorm"
)
type ArrivedAddress struct {
ProvinceID int `json:"province_id"` // 省份编号
CityID int `json:"city_id"` // 城市编号
CountyID int `json:"county_id"` // 区县编号
Address string `json:"address"` // 详细地址
Province *District `json:"province,omitempty" gorm:"foreignKey:ProvinceID"`
City *District `json:"city,omitempty" gorm:"foreignKey:CityID"`
County *District `json:"county,omitempty" gorm:"foreignKey:CountyID"`
}
// PurchaseRequisition 请购单
type PurchaseRequisition struct {
ID uint `json:"id" gorm:"primaryKey"` // 入库ID
Code string `json:"code" gorm:"unique"` // 采购申请编号
RequesterID uint `json:"requester_id"` // 申请人ID(员工)
DepartmentID uint `json:"department_id"` // 申请人归属部门ID
PlannedPurchaseDate dts.Date `json:"planned_purchase_date"` // 计划采购日期
PlannedArrivedDate dts.Date `json:"planned_arrived_date"` // 计划到货日期
ReasonID dts.NullUint `json:"reason_id"` // 需求原因ID - 补货、库存预警、销售需求
WarehouseID dts.NullUint `json:"warehouse_id"` // 入库仓库ID
ArrivedTo *ArrivedAddress `json:"arrived_to" gorm:"embedded;embeddedPrefix:arrived_"` // 到货地址
Remark string `json:"remark"` // 备注
Requester *Employee `json:"requester" orm:"foreignKey:RequesterID"` // 申请人(员工)
Department *Department `json:"department" orm:"foreignKey:DepartmentID"` // 申请人归属部门
Reason *Tag `json:"reason,omitempty" gorm:"foreignKey:ReasonID"` // 需求原因
Warehouse *Warehouse `json:"warehouse,omitempty" gorm:"foreignKey:WarehouseID"` // 入库仓库
Products []PurchaseProduct `json:"products,omitempty" gorm:"foreignKey:RequisitionID"` // 采购商品列表
Audits []PurchaseAudit `json:"audits,omitempty" gorm:"foreignKey:RequisitionID"` // 审核记录
Executions []PurchaseExecution `json:"executions,omitempty" gorm:"foreignKey:RequisitionID"` // 执行记录
// 数据操作
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"` // 删除数据的员工
}