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

---
 service/operation.go |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/service/operation.go b/service/operation.go
index c685dd9..4895c34 100644
--- a/service/operation.go
+++ b/service/operation.go
@@ -261,7 +261,7 @@
 		}
 	}
 	if len(internalInputDetails) > 0 {
-		opTypeId, err := GetTargetOperationTypeIdByOperation(originOperation, constvar.BaseOperationTypeIncoming)
+		opTypeId, err := GetTargetOperationTypeIdByWarehouseId(originOperation.ToLocation.WarehouseId, constvar.BaseOperationTypeIncoming)
 		if err != nil {
 			return err
 		}
@@ -434,3 +434,14 @@
 	}
 	return targetOT.Id, nil
 }
+
+func GetTargetOperationTypeIdByWarehouseId(warehouseId int, baseOT constvar.BaseOperationType) (operationTypeId int, err error) {
+	if warehouseId == 0 {
+		return 0, errors.New("warehouseId miss")
+	}
+	targetOT, err := models.NewOperationTypeSearch().SetBaseOperationType(baseOT).SetWarehouseId(warehouseId).First()
+	if err != nil {
+		return 0, err
+	}
+	return targetOT.Id, nil
+}

--
Gitblit v1.8.0