From 630acf0b49156f5fc21babe8f11d2a441f48fed9 Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Thu, 11 Jul 2024 16:21:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bases/BA_SERVICE.cs | 2 +- .../Bases/CAN_SA_SERVICE.cs | 8 +- .../Entities/BQ/PURCHASE_PRICE_SERVICE.cs | 1 + .../BQ/Syncs/GenerateJisInvoiceService.cs | 19 - .../Entities/BQ/INVOICE_GRP.cs | 68 ++ .../Entities/BQ/Managers/INV_MNG.cs | 1020 +++++++++-------- 6 files changed, 605 insertions(+), 513 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs index 45b238c2..3bd738fd 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs @@ -552,7 +552,7 @@ namespace Win.Sfs.SettleAccount.Bases /// 版本号 /// 发票分组 /// 原发票号 - protected async Task ReissueSecInvoice(List p_list, List p_adjlist, List p_tmplist, int p_version, string p_parentInvBillNum) where TDetail : SA_CAN_BASE + protected async Task ReissueSecInvoice(List p_list, List p_adjlist, List p_tmplist, int p_version, string p_parentInvBillNum) where TDetail : SA_CAN_BASE, new() { var flag = await _invMng.ReissueSecInvoice(p_list, p_adjlist, p_tmplist, p_parentInvBillNum, p_version).ConfigureAwait(false); if (flag) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs index ea7c8d5f..ba65e4e6 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs @@ -168,7 +168,7 @@ namespace Win.Sfs.SettleAccount.Bases /// 版本号 /// 发票分组 /// 原发票号 - protected async Task SecInvoice(List p_list, List p_adjlist, List dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType, List p_notlist = null) where TDetail : SA_CAN_BASE + protected async Task SecInvoice(List p_list, List p_adjlist, List dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType, List p_notlist = null) where TDetail : SA_CAN_BASE, new() { List invlist = new List(); @@ -176,10 +176,10 @@ namespace Win.Sfs.SettleAccount.Bases switch (businessType) { case EnumBusinessType.MaiDanJianHBPO: - invlist = await _invmng.MakeInvoice(p_list, p_adjlist, dtos, p_version, p_InvGroupNum, string.Empty, businessType, false).ConfigureAwait(false); + invlist = await _invmng.SecInvoice(p_list, p_adjlist, dtos, p_version, p_InvGroupNum, string.Empty, businessType, p_notlist).ConfigureAwait(false);//重开可以变多张发票 break; case EnumBusinessType.MaiDanJianBBAC: - invlist = await _invmng.MakeInvoice(p_list, p_adjlist, dtos, p_version, p_InvGroupNum, string.Empty, businessType, false).ConfigureAwait(false); + invlist = await _invmng.SecInvoice(p_list, p_adjlist, dtos, p_version, p_InvGroupNum, string.Empty, businessType, p_notlist).ConfigureAwait(false);//重开可以变多张发票 break; case EnumBusinessType.ZhiGongJianBBAC: invlist = await _invmng.SecInvoice(p_list, p_adjlist, dtos, p_version, p_InvGroupNum, string.Empty, businessType,p_notlist).ConfigureAwait(false);//重开可以变多张发票 @@ -197,7 +197,7 @@ namespace Win.Sfs.SettleAccount.Bases invlist = await _invmng.SecInvoice(p_list, p_adjlist, dtos, p_version, p_InvGroupNum, string.Empty, businessType, p_notlist).ConfigureAwait(false); break; case EnumBusinessType.YinDuJian: - invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, new List(), p_version, p_InvGroupNum, string.Empty, businessType, false).ConfigureAwait(false);//重开可以变多张发票 + invlist = await _invmng.SecInvoice(p_list, p_adjlist, dtos, p_version, p_InvGroupNum, string.Empty, businessType, p_notlist).ConfigureAwait(false);//重开可以变多张发票开可以变多张发票 break; } //var ls= await _invmng.SecInvoice(p_list,p_adjlist,p_tmplist,p_version, p_InvGroupNum, p_parentInvBillNum, businessType); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs index 76ff7c8f..8757a16b 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs @@ -115,6 +115,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [HttpPost] public async Task> GetListAsync(RequestDto input) { + var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false); var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false); var dtos = ObjectMapper.Map, List>(entities); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs index 76ab8092..f49b63e7 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs @@ -152,13 +152,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs }).ToList();//不能结算 entitys = entitys.OrderBy(p => p.LU).ToList(); - - - - - - - var invs = SecInvoice(entitys, new List(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType); // var invs = SecInvoice(entitys, new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, query.ToList()); if (invs.Count > 0) @@ -581,10 +574,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs // } //} _invls = invlist.Select(p => p.InvbillNum).ToList(); - - - - } return _invls; } @@ -597,7 +586,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { List _invls = new List(); - var groupDtos = dtos.GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID, p.LU })//明细 .Select(itm => new GroupPartCode { @@ -633,10 +621,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs var invlist = new List(); var salist = new List(); var adjlist = new List(); - - - - foreach (var big in biglist)//单条大于1000W的开票 { var list = p_list.Where(p => p.InvGroupNum == big.InvGroupNum && p.PartCode == big.PartCode && p.Price == big.Price && p.LU == big.LU); @@ -692,9 +676,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { groupList.AddRange(mapList); } - - - #region 发票明细 List _entityDetailList = new List(); foreach (var detail in detailDtos) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs index f9e8bfec..70c91916 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs @@ -207,6 +207,74 @@ namespace SettleAccount.Domain.BQ this.invoices = invoices; } } + + public class InvoiceByPUB where T : SA_CAN_BASE, new() + { + public string InvBillNum { set; get; } + public InvoiceByPUB() { } + private List parts = new List(); + public IReadOnlyList Parts => parts.AsReadOnly(); + public decimal TotalAmount => parts.Sum(p => p.Price); + public int PartCount => parts.GroupBy(p => new { p.LU, p.PartCode }).Count(); + public bool CanAddPart(T part) + { + return TotalAmount + part.Price < 10000000 && PartCount<15 ; + } + + public void AddPart(T part) + { + if (CanAddPart(part)) + { + part.InvbillNum = InvBillNum; + parts.Add(part); + + } + + } + } + + public class InvoiceGeneratorPUB where T : SA_CAN_BASE, new() + { + private List> invoices = new List>(); + + public IReadOnlyList> Invoices => invoices.AsReadOnly(); + + public void GenerateInvoices(List parts) + { + InvoiceByPUB currentInvoice = new InvoiceByPUB(); + invoices.Add(currentInvoice); + currentInvoice.InvBillNum = OrderNumberGenerator.GenerateOrderNumber("INV"); + foreach (var part in parts) + { + if (!currentInvoice.CanAddPart(part)) + { + currentInvoice = new InvoiceByPUB(); + currentInvoice.InvBillNum = OrderNumberGenerator.GenerateOrderNumber("INV"); + invoices.Add(currentInvoice); + } + currentInvoice.AddPart(part); + } + } + public InvoiceGeneratorPUB() + { + + } + public InvoiceGeneratorPUB(List> invoices) + { + this.invoices = invoices; + } + } + + + + + + + + + + + public class GroupPartCode { public string PartCode { set; get; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs index 844ea2b1..a591a91a 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs @@ -1007,153 +1007,230 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers /// 原发票号 [UnitOfWork(false)] public async Task> SecInvoice(List p_list, List p_ajdlist, List dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType, List p_notlist = null) - where TDetail : SA_CAN_BASE + where TDetail : SA_CAN_BASE,new() { List _invls = new List(); - var groups1 = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV - { - PartCode = p.Key.PartCode, - LU = p.Key.LU, - Amt = p.Sum(itm => itm.Amt), - Qty = p.Sum(itm => itm.Qty), - ContractDocID = p.Key.ContractDocID, - Price = p.Key.Price, - BeginDate = p.Key.BeginDate, - EndDate = p.Key.EndDate - }).ToList();//汇总记录不出现重复值 - var groups = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV - { - PartCode = p.Key.PartCode, - LU = p.Key.LU, - Amt = p.Sum(itm => itm.Amt), - Qty = p.Sum(itm => itm.Qty), - Price = p.Key.Price, - ContractDocID = p.Key.ContractDocID, - BeginDate = p.Key.BeginDate, - EndDate = p.Key.EndDate - }).ToList();//汇总记录不出现重复值 - Dictionary> invoiceMap = new Dictionary>();//发票和发票明细关系 - foreach (var group in groups) + var groupDtos = dtos.GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID, p.LU })//明细 + .Select(itm => new GroupPartCode + { + PartCode = itm.Key.PartCode, + InvGroupNum = itm.Key.InvGroupNum, + LU = itm.Key.LU, + ContactDocID = itm.Key.ContractDocID, + Price = itm.Key.Price, + Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税前 + Tax = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2),//税 + TaxAmt = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2) + Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税后进 + Qty = itm.Sum(k => k.Qty), + BeginDate = itm.Key.BeginDate, + EndDate = itm.Key.EndDate + }).ToList(); + + List biglist = new List(); + List smalllist = new List(); + foreach (var itm in groupDtos)//分类1000W以上或1000W以下 { - int i = groups1.Count(p => p.LU == group.LU - && p.PartCode == group.PartCode - && p.BeginDate == group.BeginDate - && p.EndDate == group.EndDate - && p.ContractDocID == group.ContractDocID - ); - if (i > 0) + if (itm.Amt > 10000000) { - string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV"); - List tempList = new List(); - decimal sum = group.Amt;//初始合计金额 - int partCount = 0; - foreach (var group1 in groups1) + biglist.Add(itm); + } + else + { + smalllist.Add(itm); + } + } + var groupList = new List(); + var notDetialList = new List(); + var detailList = new List(); + var invlist = new List(); + var salist = new List(); + var adjlist = new List(); + foreach (var big in biglist)//单条大于1000W的开票 + { + var list = p_list.Where(p => p.InvGroupNum == big.InvGroupNum && p.PartCode == big.PartCode && p.Price == big.Price && p.LU == big.LU); + var gener = new InvoiceGeneratorPUB(); + gener.GenerateInvoices(p_list); + var invList = gener.Invoices; + foreach (var inv in invList) + { + var partlist = inv.Parts; + if (partlist.Count > 0) { - if (group.LU == group1.LU - && group.PartCode == group1.PartCode - && group.BeginDate == group1.BeginDate - && group.EndDate == group1.EndDate - && group1.ContractDocID == group.ContractDocID - && group1.Price == group.Price - && group1.Qty == group.Qty - && group1.Amt == group.Amt + var query = from itm in p_list + join itm1 in dtos on itm.Id equals itm1.Id + select itm1; + var Dtos = query.ToList(); + var detailDtos = Dtos.GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID, p.LU })//明细 + .Select(itm => new + { + PartCode = itm.Key.PartCode, + InvGroupNum = itm.Key.InvGroupNum, + LU = itm.Key.LU, + ContactDocID = itm.Key.ContractDocID, + Price = itm.Key.Price, + Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税前 + Tax = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2),//税 + TaxAmt = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2) + Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税后进 + Qty = itm.Sum(k => k.Qty), + BeginDate = itm.Key.BeginDate, + EndDate = itm.Key.EndDate + }).ToList(); + + decimal amt = detailDtos.Sum(k => k.Amt);//金额 + decimal txtAmt = detailDtos.Sum(k => k.TaxAmt);//税后金额 + decimal realAmt = detailDtos.Sum(k => k.Tax);//税额 + + var invoicegrup = partlist.Select(p => p.GroupNum); + var mapList = new List(); + foreach (var groupnum in invoicegrup) + { + mapList.Add(new INVOICE_MAP_GROUP( + guid: GuidGenerator.Create(), + version: p_version, + invbillNum: inv.InvBillNum, + invGroupNum: p_InvGroupNum, + settleGroupNum: groupnum, + amt: 0, + extend1: string.Empty, + extend2: string.Empty ) + ); + } + if (mapList.Count > 0) { - tempList.Add(group1); - partCount++;//符合条件加入到零件中 - continue; + groupList.AddRange(mapList); } - sum += group1.Amt; - if (sum > 10000000) + #region 发票明细 + List _entityDetailList = new List(); + foreach (var detail in detailDtos) { - break; + _entityDetailList.Add( + new INVOICE_WAIT_DETAIL( + guid: GuidGenerator.Create(), + version: p_version, + invbillNum: inv.InvBillNum, + invGroupNum: p_InvGroupNum, + lU: detail.LU, + qty: detail.Qty, + bussiessType: businessType, + amt: detail.Amt, + pRICE: detail.Price, + extend1: detail.ContactDocID, + extend2: string.Empty, + beginDate: detail.BeginDate, + endDate: detail.EndDate, + partcode: detail.PartCode + )); } - tempList.Add(group1); + if (_entityDetailList.Count > 0) + { + detailList.AddRange(_entityDetailList); + } + #endregion + #region 发票 + var invbill = new INVOICE_GRP + ( + guid: GuidGenerator.Create(), + realnvBillNum: string.Empty, + invbillNum: inv.InvBillNum, + amt: amt, + taxAmt: txtAmt, + fileName: string.Empty, + businessType: businessType, + invGroupNum: p_InvGroupNum, + state: SettleBillState.已开票, + invoiceBillState: InvoiceBillState.正常, + tax: 0.13m, + parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty, + preTaxDiff: 0, + taxDiff: 0, + clientCode: string.Empty, + realAmt: realAmt + ); + string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site; + string clientCode = string.Empty; + switch (site) + { + case "1040": + clientCode = "C001"; + break; + case "1046": + clientCode = "C171"; + break; + default: + clientCode = "C004"; + break; + } + invbill.ClientCode = clientCode; + invbill.Site = dtos.FirstOrDefault().Site; + invbill.CreationTime = DateTime.MinValue; + invbill.LastModificationTime = DateTime.Now; + invlist.Add(invbill); + #endregion } - invoiceMap.Add(invoiceBillNum, tempList); - - - var query = from itm in groups1 //更新分组 - join itm1 in tempList - on - new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID, itm.PartCode, itm.Qty, itm.Price, itm.Amt } - equals - new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode, itm1.Qty, itm1.Price, itm1.Amt } - into temp - from tm in temp.DefaultIfEmpty() - where tm == null - select new TMEP_INV - { - LU = itm.LU, - Amt = itm.Amt, - Qty = itm.Qty, - Price = itm.Price, - BeginDate = itm.BeginDate, - ContractDocID = itm.ContractDocID, - EndDate = itm.EndDate, - PartCode = itm.PartCode, - - }; - groups1 = query.ToList(); } } - if (invoiceMap.Count > 0) + smalllist = smalllist.OrderBy(p => p.Amt).ToList(); + var gener1 = new InvoiceGeneratorDiff(); + gener1.GenerateInvoices(smalllist); + var invList1 = gener1.Invoices; + foreach (var inv in invList1)//小于1000W的开票 { - var groupList = new List(); - var notDetialList = new List(); - var detailList = new List(); - var invlist = new List(); - var salist = new List(); - var adjlist = new List(); - int count = invoiceMap.Keys.Count;//计算第几张发票计数器 - int i = 1; - foreach (var group in invoiceMap) + var partlist = inv.Parts; + var query = from part in p_list + join part1 in partlist on + new { part.InvGroupNum, part.PartCode, part.LU, part.Price } equals new { part1.InvGroupNum, part1.PartCode, part1.LU, part1.Price } + select part; + + var entityList = query.ToList(); + + salist.AddRange(entityList); + + if (partlist.Count > 0) { - var key = group.Key;//发票票号 - var ls = group.Value;//发票明细 - //反向查找结算数据 - var query = from itm in dtos - join itm1 in ls - on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate, itm.ContractDocID } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID } - join itm2 in p_list on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } - select itm2;//反向更新可计算数据 - foreach (var itm in query) + decimal amt = partlist.Sum(k => k.Amt);//金额 + decimal txtAmt = partlist.Sum(k => k.TaxAmt);//税后金额 + decimal realAmt = partlist.Sum(k => k.Tax);//税额 + + var invoicegroupls = entityList.Select(p => p.GroupNum); + var mapList = new List(); + foreach (var groupnum in invoicegroupls) { - itm.InvbillNum = key; - salist.Add(itm); + mapList.Add(new INVOICE_MAP_GROUP( + guid: GuidGenerator.Create(), + version: p_version, + invbillNum: inv.InvBillNum, + invGroupNum: p_InvGroupNum, + settleGroupNum: groupnum, + amt: 0, + extend1: string.Empty, + extend2: string.Empty + ) + ); } - if (!string.IsNullOrEmpty(p_parentInvBillNum)) + if (mapList.Count > 0) { - //反向查找调整数据 - var query1 = from itm in dtos - join itm1 in ls - on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate } - join itm2 in p_ajdlist on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } - select itm2; - foreach (var itm in query1) - { - itm.InvBillNum = key; - adjlist.Add(itm); - } + groupList.AddRange(mapList); } + List _entityDetailList = new List(); - foreach (var detail in ls) + foreach (var detail in partlist) { _entityDetailList.Add( new INVOICE_WAIT_DETAIL( guid: GuidGenerator.Create(), version: p_version, - invbillNum: key, + invbillNum: inv.InvBillNum, invGroupNum: p_InvGroupNum, lU: detail.LU, qty: detail.Qty, bussiessType: businessType, amt: detail.Amt, pRICE: detail.Price, - extend1: detail.ContractDocID, + extend1: detail.ContactDocID, extend2: string.Empty, - beginDate: detail.BeginDate, - endDate: detail.EndDate, + beginDate: detail.BeginDate.Value, + endDate: detail.EndDate.Value, partcode: detail.PartCode )); } @@ -1161,104 +1238,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { detailList.AddRange(_entityDetailList); } - #region 发票不能结算的明细 - var innotls = new List(); - var sq = query.GroupBy(p => new { p.LU, p.GroupNum }) - .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = group.Key, GroupNum = p.Key.GroupNum }); - foreach (var sitm in sq) - { - innotls.Add(new INVOICE_NOT_SETTLE( - guid: GuidGenerator.Create(), - version: p_version, - invGroupNum: p_InvGroupNum, - settleGroupNum: sitm.GroupNum, - lU: sitm.LU, - lU1: sitm.LU, - extend1: "可结算", - extend2: string.Empty, - qty: sitm.Qty, - p_invbillnum: group.Key - )); - } - if (innotls.Count > 0) - { - notDetialList.AddRange(innotls); - } - if (p_notlist != null && p_notlist.Count > 0) - { - var innotls1 = new List(); - - var grouplist = query.Select(p => p.GroupNum).ToList(); - - - var notlist = p_notlist.Where(p => grouplist.Contains(p.GroupNum)); - - foreach (var nitm in notlist) - { - innotls1.Add(new INVOICE_NOT_SETTLE( - guid: GuidGenerator.Create(), - version: p_version, - invGroupNum: p_InvGroupNum, - settleGroupNum: nitm.GroupNum, - lU: nitm.LU, - lU1: nitm.LU, - extend1: "不可结算", - extend2: string.Empty, - qty: nitm.Qty, - p_invbillnum: group.Key - )); - } - if (innotls.Count > 0) - { - notDetialList.AddRange(innotls1); - } - } - #endregion - decimal amt = ls.Sum(k => k.Amt);//金额 - decimal txtAmt = Math.Round(amt * 0.13m, 2);//税后金额 - decimal readAmt = amt + Math.Round(amt * 0.13m, 2);//税额 - - //var contractList = ls.Select(p => p.ContractDocID).Distinct(); - var _groupList = query.GroupBy(p => new { p.GroupNum }) - .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => Math.Round(itm.Qty * itm.Price, 2)) }).Distinct(); - List group1 = new List(); - foreach (var en in _groupList) - { - group1.Add( - new INVOICE_MAP_GROUP( - guid: GuidGenerator.Create(), - version: p_version, - invbillNum: key, - invGroupNum: p_InvGroupNum, - settleGroupNum: en.GroupNum, - amt: en.Amt, - extend1: string.Empty, - extend2: string.Empty)); - } - if (group1.Count > 0) - { - groupList.AddRange(group1); - } - var lst = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).ToList(); - string site = lst.FirstOrDefault().Site; - string clientCode = string.Empty; - switch (site) - { - case "1040": - clientCode = "C001"; - break; - case "1046": - clientCode = "C171"; - break; - default: - clientCode = "C004"; - break; - - } var invbill = new INVOICE_GRP - (guid: GuidGenerator.Create(), + ( + guid: GuidGenerator.Create(), realnvBillNum: string.Empty, - invbillNum: key, + invbillNum: inv.InvBillNum, amt: amt, taxAmt: txtAmt, fileName: string.Empty, @@ -1267,298 +1251,356 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers state: SettleBillState.已开票, invoiceBillState: InvoiceBillState.正常, tax: 0.13m, - parent: p_parentInvBillNum, + parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty, preTaxDiff: 0, taxDiff: 0, clientCode: string.Empty, - realAmt: readAmt + realAmt: realAmt ); + string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site; + string clientCode = string.Empty; + switch (site) + { + case "1040": + clientCode = "C001"; + break; + case "1046": + clientCode = "C171"; + break; + default: + clientCode = "C004"; + break; + } invbill.ClientCode = clientCode; + invbill.Site = dtos.FirstOrDefault().Site; invbill.CreationTime = DateTime.MinValue; invbill.LastModificationTime = DateTime.Now; - invbill.Site = dtos.FirstOrDefault().Site; invlist.Add(invbill); - } - var dbcontxt = await _repository.GetDbContextAsync().ConfigureAwait(false); - //_dbcontext.BulkInsert(invlist); - //_dbcontext.BulkInsert(groupList); - //_dbcontext.BulkInsert(detailList); - //_dbcontext.BulkInsert(notDetialList); - //if (salist.Count > 0) - //{ - // _dbcontext.BulkUpdate(salist); - //} - //if (adjlist.Count > 0) - //{ - // _dbcontext.BulkUpdate(adjlist); - //} - await dbcontxt.BulkInsertAsync(invlist).ConfigureAwait(false); - await dbcontxt.BulkInsertAsync(groupList).ConfigureAwait(false); - await dbcontxt.BulkInsertAsync(detailList).ConfigureAwait(false); - await dbcontxt.BulkInsertAsync(notDetialList).ConfigureAwait(false); - if (salist.Count > 0) - { - await dbcontxt.BulkUpdateAsync(salist).ConfigureAwait(false); } - if (adjlist.Count > 0) - { - await dbcontxt.BulkUpdateAsync(adjlist).ConfigureAwait(false); - } - //await _repository.DbContext.BulkInsertAsync(notDetialList); - _invls = invlist.Select(p => p.InvbillNum).ToList(); } + + var _dbcontext=await _repository.GetDbContextAsync().ConfigureAwait(false); + + if (salist.Count > 0) + { + _dbcontext.BulkUpdate(salist); + } + _dbcontext.BulkInsert(invlist); + _dbcontext.BulkInsert(groupList); + _dbcontext.BulkInsert(detailList); + if (adjlist.Count > 0) + { + _dbcontext.BulkInsert(adjlist); + } + if (notDetialList.Count > 0) + { + _dbcontext.BulkInsert(notDetialList); + } + _invls = invlist.Select(p => p.InvbillNum).ToList(); return _invls; + + + //List _invls = new List(); + //var groups1 = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV + //{ + // PartCode = p.Key.PartCode, + // LU = p.Key.LU, + // Amt = p.Sum(itm => itm.Amt), + // Qty = p.Sum(itm => itm.Qty), + // ContractDocID = p.Key.ContractDocID, + // Price = p.Key.Price, + // BeginDate = p.Key.BeginDate, + // EndDate = p.Key.EndDate + //}).ToList();//汇总记录不出现重复值 + //var groups = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV + //{ + // PartCode = p.Key.PartCode, + // LU = p.Key.LU, + // Amt = p.Sum(itm => itm.Amt), + // Qty = p.Sum(itm => itm.Qty), + // Price = p.Key.Price, + // ContractDocID = p.Key.ContractDocID, + // BeginDate = p.Key.BeginDate, + // EndDate = p.Key.EndDate + + //}).ToList();//汇总记录不出现重复值 + //Dictionary> invoiceMap = new Dictionary>();//发票和发票明细关系 + //foreach (var group in groups) + //{ + // int i = groups1.Count(p => p.LU == group.LU + // && p.PartCode == group.PartCode + // && p.BeginDate == group.BeginDate + // && p.EndDate == group.EndDate + // && p.ContractDocID == group.ContractDocID + // ); + // if (i > 0) + // { + // string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV"); + // List tempList = new List(); + // decimal sum = group.Amt;//初始合计金额 + // int partCount = 0; + // foreach (var group1 in groups1) + // { + // if (group.LU == group1.LU + // && group.PartCode == group1.PartCode + // && group.BeginDate == group1.BeginDate + // && group.EndDate == group1.EndDate + // && group1.ContractDocID == group.ContractDocID + // && group1.Price == group.Price + // && group1.Qty == group.Qty + // && group1.Amt == group.Amt + // ) + // { + // tempList.Add(group1); + // partCount++;//符合条件加入到零件中 + // continue; + // } + // sum += group1.Amt; + // if (sum > 10000000) + // { + // break; + // } + // tempList.Add(group1); + // } + // invoiceMap.Add(invoiceBillNum, tempList); + + + + + + + // var query = from itm in groups1 //更新分组 + // join itm1 in tempList + // on + // new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID, itm.PartCode, itm.Qty, itm.Price, itm.Amt } + // equals + // new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode, itm1.Qty, itm1.Price, itm1.Amt } + // into temp + // from tm in temp.DefaultIfEmpty() + // where tm == null + // select new TMEP_INV + // { + // LU = itm.LU, + // Amt = itm.Amt, + // Qty = itm.Qty, + // Price = itm.Price, + // BeginDate = itm.BeginDate, + // ContractDocID = itm.ContractDocID, + // EndDate = itm.EndDate, + // PartCode = itm.PartCode, + + // }; + // groups1 = query.ToList(); + // } + //} + //if (invoiceMap.Count > 0) + //{ + // var groupList = new List(); + // var notDetialList = new List(); + // var detailList = new List(); + // var invlist = new List(); + // var salist = new List(); + // var adjlist = new List(); + // int count = invoiceMap.Keys.Count;//计算第几张发票计数器 + // int i = 1; + // foreach (var group in invoiceMap) + // { + // var key = group.Key;//发票票号 + // var ls = group.Value;//发票明细 + // //反向查找结算数据 + // var query = from itm in dtos + // join itm1 in ls + // on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate, itm.ContractDocID } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID } + // join itm2 in p_list on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } + // select itm2;//反向更新可计算数据 + // foreach (var itm in query) + // { + // itm.InvbillNum = key; + // salist.Add(itm); + // } + // if (!string.IsNullOrEmpty(p_parentInvBillNum)) + // { + // //反向查找调整数据 + // var query1 = from itm in dtos + // join itm1 in ls + // on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate } + // join itm2 in p_ajdlist on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } + // select itm2; + // foreach (var itm in query1) + // { + // itm.InvBillNum = key; + // adjlist.Add(itm); + // } + // } + // List _entityDetailList = new List(); + // foreach (var detail in ls) + // { + // _entityDetailList.Add( + // new INVOICE_WAIT_DETAIL( + // guid: GuidGenerator.Create(), + // version: p_version, + // invbillNum: key, + // invGroupNum: p_InvGroupNum, + // lU: detail.LU, + // qty: detail.Qty, + // bussiessType: businessType, + // amt: detail.Amt, + // pRICE: detail.Price, + // extend1: detail.ContractDocID, + // extend2: string.Empty, + // beginDate: detail.BeginDate, + // endDate: detail.EndDate, + // partcode: detail.PartCode + // )); + // } + // if (_entityDetailList.Count > 0) + // { + // detailList.AddRange(_entityDetailList); + // } + // #region 发票不能结算的明细 + // var innotls = new List(); + // var sq = query.GroupBy(p => new { p.LU, p.GroupNum }) + // .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = group.Key, GroupNum = p.Key.GroupNum }); + // foreach (var sitm in sq) + // { + // innotls.Add(new INVOICE_NOT_SETTLE( + // guid: GuidGenerator.Create(), + // version: p_version, + // invGroupNum: p_InvGroupNum, + // settleGroupNum: sitm.GroupNum, + // lU: sitm.LU, + // lU1: sitm.LU, + // extend1: "可结算", + // extend2: string.Empty, + // qty: sitm.Qty, + // p_invbillnum: group.Key + // )); + // } + // if (innotls.Count > 0) + // { + // notDetialList.AddRange(innotls); + // } + // if (p_notlist != null && p_notlist.Count > 0) + // { + // var innotls1 = new List(); + + // var grouplist = query.Select(p => p.GroupNum).ToList(); + + + // var notlist = p_notlist.Where(p => grouplist.Contains(p.GroupNum)); + + // foreach (var nitm in notlist) + // { + // innotls1.Add(new INVOICE_NOT_SETTLE( + // guid: GuidGenerator.Create(), + // version: p_version, + // invGroupNum: p_InvGroupNum, + // settleGroupNum: nitm.GroupNum, + // lU: nitm.LU, + // lU1: nitm.LU, + // extend1: "不可结算", + // extend2: string.Empty, + // qty: nitm.Qty, + // p_invbillnum: group.Key + // )); + // } + // if (innotls.Count > 0) + // { + // notDetialList.AddRange(innotls1); + // } + // } + // #endregion + // decimal amt = ls.Sum(k => k.Amt);//金额 + // decimal txtAmt = Math.Round(amt * 0.13m, 2);//税后金额 + // decimal readAmt = amt + Math.Round(amt * 0.13m, 2);//税额 + + // //var contractList = ls.Select(p => p.ContractDocID).Distinct(); + // var _groupList = query.GroupBy(p => new { p.GroupNum }) + // .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => Math.Round(itm.Qty * itm.Price, 2)) }).Distinct(); + // List group1 = new List(); + // foreach (var en in _groupList) + // { + // group1.Add( + // new INVOICE_MAP_GROUP( + // guid: GuidGenerator.Create(), + // version: p_version, + // invbillNum: key, + // invGroupNum: p_InvGroupNum, + // settleGroupNum: en.GroupNum, + // amt: en.Amt, + // extend1: string.Empty, + // extend2: string.Empty)); + // } + // if (group1.Count > 0) + // { + // groupList.AddRange(group1); + // } + // var lst = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).ToList(); + // string site = lst.FirstOrDefault().Site; + // string clientCode = string.Empty; + // switch (site) + // { + // case "1040": + // clientCode = "C001"; + // break; + // case "1046": + // clientCode = "C171"; + // break; + // default: + // clientCode = "C004"; + // break; + + // } + // var invbill = new INVOICE_GRP + // (guid: GuidGenerator.Create(), + // realnvBillNum: string.Empty, + // invbillNum: key, + // amt: amt, + // taxAmt: txtAmt, + // fileName: string.Empty, + // businessType: businessType, + // invGroupNum: p_InvGroupNum, + // state: SettleBillState.已开票, + // invoiceBillState: InvoiceBillState.正常, + // tax: 0.13m, + // parent: p_parentInvBillNum, + // preTaxDiff: 0, + // taxDiff: 0, + // clientCode: string.Empty, + // realAmt: readAmt + // ); + // invbill.ClientCode = clientCode; + // invbill.CreationTime = DateTime.MinValue; + // invbill.LastModificationTime = DateTime.Now; + // invbill.Site = dtos.FirstOrDefault().Site; + // invlist.Add(invbill); + // } + // var dbcontxt = await _repository.GetDbContextAsync().ConfigureAwait(false); + + + + // await dbcontxt.BulkInsertAsync(invlist).ConfigureAwait(false); + // await dbcontxt.BulkInsertAsync(groupList).ConfigureAwait(false); + // await dbcontxt.BulkInsertAsync(detailList).ConfigureAwait(false); + // await dbcontxt.BulkInsertAsync(notDetialList).ConfigureAwait(false); + // if (salist.Count > 0) + // { + // await dbcontxt.BulkUpdateAsync(salist).ConfigureAwait(false); + // } + // if (adjlist.Count > 0) + // { + // await dbcontxt.BulkUpdateAsync(adjlist).ConfigureAwait(false); + // } + // //await _repository.DbContext.BulkInsertAsync(notDetialList); + // _invls = invlist.Select(p => p.InvbillNum).ToList(); + //} + //return _invls; } - //public async Task> SecInvoice(List p_list, List p_ajdlist, List dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) - // where TDetail : SA_CAN_BASE - //{ - // List _invls = new List(); - // var groups1 = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV - // { - // PartCode = p.Key.PartCode, - // LU = p.Key.LU, - // Amt = p.Sum(itm => itm.Amt), - // Qty = p.Sum(itm => itm.Qty), - // ContractDocID = p.Key.ContractDocID, - // Price = p.Key.Price, - // BeginDate = p.Key.BeginDate, - // EndDate = p.Key.EndDate - - // }).ToList();//汇总记录不出现重复值 - // var groups = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV - // { - // PartCode = p.Key.PartCode, - // LU = p.Key.LU, - // Amt = p.Sum(itm => itm.Amt), - // Qty = p.Sum(itm => itm.Qty), - // Price = p.Key.Price, - // ContractDocID = p.Key.ContractDocID, - // BeginDate = p.Key.BeginDate, - // EndDate = p.Key.EndDate - // }).ToList();//汇总记录不出现重复值 - // Dictionary> invoiceMap = new Dictionary>();//发票和发票明细关系 - // foreach (var group in groups) - // { - // int i = groups1.Count(p => p.LU == group.LU - // && p.PartCode == group.PartCode - // && p.BeginDate == group.BeginDate - // && p.EndDate == group.EndDate - // && p.ContractDocID == group.ContractDocID - // ); - // if (i > 0) - // { - // string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV"); - // List tempList = new List(); - // decimal sum = group.Amt;//初始合计金额 - // int partCount = 0; - // foreach (var group1 in groups1) - // { - // if (group.LU == group1.LU - // && group.PartCode == group1.PartCode - // && group.BeginDate == group1.BeginDate - // && group.EndDate == group1.EndDate - // && group1.ContractDocID == group.ContractDocID - // ) - // { - // tempList.Add(group1); - // partCount++;//符合条件加入到零件中 - // continue; - // } - // //partCount++; - // //if (partCount > 30) - // //{ - // // continue; - // //} - // if (sum > 10000000) - // { - // break; - // } - // sum += group1.Amt; - // tempList.Add(group1); - // } - // invoiceMap.Add(invoiceBillNum, tempList); - // var query = from itm in groups1 //更新分组 - // join itm1 in tempList - // on new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID, itm.PartCode } - // equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode } into temp - // from tm in temp - // where tm == null - // select new TMEP_INV - // { - // LU = itm.LU, - // Amt = itm.Amt, - // Qty = itm.Qty, - // BeginDate = itm.BeginDate, - // ContractDocID = itm.ContractDocID, - // EndDate = itm.EndDate - // }; - // groups1 = query.ToList(); - // } - // } - // if (invoiceMap.Count > 0) - // { - // var groupList = new List(); - // var notDetialList = new List(); - // var detailList = new List(); - // var invlist = new List(); - // var salist = new List(); - // var adjlist = new List(); - // foreach (var group in invoiceMap) - // { - // var key = group.Key;//发票票号 - // var ls = group.Value;//发票明细 - // //反向查找结算数据 - // var query = from itm in dtos - // join itm1 in ls - // on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate } - // join itm2 in p_list on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } - // select itm2; - // foreach (var itm in query) - // { - // itm.InvbillNum = key; - // salist.Add(itm); - // } - // if (!string.IsNullOrEmpty(p_parentInvBillNum)) - // { - // //反向查找调整数据 - // var query1 = from itm in dtos - // join itm1 in ls - // on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate } - // join itm2 in p_ajdlist on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } - // select itm2; - // foreach (var itm in query1) - // { - // itm.InvBillNum = key; - // itm.InvGroupNum = dtos.FirstOrDefault().InvGroupNum; - // adjlist.Add(itm); - // } - // } - // List _entityDetailList = new List(); - // foreach (var detail in ls) - // { - // _entityDetailList.Add( - // new INVOICE_WAIT_DETAIL( - // guid: GuidGenerator.Create(), - // version: p_version, - // invbillNum: key, - // invGroupNum: p_InvGroupNum, - // lU: detail.LU, - // qty: detail.Qty, - // bussiessType: businessType, - // amt: detail.Amt, - // pRICE: detail.Price, - // extend1: detail.ContractDocID, - // extend2: string.Empty, - // beginDate: detail.BeginDate, - // endDate: detail.EndDate, - // partcode: detail.PartCode - // )); - // } - // if (_entityDetailList.Count > 0) - // { - // detailList.AddRange(_entityDetailList); - // } - - // List amtList = new List(); - // foreach (var itm in detailList) - // { - // amtList.Add(new tempAmt1() - // { - // Amt = itm.Amt, - // Tax = Math.Round(itm.Amt * 0.13m, 2), - // TaxAmt = itm.Amt + Math.Round(itm.Amt * 0.13m, 2) - // }); - // } - // decimal amt = amtList.Sum(k => k.Amt);//金额 - // decimal txtAmt = amtList.Sum(k => k.TaxAmt);//税后金额 - // decimal readAmt = amtList.Sum(k => k.Tax);//税额 - - // //decimal amt = detailList.Sum(k => k.Amt);//金额 - // //decimal txtAmt = detailList.Sum(k => k.Amt) + Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税后金额 - // //decimal readAmt = Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税额 - - // var contractList = ls.Select(p => p.ContractDocID).Distinct(); - // var _groupList = dtos.Where(p => contractList.Contains(p.ContractDocID)).GroupBy(p => new { p.GroupNum }) - // .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct(); - // List group1 = new List(); - - // foreach (var en in _groupList) - // { - // group1.Add( - // new INVOICE_MAP_GROUP( - // guid: GuidGenerator.Create(), - // version: p_version, - // invbillNum: key, - // invGroupNum: p_InvGroupNum, - // settleGroupNum: en.GroupNum, - // amt: en.Amt, - // extend1: string.Empty, - // extend2: string.Empty)); - // } - // if (group1.Count > 0) - // { - // groupList.AddRange(group1); - // } - - // var lst = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).ToList(); - // string site = lst.FirstOrDefault().Site; - // string clientCode = string.Empty; - // switch (site) - // { - // case "1040": - // clientCode = "C001"; - // break; - // case "1046": - // clientCode = "C171"; - // break; - // default: - // clientCode = "C004"; - // break; - - // } - // var invbill = new INVOICE_GRP - // (guid: GuidGenerator.Create(), - // realnvBillNum: string.Empty, - // invbillNum: key, - // amt: amt, - // taxAmt: txtAmt, - // fileName: string.Empty, - // businessType: businessType, - // invGroupNum: p_InvGroupNum, - // state: SettleBillState.已开票, - // invoiceBillState: InvoiceBillState.正常, - // tax: 0.13m, - // parent: p_parentInvBillNum, - // preTaxDiff: 0, - // taxDiff: 0, - // clientCode: string.Empty, - // realAmt: readAmt - // ); - // invbill.ClientCode = clientCode; - // invbill.CreationTime = DateTime.MinValue; - // invbill.Site = dtos.FirstOrDefault().Site; - // invbill.LastModificationTime = DateTime.Now; - // invlist.Add(invbill); - // } - // await _repository.DbContext.BulkInsertAsync(invlist).ConfigureAwait(false); - // await _repository.DbContext.BulkInsertAsync(groupList).ConfigureAwait(false); - // await _repository.DbContext.BulkInsertAsync(detailList).ConfigureAwait(false); - // if (salist.Count > 0) - // { - // await _repository.DbContext.BulkUpdateAsync(salist).ConfigureAwait(false); - // } - // if (adjlist.Count > 0) - // { - // await _repository.DbContext.BulkUpdateAsync(adjlist).ConfigureAwait(false); - // } - // //await _repository.DbContext.BulkInsertAsync(notDetialList); - // _invls = invlist.Select(p => p.InvbillNum).ToList(); - // } - // return _invls; + + - //} [UnitOfWork(false)] public async Task> FirstInvoice(List p_list, List p_adjlist, List dtos, List p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) where TDetail : SA_CAN_BASE @@ -2762,7 +2804,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers /// /// public async Task ReissueSecInvoice(List p_list, List p_adjlist, List dtos, string p_OldInvBillNum, int p_version) - where TDetail : SA_CAN_BASE + where TDetail : SA_CAN_BASE, new() { if (!string.IsNullOrEmpty(p_OldInvBillNum)) {