|
@ -1282,14 +1282,12 @@ 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>(); |
|
|
var invlist = new List<INVOICE_GRP>(); |
|
|
var invlist = new List<INVOICE_GRP>(); |
|
|
var salist = new List<TDetail>(); |
|
|
var salist = new List<TDetail>(); |
|
|
var adjlist = new List<PUB_ADJ_DETAIL>(); |
|
|
var adjlist = new List<PUB_ADJ_DETAIL>(); |
|
|
|
|
|
|
|
|
foreach (var itm in invoiceMap)//分组影响和
|
|
|
foreach (var itm in invoiceMap)//分组影响和
|
|
|
{ |
|
|
{ |
|
|
var key = itm.Key;//发票票号
|
|
|
var key = itm.Key;//发票票号
|
|
@ -1311,21 +1309,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
adjdetails.Add(detail); |
|
|
adjdetails.Add(detail); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID,p.LU }) |
|
|
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }) |
|
|
|
|
|
.Select(itm => new |
|
|
.Select(itm => new |
|
|
{ |
|
|
{ |
|
|
PartCode = itm.Key.PartCode, |
|
|
PartCode = itm.Key.PartCode, |
|
|
InvGroupNum = itm.Key.InvGroupNum, |
|
|
InvGroupNum = itm.Key.InvGroupNum, |
|
|
LU = itm.Key.PartCode, |
|
|
LU = itm.Key.LU, |
|
|
ContactDocID = itm.Key.ContractDocID, |
|
|
ContactDocID = itm.Key.ContractDocID, |
|
|
Price = itm.Key.Price, |
|
|
Price = itm.Key.Price, |
|
|
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2), |
|
|
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2), |
|
|
Qty = itm.Sum(k => k.Qty), |
|
|
Qty = itm.Sum(k => k.Qty), |
|
|
BeginDate = itm.Key.BeginDate, |
|
|
BeginDate = itm.Key.BeginDate, |
|
|
EndDate = itm.Key.EndDate |
|
|
EndDate = itm.Key.EndDate |
|
|
}) |
|
|
}).ToList(); |
|
|
.ToList(); |
|
|
|
|
|
decimal amt = detailDtos.Sum(k => k.Amt); |
|
|
decimal amt = detailDtos.Sum(k => k.Amt); |
|
|
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2); |
|
|
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2); |
|
|
var mapList = new List<INVOICE_MAP_GROUP>(); |
|
|
var mapList = new List<INVOICE_MAP_GROUP>(); |
|
@ -1373,10 +1369,29 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
detailList.AddRange(_entityDetailList); |
|
|
detailList.AddRange(_entityDetailList); |
|
|
} |
|
|
} |
|
|
var innotls = new List<INVOICE_NOT_SETTLE>(); |
|
|
var innotls = new List<INVOICE_NOT_SETTLE>(); |
|
|
|
|
|
var sq = dtos.Where(p => itm.Value.Contains(p.GroupNum)).GroupBy(p => new { p.LU, p.GroupNum }) |
|
|
|
|
|
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = itm.Key, GroupNum = p.Key.GroupNum }); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var sitm in sq) |
|
|
|
|
|
{ |
|
|
|
|
|
innotls.Add(new INVOICE_NOT_SETTLE( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
version: p_version, |
|
|
|
|
|
invGroupNum: p_InvGroupNum, |
|
|
|
|
|
settleGroupNum: sitm.GroupNum, |
|
|
|
|
|
lU: sitm.LU, |
|
|
|
|
|
lU1: sitm.LU, |
|
|
|
|
|
extend1: string.Empty, |
|
|
|
|
|
extend2: string.Empty, |
|
|
|
|
|
qty: sitm.Qty, |
|
|
|
|
|
p_invbillnum: itm.Key |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
if (p_notlist != null && p_notlist.Count > 0) |
|
|
if (p_notlist != null && p_notlist.Count > 0) |
|
|
{ |
|
|
{ |
|
|
var groupnum = itm.Value; |
|
|
var groupnum = itm.Value; |
|
|
var notls = p_notlist.Where(p=>groupnum.Contains(p.GroupNum)).GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) }); |
|
|
var notls = p_notlist.Where(p => groupnum.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), InvBillNum = itm.Key }); |
|
|
foreach (var nitm in notls) |
|
|
foreach (var nitm in notls) |
|
|
{ |
|
|
{ |
|
|
innotls.Add(new INVOICE_NOT_SETTLE( |
|
|
innotls.Add(new INVOICE_NOT_SETTLE( |
|
@ -1384,12 +1399,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
version: p_version, |
|
|
version: p_version, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
settleGroupNum: nitm.GroupNum, |
|
|
settleGroupNum: nitm.GroupNum, |
|
|
lU: string.Empty, |
|
|
lU: nitm.LU, |
|
|
lU1: nitm.LU, |
|
|
lU1: nitm.LU, |
|
|
extend1: string.Empty, |
|
|
extend1: string.Empty, |
|
|
extend2: string.Empty, |
|
|
extend2: string.Empty, |
|
|
qty: nitm.Qty, |
|
|
qty: nitm.Qty, |
|
|
p_invbillnum:itm.Key |
|
|
p_invbillnum: itm.Key |
|
|
)); |
|
|
)); |
|
|
} |
|
|
} |
|
|
if (innotls.Count > 0) |
|
|
if (innotls.Count > 0) |
|
@ -1408,9 +1423,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
invGroupNum: p_InvGroupNum, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
state: SettleBillState.已开票, |
|
|
state: SettleBillState.已开票, |
|
|
invoiceBillState: InvoiceBillState.正常, |
|
|
invoiceBillState: InvoiceBillState.正常, |
|
|
tax: 0, |
|
|
tax: 0, |
|
|
parent: string.Empty, |
|
|
parent: string.Empty, |
|
|
preTaxDiff: 0, |
|
|
preTaxDiff: 0, |
|
|
taxDiff: 0, |
|
|
taxDiff: 0, |
|
|
clientCode: string.Empty, |
|
|
clientCode: string.Empty, |
|
|
realAmt: 0 |
|
|
realAmt: 0 |
|
@ -1418,18 +1433,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
invlist.Add(invbill); |
|
|
invlist.Add(invbill); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (salist.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var itm in invoiceMap)//分组影响和
|
|
|
|
|
|
{ |
|
|
|
|
|
var key = itm.Key;//发票票号
|
|
|
|
|
|
var ls = itm.Value;//结算分组号列表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string str = $" EXEC [p_Invoice_generation_change] @invbillnum = {"'" + key + "'"},@groupNum = {"'" + string.Join(",", ls) + "'"},@businessType = NULL"; |
|
|
|
|
|
await _repository.DbContext.Database.ExecuteSqlRawAsync(str); |
|
|
|
|
|
} |
|
|
|
|
|
// await _repository.DbContext.BulkUpdateAsync(salist,new BulkConfig() { BatchSize=10000 });
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
{ |
|
|
|
|
|
await _repository.DbContext.BulkUpdateAsync(salist); |
|
|
|
|
|
} |
|
|
|
|
|
if (adjlist.Count > 0) |
|
|
if (adjlist.Count > 0) |
|
|
{ |
|
|
{ |
|
|
await _repository.DbContext.BulkUpdateAsync(adjlist); |
|
|
await _repository.DbContext.BulkUpdateAsync(adjlist); |
|
|