From 63d4dca1ec0d293c29c8f62a8bbe1466ab2462aa Mon Sep 17 00:00:00 2001
From: yinbentan <yinbentan@live.com>
Date: 星期六, 06 七月 2024 16:32:32 +0800
Subject: [PATCH] 未选仓库的时候统计产品数量错误bug修复

---
 service/inventory_report_forms.go |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/service/inventory_report_forms.go b/service/inventory_report_forms.go
index 9d5f88d..4409d83 100644
--- a/service/inventory_report_forms.go
+++ b/service/inventory_report_forms.go
@@ -129,22 +129,27 @@
 	locationIds []int,
 	err error) {
 	productAmounts = make([]*models.LocationProductAmount, 0)
+	locationSearch := models.NewLocationSearch()
 	if params.WarehouseCode != "" {
-		locations, err := models.NewLocationSearch().SetJointName(params.WarehouseCode).FindNotTotal()
-		if err != nil {
-			return nil, nil, nil, nil, err
-		}
+		locationSearch.SetJointName(params.WarehouseCode)
+	}
 
-		for _, location := range locations {
-			locationIds = append(locationIds, location.Id)
-		}
-		productAmounts, err = models.NewLocationProductAmountSearch().SetLocationIds(locationIds).SetQuery("amount > 0").Find()
-		if err != nil {
-			return nil, nil, nil, nil, err
-		}
-		for _, amount := range productAmounts {
-			productIds = append(productIds, amount.ProductId)
-		}
+	locations, err := locationSearch.FindNotTotal()
+	if err != nil {
+		return nil, nil, nil, nil, err
+	}
+
+	for _, location := range locations {
+		locationIds = append(locationIds, location.Id)
+	}
+	productAmounts, err = models.NewLocationProductAmountSearch().
+		SetLocationIds(locationIds).SetQuery("amount > 0").
+		Find()
+	if err != nil {
+		return nil, nil, nil, nil, err
+	}
+	for _, amount := range productAmounts {
+		productIds = append(productIds, amount.ProductId)
 	}
 
 	//鏌ヨ浜у搧

--
Gitblit v1.8.0