zhangqian
2023-08-29 9984c2c7cef1cca16055ae5d49d5ad275a7981ab
model/purchase/purchase.go
@@ -28,9 +28,9 @@
   Warehouse           string              `json:"warehouse" form:"warehouse" gorm:"type:varchar(255);not null;default '';comment:收货仓库"`                      //收货仓库
   Quantity            decimal.Decimal     `json:"quantity" form:"quantity" gorm:"type:decimal(12,4);not null;comment:采购数量"`                                  // 采购数量
   TotalPrice          decimal.Decimal     `json:"totalPrice" form:"totalPrice" gorm:"type:decimal(12,2);not null;default '';comment:价税合计"`                   //价税合计
   WholeDiscountType   WholeDiscountType   `json:"wholeDiscountType" form:"wholeDiscountType" gorm:"type:decimal(12,2);not null;default '';comment:整单折扣"`     //整单折扣类型
   WholeDiscountType   WholeDiscountType   `json:"wholeDiscountType" form:"wholeDiscountType" gorm:"type:tinyint(1);not null;default '';comment:整单折扣"`     //整单折扣类型
   WholeDiscount       decimal.Decimal     `json:"wholeDiscount" form:"wholeDiscount" gorm:"type:decimal(12,2);not null;default '';comment:整单折扣"`             //整单折扣值
   PriceAdjustmentType PriceAdjustmentType `json:"priceAdjustmentType" form:"priceAdjustmentType" gorm:"type:decimal(12,2);not null;default '';comment:价格调整"` //价格调整类型
   PriceAdjustmentType PriceAdjustmentType `json:"priceAdjustmentType" form:"priceAdjustmentType" gorm:"type:tinyint(1);not null;default '';comment:价格调整"` //价格调整类型
   PriceAdjustment     decimal.Decimal     `json:"priceAdjustment" form:"priceAdjustment" gorm:"type:decimal(12,2);not null;default '';comment:价格调整"`         //价格调整值
   RealTotalPrice      decimal.Decimal     `json:"realTotalPrice" form:"realTotalPrice" gorm:"type:decimal(12,2);not null;default '';comment:最终价格"`           //最终价格
   InvoiceAmount       decimal.Decimal     `json:"invoiceAmount" form:"invoiceAmount" gorm:"type:decimal(12,2);not null;default '';comment:已收票金额"`           //已收票金额
@@ -51,13 +51,15 @@
type WholeDiscountType int
const (
   WholeDiscountTypeDefault  WholeDiscountType = 0 //无折扣
   WholeDiscountTypePercent  WholeDiscountType = 1 //百分比降价
   WholeDiscountTypeDiscount WholeDiscountType = 2 //直接降价
)
func (wdt WholeDiscountType) IsValid(totalPrice, value decimal.Decimal) bool {
   if wdt != WholeDiscountTypePercent && wdt != WholeDiscountTypeDiscount && wdt != WholeDiscountTypeDefault {
   if wdt == 0 {
      return true
   }
   if wdt != WholeDiscountTypePercent && wdt != WholeDiscountTypeDiscount {
      return false
   }
   if wdt == WholeDiscountTypeDiscount && value.GreaterThan(totalPrice) {
@@ -77,6 +79,9 @@
)
func (pat PriceAdjustmentType) IsValid(totalPrice, value decimal.Decimal) bool {
   if pat == 0 {
      return true
   }
   if pat != PriceAdjustmentTypeAdd && pat != PriceAdjustmentTypeSub {
      return false
   }