Browse Source

更新版本

master
学 赵 1 year ago
parent
commit
8ace5d9a12
  1. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs
  2. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs
  3. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
  4. 28
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  5. 81
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  6. 21
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  7. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs
  8. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
  9. 223
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
  10. 17
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  11. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs
  12. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
  13. 17
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  14. 261
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs
  15. 40
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  16. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs
  17. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  18. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs
  19. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs
  20. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs
  21. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs
  22. 84
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG_EXT.cs

2
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs

@ -90,7 +90,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
[Display(Name = "税后金额")] [Display(Name = "税后金额")]
public decimal TaxAmt { get; set; } public decimal TaxAmt { get; set; }
[Display(Name = "发票金额")] [Display(Name = "税额")]
public decimal RealAmt { get; set; } public decimal RealAmt { get; set; }
/// <summary> /// <summary>
///发票分组号 ///发票分组号

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs

@ -275,7 +275,7 @@ public class ADJ_SERVICE : BASE_SERVICE
} }
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) });
} }
List<PUB_ADJ_DETAIL_DTO> ls = new List<PUB_ADJ_DETAIL_DTO>(); List<PUB_ADJ_DETAIL_DTO> ls = new List<PUB_ADJ_DETAIL_DTO>();

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs

@ -473,7 +473,7 @@ namespace Win.Sfs.SettleAccount.Bases
throw new BusinessException("8989", "生成失败,请检查调整表和旧发票内容"); throw new BusinessException("8989", "生成失败,请检查调整表和旧发票内容");
} }
[UnitOfWork(false)]
/// <summary> /// <summary>
/// hbpo、jit、备件等 /// hbpo、jit、备件等
/// </summary> /// </summary>
@ -493,7 +493,7 @@ namespace Win.Sfs.SettleAccount.Bases
} }
[UnitOfWork(false)]
/// <summary> /// <summary>
/// 第一次开票 /// 第一次开票
/// </summary> /// </summary>

28
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs

@ -258,17 +258,43 @@ namespace Win.Sfs.SettleAccount.Bases
/// <returns></returns> /// <returns></returns>
protected async Task<List<ERR_EXP_DTO>> CheckInvoiceGenerationRules<T>(List<T> dto1s, List<PriceList> p_pricelist,EnumBusinessType p_businessType) where T : SA_CAN_BASE protected async Task<List<ERR_EXP_DTO>> CheckInvoiceGenerationRules<T>(List<T> dto1s, List<PriceList> p_pricelist,EnumBusinessType p_businessType) where T : SA_CAN_BASE
{ {
var maxDate = p_pricelist.Max(p => p.Date);
var prices = p_pricelist.Where(p => p.Date == maxDate).ToList();
var inner = from d in dto1s var inner = from d in dto1s
join p in p_pricelist on d.LU equals p.LU join p in prices on d.LU equals p.LU
where where
d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select d; select d;
var ls = inner.ToList();
var left = from d in dto1s var left = from d in dto1s
join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN } join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN }
into temp into temp
from tm in temp.DefaultIfEmpty()//校验错误项 from tm in temp.DefaultIfEmpty()//校验错误项
where tm == null where tm == null
select d; select d;
//var maxDate = p_pricelist.Max(p => p.Date);
//var left = from a in dto1s
// join b in (from p in p_pricelist
// where p.Date == maxDate
// select p) on a.LU equals b.LU into joinedResult
// from jr in joinedResult.DefaultIfEmpty()
// where a.SettleDate >= jr.BeginTime && a.SettleDate <= jr.EndTime && jr.LU == null
// select a;
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO> (); List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO> ();
string name = string.Empty; string name = string.Empty;
string keyname = string.Empty; string keyname = string.Empty;

81
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs

