|
@ -32,18 +32,20 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository; |
|
|
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository; |
|
|
|
|
|
private readonly INormalEfCoreRepository<PriceListBJ, Guid> _pricebjRepository; |
|
|
|
|
|
|
|
|
public PUB_BA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> pubRepository, INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository, BBAC_CAN_SA_MNG bbacMng, HBPO_CAN_SA_MNG hbpoMng, PUB_CAN_SA_MNG pubMng, INV_MNG invMng, |
|
|
public PUB_BA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> pubRepository, INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository, BBAC_CAN_SA_MNG bbacMng, HBPO_CAN_SA_MNG hbpoMng, PUB_CAN_SA_MNG pubMng, INV_MNG invMng, |
|
|
TaskJobService service, |
|
|
TaskJobService service, |
|
|
BaseDomainService baseservice, |
|
|
BaseDomainService baseservice, |
|
|
INormalEfCoreRepository<PriceList, Guid> priceRepository |
|
|
INormalEfCoreRepository<PriceList, Guid> priceRepository, |
|
|
|
|
|
INormalEfCoreRepository<PriceListBJ, Guid> pricebjRepository |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, wRepository, sRepository, mRepository, adjRepository, bbacMng, hbpoMng, pubMng, invMng, service,baseservice) |
|
|
) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, wRepository, sRepository, mRepository, adjRepository, bbacMng, hbpoMng, pubMng, invMng, service,baseservice) |
|
|
{ |
|
|
{ |
|
|
_priceRepository = priceRepository; |
|
|
_priceRepository = priceRepository; |
|
|
|
|
|
_pricebjRepository = pricebjRepository; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -124,11 +126,28 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
|
|
|
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
|
|
|
//var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算
|
|
|
//var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算
|
|
|
|
|
|
|
|
|
var priceList = _priceRepository.ToList();//价格单
|
|
|
|
|
|
|
|
|
List<PriceList> priceList = new List<PriceList>(); |
|
|
|
|
|
if (inv.BusinessType == EnumBusinessType.BeiJian) |
|
|
|
|
|
{ |
|
|
|
|
|
var priceListbj = _pricebjRepository.ToList();//价格单
|
|
|
|
|
|
foreach (var itm in priceListbj) |
|
|
|
|
|
{ |
|
|
|
|
|
priceList.Add(new PriceList() { LU = itm.LU, BeginTime = itm.BeginDate, EndTime = itm.EndDate, Price = itm.Price }); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
priceList = _priceRepository.ToList();//价格单
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType); |
|
|
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType); |
|
|
|
|
|
|
|
|
if (errorList.Count > 0) |
|
|
if (errorList.Count > 0) |
|
|
{ |
|
|
{ |
|
|
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errorList) }); |
|
|
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = await ExportErrorReportAsync(errorList) }); |
|
|
} |
|
|
} |
|
|
// var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
|
|
|
// var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
|
|
|
var q = from d in entitys |
|
|
var q = from d in entitys |
|
@ -161,6 +180,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
|
|
|
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
|
|
|
{ |
|
|
{ |
|
|
await ReissueFirstInvoice(publist, adjlist, dtos, version, invbillnum); |
|
|
await ReissueFirstInvoice(publist, adjlist, dtos, version, invbillnum); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else//二次开票
|
|
|
else//二次开票
|
|
|
{ |
|
|
{ |
|
@ -240,8 +264,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
invbillnum: string.Empty, |
|
|
invbillnum: string.Empty, |
|
|
partcode:itm.PartCode, |
|
|
partcode:itm.PartCode, |
|
|
pobillnum:string.Empty |
|
|
pobillnum:string.Empty |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
)); |
|
|
)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -249,12 +271,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); |
|
|
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); |
|
|
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
|
|
|
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
|
|
|
//var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算
|
|
|
//var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算
|
|
|
|
|
|
|
|
|
var priceList = _priceRepository.ToList();//价格单
|
|
|
var priceList = _priceRepository.ToList();//价格单
|
|
|
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType); |
|
|
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType); |
|
|
if (errorList.Count > 0) |
|
|
if (errorList.Count > 0) |
|
|
{ |
|
|
{ |
|
|
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errorList) }); |
|
|
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = await ExportErrorReportAsync(errorList) }); |
|
|
} |
|
|
} |
|
|
// var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
|
|
|
// var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
|
|
|
var q = from d in entitys |
|
|
var q = from d in entitys |
|
@ -310,11 +331,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
/// <param name="input"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
public virtual async Task<List<INVOICE_WAIT_DETAIL_DTO>> ReissueInvoiceList(List<PUB_ADJ_DETAIL_DTO> p_list) |
|
|
public virtual async Task<List<INVOICE_REPEAT_DTO>> ReissueInvoiceList(List<PUB_ADJ_DETAIL_DTO> p_list) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var first=p_list.FirstOrDefault(); |
|
|
var first = p_list.FirstOrDefault(); |
|
|
var invbillnum=first.InvBillNum; |
|
|
var invbillnum = first.InvBillNum; |
|
|
|
|
|
|
|
|
|
|
|
var invBilllist = new List<INVOICE_REPEAT_DTO>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<INVOICE_WAIT_DETAIL_DTO> ls = new List<INVOICE_WAIT_DETAIL_DTO>(); |
|
|
List<INVOICE_WAIT_DETAIL_DTO> ls = new List<INVOICE_WAIT_DETAIL_DTO>(); |
|
|
var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list); |
|
|
var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list); |
|
@ -373,7 +397,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
|
|
|
|
|
invbillnum: string.Empty, |
|
|
invbillnum: string.Empty, |
|
|
partcode: itm.PartCode, |
|
|
partcode: itm.PartCode, |
|
|
pobillnum:string.Empty |
|
|
pobillnum: string.Empty |
|
|
)); |
|
|
)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -421,12 +445,47 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
|
|
|
|
|
ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities); |
|
|
ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities); |
|
|
|
|
|
|
|
|
|
|
|
var invlist = ls.Select(p => p.InvbillNum).Distinct(); |
|
|
|
|
|
foreach (var itm in invlist) |
|
|
|
|
|
{ |
|
|
|
|
|
var invBill = new INVOICE_REPEAT_DTO(); |
|
|
|
|
|
var invls = ls.Where(p => p.InvbillNum == itm).ToList(); |
|
|
|
|
|
var entitylist = entities.Where(p => p.InvbillNum == itm).ToList(); |
|
|
|
|
|
var tax = inv.Tax;//税率
|
|
|
|
|
|
var amt = entitylist.Sum(p => p.Amt);//税前
|
|
|
|
|
|
var taxamt = amt + Math.Round(amt * tax, 2);//税后
|
|
|
|
|
|
var realamt = Math.Round(amt * tax, 2);//税额
|
|
|
|
|
|
invBill.Amt = amt; |
|
|
|
|
|
invBill.TaxAmt = taxamt; |
|
|
|
|
|
invBill.Tax = tax; |
|
|
|
|
|
invBill.BusinessType = inv.BusinessType; |
|
|
|
|
|
invBill.DETIAL = invls; |
|
|
|
|
|
invBill.RealAmt = realamt; |
|
|
|
|
|
invBilllist.Add(invBill); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else//二次开票
|
|
|
else//二次开票
|
|
|
{ |
|
|
{ |
|
|
var entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum); |
|
|
var entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum); |
|
|
ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities); |
|
|
ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities); |
|
|
|
|
|
var invlist = ls.Select(p => p.InvbillNum).Distinct(); |
|
|
|
|
|
foreach (var itm in invlist) |
|
|
|
|
|
{ |
|
|
|
|
|
var invBill = new INVOICE_REPEAT_DTO(); |
|
|
|
|
|
var invls = ls.Where(p => p.InvbillNum == itm).ToList(); |
|
|
|
|
|
var entitylist = entities.Where(p => p.InvbillNum == itm).ToList(); |
|
|
|
|
|
var tax = inv.Tax;//税率
|
|
|
|
|
|
var amt = entitylist.Sum(p => p.Amt);//税前
|
|
|
|
|
|
var taxamt = amt + Math.Round(amt * tax, 2);//税后
|
|
|
|
|
|
var realamt = Math.Round(amt * tax, 2);//税额
|
|
|
|
|
|
invBill.Amt = amt; |
|
|
|
|
|
invBill.TaxAmt = taxamt; |
|
|
|
|
|
invBill.Tax = tax; |
|
|
|
|
|
invBill.BusinessType = inv.BusinessType; |
|
|
|
|
|
invBill.DETIAL = invls; |
|
|
|
|
|
invBill.RealAmt = realamt; |
|
|
|
|
|
invBilllist.Add(invBill); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -440,7 +499,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
//{
|
|
|
//{
|
|
|
// throw new UserFriendlyException($"不存发票号:{invbillnum}对应的结算分组号");
|
|
|
// throw new UserFriendlyException($"不存发票号:{invbillnum}对应的结算分组号");
|
|
|
//}
|
|
|
//}
|
|
|
return ls; |
|
|
return invBilllist; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|