Browse Source

更新版本

master
学 赵 1 year ago
parent
commit
0304913e66
  1. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs
  2. 329
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  3. 358
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
  4. 200
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs

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

@ -178,7 +178,7 @@ public class ADJ_SERVICE : BASE_SERVICE
/// <exception cref="BusinessException"></exception>
[HttpPost]
[DisableRequestSizeLimit]
public async Task<IActionResult> CheckImport(List<PUB_ADJ_DETAIL_DTO> p_list)
public async Task<string> CheckImport(List<PUB_ADJ_DETAIL_DTO> p_list)
{
if (p_list.Count == 0)
{
@ -283,8 +283,7 @@ public class ADJ_SERVICE : BASE_SERVICE
}
if (errorList.Count > 0)
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errorList) });
return await ExportErrorReportAsync(errorList) ;
}
List<PUB_ADJ_DETAIL_DTO> ls = new List<PUB_ADJ_DETAIL_DTO>();
if (flag == 1)
@ -333,7 +332,7 @@ public class ADJ_SERVICE : BASE_SERVICE
ls = inner.ToList();
}
return new JsonResult(new { Code = 200, data =ls }); ;
return "OK" ;
}
}

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

@ -1,4 +1,5 @@
using DocumentFormat.OpenXml.Drawing.Charts;
using DocumentFormat.OpenXml.Spreadsheet;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization;
@ -41,7 +42,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly ADJ_SERVICE _adjservice;
public BBAC_BA_SERVICE(IExcelImportAppService excelImportService,
@ -59,8 +60,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INV_MNG invMng,
TaskJobService service,
BaseDomainService baseservice,
INormalEfCoreRepository<PriceList, Guid> priceRepository
INormalEfCoreRepository<PriceList, Guid> priceRepository,
ADJ_SERVICE adjservice
) : base(
excelImportService,
@ -79,6 +81,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
baseservice)
{
_priceRepository = priceRepository;
_adjservice = adjservice;
}
@ -347,10 +350,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual async Task<List<INVOICE_REPEAT_DTO>> ReissueInvoiceList(List<PUB_ADJ_DETAIL_DTO> p_list)
public virtual async Task<IActionResult> ReissueInvoiceList(List<PUB_ADJ_DETAIL_DTO> p_list)
{
var invBilllist = new List<INVOICE_REPEAT_DTO>();
var result =await _adjservice.CheckImport(p_list);
if(result != "OK")
{
return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName =result });
}
var invBilllist = 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)
{
@ -372,82 +381,206 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!");
}
version = settle.Version;
if (inv != null)
if (inv != null)
{
if (inv.InvoiceState == InvoiceBillState.)
{
if (inv.InvoiceState == InvoiceBillState.)
throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!");
}
if (inv.State == SettleBillState. || inv.State == SettleBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!");
}
var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件
//var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!");
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: itm.InvGroupNum,
contactid: itm.Extend1,//生产号
invbillnum: string.Empty,
partcode: itm.PartCode
));
}
if (inv.State == SettleBillState. || inv.State == SettleBillState.)
}
var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
var priceList = _priceRepository.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.IsCancel == false && p.ClientCode == inv.Site//客户零件号
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")//一次开票重开
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!");
var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
invBilllist.AddRange(ls);
}
var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件
//var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0)
else//二次开票
{
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: itm.InvGroupNum,
contactid: itm.Extend1,//生产号
invbillnum: string.Empty,
partcode: itm.PartCode
));
}
var entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
invBilllist.AddRange(ls);
}
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<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.IsCancel == false && p.ClientCode == inv.Site//客户零件号
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)
}
else
{
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票");
}
}
var invlist=invBilllist.OrderBy(p => p.PartCode).ToList();
return new JsonResult(new { Code = 200, Data= invlist });
}
[HttpPost]
[UnitOfWork(false)]
/// <summary>
/// 发票重开列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual async Task<IActionResult> ReissueInvoiceListExt(List<PUB_ADJ_DETAIL_DTO> p_list)
{
var invBilllist = new List<INVOICE_REPEAT_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($"调整表无数据!");
}
var first = p_list.FirstOrDefault();
var invbillnum = first.InvBillNum;
//var mappingList = await GetMapGroupAsync(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);
var settle = await _bbacMng.GetMainAsync(inv.InvGroupNum);
if (settle == null)
{
throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!");
}
version = settle.Version;
if (inv != null)
{
if (inv.InvoiceState == InvoiceBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!");
}
if (inv.State == SettleBillState. || inv.State == SettleBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!");
}
var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件 //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
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: itm.InvGroupNum,
contactid: itm.Extend1,//生产号
invbillnum: string.Empty,
partcode: itm.PartCode
));
}
}
var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
var priceList = _priceRepository.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.IsCancel == false && p.ClientCode == inv.Site//客户零件号
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")//一次开票重开
{
var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
@ -458,20 +591,20 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
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.DETAIL =invls ;
invBill.RealAmt = realamt;
invBilllist.Add(invBill);
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.DETAIL = invls;
invBill.RealAmt = realamt;
invBilllist.Add(invBill);
}
}
}
@ -499,22 +632,32 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
invBilllist.Add(invBill);
}
}
}
}
else
{
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票");
}
}
else
{
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票");
}
//}
//else
//{
// throw new UserFriendlyException($"不存发票号:{p_invbillnum}对应的结算分组号");
//}
return invBilllist;
return new JsonResult(new { Code = 200, Data = invBilllist });
}
}
}

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