@ -15,6 +15,7 @@ using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.ObjectMapping; using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
using Win.Abp.Snowflakes; using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
@ -151,16 +152,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//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();//价格单
// priceList.GroupBy(p => new { p.BeginTime, p.EndTime }).Select(p => p.First());
priceList.GroupBy(p => new { p.BeginTime, p.EndTime }).Select(p => p.First());
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<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys); var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
@ -288,7 +286,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
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<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys); var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
@ -343,15 +341,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
} }
[HttpPost] [HttpPost]
[UnitOfWork(false)]
/// <summary> /// <summary>
/// 发票重开列表 /// 发票重开列表
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
public virtual async Task<INVOICE_REPEAT_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 invBill = new INVOICE_REPEAT_DTO(); var invBilllist = new List<INVOICE_REPEAT_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);
if (adjlist == null && adjlist.Count==0) if (adjlist == null && adjlist.Count==0)
{ {
@ -423,7 +422,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//} //}
var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys); var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s var q = from d in dto1s
join p in priceList on d.PartCode equals p.LU join p in priceList on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime//客户零件号 where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime//客户零件号
select new TEMP_CAN_SA_DETAIL select new TEMP_CAN_SA_DETAIL
{ {
@ -452,38 +451,54 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开 if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
{ {
var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum); var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities); var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
var tax = inv.Tax; if (ls.Count > 0)
var amt = entities.Sum(p => p.Amt); {
var taxamt =amt+ Math.Round(amt * tax, 2); var invlist = ls.Select(p => p.InvbillNum).Distinct();
var billnum = string.Empty; foreach (var itm in invlist)
invBill.Amt = amt; {
invBill.TaxAmt = taxamt; var invBill = new INVOICE_REPEAT_DTO();
invBill.Tax = tax; var invls= ls.Where(p => p.InvbillNum == itm).ToList();
invBill.BusinessType=inv.BusinessType; var entitylist = entities.Where(p => p.InvbillNum == itm).ToList();
invBill.DETIAL = ls; 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);
var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities); var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
var tax = inv.Tax; var invlist = ls.Select(p => p.InvbillNum).Distinct();
var amt = entities.Sum(p => p.Amt); foreach (var itm in invlist)
var taxamt = amt + Math.Round(amt * tax, 2); {
var billnum = string.Empty; var invBill = new INVOICE_REPEAT_DTO();
invBill.Amt = amt; var invls = ls.Where(p => p.InvbillNum == itm).ToList();
invBill.TaxAmt = taxamt; var entitylist = entities.Where(p => p.InvbillNum == itm).ToList();
invBill.Tax = tax; var tax = inv.Tax;//税率
invBill.BusinessType = inv.BusinessType; var amt = entitylist.Sum(p => p.Amt);//税前
invBill.DETIAL = ls; 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);
}
} }
} }
} }
@ -496,7 +511,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//{ //{
// throw new UserFriendlyException($"不存发票号:{p_invbillnum}对应的结算分组号"); // throw new UserFriendlyException($"不存发票号:{p_invbillnum}对应的结算分组号");
//} //}
return invBill; return invBilllist;
} }

21
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs

@ -87,32 +87,33 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public async Task<IActionResult> GenerateInvoice([FromBody] string invbillNum) public async Task<IActionResult> GenerateInvoice([FromBody] string invbillNum)
{ {
var main =await _bbacMng.GetMainAsync(invbillNum); var main =await _bbacMng.GetMainAsync(invbillNum);
if (main != null) if (main != null)
{ {
if (main.State != SettleBillState.) if (main.State != SettleBillState.)
{ {
return new JsonResult(new { Code = 400, Message = "已创建发票不能重复创建" }); return new JsonResult(new { Code = 400, Message = "已创建发票不能重复创建" });
} }
var entitys = await _bbacMng.GetDetalListAsync(invbillNum);//可结算
var priceList = _priceRepository.ToList();
var datetime = priceList.Select(p => p.Date).Max();
var prices = priceList.Where(p => p.Date == datetime).ToList();
;//价格单
var errorList = await CheckInvoiceGenerationRules(entitys, prices, main.BusinessType);//校验生成规则
if (errorList.Count() > 0)
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = await ExportErrorReportAsync(errorList) });
}
if (await _bbacMng.SetForwardState(main, SettleBillState.)) if (await _bbacMng.SetForwardState(main, SettleBillState.))
{ {
var entitys = await _bbacMng.GetDetalListAsync(invbillNum);//可结算
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); var groupNumList = 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 notQuery = _notRepository.Where(p => groupNumList.Contains(p.GroupNum)).ToList();//不能结算 var notQuery = _notRepository.Where(p => groupNumList.Contains(p.GroupNum)).ToList();//不能结算
var priceList = _priceRepository.ToList();//价格单
var errorList = await CheckInvoiceGenerationRules(entitys, priceList,main.BusinessType);//校验生成规则
if (errorList.Count() > 0)
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errorList) });
}
var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys); var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s var q = from d in dto1s
join p in priceList on d.LU equals p.LU join p in prices on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select new TEMP_CAN_SA_DETAIL select new TEMP_CAN_SA_DETAIL
{ {
SettleBillNum = d.SettleBillNum, SettleBillNum = d.SettleBillNum,
Site = d.Site, Site = d.Site,
Version = d.Version, Version = d.Version,

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs

@ -61,7 +61,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
errorlist.Add(new ERR_EXP_DTO() { Message = itm }); errorlist.Add(new ERR_EXP_DTO() { Message = itm });
} }
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errorlist) }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = await ExportErrorReportAsync(errorlist) });
} }
} }
return new JsonResult(new { Code = 200, Message = "生成成功" }); return new JsonResult(new { Code = 200, Message = "生成成功" });

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs

