animeic 2 ani în urmă
părinte
comite
f31012718e

+ 5 - 8
boxcost/api/bill-purchase-excel.go

@@ -3,7 +3,6 @@ package api
 import (
 	"box-cost/db/model"
 	"fmt"
-	"strconv"
 
 	_ "image/gif"
 	_ "image/jpeg"
@@ -231,13 +230,11 @@ func (b *PurchaseBillExcel) drawTableContent() error {
 
 			confirmCount := "-"
 			realAmount := "-"
-			price, err := strconv.ParseFloat(paper.Price, 64)
-			if err != nil {
-				price = 0.00
-			}
+			price := fmt.Sprintf("%.2f", paper.Price)
+			price2 := fmt.Sprintf("%.2f", paper.Price2)
 
 			// 预算金额
-			budgetAmount := fmt.Sprintf("%.2f", float64(paper.Count)*price)
+			budgetAmount := fmt.Sprintf("%.2f", b.Content.BudgetAmount)
 			b.FormatToEmpty(&budgetAmount)
 
 			if b.Content.Status == "complete" {
@@ -246,11 +243,11 @@ func (b *PurchaseBillExcel) drawTableContent() error {
 				b.FormatToEmpty(&confirmCount)
 
 				// 实际金额
-				realAmount = fmt.Sprintf("%.2f", float64(b.Content.ConfirmCount)*price)
+				realAmount = fmt.Sprintf("%.2f", b.Content.RealAmount)
 				b.FormatToEmpty(&realAmount)
 			}
 
-			DrawRow(row, paper.Name, paper.Norm, paper.Height, paper.Width, fmt.Sprintf("%d", paper.Count), confirmCount, paper.Price, paper.Price2, budgetAmount, realAmount, deliveryTime, paper.Remark)
+			DrawRow(row, paper.Name, paper.Norm, paper.Height, paper.Width, fmt.Sprintf("%d", paper.Count), confirmCount, price, price2, budgetAmount, realAmount, deliveryTime, paper.Remark)
 			row++
 			b.Row++
 		}

+ 5 - 6
boxcost/api/plan-cost-excel.go

@@ -602,12 +602,11 @@ func (b *PlanCostExcel) drawAllContent() error {
 func (b *PlanCostExcel) Draws() {
 	b.drawTitle()
 	b.drawTableTitle()
-	// if b.Content.SupplierId != "" {
-	// 	b.drawSupplierContent()
-	// } else {
-	// 	b.drawAllContent()
-	// }
-	b.drawAllContent()
+	if b.Content.SupplierId != "" {
+		b.drawSupplierContent()
+	} else {
+		b.drawAllContent()
+	}
 
 }
 

+ 12 - 9
boxcost/api/report-produce-excel.go

@@ -191,6 +191,8 @@ func (b *ReportProduceExcel) drawTableContent() error {
 
 	produces := b.Content.Produces
 	if len(produces) > 0 {
+		startRow := b.Row
+		endRow := b.Row
 		for _, produce := range produces {
 
 			confirmCount := "-"
@@ -201,26 +203,27 @@ func (b *ReportProduceExcel) drawTableContent() error {
 			b.FormatToEmpty(&priceStr)
 
 			// 预算金额
-			budgetAmount := fmt.Sprintf("%.2f", float64(produce.OrderCount)*price)
-			b.FormatToEmpty(&budgetAmount)
-
-			b.BudgetCount += float64(produce.OrderCount) * price
+			budgetAmount := ""
 
 			// 实际完成数
-			confirmCount = fmt.Sprintf("%d", b.Content.ConfirmCount)
+			confirmCount = fmt.Sprintf("%d", produce.ConfirmCount)
 			b.FormatToEmpty(&confirmCount)
 
 			// 实际金额
-			realAmount = fmt.Sprintf("%.2f", float64(b.Content.ConfirmCount)*price)
-			b.FormatToEmpty(&realAmount)
-
-			b.RealCount += float64(b.Content.ConfirmCount) * price
+			realAmount = ""
 
 			deliveryTime := produce.DeliveryTime.Local().Format("2006-01-02")
 			DrawRow(row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), confirmCount, priceStr, budgetAmount, realAmount, deliveryTime, produce.Remark)
 			row++
 			b.Row++
 		}
+		// 多个工序 合并预算价格、实际价格
+		b.Excel.MergeCell(b.SheetName, fmt.Sprintf("I%d", startRow), fmt.Sprintf("I%d", endRow))
+		b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("I%d", startRow), b.Content.BudgetAmount)
+		b.Excel.MergeCell(b.SheetName, fmt.Sprintf("J%d", startRow), fmt.Sprintf("J%d", endRow))
+		b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("J%d", startRow), b.Content.RealAmount)
+		b.BudgetCount += b.Content.BudgetAmount
+		b.RealCount += b.Content.RealAmount
 	}
 
 	return nil

+ 7 - 10
boxcost/api/report-purchase-excel.go

@@ -3,7 +3,6 @@ package api
 import (
 	"box-cost/db/model"
 	"fmt"
-	"strconv"
 
 	_ "image/gif"
 	_ "image/jpeg"
@@ -232,26 +231,24 @@ func (b *ReportPurchaseExcel) drawTableContent() error {
 
 			confirmCount := "-"
 			realAmount := "-"
-			price, err := strconv.ParseFloat(paper.Price, 64)
-			if err != nil {
-				price = 0.00
-			}
+			price := fmt.Sprintf("%.2f", paper.Price)
+			price2 := fmt.Sprintf("%.2f", paper.Price2)
 
 			// 预算金额
-			budgetAmount := fmt.Sprintf("%.2f", float64(paper.Count)*price)
+			budgetAmount := fmt.Sprintf("%.2f", b.Content.BudgetAmount)
 			b.FormatToEmpty(&budgetAmount)
-			b.BudgetCount += float64(paper.Count) * price
+			b.BudgetCount += b.Content.BudgetAmount
 
 			// 实际完成数
 			confirmCount = fmt.Sprintf("%d", b.Content.ConfirmCount)
 			b.FormatToEmpty(&confirmCount)
 
 			// 实际金额
-			realAmount = fmt.Sprintf("%.2f", float64(b.Content.ConfirmCount)*price)
+			realAmount = fmt.Sprintf("%.2f", b.Content.RealAmount)
 			b.FormatToEmpty(&realAmount)
-			b.RealCount += float64(b.Content.ConfirmCount) * price
+			b.RealCount += b.Content.RealAmount
 
-			DrawRow(row, paper.Name, paper.Norm, paper.Height, paper.Width, fmt.Sprintf("%d", paper.Count), confirmCount, paper.Price, paper.Price2, budgetAmount, realAmount, deliveryTime, paper.Remark)
+			DrawRow(row, paper.Name, paper.Norm, paper.Height, paper.Width, fmt.Sprintf("%d", paper.Count), confirmCount, price, price2, budgetAmount, realAmount, deliveryTime, paper.Remark)
 			row++
 			b.Row++
 		}

+ 4 - 4
boxcost/db/model/bill.go

@@ -19,10 +19,10 @@ type PaperBill struct {
 	//长
 	Height string `bson:"height,omitempty" json:"height"`
 
-	Price      string `bson:"price,omitempty" json:"price"`
-	Price2     string `bson:"price2,omitempty" json:"price2"`
-	PriceUnit  string `bson:"priceUnit,omitempty" json:"priceUnit"`
-	Price2Unit string `bson:"price2Unit,omitempty" json:"price2Unit"`
+	Price      float64 `bson:"price,omitempty" json:"price"`
+	Price2     float64 `bson:"price2,omitempty" json:"price2"`
+	PriceUnit  string  `bson:"priceUnit,omitempty" json:"priceUnit"`
+	Price2Unit string  `bson:"price2Unit,omitempty" json:"price2Unit"`
 
 	//数量
 	Count int `bson:"count,omitempty" json:"count"`