Browse Source

添加红冲服务

master
学 赵 1 year ago
parent
commit
f7e4e02eff
  1. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
  2. 140
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  3. 140
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
  4. 158
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs

1
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs

@ -92,7 +92,6 @@ namespace Win.Sfs.SettleAccount.Bases
//[Route("detailquery")] //[Route("detailquery")]
public virtual async Task<PagedResultDto<TEntityDetailDto>> DetailQueryAsync(TRequestDetailInput input) public virtual async Task<PagedResultDto<TEntityDetailDto>> DetailQueryAsync(TRequestDetailInput input)
{ {
var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount).ConfigureAwait(false); var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount).ConfigureAwait(false);
var totalCount = await _detailRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false); var totalCount = await _detailRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<TEntityDetail>, List<TEntityDetailDto>>(entitys); var dtos = ObjectMapper.Map<List<TEntityDetail>, List<TEntityDetailDto>>(entitys);

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

@ -200,6 +200,146 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
return new JsonResult(new { Code = 200, Message = "重开成功" }); return new JsonResult(new { Code = 200, Message = "重开成功" });
} }
[HttpPost]
[UnitOfWork(false)]
/// <summary>
/// 红冲发票报废重开
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual async Task<IActionResult> BackReissueInvoice([FromBody] string p_invoice)
{
//var errorlist = await CheckRepeat(p_list).ConfigureAwait(false);//是否录入数据重复
//if (errorlist.Count > 0)
//{
// return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorlist).ConfigureAwait(false) });
//}
//var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list);
//if (adjlist == null && adjlist.Count == 0)
//{
// throw new UserFriendlyException($"调整表无数据!", "400");
//}
var invbillnum =p_invoice;
var version = int.Parse(DateTime.Now.ToString("yyyymm"));
var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false);
var settle = await _bbacMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false);
if (settle == null)
{
throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不粗拿在在请检查!", "400");
}
version = settle.Version;
if (inv != null)
{
if (inv.InvoiceState == InvoiceBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!", "400");
}
if (inv.State == SettleBillState. || inv.State == SettleBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前不能重开可以退回!", "400");
}
var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum).ConfigureAwait(false);//发票对应结算零件
// var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
//if (adjlist != null && adjlist.Count > 0)
//{
// var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType);
// var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault());
// foreach (var itm in adjlist)
// {
// bbaclist.Add(new BBAC_CAN_SA_DETAIL(
// guid: itm.Id,
// keyCode: itm.KeyCode,
// version: itm.Version,
// billNum: itm.InvGroupNum,
// settleBillNum: itm.SettleBillNum,
// lU: itm.LU,
// pN: itm.PN,
// site: itm.Site,
// qty: itm.Qty,
// price: itm.Price,
// category: itm.BusinessType,
// isReturn: itm.Qty > 0 ? false : true,
// settleDate: itm.SettleDate,
// groupNum: itm.GroupNum,
// invGroupNum: inv.InvGroupNum,
// contactid: itm.Extend1,//生产号
// invbillnum: string.Empty,
// partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode
// ));
// }
//}
var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
//var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算
var priceList = _priceRepository.Where(p => p.ClientCode == inv.Site && p.IsCancel == false).ToList();//价格单
//}
var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s
join p in priceList on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.ClientCode == inv.Site && p.IsCancel == false//客户零件号
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 = d.ContractDocID,
BeginDate = p.BeginTime,
EndDate = p.EndTime,
PartCode = d.PartCode
};
var dtos = q.ToList();
if (dtos != null && dtos.Count > 0)
{
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
{
await ReissueFirstInvoice(bbaclist,new List<PUB_ADJ_DETAIL>(), dtos, version, invbillnum).ConfigureAwait(false);
}
else//二次开票
{
await ReissueSecInvoice(bbaclist, new List<PUB_ADJ_DETAIL>(), dtos, version, invbillnum).ConfigureAwait(false);
}
}
}
else
{
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400");
}
//}
//else
//{
// throw new UserFriendlyException( $"不存发票号:{p_invbillnum}对应的结算分组号");
//}
return new JsonResult(new { Code = 200, Message = "重开成功" }); ;
}
[HttpPost] [HttpPost]
[UnitOfWork(false)] [UnitOfWork(false)]
/// <summary> /// <summary>

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