@ -175,7 +175,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
if (checkList.Count > 0) if (checkList.Count > 0)
{ {
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message= "请下载错误信息", fileName = fileName });
} }
#endregion #endregion

223
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs

@ -115,13 +115,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
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
join p in priceList on d.PartCode equals p.LU join p in priceList on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select new TEMP_CAN_SA_DETAIL select new TEMP_CAN_SA_DETAIL
{ {
@ -243,7 +243,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
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
@ -304,9 +304,9 @@ 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)
{ {
List<INVOICE_WAIT_DETAIL_DTO> ls = new List<INVOICE_WAIT_DETAIL_DTO>(); var invBilllist = new List<INVOICE_REPEAT_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);
if (adjlist == null && adjlist.Count == 0) if (adjlist == null && adjlist.Count == 0)
@ -319,120 +319,153 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//var mappingList = await GetMapGroupAsync(invbillnum);//发票对应结算分组 //var mappingList = await GetMapGroupAsync(invbillnum);//发票对应结算分组
//if (mappingList != null && mappingList.Count() > 0) //if (mappingList != null && mappingList.Count() > 0)
//{ //{
var version = int.Parse(DateTime.Now.ToString("yyyymm")); var version = int.Parse(DateTime.Now.ToString("yyyymm"));
//var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组 //var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组
var inv = await GetInvoiceGroupByInvBillNum(invbillnum); var inv = await GetInvoiceGroupByInvBillNum(invbillnum);
var settle = await _hbpoMng.GetMainAsync(inv.InvGroupNum); var settle = await _hbpoMng.GetMainAsync(inv.InvGroupNum);
if (settle == null) if (settle == null)
{
throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!", "400");
}
version = settle.Version;
if (inv != null)
{
if (inv.InvoiceState == InvoiceBillState.)
{ {
throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!","400"); throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!", "400");
} }
version = settle.Version; if (inv.State == SettleBillState. || inv.State == SettleBillState.)
if (inv != null)
{ {
if (inv.InvoiceState == InvoiceBillState.) throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!", "400");
{ }
throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!","400");
}
if (inv.State == SettleBillState. || inv.State == SettleBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!","400");
}
var bbaclist = await _hbpoMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件 var bbaclist = await _hbpoMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件
//var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0) if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{ {
foreach (var itm in adjlist) bbaclist.Add(new HBPO_CAN_SA_DETAIL(
{ guid: itm.Id,
bbaclist.Add(new HBPO_CAN_SA_DETAIL( keyCode: itm.KeyCode,
guid: itm.Id, version: itm.Version,
keyCode: itm.KeyCode, billNum: itm.InvGroupNum,
version: itm.Version, settleBillNum: itm.SettleBillNum,
billNum: itm.InvGroupNum, lU: itm.LU,
settleBillNum: itm.SettleBillNum, pN: itm.PN,
lU: itm.LU, site: itm.Site,
pN: itm.PN, qty: itm.Qty,
site: itm.Site, price: itm.Price,
qty: itm.Qty, businessType: itm.BusinessType,
price: itm.Price,
businessType: itm.BusinessType,
settleDate: itm.SettleDate, settleDate: itm.SettleDate,
groupNum: itm.GroupNum, groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum, invGroupNum: itm.InvGroupNum,
invbillnum: string.Empty, invbillnum: string.Empty,
partcode: itm.PartCode partcode: itm.PartCode
)); ));
}
} }
var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据 }
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据
var gNumList = entitys.Select(p => p.GroupNum).Distinct().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 await ExportErrorReportAsync(errorList); // return 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 dto1s var q = from d in dto1s
join p in priceList on d.PartCode equals p.LU join p in priceList on d.PartCode equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime//客户零件号 where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime//客户零件号
select new TEMP_CAN_SA_DETAIL select new TEMP_CAN_SA_DETAIL
{ {
Id = d.Id, Id = d.Id,
SettleBillNum = d.SettleBillNum, SettleBillNum = d.SettleBillNum,
Site = d.Site, Site = d.Site,
Version = d.Version, Version = d.Version,
Price = p.Price, Price = p.Price,
BillNum = d.BillNum, BillNum = d.BillNum,
SettleDate = d.SettleDate, SettleDate = d.SettleDate,
InvGroupNum = d.InvGroupNum, InvGroupNum = d.InvGroupNum,
LU = d.LU, LU = d.LU,
MaterialDesc = d.MaterialDesc, MaterialDesc = d.MaterialDesc,
PN = d.PN, PN = d.PN,
Qty = d.Qty, Qty = d.Qty,
GroupNum = d.GroupNum, GroupNum = d.GroupNum,
Amt = Math.Round(d.Qty * p.Price, 2), Amt = Math.Round(d.Qty * p.Price, 2),
ContractDocID = "N", ContractDocID = "N",
BeginDate = p.BeginTime, BeginDate = p.BeginTime,
EndDate = p.EndTime, EndDate = p.EndTime,
PartCode = d.PartCode PartCode = d.PartCode
}; };
var dtos = q.ToList(); var dtos = q.ToList();
if (dtos != null && dtos.Count > 0) if (dtos != null && dtos.Count > 0)
{
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
{ {
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开 var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
var 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 entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum); var invBill = new INVOICE_REPEAT_DTO();
var invls = ls.Where(p => p.InvbillNum == itm).ToList();
ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities); 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 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 entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum); var invBill = new INVOICE_REPEAT_DTO();
ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities); 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
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票","400"); {
} throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400");
}
//} //}
//else //else
//{ //{
// throw new UserFriendlyException($"不存发票号:{invbillnum}对应的结算分组号"); // throw new UserFriendlyException($"不存发票号:{invbillnum}对应的结算分组号");
//} //}
return ls; return invBilllist;
} }

