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 a19c6e05..f9bfa2e5 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 @@ -13,6 +13,7 @@ using Win.Sfs.Shared.Filter; namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos { + [Display(Name = "发票")] public class INVOICE_GRP_DTO : EntityDto { [Display(Name = "期间")] @@ -38,6 +39,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos /// [Display(Name = "税后金额")] public decimal TaxAmt { get; set; } + + [Display(Name = "金税发票税后金额")] + public decimal RealAmt { get; set; } /// ///发票分组号 /// @@ -53,10 +57,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos /// [Display(Name = "业务类别")] public EnumBusinessType BusinessType { get; set; } - /// - /// 发票状态 - /// - public int State { set; get; } + + [Display(Name = "状态")] + public SettleBillState State { get; set; } + + [Display(Name = "发票状态")] + public InvoiceBillState InvoiceState { get; set; } + + [Display(Name = "发票税后尾差")] + public decimal TaxDiff { get; set; } + [Display(Name = "客户代码")] + public string ClientCode { get; set; } + + } 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 d1d22c2c..37218761 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 @@ -78,6 +78,12 @@ public class PUB_ADJ_DETAIL_IMP_DTO public DateTime SettleDate { get; set; } [ImporterHeader(Name = "零件号")] public string LU { get; set; } + + [ImporterHeader(Name = "厂内零件号")] + public string PartCode { get; set; } + + + [ImporterHeader(Name = "标识号")] public string PN { get; set; } [ImporterHeader(Name = "数量")] diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs index fddce994..bce2a72e 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs @@ -129,7 +129,11 @@ public class ADJ_SERVICE : BASE_SERVICE businessType: itm1.BusinessType, groupNum: itm.GroupNum, oldinv: itm.InvBillNum, - inv: string.Empty); + inv: string.Empty, + partcode:itm.PartCode + + + ); await _repository.DbContext.BulkDeleteAsync(deletels);//删除发票下所有调整明细 await _repository.DbContext.BulkInsertAsync(query.ToList()); return ApplicationConsts.SuccessStr; 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 22deb4e9..35d72cbb 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 @@ -62,10 +62,6 @@ namespace Win.Sfs.SettleAccount.Bases protected readonly INV_MNG _invMng; private readonly TaskJobService _service; - - - - protected BA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, @@ -102,10 +98,10 @@ namespace Win.Sfs.SettleAccount.Bases /// /// [HttpPost] - public virtual async Task GenerateInvoice(INVOICE_GRP_REQ_DTO input) + public virtual async Task GenerateInvoice(List p_invs) { - await _invMng.SetForwardState(input.InvGroupNum, SettleBillState.商务已审核); + await _invMng.SetForwardState(p_invs, SettleBillState.商务已审核); return ApplicationConsts.SuccessStr; } @@ -212,6 +208,7 @@ namespace Win.Sfs.SettleAccount.Bases [UnitOfWork(false)] public virtual async Task ReceivedAsync(List p_ins) { + await _invMng.ReceivedAsync(p_ins); return ApplicationConsts.SuccessStr; } @@ -300,7 +297,7 @@ namespace Win.Sfs.SettleAccount.Bases return true; } - throw new BusinessException("8989", "生成失败,请检查调整表和旧发票内容"); + throw new BusinessException("8989", "生成失败,请检查调发票整表和旧发票内容"); } @@ -317,16 +314,12 @@ namespace Win.Sfs.SettleAccount.Bases /// protected async Task ReissueFirstInvoice(List p_list,List p_adjlist, List dtos, int p_version, string p_parentInvBillNum) where TDetail : SA_CAN_BASE { - var flag = await _invMng.ReissueFirstInvoice(p_list,p_adjlist,dtos, p_parentInvBillNum, p_version); if (flag==true) { return true; } - throw new BusinessException("8989", "生成失败,请检查调整表和旧发票内容"); - - } 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 157329ad..bd487df0 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 @@ -51,11 +51,9 @@ namespace Win.Sfs.SettleAccount.Bases { protected readonly INormalEfCoreRepository _repository; protected readonly INormalEfCoreRepository _detailRepository; - private readonly IExcelImportAppService _excelImportService; + private readonly IExcelImportAppService _excelImportService; protected readonly INV_MNG _invmng; - - protected CAN_SA_SERVICE( IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, @@ -82,12 +80,10 @@ namespace Win.Sfs.SettleAccount.Bases //[Route("detailquery")] public virtual async Task> DetailQueryAsync(TRequestDetailInput input) { - var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); var totalCount = await _detailRepository.GetCountByFilterAsync(input.Filters); var dtos = ObjectMapper.Map, List>(entitys); return new PagedResultDto(totalCount, dtos); - } /// /// 导出 @@ -195,8 +191,6 @@ namespace Win.Sfs.SettleAccount.Bases return true; } throw new BusinessException("8989", "生成失败,请检可结算单明细数据是否结算分组存在"); - - } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs index 9f3cf6a9..d7b992af 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs @@ -76,7 +76,7 @@ namespace Win.Sfs.SettleAccount.Bases //[Route("detailquery")] public virtual async Task> DetailQueryAsync(TRequestDetailInput input) { - + var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); var totalCount = await _detailRepository.GetCountByFilterAsync(input.Filters); var dtos = ObjectMapper.Map, List>(entitys); @@ -94,10 +94,8 @@ namespace Win.Sfs.SettleAccount.Bases { IExporter _csv = new CsvExporter(); IExporter _excel = new ExcelExporter(); - var entities = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); var dtoDetails = ObjectMapper.Map, List>(entities); - var classDisplayName = typeof(TEntityDetailExportDto).GetCustomAttribute()?.Name ?? typeof(TEntityDetailExportDto).Name; string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; byte[] result = null; 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 bdf75be1..31aadfb8 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 @@ -110,7 +110,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ invGroupNum: itm.InvGroupNum, contactid: itm.Extend1,//生产号 - invbillnum:string.Empty + invbillnum:string.Empty, + partcode:itm.PartCode )); } } 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 6774c075..6484373c 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 @@ -96,7 +96,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ settleDate: itm.SettleDate, groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, - invbillnum: string.Empty + invbillnum: string.Empty, + partcode:itm.PartCode )); } } 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 fb9a7431..5998e51d 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 @@ -80,10 +80,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// [HttpPost] - public virtual async Task ApprovalPassed(INVOICE_GRP_REQ_DTO input) + public virtual async Task ApprovalPassed(List p_invs) { - var inv = _repository.Where(p => p.InvGroupNum == input.InvGroupNum).FirstOrDefault(); - await _invMng.SetForwardState(inv, SettleBillState.财务已审核); + + await _invMng.SetForwardState(p_invs, SettleBillState.财务已审核); return ApplicationConsts.SuccessStr; } @@ -257,6 +257,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { ExportImporter _exportImporter = new ExportImporter(); var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + + + var ls = ObjectMapper.Map, List>(result); var namelist = ls.Select(p => p.InvbillNum).Distinct(); var invlist = _repository.Where(p => namelist.Contains(p.InvbillNum)).ToList(); 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 31c917c6..03c79a7f 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 @@ -96,7 +96,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ settleDate: itm.SettleDate, groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, - invbillnum: string.Empty + invbillnum: string.Empty, + partcode:itm.PartCode + )); } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs index 72277da7..f27191dc 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs @@ -123,8 +123,6 @@ namespace Win.Sfs.SettleAccount #endregion - - #region 派格 CreateMapInvoice(); CreateMapInvoiceVersion(); @@ -137,7 +135,6 @@ namespace Win.Sfs.SettleAccount CreateMapUnHQSettleAccountVersion(); #endregion - CreateMapPURCHASE_PRICE(); CreateMapTB_RePartsRelationship(); @@ -198,8 +195,6 @@ namespace Win.Sfs.SettleAccount CreateMapPUB_ADJ_DETAIL(); - - CreateMapBBAC_PD(); CreateMapBBAC_PD_DETAIL(); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs index bb6fa3de..33f21a64 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs @@ -430,6 +430,10 @@ namespace SettleAccount.Bases public string InvbillNum { get; set; } + + [Display(Name = "厂内零件号")] + public string PartCode { get; set; } + //public SA_CAN_BASE(int version, decimal price, string billNum, DateTime settleDate, string invGroupNum, string lU, string pN, string keyCode, decimal qty, string groupNum) //{ // Version = version; @@ -496,7 +500,10 @@ namespace SettleAccount.Bases /// 結算分組號 /// public string GroupNum { get; set; } - + + + public string PartCode { get; set; } + //public SA_NOT_BASE(decimal price, int version, string settleBillNum, DateTime settleDate, string invGroupNum, string lU, string pN, string keyCode, decimal qty, string groupNum) //{ // Price = price; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs index 98888d8f..b40ecfdc 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs @@ -113,10 +113,14 @@ public class BBAC_CAN_SA_DETAIL: SA_CAN_BASE public bool IsReturn { get; set; } =false; - [Display(Name="合同号")] public string ContractDocID { get; set; } + + + + + /// /// 对应字段PostingDate /// @@ -139,11 +143,11 @@ public class BBAC_CAN_SA_DETAIL: SA_CAN_BASE public BBAC_CAN_SA_DETAIL(Guid guid,string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, bool isReturn, DateTime settleDate, string groupNum, string invGroupNum - ,string contactid,string invbillnum + ,string contactid,string invbillnum,string partcode ):base(guid) { InvbillNum = invbillnum; - + PartCode=partcode; KeyCode = keyCode; Version = version; BillNum = billNum; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_NOT_SA_DETAIL.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_NOT_SA_DETAIL.cs index 668b9935..02dce42b 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_NOT_SA_DETAIL.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_NOT_SA_DETAIL.cs @@ -92,7 +92,7 @@ public class BBAC_NOT_SA_DETAIL:SA_NOT_BASE } - public BBAC_NOT_SA_DETAIL(Guid guid, string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, bool isReturn, string invGroupNum, DateTime settleDate, string groupNum,string contractDocID) + public BBAC_NOT_SA_DETAIL(Guid guid, string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, bool isReturn, string invGroupNum, DateTime settleDate, string groupNum,string contractDocID,string partcode) { Id = guid; @@ -110,5 +110,6 @@ public class BBAC_NOT_SA_DETAIL:SA_NOT_BASE SettleDate = settleDate; GroupNum = groupNum; ContractDocID = contractDocID; + PartCode = partcode; } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_CAN_SA.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_CAN_SA.cs index 152fc4a6..674b0dd9 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_CAN_SA.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_CAN_SA.cs @@ -124,7 +124,7 @@ public class HBPO_CAN_SA_DETAIL:SA_CAN_BASE /// public EnumBusinessType BusinessType { get; set; } - public HBPO_CAN_SA_DETAIL(Guid guid ,string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, DateTime settleDate, string groupNum, string invGroupNum, EnumBusinessType businessType, string invbillnum) + public HBPO_CAN_SA_DETAIL(Guid guid ,string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, DateTime settleDate, string groupNum, string invGroupNum, EnumBusinessType businessType, string invbillnum,string partcode) { InvbillNum=invbillnum; Id = guid; @@ -141,6 +141,7 @@ public class HBPO_CAN_SA_DETAIL:SA_CAN_BASE GroupNum = groupNum; InvGroupNum = invGroupNum; BusinessType = businessType; + PartCode = partcode; } public HBPO_CAN_SA_DETAIL() diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_NOT_SA_DETAIL.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_NOT_SA_DETAIL.cs index 2baf05a2..c958fcd0 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_NOT_SA_DETAIL.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_NOT_SA_DETAIL.cs @@ -99,7 +99,7 @@ public class HBPO_NOT_SA_DETAIL :SA_NOT_BASE public EnumBusinessType BusinessType { get; set; } - public HBPO_NOT_SA_DETAIL(Guid guid ,string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, DateTime settleDate, string groupNum, string invGroupNum, EnumBusinessType businessType) + public HBPO_NOT_SA_DETAIL(Guid guid ,string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, DateTime settleDate, string groupNum, string invGroupNum, EnumBusinessType businessType,string partcode) { Id = guid; KeyCode = keyCode; @@ -114,6 +114,7 @@ public class HBPO_NOT_SA_DETAIL :SA_NOT_BASE GroupNum = groupNum; InvGroupNum = invGroupNum; BusinessType = businessType; + PartCode = partcode; } public HBPO_NOT_SA_DETAIL() 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 efe59362..f38d7d1c 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 @@ -45,9 +45,28 @@ public class INVOICE_GRP : FullAuditedAggregateRoot [Display(Name = "发票状态")] public InvoiceBillState InvoiceState { get; set; } + [Display(Name = "发票未税尾差")] + public decimal PreTaxDiff { get; set; } + [Display(Name = "发票税后尾差")] + public decimal TaxDiff { get; set; } + [Display(Name = "客户代码")] + public string ClientCode { get; set; } + [Display(Name = "实际发票金额")] + public decimal RealAmt { get; set; } - public INVOICE_GRP(Guid guid, string realnvBillNum, string invbillNum, decimal amt, decimal taxAmt, string invGroupNum, string fileName, EnumBusinessType businessType, SettleBillState state,InvoiceBillState invoiceBillState,decimal tax,string parent) + + + + public INVOICE_GRP(Guid guid, string realnvBillNum, string invbillNum, decimal amt, decimal taxAmt, + string invGroupNum, + string fileName, + EnumBusinessType businessType, + SettleBillState state, + InvoiceBillState invoiceBillState, + decimal tax, + string parent, decimal preTaxDiff, decimal taxDiff, string clientCode,decimal realAmt + ) { Id= guid; RealnvBillNum = realnvBillNum; @@ -61,7 +80,11 @@ public class INVOICE_GRP : FullAuditedAggregateRoot InvoiceState = invoiceBillState; ParentInvbillNum = parent; Tax = tax; - + PreTaxDiff= preTaxDiff; + TaxDiff= taxDiff; + ClientCode = clientCode; + RealAmt = realAmt; + } 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 3a39ca0b..a86ddf69 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 @@ -70,7 +70,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers groupNum: itm.GroupNum, invGroupNum: billNumber, contactid: itm.ContractDocID, - invbillnum: string.Empty + invbillnum: string.Empty, + partcode:itm.PartCode + ); _entityList.Add(_detailEntity); 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 2fec26de..0ea54b30 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 @@ -73,7 +73,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers qty: itm.Qty, settleDate: itm.SettleDate, site: itm.Site, - invbillnum: string.Empty + invbillnum: string.Empty, + partcode:itm.PartCode ); _entityList.Add(_detailEntity); } 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 b5cb2889..8a925cc7 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 @@ -76,16 +76,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { } - public virtual async Task SetForwardState(string p_groupBillnum, SettleBillState p_State) - { - var _first = _repository.Where(p => p.InvbillNum == p_groupBillnum).FirstOrDefault(); - if (_first != null) - { - return await SetForwardState(_first, p_State); - } - return false; + //public virtual async Task SetForwardState(string p_groupBillnum, SettleBillState p_State) + //{ + // var _first = _repository.Where(p => p.InvbillNum == p_groupBillnum).FirstOrDefault(); + // if (_first != null) + // { + // return await SetForwardState(_first, p_State); + // } + // return false; - } + //} private async Task SetSettleState(INVOICE_GRP p_entiy, SettleBillState p_State, bool IsForward = true) { @@ -140,67 +140,99 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers return false; } /// - /// 向前流程 + /// 发票向前流程 /// - /// + /// /// /// /// - public virtual async Task SetForwardState(INVOICE_GRP p_entiy, SettleBillState p_State) + public virtual async Task SetForwardState(List p_invs, SettleBillState p_State) { - if (p_entiy.InvoiceState == InvoiceBillState.报废) - { - throw new BusinessException("8989", "当前发票已报废不能进行操作"); - } - - var state = p_State; - switch (p_State) + List errors = new List(); + var appls = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList(); + if (appls.Count > 0) { - case SettleBillState.财务已审核: - if (p_entiy.State == SettleBillState.商务已审核) - { + var count = appls.Select(p => p.State).Distinct().Count(); + if (count > 1) + { + throw new UserFriendlyException($"提交发票状态不一致"); + } - p_entiy.State = state; - } - else - { - throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态"); - } - break; - case SettleBillState.商务已审核: - if (p_entiy.State == SettleBillState.已开票) - { - p_entiy.State = state; - } - else - { - throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】"); - } - break; - case SettleBillState.已扣减: - if (p_entiy.State == SettleBillState.客户已收票) - { - p_entiy.State = state; - } - else - { - throw new BusinessException("8989", "当前状态不是【客户已收票】状态,无法设置成【已扣减】状态"); - } - break; - } - var flag = await SetSettleState(p_entiy, p_State, true); - if (flag == true) - { - var invlist = await _repository.Where(p => p.InvGroupNum == p_entiy.InvGroupNum).ToListAsync();//选择审批时只能整组审批 - foreach (var itm in invlist) + var nols = appls.Where(p => p.InvoiceState == InvoiceBillState.报废 || p.State == SettleBillState.客户已收票).ToList(); + if (nols.Count > 0) { - itm.State = p_entiy.State; + var invs = nols.Select(p => p.InvbillNum); + throw new UserFriendlyException($"选择发票{string.Join(",", invs)}已报废或者已收票不能进行操作"); } - await _repository.BatchUpdateAsync(invlist); + var state = p_State; + switch (p_State) + { + case SettleBillState.财务已审核: + foreach (var inv in appls) + { + if (inv.State == SettleBillState.商务已审核) + { + + inv.State = state; + } + else + { + errors.Add(inv.InvbillNum); + } + } + if (errors.Count > 0) + { + throw new UserFriendlyException($"发票{string.Join(",", errors)}当前状态不是【商务已审核】,无法设置成【财务已审核】状态"); + } + break; + case SettleBillState.商务已审核: + + foreach (var inv in appls) + { + if (inv.State == SettleBillState.已开票) + { + + inv.State = state; + } + else + { + errors.Add(inv.InvbillNum); + } + } + if (errors.Count > 0) + { + throw new UserFriendlyException($"发票{string.Join(",", errors)}当前状态不是【已开票】,无法设置成【商务已审核】状态"); + } + break; + case SettleBillState.已扣减: + foreach (var inv in appls) + { + + if (inv.State == SettleBillState.客户已收票) + { + + inv.State = state; + } + else + { + errors.Add(inv.InvbillNum); + } + } + if (errors.Count > 0) + { + throw new UserFriendlyException($"发票{string.Join(",", errors)}当前状态不是【客户已收票】,无法设置成【已扣减】状态"); + } + break; + } + + await _repository.BatchUpdateAsync(appls); return true; } - return false; + else + { + throw new UserFriendlyException($"选择发票不存在"); + } } /// @@ -210,58 +242,94 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers /// /// /// - public virtual async Task SetBackwardState(INVOICE_GRP p_entiy, SettleBillState p_State) + public virtual async Task SetBackwardState(List p_invs, SettleBillState p_State) { - var state = p_State; - switch (state) + + List errors = new List(); + var appls = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList(); + if (appls.Count > 0) { - case SettleBillState.商务已审核: - if (p_entiy.State == SettleBillState.财务已审核) - { - p_entiy.State = state; - } - else - { - throw new BusinessException("8989", "当前状态不是【财务已审核】,无法设置成【商务已审核】状态"); - } - break; - case SettleBillState.已开票: - if (p_entiy.State == SettleBillState.商务已审核) - { - p_entiy.State = state; - } - else - { - throw new BusinessException("8989", "当前状态不是【商务已审核】状态,无法设置成【已开票】"); - } - break; - case SettleBillState.客户已收票: - if (p_entiy.State == SettleBillState.已扣减) - { - p_entiy.State = state; - } - else - { - throw new BusinessException("8989", "当前状态不是【已扣减】状态,无法设置成【客户已收票】状态"); - } - break; - } - //var flag = await SetSettleState(p_entiy, p_State, false); + var count = appls.Select(p => p.State).Distinct().Count(); + if (count > 1) + { + throw new UserFriendlyException($"提交发票状态不一致"); + } + var nols = appls.Where(p => p.InvoiceState == InvoiceBillState.报废 || p.State == SettleBillState.客户已收票).ToList(); + if (nols.Count > 0) + { + var invs = nols.Select(p => p.InvbillNum); + throw new UserFriendlyException($"选择发票{string.Join(",", invs)}已报废或者已收票不能进行操作"); + } + var state = p_State; + switch (p_State) + { + case SettleBillState.商务已审核: + foreach (var inv in appls) + { + if (inv.State == SettleBillState.财务已审核) + { + + inv.State = state; + } + else + { + errors.Add(inv.InvbillNum); + } + } + if (errors.Count > 0) + { + throw new UserFriendlyException($"发票{string.Join(",", errors)}当前状态不是【财务已审核】,无法设置成【商务已审核】状态"); + } + break; + case SettleBillState.已开票: - //if (flag == true) - //{ - // var invlist = await _repository.Where(p => p.InvGroupNum == p_entiy.InvGroupNum).ToListAsync();//选择审批时只能整组审批 - // foreach (var itm in invlist) - // { - // itm.State = p_entiy.State; - // } + foreach (var inv in appls) + { + if (inv.State == SettleBillState.商务已审核) + { + + inv.State = state; + } + else + { + errors.Add(inv.InvbillNum); + } + } + if (errors.Count > 0) + { + throw new UserFriendlyException($"发票{string.Join(",", errors)}当前状态不是【商务已审核】,无法设置成【已开票】状态"); + } + break; + case SettleBillState.客户已收票: + foreach (var inv in appls) + { - await _repository.BatchUpdateAsync(p_entiy); + if (inv.State == SettleBillState.已扣减) + { + + inv.State = state; + } + else + { + errors.Add(inv.InvbillNum); + } + } + if (errors.Count > 0) + { + throw new UserFriendlyException($"发票{string.Join(",", errors)}当前状态不是【已扣减】,无法设置成【客户已收票】状态"); + } + break; + } + + await _repository.BatchUpdateAsync(appls); return true; - //} + } + else + { + throw new UserFriendlyException($"选择发票不存在"); + } - } @@ -316,16 +384,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { throw new UserFriendlyException($"发票不属于一个发票分组"); } - var lostlist = invList.Where(p => p.InvoiceState == InvoiceBillState.报废).ToList(); + var lostlist = invList.Where(p => p.InvoiceState == InvoiceBillState.报废 || p.State ==SettleBillState.客户已收票).ToList(); if (lostlist.Count > 0) { var invs=lostlist.Select(p => p.InvbillNum).ToList(); - throw new UserFriendlyException($"发票{string.Join(",",invs)}"); + throw new UserFriendlyException($"发票{string.Join(",",invs)}已经报废或客户已收票!"); } - - - - var inv = invList.FirstOrDefault(); if (inv.BusinessType == EnumBusinessType.JisBBAC) { @@ -350,8 +414,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号 } newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号 - - List entityList = new List();//结算明细 var namelist = invList.Select(p => p.InvbillNum).ToList(); if (oldlist.Count > 0) @@ -381,7 +443,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, contactid: itm.Extend1,//生产号 - invbillnum: itm.InvBillNum + invbillnum: itm.InvBillNum, + partcode:itm.PartCode )); } @@ -413,16 +476,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, contactid: itm.Extend1,//生产号 - invbillnum: itm.InvBillNum - - + invbillnum: itm.InvBillNum, + partcode:itm.PartCode )); } } entityList.AddRange(entityDetail); - } - var bbacmainlist = new List(); foreach (var itm in invList) { @@ -465,8 +525,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers } await _repository.DbContext.BulkInsertAsync(bbacmainlist); await _repository.DbContext.BulkInsertAsync(bbacDetail); + foreach (var itm in invList) + { + itm.State = SettleBillState.客户已收票; + }; + await _repository.DbContext.BulkUpdateAsync(invList); return true; - } @@ -523,7 +587,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers settleDate: itm.SettleDate, groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, - invbillnum: itm.InvBillNum + invbillnum: itm.InvBillNum, + partcode:itm.PartCode + )); } @@ -553,14 +619,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers settleDate: itm.SettleDate, groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, - invbillnum: itm.InvBillNum + invbillnum: itm.InvBillNum, + partcode: itm.PartCode + )); } } entityList.AddRange(entityDetail); - } - var bbacmainlist = new List(); foreach (var itm in invList) { @@ -603,6 +669,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers } await _repository.DbContext.BulkInsertAsync(bbacmainlist); await _repository.DbContext.BulkInsertAsync(bbacDetail); + foreach (var itm in invList) + { + itm.State = SettleBillState.客户已收票; + }; + + await _repository.DbContext.BulkUpdateAsync(invList); return true; } else @@ -656,7 +728,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers settleDate: itm.SettleDate, groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, - invbillnum: itm.InvBillNum + invbillnum: itm.InvBillNum, + partcode:itm.PartCode + )); } @@ -686,7 +760,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers settleDate: itm.SettleDate, groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, - invbillnum: itm.InvBillNum + invbillnum: itm.InvBillNum, + partcode: itm.PartCode )); } } @@ -737,10 +812,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers } await _repository.DbContext.BulkInsertAsync(bbacmainlist); await _repository.DbContext.BulkInsertAsync(bbacDetail); + + foreach (var itm in invList) + { + itm.State = SettleBillState.客户已收票; + }; + await _repository.DbContext.BulkUpdateAsync(invList); + return true; } - return false; + } public virtual async Task Reject(INVOICE_GRP p_entity) { @@ -751,19 +833,34 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers return false; } /// - /// 退回 + /// 同一退回 /// /// 发票分组号 /// public virtual async Task Reject(string groupbillNum) { + + + var ls = await _repository.Where(p => p.InvGroupNum == groupbillNum).ToListAsync(); + + + + + + + if (ls != null && ls.Count > 0) { + var count=ls.Select(p => p.State).Distinct().Count(); + if (count > 1) + { + throw new UserFriendlyException($"发票分组{groupbillNum}包含发票不是同一状态不能退回"); + } var first = ls.FirstOrDefault(); if (first.State == SettleBillState.客户已收票 || first.State == SettleBillState.已扣减) { - throw new BusinessException("8989", $"发票分组{groupbillNum}客户已经是客户已收票或已扣减状态不能退回"); + throw new UserFriendlyException( $"发票分组{groupbillNum}客户已经是客户已收票不能退回"); } foreach (var p_entity in ls) { @@ -1043,8 +1140,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers invGroupNum: p_InvGroupNum, state: SettleBillState.已开票, invoiceBillState: InvoiceBillState.正常, - tax: 0, - parent: p_parentInvBillNum + tax: 0, + parent: p_parentInvBillNum, + preTaxDiff: 0, + taxDiff: 0, + clientCode: string.Empty, + realAmt: 0 ); invlist.Add(invbill); } @@ -1191,7 +1292,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers itm.InvbillNum = key; salist.Add(itm); } - if (!string.IsNullOrEmpty(p_parentInvBillNum)) + if (!string.IsNullOrEmpty(p_parentInvBillNum))//发票作废开票 { var query1 = from itm in dtos join itm1 in ls @@ -1270,7 +1371,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers state: SettleBillState.已开票, invoiceBillState: InvoiceBillState.正常, tax: 0, - parent: p_parentInvBillNum + parent: p_parentInvBillNum, + preTaxDiff:0, + taxDiff:0, + clientCode:string.Empty, + realAmt:0 + ); invlist.Add(invbill); } @@ -1480,7 +1586,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers state: SettleBillState.已开票, invoiceBillState: InvoiceBillState.正常, tax: 0, - parent: string.Empty + parent: string.Empty, + preTaxDiff: 0, + taxDiff: 0, + clientCode: string.Empty, + realAmt: 0 ); invlist.Add(invbill); } 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 2221fc9a..8a84f773 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 @@ -67,11 +67,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers qty: itm.Qty, price: itm.Price, businessType: itm.BusinessType, - settleDate: itm.SettleDate, groupNum: itm.GroupNum, invGroupNum: billNumber, - invbillnum: string.Empty + invbillnum: string.Empty, + partcode:itm.PartCode ); _entityList.Add(_detailEntity); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_ADJ_DETAIL.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_ADJ_DETAIL.cs index b8e954b8..1167139b 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_ADJ_DETAIL.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_ADJ_DETAIL.cs @@ -70,10 +70,10 @@ public class PUB_ADJ_DETAIL : SA_NOT_BASE [Display(Name = "发票号")] public string InvBillNum { get; set; } - + public PUB_ADJ_DETAIL(Guid id, string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, string extend1, decimal price, string invGroupNum, DateTime settleDate, - EnumBusinessType businessType, string groupNum,string oldinv,string inv) + EnumBusinessType businessType, string groupNum,string oldinv,string inv,string partcode) { Id= id; KeyCode = keyCode; @@ -91,6 +91,7 @@ public class PUB_ADJ_DETAIL : SA_NOT_BASE GroupNum = groupNum; OldInvBillNum= oldinv; InvBillNum = inv; + PartCode = partcode; } public PUB_ADJ_DETAIL() diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_CAN_SA.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_CAN_SA.cs index 9b70a57e..9966b222 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_CAN_SA.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_CAN_SA.cs @@ -118,7 +118,7 @@ public class PUB_CAN_SA_DETAIL : SA_CAN_BASE //[Display(Name = "结算分组")] //public string GroupNum { get; set; } = null!; - public PUB_CAN_SA_DETAIL(Guid guid, string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, string invGroupNum, DateTime settleDate, EnumBusinessType businessType, + public PUB_CAN_SA_DETAIL(Guid guid, string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, string invGroupNum, DateTime settleDate, EnumBusinessType businessType,string partcode, string groupNum, string invbillnum ) @@ -138,6 +138,7 @@ public class PUB_CAN_SA_DETAIL : SA_CAN_BASE SettleDate = settleDate; BusinessType = businessType; GroupNum = groupNum; + PartCode = partcode; } public PUB_CAN_SA_DETAIL() diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_NOT_SA_DETAIL.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_NOT_SA_DETAIL.cs index 3317e6b4..9d4b3741 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_NOT_SA_DETAIL.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_NOT_SA_DETAIL.cs @@ -1,4 +1,4 @@ -using SettleAccount.Bases; +using SettleAccount.Bases; using System; using System.ComponentModel.DataAnnotations; using Win.Sfs.SettleAccount; @@ -70,7 +70,7 @@ public class PUB_NOT_SA_DETAIL : SA_NOT_BASE //[Display(Name = "结算分组")] //public string GroupNum { get; set; } = null!; - public PUB_NOT_SA_DETAIL(string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, string extend1, string extend2, string extend3, decimal price, string invGroupNum, DateTime settleDate, EnumBusinessType businessType, string groupNum) + public PUB_NOT_SA_DETAIL(string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, string extend1, string extend2, string extend3, decimal price, string invGroupNum, DateTime settleDate, EnumBusinessType businessType, string groupNum,string partcode) { KeyCode = keyCode; Version = version; @@ -87,6 +87,7 @@ public class PUB_NOT_SA_DETAIL : SA_NOT_BASE SettleDate = settleDate; BusinessType = businessType; GroupNum = groupNum; + PartCode = partcode; } public PUB_NOT_SA_DETAIL() diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContext.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContext.cs index 7a86ab2a..39953f98 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContext.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContext.cs @@ -15,6 +15,7 @@ namespace Win.Sfs.SettleAccount : base(options) { this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(30)); + } protected override void OnModelCreating(ModelBuilder builder)