From ff577f9ebe44d7c1d6f6d73f61602b8ed98db0ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 11 Sep 2023 14:01:06 +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 | 5 +- .../Entities/BQ/BBAC_BA_SERVICE.cs | 5 +- .../Entities/BQ/HBPO_BA_SERVICE.cs | 191 +----------------- .../Entities/BQ/Managers/INV_MNG_EXT.cs | 80 +------- 4 files changed, 12 insertions(+), 269 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 3d5f2251..780451e4 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 @@ -159,6 +159,9 @@ namespace Win.Sfs.SettleAccount.Bases var sdtos = ObjectMapper.Map, List>(s); if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) { + + + var A = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); var AMap = ObjectMapper.Map, List>(A); var wquery = from itm in AMap @@ -452,7 +455,7 @@ namespace Win.Sfs.SettleAccount.Bases } - + [UnitOfWork(false)] /// /// 第一次开票 /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs index 0fb6605e..19a8939b 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs @@ -453,9 +453,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ }; var dtos = q.ToList(); - - - var testls = dtos.Where(p => string.IsNullOrEmpty(p.LU)).ToList(); if (dtos != null && dtos.Count > 0) @@ -602,7 +599,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var invBill = new INVOICE_REPEAT_DTO(); var invls = ls.Where(p => p.InvbillNum == itm).ToList(); var entitylist = entities.Where(p => p.InvbillNum == itm).ToList(); - var tax = inv.Tax;//税率 + var tax = inv.Tax==0?0.13m:inv.Tax;//税率 var amt = entitylist.Sum(p => p.Amt);//税前 var taxamt = amt + Math.Round(amt * tax, 2);//税后 var realamt = Math.Round(amt * tax, 2);//税额 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs index afe467f7..4614b6d6 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs @@ -301,153 +301,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } - //[HttpPost] - //[UnitOfWork(false)] - ///// - ///// 发票重开列表 - ///// - ///// - ///// - //public virtual async Task ReissueInvoiceList(List p_list) - //{ - - // var result = await _adjservice.CheckImport(p_list); - // if (result != "OK") - // { - // return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result }); - // } - - // var invBilllist = new List(); - // var adjlist = ObjectMapper.Map, List>(p_list); - // if (adjlist == null && adjlist.Count == 0) - // { - // throw new UserFriendlyException($"调整表无数据!"); - // } - // var first = p_list.FirstOrDefault(); - // var invbillnum = first.InvBillNum; - // //var mappingList = await GetMapGroupAsync(invbillnum);//发票对应结算分组 - // //if (mappingList != null && mappingList.Count() > 0) - // //{ - // var version = int.Parse(DateTime.Now.ToString("yyyymm")); - // //var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组 - // var inv = await GetInvoiceGroupByInvBillNum(invbillnum); - - // var settle = await _bbacMng.GetMainAsync(inv.InvGroupNum); - - // if (settle == null) - // { - // throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!"); - // } - // version = settle.Version; - // if (inv != null) - // { - // if (inv.InvoiceState == InvoiceBillState.报废) - // { - // throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!"); - // } - // if (inv.State == SettleBillState.商务已审核 || inv.State == SettleBillState.已开票) - // { - // throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!"); - // } - - // var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件 - // //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 - // if (adjlist != null && adjlist.Count() > 0) - // { - // foreach (var itm in adjlist) - // { - // bbaclist.Add(new BBAC_CAN_SA_DETAIL( - // guid: itm.Id, - // keyCode: itm.KeyCode, - // version: itm.Version, - // billNum: itm.InvGroupNum, - // settleBillNum: itm.SettleBillNum, - // lU: itm.LU, - // pN: itm.PN, - // site: itm.Site, - // qty: itm.Qty, - // price: itm.Price, - // category: itm.BusinessType, - // isReturn: itm.Qty > 0 ? false : true, - // settleDate: itm.SettleDate, - // groupNum: itm.GroupNum, - // invGroupNum: itm.InvGroupNum, - // contactid: itm.Extend1,//生产号 - // invbillnum: string.Empty, - // partcode: itm.PartCode - // )); - // } - // } - // var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据 - // var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); - // var priceList = _priceRepository.ToList();//价格单 - - // var dto1s = ObjectMapper.Map, List>(entitys); - // var q = from d in dto1s - // join p in priceList on d.LU equals p.LU - // where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号 - // select new TEMP_CAN_SA_DETAIL - // { - // Id = d.Id, - // SettleBillNum = d.SettleBillNum, - // Site = d.Site, - // Version = d.Version, - // Price = p.Price, - // BillNum = d.BillNum, - // SettleDate = d.SettleDate, - // InvGroupNum = d.InvGroupNum, - // LU = d.LU, - // MaterialDesc = d.MaterialDesc, - // PN = d.PN, - // Qty = d.Qty, - // GroupNum = d.GroupNum, - // Amt = Math.Round(d.Qty * p.Price, 2), - // ContractDocID = d.ContractDocID, - // BeginDate = p.BeginTime, - // EndDate = p.EndTime, - // PartCode = d.PartCode - - // }; - // var dtos = q.ToList(); - // if (dtos != null && dtos.Count > 0) - // { - // if (invbillnum.Substring(0, 3) == "INV")//一次开票重开 - // { - // var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum); - // var ls = ObjectMapper.Map, List>(entities); - // invBilllist.AddRange(ls); - - // } - // else//二次开票 - // { - // var entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum); - // var ls = ObjectMapper.Map, List>(entities); - // invBilllist.AddRange(ls); - - // } - - // } - // else - // { - // throw new UserFriendlyException($"不存发票号为:{invbillnum}发票"); - // } - // } - // var invlist = invBilllist.OrderBy(p => p.PartCode); - // return new JsonResult(new { Code = 200, Data = invlist }); - - //} - - - - - - - - - - - - [HttpPost] /// 发票重开列表 /// @@ -569,52 +422,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum); var ls = ObjectMapper.Map, List>(entities); - invBilllist.AddRange(ls); - //var invlist = ls.Select(p => p.InvbillNum).Distinct(); - //foreach (var itm in invlist) - //{ - // var invBill = new INVOICE_REPEAT_DTO(); - // var invls = ls.Where(p => p.InvbillNum == itm).ToList(); - // var entitylist = entities.Where(p => p.InvbillNum == itm).ToList(); - // var tax = inv.Tax;//税率 - // var amt = entitylist.Sum(p => p.Amt);//税前 - // var taxamt = amt + Math.Round(amt * tax, 2);//税后 - // var realamt = Math.Round(amt * tax, 2);//税额 - // invBill.Amt = amt; - // invBill.TaxAmt = taxamt; - // invBill.Tax = tax; - // invBill.BusinessType = inv.BusinessType; - // invBill.DETAIL = invls; - // invBill.RealAmt = realamt; - // invBilllist.Add(invBill); - //} + } else//二次开票 { var entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum); var ls = ObjectMapper.Map, List>(entities); invBilllist.AddRange(ls); - - //var invlist = ls.Select(p => p.InvbillNum).Distinct(); - //foreach (var itm in invlist) - //{ - // var invBill = new INVOICE_REPEAT_DTO(); - // var invls = ls.Where(p => p.InvbillNum == itm).ToList(); - // var entitylist = entities.Where(p => p.InvbillNum == itm).ToList(); - // var tax = inv.Tax;//税率 - // var amt = entitylist.Sum(p => p.Amt);//税前 - // var taxamt = amt + Math.Round(amt * tax, 2);//税后 - // var realamt = Math.Round(amt * tax, 2);//税额 - // invBill.Amt = amt; - // invBill.TaxAmt = taxamt; - // invBill.Tax = tax; - // invBill.BusinessType = inv.BusinessType; - // invBill.DETAIL = invls; - // invBill.RealAmt = realamt; - // invBilllist.Add(invBill); - //} - } } } @@ -762,7 +577,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var invBill = new INVOICE_REPEAT_DTO(); var invls = ls.Where(p => p.InvbillNum == itm).ToList(); var entitylist = entities.Where(p => p.InvbillNum == itm).ToList(); - var tax = inv.Tax;//税率 + var tax = inv.Tax == 0 ? 0.13m : inv.Tax;//税率 var amt = entitylist.Sum(p => p.Amt);//税前 var taxamt = amt + Math.Round(amt * tax, 2);//税后 var realamt = Math.Round(amt * tax, 2);//税额 @@ -785,7 +600,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var invBill = new INVOICE_REPEAT_DTO(); var invls = ls.Where(p => p.InvbillNum == itm).ToList(); var entitylist = entities.Where(p => p.InvbillNum == itm).ToList(); - var tax = inv.Tax;//税率 + var tax = inv.Tax == 0 ? 0.13m : inv.Tax;//税率 var amt = entitylist.Sum(p => p.Amt);//税前 var taxamt = amt + Math.Round(amt * tax, 2);//税后 var realamt = Math.Round(amt * tax, 2);//税额 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG_EXT.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG_EXT.cs index dcbbde6d..a3af7837 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG_EXT.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG_EXT.cs @@ -312,21 +312,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers var ls = itm.Value;//结算分组号列表 //反向查找结算数据 var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList(); - //foreach (var detail in invdetails) - //{ - // detail.InvbillNum = key; - // salist.Add(detail); - //} - //if (!string.IsNullOrEmpty(p_parentInvBillNum)) - //{ - // //反向查找调整数据 - // var adjdetails = p_adjlist.Where(p => ls.Contains(p.GroupNum)).ToList(); - // foreach (var detail in adjdetails) - // { - // detail.InvBillNum = key; - // adjdetails.Add(detail); - // } - //} + var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode,p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }) .Select(itm => new { @@ -344,25 +330,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers decimal amt = detailDtos.Sum(k => k.Amt);//金额 decimal txtAmt = detailDtos.Sum(k => k.Amt) + Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税后金额 decimal realAmt = Math.Round(detailDtos.Sum(k => k.Amt) * 0.13m, 2);//税额 - //var mapList = new List(); - //foreach (var groupnum in ls) - //{ - // mapList.Add(new INVOICE_MAP_GROUP( - // guid: GuidGenerator.Create(), - // version: p_version, - // invbillNum: key, - // invGroupNum: p_InvGroupNum, - // settleGroupNum: groupnum, - // amt: 0, - // extend1: string.Empty, - // extend2: string.Empty - // ) - // ); - //} - //if (mapList.Count > 0) - //{ - // groupList.AddRange(mapList); - //} + List _entityDetailList = new List(); foreach (var detail in detailDtos) { @@ -388,31 +356,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { detailList.AddRange(_entityDetailList); } - //var innotls = new List(); - //if (p_notlist != null && p_notlist.Count > 0) - //{ - // var notls = p_notlist.Where(p=>ls.Contains(p.GroupNum)).GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) }); - // foreach (var nitm in notls) - // { - // innotls.Add(new INVOICE_NOT_SETTLE( - // guid: GuidGenerator.Create(), - // version: p_version, - // invGroupNum: p_InvGroupNum, - // settleGroupNum: nitm.GroupNum, - // lU: string.Empty, - // lU1: nitm.LU, - // extend1: string.Empty, - // extend2: string.Empty, - // qty: nitm.Qty, - // p_invbillnum:key - - // )); - // } - // if (innotls.Count > 0) - // { - // notDetialList.AddRange(innotls); - // } - //} + var invbill = new INVOICE_GRP (guid: GuidGenerator.Create(), realnvBillNum: string.Empty, @@ -433,23 +377,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers ); invlist.Add(invbill); } - //await _repository.DbContext.BulkInsertAsync(invlist); - //await _repository.DbContext.BulkInsertAsync(groupList); - //await _repository.DbContext.BulkInsertAsync(detailList); - - //if (salist.Count > 0) - //{ - // await _repository.DbContext.BulkUpdateAsync(salist); - //} - //if (adjlist.Count > 0) - //{ - // await _repository.DbContext.BulkUpdateAsync(adjlist); - //} - //if (notDetialList.Count > 0) - //{ - // await _repository.DbContext.BulkInsertAsync(notDetialList); - //} - //_invls = invlist.Select(p => p.InvbillNum).ToList(); + } return detailList;