17
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs

@ -87,18 +87,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
return new JsonResult(new { Code = 400, Message = "已创建发票不能重复创建" }); return new JsonResult(new { Code = 400, Message = "已创建发票不能重复创建" });
} }
var entitys = await _hbpoMng.GetDetalListAsync(invbillnum);
var priceList = _priceRepository.ToList();//价格单
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, main.BusinessType);//校验生成规则
if (errorList.Count() > 0)
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = await ExportErrorReportAsync(errorList) });
}
if (await _hbpoMng.SetForwardState(main, SettleBillState.)) if (await _hbpoMng.SetForwardState(main, SettleBillState.))
{ {
var entitys = await _hbpoMng.GetDetalListAsync(invbillnum);
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
var notQuery = _notRepository.Where(p => groupNumList.Contains(p.GroupNum)).ToList(); var notQuery = _notRepository.Where(p => groupNumList.Contains(p.GroupNum)).ToList();
var priceList = _priceRepository.ToList();//价格单
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, main.BusinessType);//校验生成规则
if (errorList.Count() > 0)
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, 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 dto1s var q = from d in dto1s
join p in priceList on d.LU equals p.LU join p in priceList on d.LU equals p.LU

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs

@ -65,7 +65,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
errorlist.Add(new ERR_EXP_DTO() { Message = itm }); errorlist.Add(new ERR_EXP_DTO() { Message = itm });
} }
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errorlist) }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = await ExportErrorReportAsync(errorlist) });
} }
} }
return new JsonResult(new { Code = 200, Message = "生成成功" }); return new JsonResult(new { Code = 200, Message = "生成成功" });

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs

@ -230,7 +230,7 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
if (checkList.Count > 0) if (checkList.Count > 0)
{ {
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = fileName });
} }
#endregion #endregion
@ -269,7 +269,7 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
if (checkList.Count > 0) if (checkList.Count > 0)
{ {
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = fileName });
} }
#endregion #endregion

17
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs

