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 6143dcf2..fc31f9e5 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 @@ -167,7 +167,7 @@ namespace Win.Sfs.SettleAccount.Bases invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, new List(), p_version, p_InvGroupNum, string.Empty, businessType, false).ConfigureAwait(false);//重开可以变多张发票 break; case EnumBusinessType.ZhiGongJianHBPO: - 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).ConfigureAwait(false); break; case EnumBusinessType.BeiJian: invlist = await _invmng.BJInvoice(p_list, p_adjlist, dtos, new List(), p_version, p_InvGroupNum, string.Empty, businessType, false).ConfigureAwait(false); @@ -216,7 +216,7 @@ namespace Win.Sfs.SettleAccount.Bases invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType, true).ConfigureAwait(false);//重开可以变多张发票 break; case EnumBusinessType.ZhiGongJianHBPO: - invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType, true).ConfigureAwait(false);//重开可以变多张发票 + invlist = await _invmng.FirstInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType).ConfigureAwait(false);//重开可以变多张发票 break; case EnumBusinessType.BeiJian: invlist = await _invmng.BJInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType, true).ConfigureAwait(false); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs index db6f306b..5d4c8b62 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Reflection; using System.Threading.Tasks; using Magicodes.ExporterAndImporter.Core; @@ -12,7 +13,10 @@ using Shouldly; using Volo.Abp.Application.Dtos; using Win.Abp.Snowflakes; using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.Bases.DomainServices; using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Entities.Prices; +using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Bases @@ -24,15 +28,18 @@ namespace Win.Sfs.SettleAccount.Bases where TEntityDetailExportDto : class, new() { protected readonly INormalEfCoreRepository _detailRepository; + private readonly BaseDomainService _baseservice; protected NOT_SA_SERVICE( IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, - INormalEfCoreRepository detailRepository + INormalEfCoreRepository detailRepository, + BaseDomainService baseservice ) : base(excelImportService, snowflakeIdGenerator, commonManager) { + _baseservice = baseservice; _detailRepository = detailRepository; } @@ -99,6 +106,85 @@ namespace Win.Sfs.SettleAccount.Bases return new JsonResult(new { Code = 200, Message = "生成成功" }); } + /// + /// 校验规则 + /// + /// + /// + /// + protected async Task> CheckInvoiceGenerationRules(List dto1s, string p_site, List p_pricelist, EnumBusinessType p_businessType) where T : SA_CAN_BASE + { + + //var maxDate = p_pricelist.Max(p => p.Date); + + var first = dto1s.FirstOrDefault(); + var usepriceList = p_pricelist.Where(p => p.ClientCode == first.Site && p.IsCancel == false).ToList(); + var errorlist = _baseservice.CheckPriceListContinuity(usepriceList); + + var prices = p_pricelist.Where(p => p.ClientCode == p_site && p.IsCancel == false).ToList(); + + var inner = from d in dto1s + join p in prices on d.LU equals p.LU + where + d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.ClientCode == d.Site && p.IsCancel == false + select d; + var ls = inner.ToList(); + var left = from d in dto1s + join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN } + into temp + from tm in temp.DefaultIfEmpty()//校验错误项 + where tm == null + select d; + + 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 errorlist) + { + errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = $"{name}", Message = $"LU:{error.LU},价格表开始日期:{error.BeginTime}价格表结束日期:{error.EndTime}在用价格时间段有交集或价格时间不连续!" }); + } + foreach (var error in left) + { + errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = $"{name}", Message = $"LU:{error.LU}{keyname}:{error.PN},下线日期:{error.SettleDate}没有对应区间销售价格表!" }); + } + return errorList; + } + } + + } + + diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs index fb944620..0c889c03 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs @@ -7,6 +7,7 @@ using SettleAccount.Domain.BQ; using Win.Abp.Snowflakes; using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount.Bases; +using Win.Sfs.SettleAccount.Bases.DomainServices; using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; @@ -31,8 +32,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly BBAC_NOT_SA_MNG _bbacNotMng; public BBAC_NOT_SA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, - ICommonManager commonManager, INormalEfCoreRepository detailRepository, BBAC_NOT_SA_MNG bbacNotMng) : - base(excelImportService, snowflakeIdGenerator, commonManager, detailRepository) + ICommonManager commonManager, INormalEfCoreRepository detailRepository, BBAC_NOT_SA_MNG bbacNotMng, BaseDomainService baseservice) : + base(excelImportService, snowflakeIdGenerator, commonManager, detailRepository,baseservice) { _bbacNotMng = bbacNotMng; } @@ -47,6 +48,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } else { + var errors = await _bbacNotMng.GenerateSettlementOrder(entitys).ConfigureAwait(false); if (errors.Count > 0) { 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 f8ffc4d9..dc0fb2f5 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 @@ -60,6 +60,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var version = int.Parse(DateTime.Now.ToString("yyyymm")); //var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组 var inv = await GetInvoiceGroupByInvBillNum(p_invbillnum).ConfigureAwait(false); + var settle = await _hbpoMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false); if (settle == null) @@ -218,7 +219,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { 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( @@ -323,9 +323,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } var first = p_list.FirstOrDefault(); var invbillnum = first.InvBillNum; - var version = int.Parse(DateTime.Now.ToString("yyyymm")); - var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false); var settle = await _hbpoMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false); if (settle == null) @@ -365,16 +363,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ settleDate: itm.SettleDate, groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, - invbillnum: string.Empty, partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode )); } } var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据 - var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); - - var priceList = _priceRepository.ToList();//价格单 + var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();// + var priceList = _priceRepository.ToList(); + //价格单 //var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType); //if (errorList.Count() > 0) //{ diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs index 4c55ad26..bcda4f67 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs @@ -7,6 +7,7 @@ using SettleAccount.Domain.BQ; using Win.Abp.Snowflakes; using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount.Bases; +using Win.Sfs.SettleAccount.Bases.DomainServices; using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; @@ -34,8 +35,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository detailRepository, - HBPO_NOT_SA_MNG hbpoNotMng - ) : base(excelImportService, snowflakeIdGenerator, commonManager, detailRepository) + HBPO_NOT_SA_MNG hbpoNotMng, BaseDomainService baseservice + ) : base(excelImportService, snowflakeIdGenerator, commonManager, detailRepository,baseservice) { _hbpoNotMng = hbpoNotMng; } 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 9a363ef7..3e1c6510 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 @@ -364,11 +364,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ .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) + if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType==EnumBusinessType.ZhiGongJianHBPO) { entity.INVOICE_MAP_GROUP = lscompare.ToList().OrderBy(p => p.SettleGroupNum).ToList();//包含不可结结算分组号 } - if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) + if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO ) { //List maidan = new List(); @@ -482,7 +482,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ #endregion // 发票分组 - if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO) + if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType==EnumBusinessType.ZhiGongJianHBPO) { if (m != null) { @@ -512,7 +512,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } } //jis业务,发票分组对应关系,未结数据,调整数据 - if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO) + if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType==EnumBusinessType.ZhiGongJianHBPO) { foreach (var itm in entities) { 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 9ad7f011..2ffbe5c2 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 @@ -220,8 +220,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var inv = await GetInvoiceGroupByInvBillNum(p_invbillnum).ConfigureAwait(false); var settle = await _pubMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false); - - if (settle == null) { throw new BusinessException("8989", $"选择发票:{p_invbillnum}对应的可结算单不在请检查!"); @@ -359,6 +357,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!", "400"); } version = settle.Version; + if (inv != null) { if (inv.InvoiceState == InvoiceBillState.报废) @@ -374,15 +373,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ 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( @@ -397,11 +393,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ qty: itm.Qty, price: itm.Price, businessType: itm.BusinessType, - settleDate: itm.SettleDate, groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, - invbillnum: string.Empty, partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode, pobillnum: string.Empty @@ -410,7 +404,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据 var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); - var priceList = _priceRepository.ToList();//价格单 //var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType); //if (errorList.Count() > 0) @@ -491,7 +484,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ invBill.RealAmt = realamt; invBilllist.Add(invBill); } - } } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs index db1e986f..2ae2938f 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs @@ -7,6 +7,7 @@ using SettleAccount.Domain.BQ; using Win.Abp.Snowflakes; using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount.Bases; +using Win.Sfs.SettleAccount.Bases.DomainServices; using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; @@ -29,8 +30,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository detailRepository, - PUB_NOT_SA_MNG pubNotMng - ) : base(excelImportService, snowflakeIdGenerator, commonManager, detailRepository) + PUB_NOT_SA_MNG pubNotMng, + BaseDomainService baseservice + ) : base(excelImportService, snowflakeIdGenerator, commonManager, detailRepository,baseservice) { _pubNotMng = pubNotMng; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs index 5e5e5886..7a056f12 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs @@ -57,8 +57,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers errors.Add($"生产号{itm.PN}零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据"); } } - - if (errors.Count > 0) { return errors; @@ -74,7 +72,33 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers _entity.Site = first.Site; _entity.BusinessType = EnumBusinessType.JisBBAC; var _entityList = new List(); - foreach (var itm in p_list) + var site = first.Site; + var pricelist = _priceRepository.Where(p => p.ClientCode == site && p.IsCancel == false).ToList(); + var query = from d in p_list + join p in pricelist + on d.LU equals p.LU + where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == first.Site + select new BBAC_CAN_SA_DETAIL() + { + ContractDocID = d.ContractDocID, + IsMaiDan=d.IsMaiDan, + Version=d.Version, + KeyCode=d.KeyCode, + Site = site, + BusinessType = d.BusinessType, + ErpLoc = d.ErpLoc, + CreationTime = d.CreationTime, + GroupNum = d.GroupNum, + InvGroupNum = d.InvGroupNum, + LU = d.LU, + PN = d.PN, + SettleBillNum = d.SettleBillNum, + Price = p.Price, + SettleDate = d.SettleDate, + RealPartCode = d.RealPartCode, + Qty = d.Qty + }; + foreach (var itm in query.ToList()) { var _detailEntity = new BBAC_CAN_SA_DETAIL( guid: GuidGenerator.Create(), diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs index 72272987..da43b2a9 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs @@ -1,12 +1,14 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; +using System.Security.Policy; using System.Threading.Tasks; using EFCore.BulkExtensions; using SettleAccount.Domain.BQ; using Volo.Abp.Domain.Services; using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases.DomainServices; +using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ.Managers @@ -25,6 +27,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers private readonly INormalEfCoreRepository _repository; private readonly INormalEfCoreRepository _detailRepository; private readonly INormalEfCoreRepository _notRepository; + private readonly INormalEfCoreRepository _priceRepository; private readonly BaseDomainService _service; public HBPO_NOT_SA_MNG() { @@ -78,7 +81,30 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers _entity.SetId(Guid.NewGuid()); _entity.Site = first.Site; var _entityList = new List(); - foreach (var itm in p_list) + var site= first.Site; + var pricelist=_priceRepository.Where(p => p.ClientCode == site && p.IsCancel == false).ToList(); + var query = from d in p_list + join p in pricelist + on d.LU equals p.LU + where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == first.Site + select new HBPO_NOT_SA_DETAIL() + { + Site = site, + BusinessType = d.BusinessType, + ErpLoc = d.ErpLoc, + CreationTime = d.CreationTime, + GroupNum = d.GroupNum, + InvGroupNum = d.InvGroupNum, + LU = d.LU, + PN = d.PN, + SettleBillNum = d.SettleBillNum, + Price = p.Price, + SettleDate = d.SettleDate, + RealPartCode = d.RealPartCode, + Qty = d.Qty + }; + + foreach (var itm in query.ToList()) { var _detailEntity = new HBPO_CAN_SA_DETAIL( GuidGenerator.Create(), 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 b82c4e64..3c7267fc 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 @@ -27,6 +27,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers private readonly INormalEfCoreRepository _nothbpoRepository; + private readonly INormalEfCoreRepository _notpubRepository; + + private readonly INormalEfCoreRepository _notRepository; private readonly INormalEfCoreRepository _adjRepository; protected readonly INormalEfCoreRepository _codesetRepository; @@ -50,7 +53,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers INormalEfCoreRepository notRepository, INormalEfCoreRepository adjRepository, INormalEfCoreRepository codesetRepository, - INormalEfCoreRepository nothbpoRepository + INormalEfCoreRepository nothbpoRepository, + INormalEfCoreRepository notpubRepository ) { @@ -68,6 +72,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers _pdpubRepository = pdpubRepository; _codesetRepository = codesetRepository; _nothbpoRepository = nothbpoRepository; + _notpubRepository = notpubRepository; } public INV_MNG() @@ -1614,29 +1619,65 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers if (p_first == true) { - var mng = await _hbpoMng.GetMainAsync(p_InvGroupNum); - var notsettle = _nothbpoRepository.Where(p => p.SettleBillNum == mng.SettleBillNum);//一次开票时查找不可结数据,追加需求 - if (notsettle != null && notsettle.Count() > 0) + + var settleBillnum = string.Empty; + + if (businessType == EnumBusinessType.ZhiGongJianHBPO) { - var innotls = new List(); - foreach (var nitm in notsettle) + var mng = await _pubMng.GetMainAsync(p_InvGroupNum); + settleBillnum=mng.SettleBillNum; + var notsettle = _nothbpoRepository.Where(p => p.SettleBillNum == settleBillnum);//一次开票时查找不可结数据,追加需求 + if (notsettle != null && notsettle.Count() > 0) { - 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 - )); + 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); + } } - if (innotls.Count > 0) + } + else + { + var mng = await _hbpoMng.GetMainAsync(p_InvGroupNum); + settleBillnum = mng.SettleBillNum; + var notsettle = _notpubRepository.Where(p => p.SettleBillNum == 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); + } } } } @@ -2012,7 +2053,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers invlist = await JITInvoice(p_list, p_adjlist, dtos, new List(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, true).ConfigureAwait(false);//重开可以变多张发票 break; case EnumBusinessType.ZhiGongJianHBPO: - invlist = await JITInvoice(p_list, p_adjlist, dtos, new List(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, true).ConfigureAwait(false);//重开可以变多张发票 + invlist = await FirstInvoice(p_list, p_adjlist, dtos, new List(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType).ConfigureAwait(false);//重开可以变多张发票 break; case EnumBusinessType.BeiJian: invlist = await BJInvoice(p_list, p_adjlist, dtos, new List(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, true).ConfigureAwait(false); 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 8b21c361..9cbf3989 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 @@ -803,7 +803,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers invlist = await JITInvoiceExtend(p_list, p_adjlist, dtos, new List(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, true).ConfigureAwait(false);//重开可以变多张发票 break; case EnumBusinessType.ZhiGongJianHBPO: - invlist = await JITInvoiceExtend(p_list, p_adjlist, dtos, new List(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, true).ConfigureAwait(false);//重开可以变多张发票 + invlist = await MakeInvoiceExtend(p_list, p_adjlist, dtos, p_version, inv.InvGroupNum, string.Empty, inv.BusinessType, true).ConfigureAwait(false);//重开可以变多张发票 break; case EnumBusinessType.BeiJian: invlist = await BJInvoiceExtend(p_list, p_adjlist, dtos, new List(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, true).ConfigureAwait(false); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs index 88809c83..170ebef6 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs @@ -46,6 +46,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers } public virtual async Task> GenerateSettlementOrder(List p_list) { + var first= p_list.FirstOrDefault(); + + + + + List errors = new List(); var query = p_list.Select(p => p.BusinessType).Distinct().ToList(); if (query.Count > 1) @@ -60,8 +66,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers } } - var first = p_list.FirstOrDefault(); - if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO + + if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.BeiJian || first.BusinessType == EnumBusinessType.YinDuJian ) { @@ -103,7 +109,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers var _entityList = new List(); foreach (var itm in notlist) { - var _detailEntity = new PUB_CAN_SA_DETAIL( + var _detailEntity = new PUB_CAN_SA_DETAIL( guid: GuidGenerator.Create(), keyCode: itm.KeyCode, version: itm.Version, @@ -124,15 +130,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers ); _detailEntity.IndexNum = itm.IndexNum; _detailEntity.RealPartCode = itm.RealPartCode; + _entityList.Add(_detailEntity); } await _repository.DbContext.BulkDeleteAsync(p_list).ConfigureAwait(false); await _repository.DbContext.BulkInsertAsync(new List() { _entity }).ConfigureAwait(false); await _repository.DbContext.BulkInsertAsync(_entityList).ConfigureAwait(false); - } else { + var _first=p_list.FirstOrDefault(); var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); var _entity = new PUB_CAN_SA(); _entity.SetId(Guid.NewGuid()); @@ -141,10 +148,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers _entity.Version = int.Parse(DateTime.Now.ToString("yyyymm")); _entity.State = SettleBillState.未结状态; _entity.SettleBillNum = string.Empty; + _entity.BusinessType=_first.BusinessType; + _entity.Site = _first.Site; + var _entityList = new List(); foreach (var itm in p_list) { - var _detailEntity = new PUB_CAN_SA_DETAIL( + var _detailEntity = new PUB_CAN_SA_DETAIL( guid: GuidGenerator.Create(), keyCode: itm.KeyCode, version: itm.Version, @@ -163,8 +173,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers partcode: itm.PartCode, pobillnum: string.Empty ); - _detailEntity.RealPartCode = string.IsNullOrEmpty(itm.RealPartCode) ? itm.PartCode : itm.RealPartCode; - _entityList.Add(_detailEntity); + _detailEntity.RealPartCode = string.IsNullOrEmpty(itm.RealPartCode) ? itm.PartCode : itm.RealPartCode; + _entityList.Add(_detailEntity); } // _repository.DbContext.Database.BeginTransaction(); await _repository.DbContext.BulkDeleteAsync(p_list).ConfigureAwait(false);