@ -10,6 +10,7 @@ using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Uow;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases;
@ -29,20 +30,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[Route("api/settleaccount/[controller]/[action]")]
public class HBPO_BA_SERVICE : BA_SERVICE
{
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly ADJ_SERVICE _adjservice;
public HBPO_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,
BaseDomainService baseservice,
INormalEfCoreRepository<PriceList, Guid> priceRepository
INormalEfCoreRepository<PriceList, Guid> priceRepository,
ADJ_SERVICE adjservice
)
: base(excelImportService, snowflakeIdGenerator, commonManager, repository, wRepository, sRepository, mRepository, adjRepository, bbacMng, hbpoMng, pubMng, invMng, service,baseservice)
{
_priceRepository= priceRepository;
_adjservice = adjservice;
}
@ -296,6 +299,150 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
//[HttpPost]
//[UnitOfWork(false)]
///// <summary>
///// 发票重开列表
///// </summary>
///// <param name="input"></param>
///// <returns></returns>
//public virtual async Task<IActionResult> ReissueInvoiceList(List<PUB_ADJ_DETAIL_DTO> p_list)
//{
// var result = await _adjservice.CheckImport(p_list);
// if (result != "OK")
// {
// return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result });
// }
// var invBilllist = 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($"调整表无数据!");
// }
// var first = p_list.FirstOrDefault();
// var invbillnum = first.InvBillNum;
// //var mappingList = await GetMapGroupAsync(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);
// var settle = await _bbacMng.GetMainAsync(inv.InvGroupNum);
// if (settle == null)
// {
// throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!");
// }
// version = settle.Version;
// if (inv != null)
// {
// if (inv.InvoiceState == InvoiceBillState.报废)
// {
// throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!");
// }
// if (inv.State == SettleBillState.商务已审核 || inv.State == SettleBillState.已开票)
// {
// throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!");
// }
// var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件
// //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
// if (adjlist != null && adjlist.Count() > 0)
// {
// 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: itm.InvGroupNum,
// contactid: itm.Extend1,//生产号
// invbillnum: string.Empty,
// partcode: itm.PartCode
// ));
// }
// }
// var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据
// var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
// var priceList = _priceRepository.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.IsCancel == false && p.ClientCode == inv.Site//客户零件号
// 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")//一次开票重开
// {
// var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
// var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
// invBilllist.AddRange(ls);
// }
// else//二次开票
// {
// var entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
// var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
// invBilllist.AddRange(ls);
// }
// }
// else
// {
// throw new UserFriendlyException($"不存发票号为:{invbillnum}发票");
// }
// }
// var invlist = invBilllist.OrderBy(p => p.PartCode);
// return new JsonResult(new { Code = 200, Data = invlist });
//}
@ -304,8 +451,204 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual async Task<List<INVOICE_REPEAT_DTO>> ReissueInvoiceList(List<PUB_ADJ_DETAIL_DTO> p_list)
public virtual async Task<IActionResult> ReissueInvoiceList(List<PUB_ADJ_DETAIL_DTO> p_list)
{
var result = await _adjservice.CheckImport(p_list);
if (result != "OK")
{
return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result });
}
var invBilllist = 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($"调整表无数据!");
}
var first = p_list.FirstOrDefault();
var invbillnum = first.InvBillNum;
//var mappingList = await GetMapGroupAsync(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);
var settle = await _hbpoMng.GetMainAsync(inv.InvGroupNum);
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 _hbpoMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件
//var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
bbaclist.Add(new HBPO_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,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: string.Empty,
partcode: itm.PartCode
));
}
}
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<HBPO_CAN_SA_DETAIL>, List<HBPO_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 && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号
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 dtos = q.ToList();
if (dtos != null && dtos.Count > 0)
{
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);
invBilllist.AddRange(ls);
//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.DETAIL = invls;
// invBill.RealAmt = realamt;
// invBilllist.Add(invBill);
//}
}
else//二次开票
{
var entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
invBilllist.AddRange(ls);
//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.DETAIL = invls;
// invBill.RealAmt = realamt;
// invBilllist.Add(invBill);
//}
}
}
}
else
{
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400");
}
var invlist = invBilllist.OrderBy(p => p.PartCode).ToList();
//}
//else
//{
// throw new UserFriendlyException($"不存发票号:{invbillnum}对应的结算分组号");
//}
return new JsonResult(new { Code = 200, Message = "生成成功", Data= invBilllist });
}
[HttpPost]
/// 发票重开列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual async Task<IActionResult> ReissueInvoiceListExt(List<PUB_ADJ_DETAIL_DTO> p_list)
{
var result = await _adjservice.CheckImport(p_list);
if (result != "OK")
{
return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result });
}
var invBilllist = new List<INVOICE_REPEAT_DTO>();
var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list);
@ -465,7 +808,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//{
// throw new UserFriendlyException($"不存发票号:{invbillnum}对应的结算分组号");
//}
return invBilllist;
return new JsonResult(new { Code = 200, Message = "生成成功", Data = invBilllist });
}
@ -474,6 +819,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
}

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