@ -16,6 +16,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Management;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -110,7 +111,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
} }
if (errors.Count() > 0) if (errors.Count() > 0)
{ {
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errors) }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = await ExportErrorReportAsync(errors) });
} }
} }
await _invMng.SetForwardState(p_invs, SettleBillState.); await _invMng.SetForwardState(p_invs, SettleBillState.);
@ -161,7 +162,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var wquery = from itm in AMap var wquery = from itm in AMap
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp
select from tm in temp.DefaultIfEmpty() from tm in temp.DefaultIfEmpty()
select select
new INVOICE_WAIT_DETAIL_BBAC_DTO() new INVOICE_WAIT_DETAIL_BBAC_DTO()
{ {
@ -181,7 +182,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BeginDate = itm.BeginDate, BeginDate = itm.BeginDate,
EndDate = itm.EndDate, EndDate = itm.EndDate,
}; };
entity.INVOICE_WAIT_DETAIL_BBAC = AMap; entity.INVOICE_WAIT_DETAIL_BBAC = wquery.ToList();
} }
else if (invs.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian) else if (invs.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian)
{ {
@ -191,7 +192,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var wquery = from itm in BMap var wquery = from itm in BMap
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp
select from tm in temp.DefaultIfEmpty() from tm in temp.DefaultIfEmpty()
select select
new INVOICE_WAIT_DETAIL_BJ_DTO() new INVOICE_WAIT_DETAIL_BJ_DTO()
{ {
@ -211,7 +212,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BeginDate = itm.BeginDate, BeginDate = itm.BeginDate,
EndDate = itm.EndDate, EndDate = itm.EndDate,
}; };
entity.INVOICE_WAIT_DETAIL_BJ = BMap; entity.INVOICE_WAIT_DETAIL_BJ = wquery.ToList();
} }
else else
{ {
@ -221,7 +222,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var wquery = from itm in wdtos var wquery = from itm in wdtos
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp
select from tm in temp.DefaultIfEmpty() from tm in temp.DefaultIfEmpty()
select select
new INVOICE_WAIT_DETAIL_DTO() new INVOICE_WAIT_DETAIL_DTO()
{ {
@ -243,7 +244,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
EndDate = itm.EndDate, EndDate = itm.EndDate,
}; };
entity.INVOICE_WAIT_DETAIL = wdtos; entity.INVOICE_WAIT_DETAIL= wquery.ToList();
} }
var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
@ -437,6 +438,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (number + 1 > lineN) if (number + 1 > lineN)
{ {
INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO();
entity.RealInvBillNum = lsC[number].RealInvBillNum; entity.RealInvBillNum = lsC[number].RealInvBillNum;
entity.InvDate = lsC[number].InvDate; entity.InvDate = lsC[number].InvDate;
entity.InvBillNum = lsC[number].InvBillNum; entity.InvBillNum = lsC[number].InvBillNum;

261
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs

@ -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);
@ -326,121 +350,156 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//var mappingList = await GetMapGroupAsync(invbillnum);//发票对应结算分组 //var mappingList = await GetMapGroupAsync(invbillnum);//发票对应结算分组
//if (mappingList != null && mappingList.Count() > 0) //if (mappingList != null && mappingList.Count() > 0)
//{ //{
var version = int.Parse(DateTime.Now.ToString("yyyymm")); var version = int.Parse(DateTime.Now.ToString("yyyymm"));
//var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组 //var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组
var inv = await GetInvoiceGroupByInvBillNum(invbillnum); var inv = await GetInvoiceGroupByInvBillNum(invbillnum);
var settle = await _pubMng.GetMainAsync(inv.InvGroupNum); var settle = await _pubMng.GetMainAsync(inv.InvGroupNum);
if (settle == null) if (settle == null)
{
throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!", "400");
}
version = settle.Version;
if (inv != null)
{
if (inv.InvoiceState == InvoiceBillState.)
{ {
throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!", "400"); throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!", "400");
} }
version = settle.Version; if (inv.State == SettleBillState. || inv.State == SettleBillState.)
if (inv != null)
{ {
if (inv.InvoiceState == InvoiceBillState.) throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!", "400");
{ }
throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!", "400");
}
if (inv.State == SettleBillState. || inv.State == SettleBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!", "400");
}
var bbaclist = await _pubMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件 var bbaclist = await _pubMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件
//var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0) if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{ {
foreach (var itm in adjlist) bbaclist.Add(new PUB_CAN_SA_DETAIL(
{ guid: itm.Id,
bbaclist.Add(new PUB_CAN_SA_DETAIL( keyCode: itm.KeyCode,
guid: itm.Id, version: itm.Version,
keyCode: itm.KeyCode, billNum: itm.InvGroupNum,
version: itm.Version, settleBillNum: itm.SettleBillNum,
billNum: itm.InvGroupNum, lU: itm.LU,
settleBillNum: itm.SettleBillNum, pN: itm.PN,
lU: itm.LU, site: itm.Site,
pN: itm.PN, qty: itm.Qty,
site: itm.Site, price: itm.Price,
qty: itm.Qty, businessType: itm.BusinessType,
price: itm.Price,
businessType: itm.BusinessType,
settleDate: itm.SettleDate, settleDate: itm.SettleDate,
groupNum: itm.GroupNum, groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum, invGroupNum: itm.InvGroupNum,
invbillnum: string.Empty, invbillnum: string.Empty,
partcode: itm.PartCode, partcode: itm.PartCode,
pobillnum:string.Empty pobillnum: string.Empty
)); ));
}
} }
var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据 }
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); 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)
//{
// return await ExportErrorReportAsync(errorList);
//}
var dto1s = ObjectMapper.Map<List<PUB_CAN_SA_DETAIL>, List<PUB_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s
join p in priceList on d.PartCode equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime//客户零件号
select new TEMP_CAN_SA_DETAIL
{
Id = d.Id,
SettleBillNum = d.SettleBillNum,
Site = d.Site,
Version = d.Version,
Price = p.Price,
BillNum = d.BillNum,
SettleDate = d.SettleDate,
InvGroupNum = d.InvGroupNum,
LU = d.LU,
MaterialDesc = d.MaterialDesc,
PN = d.PN,
Qty = d.Qty,
GroupNum = d.GroupNum,
Amt = Math.Round(d.Qty * p.Price, 2),
ContractDocID = "N",
BeginDate = p.BeginTime,
EndDate = p.EndTime,
PartCode = d.PartCode
}; var priceList = _priceRepository.ToList();//价格单
var dtos = q.ToList(); //var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType);
if (dtos != null && dtos.Count > 0) //if (errorList.Count() > 0)
{ //{
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开 // return await ExportErrorReportAsync(errorList);
//}
var dto1s = ObjectMapper.Map<List<PUB_CAN_SA_DETAIL>, List<PUB_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s
join p in priceList on d.PartCode equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime//客户零件号
select new TEMP_CAN_SA_DETAIL
{ {
var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum); Id = d.Id,
SettleBillNum = d.SettleBillNum,
Site = d.Site,
Version = d.Version,
Price = p.Price,
BillNum = d.BillNum,
SettleDate = d.SettleDate,
InvGroupNum = d.InvGroupNum,
LU = d.LU,
MaterialDesc = d.MaterialDesc,
PN = d.PN,
Qty = d.Qty,
GroupNum = d.GroupNum,
Amt = Math.Round(d.Qty * p.Price, 2),
ContractDocID = "N",
BeginDate = p.BeginTime,
EndDate = p.EndTime,
PartCode = d.PartCode
ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities); };
var dtos = q.ToList();
if (dtos != null && dtos.Count > 0)
{
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
{
var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
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);
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 entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum); var invBill = new INVOICE_REPEAT_DTO();
ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities); 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
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400"); {
} throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400");
}
//} //}
//else //else
//{ //{
// throw new UserFriendlyException($"不存发票号:{invbillnum}对应的结算分组号"); // throw new UserFriendlyException($"不存发票号:{invbillnum}对应的结算分组号");
//} //}
return ls; return invBilllist;
} }

