zhangqian
2023-08-29 efea3aaac3a6358cbe74891d47221b835a38d297
增加开票金额,已付金额
6个文件已修改
63 ■■■■■ 已修改文件
api/v1/purchase/purchase.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/purchase/purchase.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/purchase/purchase.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/purchase/purchase.go
@@ -1,6 +1,7 @@
package purchase
import (
    "fmt"
    "github.com/gin-gonic/gin"
    "github.com/mitchellh/mapstructure"
    "go.uber.org/zap"
@@ -12,6 +13,7 @@
    purchaserequest "srm/model/purchase/request"
    "strconv"
    "strings"
    "time"
    //"srm/model/purchase"
@@ -52,6 +54,7 @@
    purchaseRecord.Status = purchase.OrderStatusConfirmed
    purchaseRecord.HandledBy = "admin"
    purchaseRecord.Creator = "admin"
    purchaseRecord.Number = fmt.Sprintf("CG%v", time.Now().Unix())
    if !purchaseRecord.WholeDiscountType.IsValid(purchaseRecord.TotalPrice, purchaseRecord.WholeDiscount) {
        response.FailWithMessage("整单折扣数值不正确", c)
docs/docs.go
@@ -8456,6 +8456,10 @@
                    "description": "主键ID",
                    "type": "integer"
                },
                "invoiceAmount": {
                    "description": "已收票金额",
                    "type": "number"
                },
                "name": {
                    "description": "采购名称",
                    "type": "string"
@@ -8471,6 +8475,10 @@
                "orderType": {
                    "description": "单据类型",
                    "type": "string"
                },
                "paidAmount": {
                    "description": "已付金额",
                    "type": "number"
                },
                "phone": {
                    "description": "联系人电话",
@@ -8507,6 +8515,10 @@
                    "description": "备注",
                    "type": "string"
                },
                "shouldPayAmount": {
                    "description": "应付金额",
                    "type": "number"
                },
                "signingDate": {
                    "description": "签约日期",
                    "type": "string"
@@ -8528,6 +8540,10 @@
                },
                "totalPrice": {
                    "description": "价税合计",
                    "type": "number"
                },
                "unInvoiceAmount": {
                    "description": "未收票金额",
                    "type": "number"
                },
                "warehouse": {
@@ -8613,14 +8629,17 @@
        "purchase.WholeDiscountType": {
            "type": "integer",
            "enum": [
                0,
                1,
                2
            ],
            "x-enum-comments": {
                "WholeDiscountTypeDefault": "无折扣",
                "WholeDiscountTypeDiscount": "直接降价",
                "WholeDiscountTypePercent": "百分比降价"
            },
            "x-enum-varnames": [
                "WholeDiscountTypeDefault",
                "WholeDiscountTypePercent",
                "WholeDiscountTypeDiscount"
            ]
docs/swagger.json
@@ -8447,6 +8447,10 @@
                    "description": "主键ID",
                    "type": "integer"
                },
                "invoiceAmount": {
                    "description": "已收票金额",
                    "type": "number"
                },
                "name": {
                    "description": "采购名称",
                    "type": "string"
@@ -8462,6 +8466,10 @@
                "orderType": {
                    "description": "单据类型",
                    "type": "string"
                },
                "paidAmount": {
                    "description": "已付金额",
                    "type": "number"
                },
                "phone": {
                    "description": "联系人电话",
@@ -8498,6 +8506,10 @@
                    "description": "备注",
                    "type": "string"
                },
                "shouldPayAmount": {
                    "description": "应付金额",
                    "type": "number"
                },
                "signingDate": {
                    "description": "签约日期",
                    "type": "string"
@@ -8519,6 +8531,10 @@
                },
                "totalPrice": {
                    "description": "价税合计",
                    "type": "number"
                },
                "unInvoiceAmount": {
                    "description": "未收票金额",
                    "type": "number"
                },
                "warehouse": {
@@ -8604,14 +8620,17 @@
        "purchase.WholeDiscountType": {
            "type": "integer",
            "enum": [
                0,
                1,
                2
            ],
            "x-enum-comments": {
                "WholeDiscountTypeDefault": "无折扣",
                "WholeDiscountTypeDiscount": "直接降价",
                "WholeDiscountTypePercent": "百分比降价"
            },
            "x-enum-varnames": [
                "WholeDiscountTypeDefault",
                "WholeDiscountTypePercent",
                "WholeDiscountTypeDiscount"
            ]
docs/swagger.yaml
@@ -725,6 +725,9 @@
      id:
        description: 主键ID
        type: integer
      invoiceAmount:
        description: 已收票金额
        type: number
      name:
        description: 采购名称
        type: string
@@ -737,6 +740,9 @@
      orderType:
        description: 单据类型
        type: string
      paidAmount:
        description: 已付金额
        type: number
      phone:
        description: 联系人电话
        type: string
@@ -761,6 +767,9 @@
      remark:
        description: 备注
        type: string
      shouldPayAmount:
        description: 应付金额
        type: number
      signingDate:
        description: 签约日期
        type: string
@@ -775,6 +784,9 @@
        type: integer
      totalPrice:
        description: 价税合计
        type: number
      unInvoiceAmount:
        description: 未收票金额
        type: number
      warehouse:
        description: 收货仓库
@@ -834,13 +846,16 @@
    type: object
  purchase.WholeDiscountType:
    enum:
    - 0
    - 1
    - 2
    type: integer
    x-enum-comments:
      WholeDiscountTypeDefault: 无折扣
      WholeDiscountTypeDiscount: 直接降价
      WholeDiscountTypePercent: 百分比降价
    x-enum-varnames:
    - WholeDiscountTypeDefault
    - WholeDiscountTypePercent
    - WholeDiscountTypeDiscount
  purchaserequest.AddPurchase:
model/purchase/purchase.go
@@ -32,6 +32,10 @@
    PriceAdjustmentType PriceAdjustmentType `json:"priceAdjustmentType" form:"priceAdjustmentType" gorm:"type:decimal(12,2);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:已收票金额"`            //已收票金额
    UnInvoiceAmount     decimal.Decimal     `json:"unInvoiceAmount" form:"unInvoiceAmount" gorm:"type:decimal(12,2);not null;default '';comment:未收票金额"`        //未收票金额
    ShouldPayAmount     decimal.Decimal     `json:"shouldPayAmount" form:"shouldPayAmount" gorm:"type:decimal(12,2);not null;default '';comment:应付金额"`         //应付金额
    PaidAmount          decimal.Decimal     `json:"paidAmount" form:"paidAmount" gorm:"type:decimal(12,2);not null;default '';comment:已付金额"`                   //已付金额
}
type OrderStatus int
service/purchase/purchase.go
@@ -43,6 +43,9 @@
        if !realTotalPrice.Equal(record.RealTotalPrice) {
            return errors.New("最终价格计算错误")
        }
        record.UnInvoiceAmount = record.RealTotalPrice
        record.ShouldPayAmount = record.RealTotalPrice
        err = tx.Create(&record).Error
        if err != nil {
            return err