@ -50,6 +50,146 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
_relationRepository = relationRepository; _relationRepository = relationRepository;
_pdRepository = pdRepository; _pdRepository = pdRepository;
} }
[HttpPost]
[UnitOfWork(false)]
/// <summary>
/// 发票重开
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual async Task<IActionResult> BackReissueInvoice([FromBody] string p_inv)
{
//var errorlist = await CheckRepeat(p_list).ConfigureAwait(false);
//if (errorlist.Count > 0)
//{
// return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorlist).ConfigureAwait(false) });
//}
//var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list);
//if (adjlist == null && adjlist.Count == 0)
//{
// throw new UserFriendlyException($"调整表无数据!", "400");
//}
//var first = p_list.FirstOrDefault();
var invbillnum = p_inv;
//var mappingList = await GetMapGroupAsync(p_invbillnum);//发票对应结算分组
//if (mappingList != null && mappingList.Count() > 0)
//{
var version = int.Parse(DateTime.Now.ToString("yyyymm"));
//var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组
var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false);
var settle = await _hbpoMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false);
if (settle == null)
{
throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不存在请检查!", "400");
}
version = settle.Version;
if (inv != null)
{
if (inv.InvoiceState == InvoiceBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!", "400");
}
if (inv.State == SettleBillState. || inv.State == SettleBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!", "400");
}
var hbpolist = await _hbpoMng.GetContainsAsync(inv.InvbillNum).ConfigureAwait(false);//结算分组对应结算零件
// var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
//if (adjlist != null && adjlist.Count > 0)
//{
// var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType).ToList();
// var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault());
// var errors = await CheckAdJRules(adjlist, relist.ToList(), inv.BusinessType);
// if (errors.Count > 0)
// {
// return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errors).ConfigureAwait(false) });
// }
// foreach (var itm in adjlist)
// {
// hbpolist.Add(new HBPO_CAN_SA_DETAIL(
// guid: GuidGenerator.Create(),
// keyCode: itm.KeyCode,
// version: itm.Version,
// billNum: itm.InvGroupNum,
// settleBillNum: itm.SettleBillNum,
// lU: itm.LU,
// pN: itm.PN,
// site: itm.Site,
// qty: itm.Qty,
// price: itm.Price,
// businessType: itm.BusinessType,
// settleDate: itm.SettleDate,
// groupNum: itm.GroupNum,
// invGroupNum: inv.InvGroupNum,
// invbillnum: string.Empty,
// partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode
// ));
// }
//}
var entitys = hbpolist;//合并库存调整单和就发票可结算明细数据
var gNumList = entitys.Select(p => 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 priceList = _priceRepository.Where(p => p.IsCancel == false).ToList();//价格单
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType).ConfigureAwait(false);
if (errorList.Count > 0)
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) });
}
// var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in entitys
join p in priceList on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site
select new TEMP_CAN_SA_DETAIL
{
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 dtos = q.ToList();
if (dtos != null && dtos.Count > 0)
{
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
{
await ReissueFirstInvoice(hbpolist, new List<PUB_ADJ_DETAIL>(), dtos, version, invbillnum).ConfigureAwait(false);
}
else//二次开票
{
await ReissueSecInvoice(hbpolist, new List<PUB_ADJ_DETAIL>(), dtos, version, invbillnum).ConfigureAwait(false);
}
}
}
else
{
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400");
}
//}
//else
//{
// throw new UserFriendlyException( $"不存发票号:{p_invbillnum}对应的结算分组号");
//}
return new JsonResult(new { Code = 200, Message = "发票重开成功" });
}
/// <summary> /// <summary>
/// 发票重开 /// 发票重开
/// </summary> /// </summary>

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