40
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs

@ -77,29 +77,29 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
return new JsonResult(new { Code = 400, Message = "已创建发票不能重复创建" }); return new JsonResult(new { Code = 400, Message = "已创建发票不能重复创建" });
} }
if (await _pubMng.SetForwardState(main, SettleBillState.)) var entitys = await _pubMng.GetDetalListAsync(billnum);
List<PriceList> priceList = new List<PriceList>();
if (main.BusinessType == EnumBusinessType.BeiJian)
{ {
var entitys = await _pubMng.GetDetalListAsync(billnum); var priceListbj = _pricebjRepository.ToList();//价格单
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); foreach (var itm in priceListbj)
List<PriceList> priceList = new List<PriceList>();
if (main.BusinessType == EnumBusinessType.BeiJian)
{ {
var priceListbj = _pricebjRepository.ToList();//价格单 priceList.Add(new PriceList() { LU = itm.LU, BeginTime = itm.BeginDate, EndTime = itm.EndDate, Price = itm.Price });
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, main.BusinessType);//校验生成规则
if (errorList.Count() > 0)
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errorList) });
} }
}
else
{
priceList = _priceRepository.ToList();//价格单
}
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, main.BusinessType);//校验生成规则
if (errorList.Count() > 0)
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = await ExportErrorReportAsync(errorList) });
}
if (await _pubMng.SetForwardState(main, SettleBillState.))
{
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
var dto1s = ObjectMapper.Map<List<PUB_CAN_SA_DETAIL>, List<PUB_CAN_SA_DETAIL_DTO>>(entitys); var dto1s = ObjectMapper.Map<List<PUB_CAN_SA_DETAIL>, List<PUB_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s var q = from d in dto1s
join p in priceList on d.LU equals p.LU join p in priceList on d.LU equals p.LU
@ -130,9 +130,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
if (billnum.Substring(0, 1) == "C")//一次开票 if (billnum.Substring(0, 1) == "C")//一次开票
{ {
await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, new List<TEMP_NOT_SA_DETAIL>(), main.Version, main.InvGroupNum, string.Empty, main.BusinessType); await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, new List<TEMP_NOT_SA_DETAIL>(), main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
} }
else//二次开票 else//二次开票
{ {

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs

@ -61,7 +61,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
errorlist.Add(new ERR_EXP_DTO() { Message = itm }); errorlist.Add(new ERR_EXP_DTO() { Message = itm });
} }
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errorlist) }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = await ExportErrorReportAsync(errorlist) });
} }
} }

