/// <summary> /// Step 2. 在商务报表查找符合条件的"结转前期库存" /// </summary> /// <param name="sellModel"></param> /// <param name="mappingEntityList"></param> private static void Step2_ProcessJieSuanQianQiKuCun(SellModel sellModel, List <MappingModel> mappingModelList) { //在商务报表中查找货号 var mappingModelList_Buy = mappingModelList.Where(v => v.ProductNo.Equals(sellModel.ProductNo) && v.MaiMai == 2).ToList(); var mappingModelList_Sell = mappingModelList.Where(v => v.ProductNo.Equals(sellModel.ProductNo) && v.MaiMai == 1).ToList(); var buyTotalCount = mappingModelList_Buy.Sum(v => v.KaiChuShouDaoFaPiaoDunShu); var sellTotalCount = mappingModelList_Sell.Sum(v => v.KaiChuShouDaoFaPiaoDunShu); if (buyTotalCount == sellTotalCount) { List <string> butContractNoList = mappingModelList_Buy.Select(v => v.ContractNo).Distinct().ToList(); List <string> gouXiaoHeTongTaiTou = mappingModelList_Buy.Select(v => v.GouXiaoHeTongTaiTou).Distinct().ToList(); //设置销项 sellModel.SetSellMode(SellModelSaleMode.JieSuanQianQiKuCun); sellModel.SetCaiGouContractNo(string.Join(";", butContractNoList)); sellModel.SetCaiGouDanWei(string.Join(";", gouXiaoHeTongTaiTou)); sellModel.SetJinXiangShouPiaoDunShu(buyTotalCount); sellModel.SetKuCun(buyTotalCount - sellModel.ProductCount); sellModel.RelativeBusinessIds.AddRange(mappingModelList_Buy.Select(v => v.Id)); sellModel.RelativeBusinessIds.AddRange(mappingModelList_Sell.Select(v => v.Id)); sellModel.RelativeBusinessIds.RemoveAll(v => sellModel.BusinessNo == v); } }
/// <summary> /// Step 1. 在本期销项明细表和本期进项明细表中找到直运的记录 /// </summary> /// <param name="sellModel"></param> /// <param name="buyModelList"></param> private static void Step1_FindDirectBusiness(SellModel sellModel, List <BuyModel> buyModelList) { //在本期进项明细表中查找货号 var buyModelList_ProductNoMatched = buyModelList.Where(v => v.ProductNo.Equals(sellModel.ProductNo)).ToList(); //正好有一个货号匹配的并且产品数相同,则视为“直运” if (buyModelList_ProductNoMatched.Count == 1) { if (buyModelList_ProductNoMatched[0].ReceiveTicketCount == sellModel.ProductCount) { var buyModel = buyModelList_ProductNoMatched[0]; // 设置销项 sellModel.SetSellMode(SellModelSaleMode.DirectBusiness); sellModel.SetCaiGouContractNo(buyModel.BuyContractNo); sellModel.SetCaiGouDanWei(buyModel.XiaoFangMinCheng); sellModel.SetJinXiangShouPiaoDunShu(buyModel.ReceiveTicketCount); sellModel.RelativeBusinessIds.Add(buyModel.Id); //设置进项 buyModel.SetSellMode(BuyModelSaleMode.DirectBusiness); buyModel.RelativeBusinessIds.Add(sellModel.BusinessNo); } } }