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 6aede947..72c6b202 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 @@ -307,8 +307,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "零件号")] public string LU { set; get; } - [Display(Name = "数量")] - public decimal Qty { set; get; } + } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs index 997fb967..60a5a8ce 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs @@ -9,7 +9,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos public class PUB_ADJ_DETAIL_DTO : EntityDto { - [Display(Name = "金税发票")] + [ExporterHeader(DisplayName = "金税发票")] public string RealInvBillNum { get; set; } ///// /////作废发票号 @@ -19,29 +19,32 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos /// ///发票号 /// - [Display(Name = "发票号")] + [ExporterHeader(DisplayName = "发票号")] public string InvBillNum { get; set; } /// /// 下线日期 /// - [Display(Name = "下线日期")] + [ExporterHeader(DisplayName = "下线日期")] public DateTime SettleDate { get; set; } //[Display(Name = "发票分组号")] //public string InvGroupNum { get; set; } - [Display(Name = "零件号")] + [ExporterHeader(DisplayName = "零件号")] public string LU { get; set; } - [Display(Name = "标识号")] + [ExporterHeader(DisplayName = "标识号")] public string PN { get; set; } - [Display(Name = "数量")] + [ExporterHeader(DisplayName = "数量")] public decimal Qty { get; set; } - [Display(Name = "结算分组")] + [ExporterHeader(DisplayName = "结算分组")] public string GroupNum { get; set; } - [Display(Name = "键值")] + [ExporterHeader(DisplayName = "键值")] public string KeyCode { get; set; } - [Display(Name = "价格")] + [ExporterHeader(DisplayName = "价格")] public decimal Price { get; set; } + [ExporterHeader(IsIgnore =false)] + public string PartCode { get; set; } + } public class PUB_ADJ_DETAIL_EXP_DTO 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 5a0e8c27..0a35d164 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 @@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Reflection; using System.Threading.Tasks; +using Castle.Core.Internal; using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Csv; using Magicodes.ExporterAndImporter.Excel; @@ -25,6 +26,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Temp; using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.Entities.TaskJobs; using Win.Sfs.SettleAccount.ExportReports; +using Win.Sfs.SettleAccount.MaterialRelationships; using Win.Sfs.Shared.Filter; using Win.Sfs.Shared.RepositoryBase; @@ -121,6 +123,7 @@ namespace Win.Sfs.SettleAccount.Bases } return new PagedResultDto(totalCount, dtos); } + /// /// 查询明细明细 /// @@ -180,7 +183,6 @@ namespace Win.Sfs.SettleAccount.Bases 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", "");//供应商代码 @@ -257,6 +259,7 @@ namespace Win.Sfs.SettleAccount.Bases 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 @@ -329,8 +332,6 @@ namespace Win.Sfs.SettleAccount.Bases } 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 @@ -500,6 +501,11 @@ namespace Win.Sfs.SettleAccount.Bases return null; } + + + + + /// /// hbpo、jit、备件等 /// @@ -598,13 +604,64 @@ namespace Win.Sfs.SettleAccount.Bases return errors; } - /// - /// 校验规则 - /// - /// - /// - /// - protected async Task> CheckInvoiceGenerationRules(List dto1s, List p_pricelist, EnumBusinessType p_businessType) where T : SA_CAN_BASE + protected async Task> CheckAdJRules(List p_dtos,List p_ship ,EnumBusinessType p_businessType) + { + var query= from dto in p_dtos + join itm1 in p_ship on dto.LU equals itm1.SettleMaterialCode into temp + from tm in temp.DefaultIfEmpty() + where tm == null + select dto; + List errorList = new List(); + + string name = string.Empty; + string keyname = string.Empty; + switch (p_businessType) + { + case EnumBusinessType.MaiDanJianHBPO: + name = "HBPO买单件"; + keyname = "生产码"; + break; + case EnumBusinessType.ZhiGongJianHBPO: + name = "HBPO直供件"; + keyname = "发货单号"; + break; + case EnumBusinessType.ZhiGongJianBBAC: + name = "BBAC直供件"; + keyname = "发货单号"; + break; + case EnumBusinessType.YinDuJian: + name = "HBPO印度件"; + keyname = "发货单号"; + break; + case EnumBusinessType.JisBBAC: + name = "BBAC-JIS"; + keyname = "生产码"; + break; + case EnumBusinessType.JisHBPO: + name = "HBPO-JIS"; + keyname = "生产码"; + break; + case EnumBusinessType.BeiJian: + name = "备件"; + keyname = "交付识别号"; + break; + } + + foreach (var error in query.ToList()) + { + errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = $"{name}", Message = $"LU:{error.LU}{keyname}:{error.PN},客户零件关系表没有对应厂内物料号!" }); + } + return errorList; + + } + + /// + /// 校验规则 + /// + /// + /// + /// + protected async Task> CheckInvoiceGenerationRules(List dto1s, List p_pricelist, EnumBusinessType p_businessType) where T : SA_CAN_BASE { var first = dto1s.Where(p=>!string.IsNullOrEmpty(p.Site)).FirstOrDefault(); 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 7ddec48d..a1c4c035 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 @@ -20,6 +20,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Temp; using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.Entities.TaskJobs; +using Win.Sfs.SettleAccount.MaterialRelationships; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ { @@ -32,6 +33,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { private readonly INormalEfCoreRepository _priceRepository; + + private readonly INormalEfCoreRepository _relationRepository; + private readonly ADJ_SERVICE _adjservice; public BBAC_BA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, @@ -42,6 +46,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ INormalEfCoreRepository sRepository, INormalEfCoreRepository mRepository, INormalEfCoreRepository adjRepository, + + INormalEfCoreRepository relationRepository, + BBAC_CAN_SA_MNG bbacMng, HBPO_CAN_SA_MNG hbpoMng, PUB_CAN_SA_MNG pubMng, @@ -66,6 +73,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ service, baseservice) { + _relationRepository = relationRepository; _priceRepository = priceRepository; _adjservice = adjservice; } @@ -77,13 +85,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// public override async Task ReissueInvoice([FromBody] string p_invbillnum) { - var version = int.Parse(DateTime.Now.ToString("yyyymm")); - var inv = await GetInvoiceGroupByInvBillNum(p_invbillnum).ConfigureAwait(false); - var settle = await _bbacMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false); + + + if (settle == null) { throw new UserFriendlyException($"选择发票:{p_invbillnum}对应的可结算单不在请检查!", "400"); @@ -203,6 +211,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// public virtual async Task ReissueInvoiceExtend(List p_list) { + var errorlist = await CheckRepeat(p_list).ConfigureAwait(false);//是否录入数据重复 if (errorlist.Count > 0) { @@ -237,6 +246,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 if (adjlist != null && adjlist.Count > 0) { + + var relationList =_relationRepository.Where(p => p.BusinessType == inv.BusinessType); + + var relist= relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault()); + + foreach (var itm in adjlist) { bbaclist.Add(new BBAC_CAN_SA_DETAIL( @@ -245,7 +260,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ version: itm.Version, billNum: itm.InvGroupNum, settleBillNum: itm.SettleBillNum, - lU: itm.LU, + lU: itm.LU, pN: itm.PN, site: itm.Site, qty: itm.Qty, @@ -257,7 +272,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ invGroupNum: itm.InvGroupNum, contactid: itm.Extend1,//生产号 invbillnum: string.Empty, - partcode: itm.PartCode + partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode )); } } @@ -331,6 +346,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// public virtual async Task ReissueInvoiceList(List p_list) { + var result = await _adjservice.CheckImport(p_list).ConfigureAwait(false); if (result != "OK") { @@ -372,6 +388,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 if (adjlist != null && adjlist.Count > 0) { + var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType); + + var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault()); + var errorList=await CheckAdJRules(adjlist, relist.ToList(),inv.BusinessType); + if (errorList.Count > 0) + { + return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); + } + foreach (var itm in adjlist) { bbaclist.Add(new BBAC_CAN_SA_DETAIL( @@ -392,7 +417,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ invGroupNum: itm.InvGroupNum, contactid: itm.Extend1,//生产号 invbillnum: string.Empty, - partcode: itm.PartCode + partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode )); } } @@ -501,6 +526,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum).ConfigureAwait(false);//结算分组对应结算零件 //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 if (adjlist != null && adjlist.Count > 0) { + var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType); + var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault()); + var errorList = await CheckAdJRules(adjlist, relist.ToList(), inv.BusinessType); + if (errorList.Count > 0) + { + return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); + } + foreach (var itm in adjlist) { bbaclist.Add(new BBAC_CAN_SA_DETAIL( @@ -521,7 +554,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ invGroupNum: itm.InvGroupNum, contactid: itm.Extend1,//生产号 invbillnum: string.Empty, - partcode: itm.PartCode + partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode )); } } 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 b6def4bf..f4411e89 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 @@ -19,6 +19,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Temp; using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.Entities.TaskJobs; +using Win.Sfs.SettleAccount.MaterialRelationships; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ @@ -27,7 +28,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [Route("api/settleaccount/[controller]/[action]")] public class HBPO_BA_SERVICE : BA_SERVICE { - + private readonly INormalEfCoreRepository _relationRepository; private readonly INormalEfCoreRepository _priceRepository; private readonly ADJ_SERVICE _adjservice; @@ -37,12 +38,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ TaskJobService service, BaseDomainService baseservice, INormalEfCoreRepository priceRepository, - ADJ_SERVICE adjservice + ADJ_SERVICE adjservice, + INormalEfCoreRepository relationRepository ) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, wRepository, sRepository, mRepository, adjRepository, bbacMng, hbpoMng, pubMng, invMng, service, baseservice) { _priceRepository = priceRepository; _adjservice = adjservice; + _relationRepository = relationRepository; } /// /// 发票重开 @@ -208,6 +211,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 if (adjlist != null && adjlist.Count > 0) { + var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType); + var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault()); + var errors = await CheckAdJRules(adjlist, relist.ToList(), inv.BusinessType); + if (errors.Count > 0) + { + return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errors).ConfigureAwait(false) }); + } + foreach (var itm in adjlist) { hbpolist.Add(new HBPO_CAN_SA_DETAIL( @@ -226,7 +237,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, invbillnum: string.Empty, - partcode: itm.PartCode + partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode )); } } @@ -335,6 +346,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var bbaclist = await _hbpoMng.GetContainsAsync(inv.InvbillNum).ConfigureAwait(false);//结算分组对应结算零件 //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 if (adjlist != null && adjlist.Count > 0) { + var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType); + var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault()); foreach (var itm in adjlist) { bbaclist.Add(new HBPO_CAN_SA_DETAIL( @@ -354,7 +367,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ invGroupNum: itm.InvGroupNum, invbillnum: string.Empty, - partcode: itm.PartCode + partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode )); } } @@ -481,6 +494,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 if (adjlist != null && adjlist.Count > 0) { + var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType); + + var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault()); + + + var errorList = await CheckAdJRules(adjlist, relist.ToList(), inv.BusinessType); + if (errorList.Count > 0) + { + return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); + } + foreach (var itm in adjlist) { bbaclist.Add(new HBPO_CAN_SA_DETAIL( @@ -501,7 +525,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ invGroupNum: itm.InvGroupNum, invbillnum: string.Empty, - partcode: itm.PartCode + partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode )); } } 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 2f81cf39..fba10da7 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 @@ -386,7 +386,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ entity.MAIDAN_HBPO_INVOICE_MAP_GROUP = maiquery.ToList(); List unsettle = new List(); - foreach (var itm in notquery.ToList()) + foreach (var itm in sdtos) { unsettle.Add(new MAIDAN_HBPO_UNSETTLED_DETAIL_DTO() { GroupNum=itm.InvGroupNum, diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs index 2179bb47..62355113 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs @@ -19,6 +19,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Temp; using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.Entities.TaskJobs; +using Win.Sfs.SettleAccount.MaterialRelationships; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ @@ -30,20 +31,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly INormalEfCoreRepository _priceRepository; private readonly INormalEfCoreRepository _pricebjRepository; private readonly ADJ_SERVICE _adjservice; + private readonly INormalEfCoreRepository _relationRepository; public PUB_BA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository pubRepository, INormalEfCoreRepository repository, INormalEfCoreRepository wRepository, INormalEfCoreRepository sRepository, INormalEfCoreRepository mRepository, INormalEfCoreRepository adjRepository, BBAC_CAN_SA_MNG bbacMng, HBPO_CAN_SA_MNG hbpoMng, PUB_CAN_SA_MNG pubMng, INV_MNG invMng, TaskJobService service, BaseDomainService baseservice, INormalEfCoreRepository priceRepository, INormalEfCoreRepository pricebjRepository, - ADJ_SERVICE adjservice - + ADJ_SERVICE adjservice, + INormalEfCoreRepository relationRepository ) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, wRepository, sRepository, mRepository, adjRepository, bbacMng, hbpoMng, pubMng, invMng, service, baseservice) { _priceRepository = priceRepository; _pricebjRepository = pricebjRepository; _adjservice = adjservice; + _relationRepository = relationRepository; } /// @@ -96,6 +99,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 if (adjlist != null && adjlist.Count > 0) { + var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType); + + var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault()); + + var errors = await CheckAdJRules(adjlist, relist.ToList(), inv.BusinessType); + if (errors.Count > 0) + { + return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errors).ConfigureAwait(false) }); + } + foreach (var itm in adjlist) { publist.Add(new PUB_CAN_SA_DETAIL( @@ -114,7 +127,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, invbillnum: string.Empty, - partcode: itm.PartCode, + partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode, pobillnum: string.Empty )); } @@ -360,6 +373,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 if (adjlist != null && adjlist.Count > 0) { + var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType); + + var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault()); + + var errorList = await CheckAdJRules(adjlist, relist.ToList(), inv.BusinessType); + if (errorList.Count > 0) + { + return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); + } + foreach (var itm in adjlist) { bbaclist.Add(new PUB_CAN_SA_DETAIL( @@ -380,7 +403,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ invGroupNum: itm.InvGroupNum, invbillnum: string.Empty, - partcode: itm.PartCode, + partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode, pobillnum: string.Empty )); } @@ -528,6 +551,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var bbaclist = await _pubMng.GetContainsAsync(inv.InvbillNum).ConfigureAwait(false);//结算分组对应结算零件 //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 if (adjlist != null && adjlist.Count > 0) { + var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType); + + var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault()).ToList(); + + var errorList = await CheckAdJRules(adjlist, relist.ToList(), inv.BusinessType); + if (errorList.Count > 0) + { + return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); + } + foreach (var itm in adjlist) { bbaclist.Add(new PUB_CAN_SA_DETAIL( @@ -546,7 +579,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, invbillnum: string.Empty, - partcode: itm.PartCode, + partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode, pobillnum: string.Empty )); } 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 64cddd15..992f2766 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 @@ -1616,32 +1616,47 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { groupList.AddRange(mapList); } - var notsettle= _nothbpoRepository.Where(p => p.SettleBillNum == p_InvGroupNum);//一次开票时查找不可结数据,追加需求 - if (notsettle != null && notsettle.Count() > 0) + + if (p_first == true) { - var innotls = new List(); - foreach (var nitm in notsettle) - { - innotls.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: string.Empty - )); - } - if (innotls.Count > 0) + var mng = await _hbpoMng.GetMainAsync(p_InvGroupNum); + + + var notsettle = _nothbpoRepository.Where(p => p.SettleBillNum == mng.SettleBillNum);//一次开票时查找不可结数据,追加需求 + + if (notsettle != null && notsettle.Count() > 0) { - notDetialList.AddRange(innotls); + var innotls = new List(); + foreach (var nitm in notsettle) + { + innotls.Add(new INVOICE_NOT_SETTLE( + guid: GuidGenerator.Create(), + version: p_version, + invGroupNum: p_InvGroupNum, + settleGroupNum: nitm.GroupNum, + lU: nitm.LU, + lU1: nitm.LU, + extend1: nitm.PN, + extend2: string.Empty, + qty: nitm.Qty, + p_invbillnum: string.Empty + )); + } + if (innotls.Count > 0) + { + notDetialList.AddRange(innotls); + } + } + + + } + + + //invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV"); } 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 ccfc6cd8..8b21c361 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 @@ -589,6 +589,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV"); } + List invoiceGroupNumList = new List();//每个发票对应的结算分组号 List List = new List(); decimal sum = itm.Value;//初始分组合计金额