8
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs

@ -244,7 +244,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
if (checkList.Count > 0) if (checkList.Count > 0)
{ {
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = fileName });
} }
#endregion #endregion
@ -281,7 +281,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
if (checkList.Count > 0) if (checkList.Count > 0)
{ {
string fileName = await ExportErrorReportAsync(checkList); string fileName = await ExportErrorReportAsync(checkList);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = fileName });
} }
#endregion #endregion
@ -311,7 +311,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
if (checkList.Count > 0) if (checkList.Count > 0)
{ {
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = fileName });
} }
#endregion #endregion
@ -342,7 +342,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
if (checkList.Count > 0) if (checkList.Count > 0)
{ {
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = fileName });
} }
#endregion #endregion

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs

@ -73,7 +73,7 @@ public class PURCHASE_PRICE_SERVICE : SettleAccountApplicationBase<PURCHASE_PRIC
if (checkList.Count > 0) if (checkList.Count > 0)
{ {
string fileName = await ExportErrorReportAsync(checkList); string fileName = await ExportErrorReportAsync(checkList);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = fileName });
} }
foreach (var itm in _ls) foreach (var itm in _ls)
{ {

5
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs

@ -34,12 +34,9 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
{ {
using var serviceScope = _serviceProvider.CreateScope(); using var serviceScope = _serviceProvider.CreateScope();
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
await HandDelEdiDataAsync().ConfigureAwait(false); await HandDelEdiDataAsync().ConfigureAwait(false);
var seDetailGroup = db.Set<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace }).Select(t => new { t.Key.PN, LU = t.Key.CustomerPartCodeNoSpace }); var seDetailGroup = db.Set<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace }).Select(t => new { t.Key.PN, LU = t.Key.CustomerPartCodeNoSpace });
var ediDetailGroup = db.Set<BBAC_SE_EDI>().Where(t => t.IsDeleted == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU }); var ediDetailGroup = db.Set<BBAC_SE_EDI>().Where(t => t.IsDeleted == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU });
var keyCodes = from se in seDetailGroup var keyCodes = from se in seDetailGroup
from edi in ediDetailGroup from edi in ediDetailGroup
where se.PN == edi.PN && se.LU == edi.LU where se.PN == edi.PN && se.LU == edi.LU
@ -52,7 +49,6 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
from keyCode in keyCodes from keyCode in keyCodes
where edi.PN == keyCode.PN && edi.LU == keyCode.LU && edi.IsDeleted == false && edi.IsHaveSeData == false where edi.PN == keyCode.PN && edi.LU == keyCode.LU && edi.IsDeleted == false && edi.IsHaveSeData == false
select edi; select edi;
var seDetails = seDetailsQuery.Take(5000).ToList(); var seDetails = seDetailsQuery.Take(5000).ToList();
var ediDetails = ediDetailsQuery.Take(5000).ToList(); var ediDetails = ediDetailsQuery.Take(5000).ToList();
seDetails.ForEach(t => t.IsHaveEdiData = true); seDetails.ForEach(t => t.IsHaveEdiData = true);
@ -92,7 +88,6 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
//Edi 删除的数据(有发运数据) //Edi 删除的数据(有发运数据)
var ediDelKeyCodes = db.Set<BBAC_SE_EDI>().Where(t => t.IsDeleted == true && t.IsHaveSeData == true).Select(t => new { t.PN, t.LU }).Distinct().ToList(); var ediDelKeyCodes = db.Set<BBAC_SE_EDI>().Where(t => t.IsDeleted == true && t.IsHaveSeData == true).Select(t => new { t.PN, t.LU }).Distinct().ToList();
if (ediDelKeyCodes.Any()) if (ediDelKeyCodes.Any())
{ {
var seDetails = db.Set<BBAC_SE_DETAIL>().Join(ediDelKeyCodes, a => new { a.PN, LU = a.CustomerPartCodeNoSpace }, b => new { b.PN, b.LU }, (a, b) => a); var seDetails = db.Set<BBAC_SE_DETAIL>().Join(ediDelKeyCodes, a => new { a.PN, LU = a.CustomerPartCodeNoSpace }, b => new { b.PN, b.LU }, (a, b) => a);

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs

@ -91,7 +91,7 @@ public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase<TB_Re
if (checkList.Count > 0) if (checkList.Count > 0)
{ {
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = fileName });
} }
foreach (var itm in _ls) foreach (var itm in _ls)
{ {

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs

@ -75,7 +75,7 @@ public class MaterialRelationshipAppService : SettleAccountApplicationBase<Mater
if (checkList.Count > 0) if (checkList.Count > 0)
{ {
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = fileName });
} }
foreach (var itm in _ls) foreach (var itm in _ls)
{ {

84
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG_EXT.cs

@ -21,6 +21,7 @@ using Volo.Abp.Data;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services; using Volo.Abp.Domain.Services;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Entities.BQ.Temp; using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.Entities.Prices;
@ -261,7 +262,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
return detailList; return detailList;
} }
[UnitOfWork(false)]
public async Task<List<INVOICE_WAIT_DETAIL>> FirstInvoiceExtend<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) public async Task<List<INVOICE_WAIT_DETAIL>> FirstInvoiceExtend<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
where TDetail : SA_CAN_BASE where TDetail : SA_CAN_BASE
{ {
@ -315,35 +316,32 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
} }
if (invoiceMap.Keys.Count > 0) if (invoiceMap.Keys.Count > 0)
{ {
var groupList = new List<INVOICE_MAP_GROUP>(); var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>(); var notDetialList = new List<INVOICE_NOT_SETTLE>();
var invlist = new List<INVOICE_GRP>(); var invlist = new List<INVOICE_GRP>();
var salist = new List<TDetail>(); var salist = new List<TDetail>();
var adjlist = new List<PUB_ADJ_DETAIL>(); var adjlist = new List<PUB_ADJ_DETAIL>();
foreach (var itm in invoiceMap)//分组影响和 foreach (var itm in invoiceMap)//分组影响和
{ {
var key = itm.Key;//发票票号 var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表 var ls = itm.Value;//结算分组号列表
//反向查找结算数据 //反向查找结算数据
var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList(); var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList();
foreach (var detail in invdetails) //foreach (var detail in invdetails)
{ //{
detail.InvbillNum = key; // detail.InvbillNum = key;
salist.Add(detail); // salist.Add(detail);
} //}
if (!string.IsNullOrEmpty(p_parentInvBillNum)) //if (!string.IsNullOrEmpty(p_parentInvBillNum))
{ //{
//反向查找调整数据 // //反向查找调整数据
var adjdetails = p_adjlist.Where(p => ls.Contains(p.GroupNum)).ToList(); // var adjdetails = p_adjlist.Where(p => ls.Contains(p.GroupNum)).ToList();
foreach (var detail in adjdetails) // foreach (var detail in adjdetails)
{ // {
detail.InvBillNum = key; // detail.InvBillNum = key;
adjdetails.Add(detail); // adjdetails.Add(detail);
} // }
} //}
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }) var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID })
.Select(itm => new .Select(itm => new
@ -405,31 +403,31 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{ {
detailList.AddRange(_entityDetailList); detailList.AddRange(_entityDetailList);
} }
var innotls = new List<INVOICE_NOT_SETTLE>(); //var innotls = new List<INVOICE_NOT_SETTLE>();
if (p_notlist != null && p_notlist.Count > 0) //if (p_notlist != null && p_notlist.Count > 0)
{ //{
var notls = p_notlist.Where(p=>ls.Contains(p.GroupNum)).GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) }); // var notls = p_notlist.Where(p=>ls.Contains(p.GroupNum)).GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
foreach (var nitm in notls) // foreach (var nitm in notls)
{ // {
innotls.Add(new INVOICE_NOT_SETTLE( // innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(), // guid: GuidGenerator.Create(),
version: p_version, // version: p_version,
invGroupNum: p_InvGroupNum, // invGroupNum: p_InvGroupNum,
settleGroupNum: nitm.GroupNum, // settleGroupNum: nitm.GroupNum,
lU: string.Empty, // lU: string.Empty,
lU1: nitm.LU, // lU1: nitm.LU,
extend1: string.Empty, // extend1: string.Empty,
extend2: string.Empty, // extend2: string.Empty,
qty: nitm.Qty, // qty: nitm.Qty,
p_invbillnum:key // p_invbillnum:key
)); // ));
} // }
if (innotls.Count > 0) // if (innotls.Count > 0)
{ // {
notDetialList.AddRange(innotls); // notDetialList.AddRange(innotls);
} // }
} //}
var invbill = new INVOICE_GRP var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(), (guid: GuidGenerator.Create(),
realnvBillNum: string.Empty, realnvBillNum: string.Empty,

Loading…
Cancel
Save