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. 87
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  6. 25
      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. 225
      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 = "税后金额")]
public decimal TaxAmt { get; set; }
[Display(Name = "发票金额")]
[Display(Name = "税额")]
public decimal RealAmt { get; set; }
/// <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)
{
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>();

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", "生成失败,请检查调整表和旧发票内容");
}
[UnitOfWork(false)]
/// <summary>
/// hbpo、jit、备件等
/// </summary>
@ -493,7 +493,7 @@ namespace Win.Sfs.SettleAccount.Bases
}
[UnitOfWork(false)]
/// <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>
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
join p in p_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
select d;
var ls = inner.ToList();
var left = from d in dto1s
join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN }
into temp
from tm in temp.DefaultIfEmpty()//校验错误项
where tm == null
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> ();
string name = string.Empty;
string keyname = string.Empty;

87
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.Application.Services;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
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 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);
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);
@ -288,7 +286,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var errorList =await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType);
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);
@ -343,15 +341,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
[HttpPost]
[UnitOfWork(false)]
/// <summary>
/// 发票重开列表
/// </summary>
/// <param name="input"></param>
/// <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);
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 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//客户零件号
select new TEMP_CAN_SA_DETAIL
{
@ -452,38 +451,54 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
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 tax = inv.Tax;
var amt = entities.Sum(p => p.Amt);
var taxamt =amt+ Math.Round(amt * tax, 2);
var billnum = string.Empty;
invBill.Amt = amt;
invBill.TaxAmt = taxamt;
invBill.Tax = tax;
invBill.BusinessType=inv.BusinessType;
invBill.DETIAL = ls;
if (ls.Count > 0)
{
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//二次开票
{
var entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
var tax = inv.Tax;
var amt = entities.Sum(p => p.Amt);
var taxamt = amt + Math.Round(amt * tax, 2);
var billnum = string.Empty;
invBill.Amt = amt;
invBill.TaxAmt = taxamt;
invBill.Tax = tax;
invBill.BusinessType = inv.BusinessType;
invBill.DETIAL = 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.DETIAL = invls;
invBill.RealAmt = realamt;
invBilllist.Add(invBill);
}
}
}
}
@ -496,7 +511,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//{
// throw new UserFriendlyException($"不存发票号:{p_invbillnum}对应的结算分组号");
//}
return invBill;
return invBilllist;
}