@ -33,19 +33,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly INormalEfCoreRepository<PriceListBJ, Guid> _pricebjRepository;
private readonly ADJ_SERVICE _adjservice;
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,
BaseDomainService baseservice,
INormalEfCoreRepository<PriceList, Guid> priceRepository,
INormalEfCoreRepository<PriceListBJ, Guid> pricebjRepository
INormalEfCoreRepository<PriceListBJ, Guid> pricebjRepository,
ADJ_SERVICE adjservice
) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, wRepository, sRepository, mRepository, adjRepository, bbacMng, hbpoMng, pubMng, invMng, service,baseservice)
{
_priceRepository = priceRepository;
_pricebjRepository = pricebjRepository;
_adjservice= adjservice;
}
@ -331,15 +333,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual async Task<List<INVOICE_REPEAT_DTO>> ReissueInvoiceList(List<PUB_ADJ_DETAIL_DTO> p_list)
public virtual async Task<IActionResult> ReissueInvoiceListExt(List<PUB_ADJ_DETAIL_DTO> p_list)
{
var result = await _adjservice.CheckImport(p_list);
if (result != "OK")
{
return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result });
}
var first = p_list.FirstOrDefault();
var invbillnum = first.InvBillNum;
var invBilllist = new List<INVOICE_REPEAT_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);
if (adjlist == null && adjlist.Count == 0)
@ -371,9 +377,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!", "400");
}
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)
{
foreach (var itm in adjlist)
@ -499,13 +504,190 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//{
// throw new UserFriendlyException($"不存发票号:{invbillnum}对应的结算分组号");
//}
return invBilllist;
return new JsonResult(new { Code = 200, Message = "生成成功", Data = invBilllist });
}
[HttpPost]
public virtual async Task<IActionResult> ReissueInvoiceList(List<PUB_ADJ_DETAIL_DTO> p_list)
{
var result = await _adjservice.CheckImport(p_list);
if (result != "OK")
{
return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result });
}
var first = p_list.FirstOrDefault();
var invbillnum = first.InvBillNum;
var invBilllist = 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);
if (adjlist == null && adjlist.Count == 0)
{
throw new UserFriendlyException($"调整表无数据!", "400");
}
//var mappingList = await GetMapGroupAsync(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);
var settle = await _pubMng.GetMainAsync(inv.InvGroupNum);
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 _pubMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件
//var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
bbaclist.Add(new PUB_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,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: string.Empty,
partcode: itm.PartCode,
pobillnum: string.Empty
));
}
}
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 && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号
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 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);
invBilllist.AddRange(ls.ToList());
//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.DETAIL = invls;
// invBill.RealAmt = realamt;
// invBilllist.Add(invBill);
//}
}
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 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.DETAIL = invls;
// invBill.RealAmt = realamt;
// invBilllist.Add(invBill);
//}
invBilllist.AddRange(ls.ToList());
}
}
}
else
{
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400");
}
//}
//else
//{
// throw new UserFriendlyException($"不存发票号:{invbillnum}对应的结算分组号");
//}
return new JsonResult(new { Code = 200, Message = "生成成功", Data = invBilllist });
}

Loading…
Cancel
Save