|
@ -1,6 +1,7 @@ |
|
|
using EFCore.BulkExtensions; |
|
|
using EFCore.BulkExtensions; |
|
|
using EmptyFiles; |
|
|
using EmptyFiles; |
|
|
using Hangfire; |
|
|
using Hangfire; |
|
|
|
|
|
using Hangfire.Storage.Monitoring; |
|
|
using Microsoft.AspNetCore.Razor.Language.Intermediate; |
|
|
using Microsoft.AspNetCore.Razor.Language.Intermediate; |
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax; |
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax; |
|
@ -43,6 +44,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
private readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _groupRepository; |
|
|
private readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _groupRepository; |
|
|
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _detailRepository; |
|
|
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _detailRepository; |
|
|
|
|
|
|
|
|
|
|
|
private readonly INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> _nothbpoRepository; |
|
|
|
|
|
|
|
|
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _notRepository; |
|
|
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _notRepository; |
|
|
private readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _adjRepository; |
|
|
private readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _adjRepository; |
|
@ -66,7 +68,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> detailRepository, |
|
|
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> detailRepository, |
|
|
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> notRepository, |
|
|
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> notRepository, |
|
|
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository, |
|
|
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository, |
|
|
INormalEfCoreRepository<CodeSetting, Guid> codesetRepository |
|
|
INormalEfCoreRepository<CodeSetting, Guid> codesetRepository, |
|
|
|
|
|
INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> nothbpoRepository |
|
|
) |
|
|
) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
@ -83,6 +86,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
_pdhbpoRepository=pdhbpoRepository; |
|
|
_pdhbpoRepository=pdhbpoRepository; |
|
|
_pdpubRepository =pdpubRepository; |
|
|
_pdpubRepository =pdpubRepository; |
|
|
_codesetRepository = codesetRepository; |
|
|
_codesetRepository = codesetRepository; |
|
|
|
|
|
_nothbpoRepository = nothbpoRepository; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public INV_MNG() |
|
|
public INV_MNG() |
|
@ -564,7 +568,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
version: itm.Version, |
|
|
version: itm.Version, |
|
|
billNum: itm.InvbillNum, |
|
|
billNum: itm.InvbillNum, |
|
|
lU: itm.LU, |
|
|
lU: itm.LU, |
|
|
|
|
|
|
|
|
rELU: string.Empty, |
|
|
rELU: string.Empty, |
|
|
pN: itm.PN, |
|
|
pN: itm.PN, |
|
|
rEPN: string.Empty, |
|
|
rEPN: string.Empty, |
|
@ -579,9 +582,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
extend3: string.Empty, |
|
|
extend3: string.Empty, |
|
|
extend4: itm.PartCode, |
|
|
extend4: itm.PartCode, |
|
|
p_businessType:itm.BusinessType |
|
|
p_businessType:itm.BusinessType |
|
|
|
|
|
|
|
|
);//厂内实际零件号
|
|
|
);//厂内实际零件号
|
|
|
|
|
|
|
|
|
detail.RELU = string.IsNullOrEmpty(itm.RealPartCode) ? itm.PartCode : itm.RealPartCode;//厂内替换零件号
|
|
|
detail.RELU = string.IsNullOrEmpty(itm.RealPartCode) ? itm.PartCode : itm.RealPartCode;//厂内替换零件号
|
|
|
detail.Extend2 = itm.ErpLoc;//ERP库位
|
|
|
detail.Extend2 = itm.ErpLoc;//ERP库位
|
|
|
bbacDetail.Add(detail); |
|
|
bbacDetail.Add(detail); |
|
@ -942,7 +943,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
await _bbacMng.SetNewState(groupbillNum); |
|
|
await _bbacMng.SetNewState(groupbillNum); |
|
|
} |
|
|
} |
|
|
else if (first.BusinessType == EnumBusinessType.JisHBPO) |
|
|
else if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType==EnumBusinessType.JisHBPO) |
|
|
{ |
|
|
{ |
|
|
await _hbpoMng.SetNewState(groupbillNum); |
|
|
await _hbpoMng.SetNewState(groupbillNum); |
|
|
} |
|
|
} |
|
@ -962,38 +963,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//public INVOICE_GRP FindAncestor(List<INVOICE_GRP> p_list,INVOICE_GRP currentNode, string invbillNum)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// if (currentNode == null || currentNode.InvbillNum == invbillNum)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// return currentNode;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// var parentNode=p_list.Where(p => p.InvbillNum == currentNode.InvbillNum).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
// return FindAncestor(p_list, parentNode, invbillNum);
|
|
|
|
|
|
//}
|
|
|
|
|
|
//public virtual async Task<bool> IsSplittingMultipleInvoices(List<string> invs, string p_invbillnum)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// _repository.Where(p=>)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 返回到财务审核状态
|
|
|
/// 返回到财务审核状态
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -1690,7 +1659,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
var key = group.Key;//发票票号
|
|
|
var key = group.Key;//发票票号
|
|
|
var ls = group.Value;//发票明细
|
|
|
var ls = group.Value;//发票明细
|
|
|
|
|
|
|
|
|
//更新结算记录更新
|
|
|
//更新结算记录更新
|
|
|
var query = from itm in dtos |
|
|
var query = from itm in dtos |
|
|
join itm1 in ls |
|
|
join itm1 in ls |
|
@ -1716,6 +1684,57 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
adjlist.Add(itm); |
|
|
adjlist.Add(itm); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (p_first == true)//第一次开票需要有分组号
|
|
|
|
|
|
{ |
|
|
|
|
|
var mapList = new List<INVOICE_MAP_GROUP>(); |
|
|
|
|
|
var invoiceGroupList = query.GroupBy(p => new { p.GroupNum, p.PN }).Select(p => p.FirstOrDefault()).ToList(); |
|
|
|
|
|
foreach (var groupnum in invoiceGroupList)//一次开票可结
|
|
|
|
|
|
{ |
|
|
|
|
|
mapList.Add(new INVOICE_MAP_GROUP( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
version: p_version, |
|
|
|
|
|
invbillNum: key, |
|
|
|
|
|
invGroupNum: p_InvGroupNum, |
|
|
|
|
|
settleGroupNum: groupnum.GroupNum, |
|
|
|
|
|
amt: 0, |
|
|
|
|
|
extend1: groupnum.PN, |
|
|
|
|
|
extend2: string.Empty |
|
|
|
|
|
) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
if (mapList.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
groupList.AddRange(mapList); |
|
|
|
|
|
} |
|
|
|
|
|
var notsettle= _nothbpoRepository.Where(p => p.SettleBillNum == p_InvGroupNum);//一次开票时查找不可结数据,追加需求
|
|
|
|
|
|
|
|
|
|
|
|
if (notsettle != null && notsettle.Count() > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var innotls = new List<INVOICE_NOT_SETTLE>(); |
|
|
|
|
|
foreach (var nitm in notsettle) |
|
|
|
|
|
{ |
|
|
|
|
|
innotls.Add(new INVOICE_NOT_SETTLE( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
version: p_version, |
|
|
|
|
|
invGroupNum: p_InvGroupNum, |
|
|
|
|
|
settleGroupNum: nitm.GroupNum, |
|
|
|
|
|
lU: nitm.LU, |
|
|
|
|
|
lU1: nitm.LU, |
|
|
|
|
|
extend1: "不可结算", |
|
|
|
|
|
extend2: string.Empty, |
|
|
|
|
|
qty: nitm.Qty, |
|
|
|
|
|
p_invbillnum: string.Empty |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
if (innotls.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
notDetialList.AddRange(innotls); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
//invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|
foreach (var detail in ls) |
|
|
foreach (var detail in ls) |
|
|
{ |
|
|
{ |
|
@ -1744,8 +1763,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
decimal amt = detailList.Sum(k => k.Amt);//金额
|
|
|
decimal amt = detailList.Sum(k => k.Amt);//金额
|
|
|
decimal txtAmt = detailList.Sum(k => k.Amt) + Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税后金额
|
|
|
decimal txtAmt = detailList.Sum(k => k.Amt) + Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税后金额
|
|
|
decimal realAmt = Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税额
|
|
|
decimal realAmt = Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税额
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var invbill = new INVOICE_GRP |
|
|
var invbill = new INVOICE_GRP |
|
|
(guid: GuidGenerator.Create(), |
|
|
(guid: GuidGenerator.Create(), |
|
|
realnvBillNum: string.Empty, |
|
|
realnvBillNum: string.Empty, |
|
@ -1763,14 +1780,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
taxDiff: 0, |
|
|
taxDiff: 0, |
|
|
clientCode: "C004", |
|
|
clientCode: "C004", |
|
|
realAmt: realAmt |
|
|
realAmt: realAmt |
|
|
|
|
|
|
|
|
); |
|
|
); |
|
|
invbill.Site = dtos.FirstOrDefault().Site; |
|
|
invbill.Site = dtos.FirstOrDefault().Site; |
|
|
invbill.CreationTime = DateTime.Now; |
|
|
invbill.CreationTime = DateTime.Now; |
|
|
invlist.Add(invbill); |
|
|
invlist.Add(invbill); |
|
|
} |
|
|
} |
|
|
await _repository.DbContext.BulkInsertAsync(invlist); |
|
|
await _repository.DbContext.BulkInsertAsync(invlist); |
|
|
//await _repository.DbContext.BulkInsertAsync(groupList);
|
|
|
await _repository.DbContext.BulkInsertAsync(groupList); |
|
|
await _repository.DbContext.BulkInsertAsync(detailList); |
|
|
await _repository.DbContext.BulkInsertAsync(detailList); |
|
|
if (salist.Count > 0) |
|
|
if (salist.Count > 0) |
|
|
{ |
|
|
{ |
|
@ -1780,7 +1796,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
await _repository.DbContext.BulkUpdateAsync(adjlist); |
|
|
await _repository.DbContext.BulkUpdateAsync(adjlist); |
|
|
} |
|
|
} |
|
|
//await _repository.DbContext.BulkInsertAsync(notDetialList);
|
|
|
await _repository.DbContext.BulkInsertAsync(notDetialList); |
|
|
_invls = invlist.Select(p => p.InvbillNum).ToList(); |
|
|
_invls = invlist.Select(p => p.InvbillNum).ToList(); |
|
|
} |
|
|
} |
|
|
return _invls; |
|
|
return _invls; |
|
@ -1820,7 +1836,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV"); |
|
|
invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
|
|
|
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
|
|
|
List<string> List = new List<string>(); |
|
|
List<string> List = new List<string>(); |
|
|
decimal sum = itm.Value;//初始分组合计金额
|
|
|
decimal sum = itm.Value;//初始分组合计金额
|
|
@ -1857,7 +1872,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
} |
|
|
} |
|
|
if (invoiceMap.Keys.Count > 0) |
|
|
if (invoiceMap.Keys.Count > 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var groupList = new List<INVOICE_MAP_GROUP>(); |
|
|
var groupList = new List<INVOICE_MAP_GROUP>(); |
|
|
var notDetialList = new List<INVOICE_NOT_SETTLE>(); |
|
|
var notDetialList = new List<INVOICE_NOT_SETTLE>(); |
|
|
var detailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|
var detailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|