25
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)
{
var main =await _bbacMng.GetMainAsync(invbillNum);
if (main != null)
{
if (main.State != SettleBillState.)
{
return new JsonResult(new { Code = 400, Message = "已创建发票不能重复创建" });
}
if (await _bbacMng.SetForwardState(main, SettleBillState.))
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)
{
var entitys = await _bbacMng.GetDetalListAsync(invbillNum);//可结算
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = await ExportErrorReportAsync(errorList) });
}
if (await _bbacMng.SetForwardState(main, SettleBillState.))
{
var groupNumList = entitys.Select(p => 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 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 notQuery = _notRepository.Where(p => groupNumList.Contains(p.GroupNum)).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
join p in prices on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select new TEMP_CAN_SA_DETAIL
{
SettleBillNum = d.SettleBillNum,
Site = d.Site,
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 });
}
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 = "生成成功" });

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)
{
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

225
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)
{
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 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
select new TEMP_CAN_SA_DETAIL
{
@ -243,7 +243,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType);
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 q = from d in entitys
@ -304,9 +304,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
/// <param name="input"></param>
/// <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);
if (adjlist == null && adjlist.Count == 0)
@ -319,120 +319,153 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//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 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);
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 != null)
if (inv.State == SettleBillState. || inv.State == SettleBillState.)
{
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)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!","400");
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 bbaclist = await _hbpoMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件
//var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0)
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//客户零件号
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")//一次开票重开
{
foreach (var itm in adjlist)
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)
{
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 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);
}
}
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//客户零件号
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)
else//二次开票
{
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
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 ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
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//二次开票
{
var entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
}
}
}
else
{
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票","400");
}
}
else
{
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400");
}
//}
//else
//{
// 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 = "已创建发票不能重复创建" });
}
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.))
{
var entitys = await _hbpoMng.GetDetalListAsync(invbillnum);
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().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 q = from d in dto1s
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 });
}
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 = "生成成功" });

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)
{
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
@ -269,7 +269,7 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
if (checkList.Count > 0)
{
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

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.ComponentModel.DataAnnotations;
using System.Linq;
using System.Management;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@ -110,7 +111,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
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.);
@ -161,7 +162,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var wquery = from itm in AMap
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp
select from tm in temp.DefaultIfEmpty()
from tm in temp.DefaultIfEmpty()
select
new INVOICE_WAIT_DETAIL_BBAC_DTO()
{
@ -181,7 +182,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BeginDate = itm.BeginDate,
EndDate = itm.EndDate,
};
entity.INVOICE_WAIT_DETAIL_BBAC = AMap;
entity.INVOICE_WAIT_DETAIL_BBAC = wquery.ToList();
}
else if (invs.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian)
{
@ -191,7 +192,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var wquery = from itm in BMap
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp
select from tm in temp.DefaultIfEmpty()
from tm in temp.DefaultIfEmpty()
select
new INVOICE_WAIT_DETAIL_BJ_DTO()
{
@ -211,7 +212,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BeginDate = itm.BeginDate,
EndDate = itm.EndDate,
};
entity.INVOICE_WAIT_DETAIL_BJ = BMap;
entity.INVOICE_WAIT_DETAIL_BJ = wquery.ToList();
}
else
{
@ -221,7 +222,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var wquery = from itm in wdtos
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp
select from tm in temp.DefaultIfEmpty()
from tm in temp.DefaultIfEmpty()
select
new INVOICE_WAIT_DETAIL_DTO()
{
@ -243,7 +244,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
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);
@ -437,6 +438,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (number + 1 > lineN)
{
INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO();
entity.RealInvBillNum = lsC[number].RealInvBillNum;
entity.InvDate = lsC[number].InvDate;
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<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,
TaskJobService service,
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)
{
_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 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);
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 q = from d in entitys
@ -161,6 +180,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
{
await ReissueFirstInvoice(publist, adjlist, dtos, version, invbillnum);
}
else//二次开票
{
@ -240,8 +264,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
invbillnum: string.Empty,
partcode:itm.PartCode,
pobillnum:string.Empty
));
}
}
@ -249,12 +271,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
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.ToList();//价格单
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType);
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 q = from d in entitys
@ -310,11 +331,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
/// <param name="input"></param>
/// <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 invbillnum=first.InvBillNum;
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);
@ -326,121 +350,156 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//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 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);
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 != null)
if (inv.State == SettleBillState. || inv.State == SettleBillState.)
{
if (inv.InvoiceState == InvoiceBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!", "400");
}
if (inv.State == SettleBillState. || inv.State == SettleBillState.)
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!", "400");
}
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)
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)
{
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,
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,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: string.Empty,
partcode: itm.PartCode,
pobillnum:string.Empty
));
}
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//客户零件号
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 entitys = bbaclist;//合并库存调整单和就发票可结算明细数据
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
};
var dtos = q.ToList();
if (dtos != null && dtos.Count > 0)
{
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
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
{
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);
ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
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
{
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400");
}
}
else
{
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400");
}
//}
//else
//{
// 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 = "已创建发票不能重复创建" });
}
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 groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
List<PriceList> priceList = new List<PriceList>();
if (main.BusinessType == EnumBusinessType.BeiJian)
var priceListbj = _pricebjRepository.ToList();//价格单
foreach (var itm in priceListbj)
{
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, main.BusinessType);//校验生成规则
if (errorList.Count() > 0)
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errorList) });
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, 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 q = from d in dto1s
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")//一次开票
{
await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, new List<TEMP_NOT_SA_DETAIL>(), main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
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 });
}
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)
{
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
@ -281,7 +281,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
if (checkList.Count > 0)
{
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
@ -311,7 +311,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
if (checkList.Count > 0)
{
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
@ -342,7 +342,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
if (checkList.Count > 0)
{
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

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)
{
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)
{

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();
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
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 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
from edi in ediDetailGroup
where se.PN == edi.PN && se.LU == edi.LU
@ -52,7 +49,6 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
from keyCode in keyCodes
where edi.PN == keyCode.PN && edi.LU == keyCode.LU && edi.IsDeleted == false && edi.IsHaveSeData == false
select edi;
var seDetails = seDetailsQuery.Take(5000).ToList();
var ediDetails = ediDetailsQuery.Take(5000).ToList();
seDetails.ForEach(t => t.IsHaveEdiData = true);
@ -92,7 +88,6 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
//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();
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);

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)
{
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)
{

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)
{
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)
{

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.Repositories;
using Volo.Abp.Domain.Services;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices;
@ -261,7 +262,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
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)
where TDetail : SA_CAN_BASE
{
@ -315,35 +316,32 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
if (invoiceMap.Keys.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var invlist = new List<INVOICE_GRP>();
var salist = new List<TDetail>();
var adjlist = new List<PUB_ADJ_DETAIL>();
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
//反向查找结算数据
var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList();
foreach (var detail in invdetails)
{
detail.InvbillNum = key;
salist.Add(detail);
}
if (!string.IsNullOrEmpty(p_parentInvBillNum))
{
//反向查找调整数据
var adjdetails = p_adjlist.Where(p => ls.Contains(p.GroupNum)).ToList();
foreach (var detail in adjdetails)
{
detail.InvBillNum = key;
adjdetails.Add(detail);
}
}
//foreach (var detail in invdetails)
//{
// detail.InvbillNum = key;
// salist.Add(detail);
//}
//if (!string.IsNullOrEmpty(p_parentInvBillNum))
//{
// //反向查找调整数据
// var adjdetails = p_adjlist.Where(p => ls.Contains(p.GroupNum)).ToList();
// foreach (var detail in adjdetails)
// {
// detail.InvBillNum = key;
// 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 })
.Select(itm => new
@ -405,31 +403,31 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
detailList.AddRange(_entityDetailList);
}
var innotls = new List<INVOICE_NOT_SETTLE>();
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) });
foreach (var nitm in notls)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty,
p_invbillnum:key
//var innotls = new List<INVOICE_NOT_SETTLE>();
//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) });
// foreach (var nitm in notls)
// {
// innotls.Add(new INVOICE_NOT_SETTLE(
// guid: GuidGenerator.Create(),
// version: p_version,
// invGroupNum: p_InvGroupNum,
// settleGroupNum: nitm.GroupNum,
// lU: string.Empty,
// lU1: nitm.LU,
// extend1: string.Empty,
// extend2: string.Empty,
// qty: nitm.Qty,
// p_invbillnum:key
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
}
// ));
// }
// if (innotls.Count > 0)
// {
// notDetialList.AddRange(innotls);
// }
//}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,

Loading…
Cancel
Save