@ -50,6 +50,164 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
_relationRepository = relationRepository; _relationRepository = relationRepository;
_pdRepository = pdRepository; _pdRepository = pdRepository;
} }
/// <summary>
/// 提交发票
/// </summary>
/// <param name="p_list"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
/// <exception cref="BusinessException"></exception>
[HttpPost]
[UnitOfWork(false)]
public virtual async Task<IActionResult> BackReissueInvoice([FromBody] string p_inv)
{
//var errorlist = await CheckRepeat(p_list).ConfigureAwait(false);
//if (errorlist.Count > 0)
//{
// return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorlist) });
//}
//var first = p_list.FirstOrDefault();
var invbillnum = p_inv;
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);
//if (adjlist == null && adjlist.Count == 0)
//{
// throw new UserFriendlyException($"调整表无数据!", "400");
//}
//var mappingList = await GetMapGroupAsync(p_invbillnum);//发票对应结算分组
//if (mappingList != null && mappingList.Count() > 0)
//{
var version = int.Parse(DateTime.Now.ToString("yyyymm"));
//var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组
var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false);
var settle = await _pubMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false);
if (settle == null)
{
throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!", "400");
}
version = settle.Version;
if (inv != null)
{
if (inv.InvoiceState == InvoiceBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!", "400");
}
if (inv.State == SettleBillState. || inv.State == SettleBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前不能重开可以退回!", "400");
}
var publist = await _pubMng.GetContainsAsync(inv.InvbillNum).ConfigureAwait(false);//结算分组对应结算零件
//var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
//if (adjlist != null && adjlist.Count > 0)
//{
// var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType).ToList();
// var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault());
// var errors = await CheckAdJRules(adjlist, relist.ToList(), inv.BusinessType);
// if (errors.Count > 0)
// {
// return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errors).ConfigureAwait(false) });
// }
// foreach (var itm in adjlist)
// {
// publist.Add(new PUB_CAN_SA_DETAIL(
// guid: GuidGenerator.Create(),
// keyCode: itm.KeyCode,
// version: itm.Version,
// billNum: itm.InvGroupNum,
// settleBillNum: itm.SettleBillNum,
// lU: itm.LU,
// pN: itm.PN,
// site: itm.Site,
// qty: itm.Qty,
// price: itm.Price,
// businessType: itm.BusinessType,
// settleDate: itm.SettleDate,
// groupNum: itm.GroupNum,
// invGroupNum: inv.InvGroupNum,
// invbillnum: string.Empty,
// partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode,
// pobillnum: string.Empty
// ));
// }
//}
var entitys = publist;//合并库存调整单和就发票可结算明细数据
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
//var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).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, ClientCode = "1049" });
}
}
else
{
priceList = _priceRepository.Where(p => p.IsCancel == false && p.ClientCode == inv.Site).ToList();//价格单
}
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType).ConfigureAwait(false);
if (errorList.Count > 0)
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) });
}
// var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in entitys
join p in priceList on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site
select new TEMP_CAN_SA_DETAIL
{
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 dtos = q.ToList();
if (dtos != null && dtos.Count > 0)
{
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
{
await ReissueFirstInvoice(publist,new List<PUB_ADJ_DETAIL>(), dtos, version, invbillnum).ConfigureAwait(false);
}
else//二次开票
{
await ReissueSecInvoice(publist, new List<PUB_ADJ_DETAIL>(), dtos, version, invbillnum).ConfigureAwait(false);
}
}
}
else
{
throw new BusinessException("8989", $"不存发票号为:{invbillnum}发票");
}
//}
//else
//{
// throw new BusinessException("8989", $"不存发票号:{p_invbillnum}对应的结算分组号");
//}
return new JsonResult(new { Code = 200, Message = "发票重开成功" });
}
/// <summary> /// <summary>
/// 提交发票 /// 提交发票

Loading…
Cancel
Save