From 95c4151f986ac883989213a1df9d29c67aeacf78 Mon Sep 17 00:00:00 2001 From: chenlin Date: Tue, 19 Nov 2024 19:19:13 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=BA=93=E5=AD=98=E8=B0=83=E6=8B=A8?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E5=A2=9E=E5=8A=A0=E8=B0=83=E6=8B=A8=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E5=AD=97=E6=AE=B5=EF=BC=9B=202=E3=80=81=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E8=AE=A2=E5=8D=95=E8=A1=A8=E5=A2=9E=E5=8A=A0=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E9=87=91=E9=A2=9D=E5=AD=97=E6=AE=B5=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/models/inventory_report.go | 4 +++- app/admin/models/purchase.go | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/admin/models/inventory_report.go b/app/admin/models/inventory_report.go index 0b80a0f..c927feb 100644 --- a/app/admin/models/inventory_report.go +++ b/app/admin/models/inventory_report.go @@ -153,6 +153,7 @@ type ReportAllotDetailData struct { IMEIType uint32 `json:"imei_type"` // 1-无串码 2-串码 IMEI string `json:"imei"` // 商品串码 Remark string `json:"remark"` // 备注 + AllotAmount float64 `json:"allot_amount"` // 调拨金额 } // InventoryReportByOtherReq 其他出入库汇总入参 @@ -1166,7 +1167,8 @@ func (m *InventoryReportAllotDetailReq) ReportAllotDetailList(c *gin.Context) (* "erp_inventory_allot_commodity.imei_type, "+ "erp_inventory_allot_commodity.imei, "+ "erp_inventory_allot_commodity.count, "+ - "erp_inventory_allot_commodity.remark"). + "erp_inventory_allot_commodity.remark, "+ + "erp_inventory_allot_commodity.amount as allot_amount"). Joins("JOIN erp_inventory_allot_commodity ON erp_inventory_allot_commodity.allot_order_id = erp_inventory_allot_order.id"). Where("erp_inventory_allot_order.state <> ?", ErpInventoryAllotOrderUnAudit) // 排除待审核的订单 diff --git a/app/admin/models/purchase.go b/app/admin/models/purchase.go index 5408b7c..9d22c9a 100644 --- a/app/admin/models/purchase.go +++ b/app/admin/models/purchase.go @@ -66,6 +66,7 @@ type ErpPurchaseOrder struct { Commodities []ErpPurchaseCommodity `json:"commodities" gorm:"-"` // InventoryId uint32 `json:"inventory_id" gorm:"-"` // 最近入库人id InventoryName string `json:"inventory_name" gorm:"-"` // 最近入库人名称 + Amount float64 `json:"amount" gorm:"-"` // 计划采购金额 } // ErpPurchaseCommodity 采购订单商品表 @@ -93,7 +94,7 @@ type ErpPurchaseCommodity struct { DefaultEmployeePrice float64 `json:"default_employee_price" gorm:"-"` // 默认员工成本价 EffectiveCount uint32 `json:"effective_count" gorm:"-"` // 有效数量(该商品实际库存详情处剩余有效数,不包含已出库的数量) ErpCategoryID uint32 `json:"erp_category_id" gorm:"-"` // 商品分类id - ErpCategoryName string `json:"erp_category_name" gorm:"-"` // 商品分类名称 + ErpCategoryName string `json:"erp_category_name" gorm:"-"` // 商品分类名称 } // ErpPurchaseInventory 采购入库执行信息 @@ -657,12 +658,25 @@ func (m *ErpPurchaseOrderListReq) List(c *gin.Context) (*ErpPurchaseOrderListRes if v.AuditTime != nil && v.AuditTime.IsZero() { orders[i].AuditTime = nil } + + orders[i].Amount, _ = getPurchaseOrderAmount(v.ID) } resp.List = orders return resp, nil } +func getPurchaseOrderAmount(purchaseOrderId uint32) (float64, error) { + var amount float64 + err := orm.Eloquent.Table("erp_purchase_commodity"). + Where("erp_purchase_order_id = ?", purchaseOrderId). + Pluck("sum(amount)", &amount).Error + if err != nil { + return 0, err + } + return amount, nil +} + // newErpPurchaseSn 生成采购订单号 func newErpPurchaseSn(purchaseType string) string { var prefix string