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 315a9f5a..08e59ab0 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 @@ -34,6 +34,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly INormalEfCoreRepository _priceRepository; private readonly INormalEfCoreRepository _pdRepository; private readonly INormalEfCoreRepository _relationRepository; + private readonly INormalEfCoreRepository _invSyncrepository; private readonly ADJ_SERVICE _adjservice; public BBAC_BA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, @@ -46,6 +47,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ INormalEfCoreRepository adjRepository, INormalEfCoreRepository pdRepository, INormalEfCoreRepository relationRepository, + INormalEfCoreRepository invSyncrepository, BBAC_CAN_SA_MNG bbacMng, HBPO_CAN_SA_MNG hbpoMng, @@ -75,6 +77,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ _priceRepository = priceRepository; _adjservice = adjservice; _pdRepository = pdRepository; + _invSyncrepository = invSyncrepository; } /// @@ -469,6 +472,9 @@ 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") @@ -484,6 +490,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } var first = p_list.FirstOrDefault(); var invbillnum = first.InvBillNum; + var count = _pdRepository.Count(p => p.BillNum == invbillnum); if (count > 0) { @@ -496,10 +503,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组 var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false); + if (inv == null) { throw new UserFriendlyException($"无原发票记录!", "400"); } + if (inv.State == SettleBillState.红冲发票) + { + if (_invSyncrepository.Any(p => p.InvoiceNumber == inv.RealnvBillNum)) + { + throw new UserFriendlyException($"红冲金税发票号{inv.RealnvBillNum}已经传过QAD,请更改金税发票号和开票日期后再进行重开!", "400"); + } + } + + + if (inv.InvoiceState == InvoiceBillState.报废) { throw new UserFriendlyException($"已经报废发票不能再次报废!", "400"); 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 1561639b..ec10b75f 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 @@ -31,6 +31,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly INormalEfCoreRepository _relationRepository; private readonly INormalEfCoreRepository _pdRepository; private readonly INormalEfCoreRepository _priceRepository; + private readonly INormalEfCoreRepository _invSyncrepository; private readonly ADJ_SERVICE _adjservice; public HBPO_BA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository pubRepository, INormalEfCoreRepository repository, INormalEfCoreRepository wRepository, INormalEfCoreRepository sRepository, INormalEfCoreRepository mRepository, @@ -41,7 +42,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ INormalEfCoreRepository priceRepository, ADJ_SERVICE adjservice, INormalEfCoreRepository relationRepository, - INormalEfCoreRepository pdRepository + INormalEfCoreRepository pdRepository, + INormalEfCoreRepository invSyncrepository ) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, wRepository, sRepository, mRepository, adjRepository, bbacMng, hbpoMng, pubMng, invMng, service, baseservice) { @@ -49,6 +51,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ _adjservice = adjservice; _relationRepository = relationRepository; _pdRepository = pdRepository; + _invSyncrepository = invSyncrepository; + } [HttpPost] [UnitOfWork(false)] @@ -488,6 +492,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { throw new UserFriendlyException($"无原发票记录!", "400"); } + if (inv.State == SettleBillState.红冲发票) + { + if (_invSyncrepository.Any(p => p.InvoiceNumber == inv.RealnvBillNum)) + { + throw new UserFriendlyException($"红冲金税发票号{inv.RealnvBillNum}已经传过QAD,请更改金税发票号和开票日期后再进行重开!", "400"); + } + } + + if (inv.InvoiceState == InvoiceBillState.报废) { throw new UserFriendlyException($"已经报废发票不能再次报废!", "400"); 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 7494cb3a..d63f4209 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 @@ -1268,21 +1268,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { var newinv1 = result.Where(p => p.InvbillNum == inv.InvbillNum).FirstOrDefault(); var newinv = ls.Where(p => p.InvbillNum == inv.InvbillNum).FirstOrDefault(); - if (inv.State == SettleBillState.红冲发票 && inv.InvoiceState == InvoiceBillState.正常) - { - inv.RealnvBillNum = newinv.RealnvBillNum; - } - else - { - - inv.Tax = 0.13m; - inv.RealnvBillNum = newinv.RealnvBillNum; - inv.TaxDiff = newinv.PreTaxDiff; - inv.CreationTime = newinv1.InvoiceDate; - inv.FileName = newinv1.FileName; - } + inv.Tax = 0.13m; + inv.RealnvBillNum = newinv.RealnvBillNum; + inv.TaxDiff = newinv.PreTaxDiff; + inv.CreationTime = newinv1.InvoiceDate; + inv.FileName = newinv1.FileName; + } await _repository.DbContext.BulkUpdateAsync(invlist).ConfigureAwait(false); 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 b7eca9e3..5bf9b69d 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 @@ -34,7 +34,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly ADJ_SERVICE _adjservice; private readonly INormalEfCoreRepository _relationRepository; private readonly INormalEfCoreRepository _pdRepository; - + private readonly INormalEfCoreRepository _invSyncrepository; private readonly INormalEfCoreRepository _priceYinDuRepository; 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, @@ -45,7 +45,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ ADJ_SERVICE adjservice, INormalEfCoreRepository relationRepository, INormalEfCoreRepository pdRepository, - INormalEfCoreRepository priceYinDuRepository + INormalEfCoreRepository priceYinDuRepository, + INormalEfCoreRepository invSyncrepository ) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, wRepository, sRepository, mRepository, adjRepository, bbacMng, hbpoMng, pubMng, invMng, service, baseservice) { @@ -55,6 +56,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ _relationRepository = relationRepository; _pdRepository = pdRepository; _priceYinDuRepository = priceYinDuRepository; + _invSyncrepository = invSyncrepository; } /// /// 提交发票 @@ -891,6 +893,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { throw new UserFriendlyException($"无原发票记录!", "400"); } + if (inv.State == SettleBillState.红冲发票) + { + if (_invSyncrepository.Any(p => p.InvoiceNumber == inv.RealnvBillNum)) + { + throw new UserFriendlyException($"红冲金税发票号{inv.RealnvBillNum}已经传过QAD,请更改金税发票号和开票日期后再进行重开!", "400"); + } + } if (inv.InvoiceState == InvoiceBillState.报废) { throw new UserFriendlyException($"已经报废发票不能再次报废!", "400");