diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs index 543ce7a4..4496dad8 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs @@ -325,7 +325,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos public class INVOICE_WAIT_DETAIL_BJ_DTO { - public int Version { get; set; } + [Display(Name = "金税发票号")] public string RealInvbillNum { get; set; } [Display(Name = "发票日期")] @@ -347,16 +347,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos public string VendorCode { get; set; } [Display(Name = "供应商名称")] public string VendorName { get; set; } - [Display(Name = "PurchaseOrderNumber")] - public string PurchaseOrderNumber { get; set; } - [Display(Name = "业务分类")] + + [Display(Name = "交付索引号")] public string DeliveryIndexNumber { get; set; } /// ///零件号 /// [Display(Name = "零件号")] public string PartCode { get; set; } - [Display(Name = "PartName")] + [Display(Name = "零件名称")] public string PartName { get; set; } /// ///发票分组号 @@ -409,7 +408,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos } - + // DeliveryNumber = inv1.GetProperty("DeliveryNumber", ""),//交货号 + // InvoiceNumber = inv1.GetProperty("InvoiceNumber", ""),//发票号 + // VendorCode = inv1.GetProperty("VendorCode", ""),//供应商代码 + // VendorName = inv1.GetProperty("VendorName", ""),//供应商名称 + // PurchaseOrderNumber = inv1.GetProperty("PurchaseOrderNumber", ""),//采购订单号 + // DeliveryIndexNumber = inv1.GetProperty("DeliveryIndexNumber", ""),//交付索引号 + // PartName = inv1.GetProperty("PartName", ""),//零件名称 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 544ae483..3f460f75 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 @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc; using SettleAccount.Bases; using SettleAccount.Domain.BQ; using Shouldly; +using SqlSugar; using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Uow; @@ -133,8 +134,8 @@ namespace Win.Sfs.SettleAccount.Bases var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var mdtos = ObjectMapper.Map, List>(m); - var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); - var sdtos = ObjectMapper.Map, List>(s); + var first = invs.FirstOrDefault(); + if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) { var A = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); @@ -146,7 +147,6 @@ namespace Win.Sfs.SettleAccount.Bases select new INVOICE_WAIT_DETAIL_BBAC_DTO() { - PartDesc = tm == null ? string.Empty : itm.PartDesc, InvDate = itm1.CreationTime, RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, @@ -158,72 +158,106 @@ namespace Win.Sfs.SettleAccount.Bases PRICE = itm.PRICE, Qty = itm.Qty, Amt = itm.Amt, - + BussiessType = itm.BussiessType, Extend1 = itm.Extend1, BeginDate = itm.BeginDate, EndDate = itm.EndDate, }; - entity.INVOICE_WAIT_DETAIL_BBAC = wquery.ToList(); + entity.INVOICE_WAIT_DETAIL_BBAC = wquery.OrderBy(p => p.LU).ToList(); } else if (invs.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian) { var B = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); - var BMap = ObjectMapper.Map, List>(B); + B.OrderBy(p => p.LineCode); + + List BMap = new List(); + foreach (var itm in B) + { + INVOICE_WAIT_DETAIL_BJ_DTO bj = new INVOICE_WAIT_DETAIL_BJ_DTO(); + bj.LU = itm.LU; + bj.PartCode = itm.PartCode; + bj.PRICE = itm.PRICE; + + bj.InvGroupNum = itm.InvGroupNum; + bj.DeliveryNumber = itm.ExtraProperties["DeliveryIndexNumber"].ToSqlValue(); + + //bj.DeliveryNumber = itm.GetProperty("DeliveryNumber", "");//交货号 + //bj.InvbillNum = itm.GetProperty("InvoiceNumber", "");//发票号 + //bj.VendorCode = itm.GetProperty("VendorCode", "");//供应商代码 + //bj.VendorName = itm.GetProperty("VendorName", "");//供应商名称 + //bj.PurchaseOrderNumber = itm.GetProperty("PurchaseOrderNumber", "");//采购订单号 + //bj.DeliveryIndexNumber = itm.GetProperty("DeliveryIndexNumber", "");//交付索引号 + //bj.PartName = itm.GetProperty("PartName", "");//零件名称 + + BMap.Add(bj); + } + + //var BMap = ObjectMapper.Map, List>(B); var wquery = from itm in BMap join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp from tm in temp.DefaultIfEmpty() select - new INVOICE_WAIT_DETAIL_BJ_DTO() - { - PartDesc = tm == null ? string.Empty : itm.PartDesc, - InvDate = itm1.CreationTime, - RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, - Version = itm.Version, - InvbillNum = itm.InvbillNum, - InvGroupNum = itm.InvGroupNum, - LU = itm.LU, - PartCode = itm.PartCode, - PRICE = itm.PRICE, - Qty = itm.Qty, - Amt = itm.Amt, - - Extend1 = itm.Extend1, - BeginDate = itm.BeginDate, - EndDate = itm.EndDate, - }; + new INVOICE_WAIT_DETAIL_BJ_DTO() + { + PartDesc = tm == null ? string.Empty : itm.PartDesc, + InvDate = itm1.CreationTime, + RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, + Version = itm.Version, + InvbillNum = itm.InvbillNum, + InvGroupNum = itm.InvGroupNum, + LU = itm.LU, + PartCode = itm.PartCode, + PRICE = itm.PRICE, + Qty = itm.Qty, + Amt = itm.Amt, + DeliveryNumber = itm.DeliveryNumber, + VendorCode = itm.VendorCode, + VendorName = itm.VendorName, + //PurchaseOrderNumber = itm.PurchaseOrderNumber, + DeliveryIndexNumber = itm.DeliveryIndexNumber, + Extend1 = itm.Extend1, + BeginDate = itm.BeginDate, + EndDate = itm.EndDate, + }; entity.INVOICE_WAIT_DETAIL_BJ = wquery.ToList(); } else { - var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); + + var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); var wdtos = ObjectMapper.Map, List>(w); var wquery = from itm in wdtos join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp from tm in temp.DefaultIfEmpty() select - new INVOICE_WAIT_DETAIL_DTO() - { - PartDesc = tm == null ? string.Empty : itm.PartDesc, - InvDate = itm1.CreationTime, - RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, - Version = itm.Version, - InvbillNum = itm.InvbillNum, - InvGroupNum = itm.InvGroupNum, - LU = itm.LU, - PartCode = itm.PartCode, - PRICE = itm.PRICE, - Qty = itm.Qty, - Amt = itm.Amt, - BussiessType = itm.BussiessType, - // Extend1 = itm.Extend1, - BeginDate = itm.BeginDate, - EndDate = itm.EndDate, - }; - entity.INVOICE_WAIT_DETAIL = wdtos; + new INVOICE_WAIT_DETAIL_DTO() + { + PartDesc = tm == null ? string.Empty : itm.PartDesc, + InvDate = itm1.CreationTime, + RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, + Version = itm.Version, + InvbillNum = itm.InvbillNum, + InvGroupNum = itm.InvGroupNum, + LU = itm.LU, + PartCode = itm.PartCode, + PRICE = itm.PRICE, + Qty = itm.Qty, + Amt = itm.Amt, + BussiessType = itm.BussiessType, + //Extend1 = itm.Extend1, + BeginDate = itm.BeginDate, + EndDate = itm.EndDate, + }; + entity.INVOICE_WAIT_DETAIL = wquery.OrderBy(p => p.LU).ToList(); } + var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); + var sdtos = ObjectMapper.Map, List>(s);//不可结 + var adjs = await _adjRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false);//调整数据 + var adjdtos = ObjectMapper.Map, List>(adjs);//调整数据DTO + var notquery = from itm in sdtos join itm1 in invs on itm.InvBillNum equals itm1.InvbillNum select @@ -249,8 +283,7 @@ namespace Win.Sfs.SettleAccount.Bases InvGroupNum = itm.InvGroupNum, SettleGroupNum = itm.SettleGroupNum }; - var adjs = await _adjRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false); - var adjdtos = ObjectMapper.Map, List>(adjs); + var adjQuery = from itm in adjdtos join itm1 in invs on itm.InvBillNum equals itm1.InvbillNum select @@ -266,9 +299,68 @@ namespace Win.Sfs.SettleAccount.Bases KeyCode = itm.KeyCode, Price = itm.Price }; - entity.INVOICE_NOT_SETTLE = notquery.ToList(); - entity.INVOICE_MAP_GROUP = mquery.ToList(); - entity.ADJ_DETAIL = adjQuery.ToList(); + + entity.INVOICE_NOT_SETTLE = notquery.OrderBy(p => p.SettleGroupNum).ThenBy(p => p.LU).ToList(); + + var lscompare = entity.INVOICE_NOT_SETTLE.GroupBy(x => new { x.InvBillNum, x.SettleGroupNum }).Select(p => + new INVOICE_MAP_GROUP_DTO() + { + InvbillNum = p.FirstOrDefault().InvBillNum, + InvGroupNum = p.FirstOrDefault().InvGroupNum, + RealInvBillNum = p.FirstOrDefault().RealInvBillNum, + InvDate = p.FirstOrDefault().InvDate, + SettleGroupNum = p.FirstOrDefault().SettleGroupNum, + } + ); + if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)//BBAC直供未结 + { + //var all = entity.INVOICE_NOT_SETTLE.Select(p => p.SettleGroupNum).Distinct().ToList();//全部分组号 + //var part = mquery.ToList().Select(p => p.SettleGroupNum).Distinct().ToList();//发票对应分组号 + //var unsettled = all.Where(p => !part.Contains(p));//排除发票对应分组号,都为不可结 + var unsettledList = sdtos + .GroupBy(p => new { p.LU, p.SettleGroupNum }) + .Select(p => new JIT_UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) }); + entity.JIT_UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); + } + + + if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC) + { + entity.INVOICE_MAP_GROUP = lscompare.ToList().OrderBy(p => p.SettleGroupNum).ToList();//包含不可结结算分组号 + } + if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) + { + //List maidan = new List(); + + var maiquery = from itm in m + join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum + select + new MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO() + { + Extend1 = itm.Extend1, + InvGroupNum = itm.InvGroupNum, + SettleGroupNum = itm.SettleGroupNum, + InvbillNum = itm.InvbillNum, + RealInvBillNum = itm1.RealnvBillNum + }; + + entity.MAIDAN_HBPO_INVOICE_MAP_GROUP = maiquery.ToList(); + List unsettle = new List(); + foreach (var itm in notquery.ToList()) + { + unsettle.Add(new MAIDAN_HBPO_UNSETTLED_DETAIL_DTO() + { + GroupNum = itm.InvGroupNum, + LU = itm.LU, + PN = itm.Extend1, + + }); + } + entity.MAIDAN_HBPO_UNSETTLED_DETAIL = unsettle; + + } + + entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); return entity; } /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs index 9b68ff22..11c505e3 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs @@ -199,9 +199,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ bj.LU = itm.LU; bj.PartCode = itm.PartCode; bj.PRICE = itm.PRICE; - + bj.InvbillNum = itm.InvbillNum; bj.InvGroupNum = itm.InvGroupNum; bj.DeliveryNumber =itm.ExtraProperties["DeliveryIndexNumber"].ToSqlValue(); + bj.Qty = itm.Qty; + bj.PRICE = itm.PRICE; + bj.Amt = Math.Round(itm.PRICE * itm.Qty, 2); + bj.Extend1=itm.Extend1; + bj.VendorCode = itm.ExtraProperties["VendorCode"].ToSqlValue();//供应商代码 + bj.VendorName = itm.ExtraProperties["VendorName"].ToSqlValue();//供应商名称 + bj.DeliveryNumber = itm.ExtraProperties["DeliveryNumber"].ToSqlValue();//交货号; + //bj.DeliveryNumber = itm.GetProperty("DeliveryNumber", "");//交货号 //bj.InvbillNum = itm.GetProperty("InvoiceNumber", "");//发票号 //bj.VendorCode = itm.GetProperty("VendorCode", "");//供应商代码 @@ -209,10 +217,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //bj.PurchaseOrderNumber = itm.GetProperty("PurchaseOrderNumber", "");//采购订单号 //bj.DeliveryIndexNumber = itm.GetProperty("DeliveryIndexNumber", "");//交付索引号 //bj.PartName = itm.GetProperty("PartName", "");//零件名称 + + BMap.Add(bj); } //var BMap = ObjectMapper.Map, List>(B); - var wquery = from itm in BMap + var bjquery = from itm in BMap join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp from tm in temp.DefaultIfEmpty() @@ -233,13 +243,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ DeliveryNumber = itm.DeliveryNumber , VendorCode = itm.VendorCode , VendorName = itm.VendorName , - PurchaseOrderNumber = itm.PurchaseOrderNumber, + // PurchaseOrderNumber = itm.PurchaseOrderNumber, DeliveryIndexNumber =itm.DeliveryIndexNumber , Extend1 = itm.Extend1, BeginDate = itm.BeginDate, EndDate = itm.EndDate, }; - entity.INVOICE_WAIT_DETAIL_BJ = wquery.ToList(); + entity.INVOICE_WAIT_DETAIL_BJ = bjquery.ToList(); } else { @@ -442,13 +452,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var hbpounsettle = invdetail.MAIDAN_HBPO_UNSETTLED_DETAIL;//买单HBPO未结 var jitunsettle = invdetail.JIT_UNSETTLED_DETAIL;//买单HBPO未结 - - - var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute()?.Name ?? typeof(INVOICE_GRP_DTO).Name; string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; -#region 发票明细 + #region 发票明细 if (entities.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) { _excel.Append(bbac, "发票明细"); @@ -466,7 +473,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // 发票分组 if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO) { - _excel.Append(m, "发票结算分组对应");//发票分组对应结算号 + if (m != null) + { + _excel.Append(m, "发票结算分组对应");//发票分组对应结算号 + } + if (unsettle != null) + { + _excel.Append(unsettle, "未结零件汇总"); + } + + } if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) { @@ -479,10 +495,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ _excel.Append(hbpounsettle, "未结零件汇总"); } } - if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC) - { - _excel.Append(unsettle, "未结零件汇总"); - } + //jis业务,发票分组对应关系,未结数据,调整数据 if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs index df6db51b..47c00c1f 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs @@ -80,7 +80,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var priceListbj = _pricebjRepository.Where(p => p.IsCancel == false).ToList(); //价格单 foreach (var itm in priceListbj) { - priceList.Add(new PriceList() { LU = itm.LU, BeginTime = itm.BeginDate, EndTime = itm.EndDate, Price = itm.Price }); + priceList.Add(new PriceList() { LU = itm.LU, BeginTime = itm.BeginDate, EndTime = itm.EndDate, Price = itm.Price ,ClientCode="1049"}); } } else 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 b9682692..2d33cc93 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 @@ -2177,7 +2177,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers InvoiceNumber = inv1.GetProperty("InvoiceNumber", ""),//发票号 VendorCode = inv1.GetProperty("VendorCode", ""),//供应商代码 VendorName = inv1.GetProperty("VendorName", ""),//供应商名称 - PurchaseOrderNumber = inv1.GetProperty("PurchaseOrderNumber", ""),//采购订单号 + DeliveryIndexNumber = inv1.GetProperty("DeliveryIndexNumber", ""),//交付索引号 PartName = inv1.GetProperty("PartName", ""),//零件名称 };