|
@ -773,7 +773,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
var involdList = invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList(); |
|
|
var involdList = invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList(); |
|
|
var involdname = involdList.Select(p => p.InvbillNum); |
|
|
var involdname = involdList.Select(p => p.InvbillNum); |
|
|
var adjlist = _adjRepository.Where(p => involdname.Contains(p.InvBillNum)); |
|
|
var adjlist = _adjRepository.Where(p => involdname.Contains(p.InvBillNum)); |
|
|
|
|
|
|
|
|
if (adjlist != null && adjlist.Count() > 0) |
|
|
if (adjlist != null && adjlist.Count() > 0) |
|
|
{ |
|
|
{ |
|
|
foreach (var itm in adjlist) |
|
|
foreach (var itm in adjlist) |
|
@ -799,7 +798,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
); |
|
|
); |
|
|
detail.RealPartCode = itm.RealPartCode;//厂内替换零件号
|
|
|
detail.RealPartCode = itm.RealPartCode;//厂内替换零件号
|
|
|
detail.ErpLoc = itm.ErpLoc;//ERP库位
|
|
|
detail.ErpLoc = itm.ErpLoc;//ERP库位
|
|
|
|
|
|
|
|
|
entityList.Add(detail); |
|
|
entityList.Add(detail); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -878,7 +876,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
extend3: string.Empty, |
|
|
extend3: string.Empty, |
|
|
extend4: itm.PartCode |
|
|
extend4: itm.PartCode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
); |
|
|
); |
|
|
entity.RELU =string.IsNullOrEmpty(itm.RealPartCode)?itm.PartCode:itm.RealPartCode;//厂内替换零件号
|
|
|
entity.RELU =string.IsNullOrEmpty(itm.RealPartCode)?itm.PartCode:itm.RealPartCode;//厂内替换零件号
|
|
|
entity.Extend2 = itm.ErpLoc;//ERP库位
|
|
|
entity.Extend2 = itm.ErpLoc;//ERP库位
|
|
@ -1353,8 +1350,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
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>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<string> lsby = new List<string>(); |
|
|
List<string> lsby = new List<string>(); |
|
|
var grouplist = p_list.Select(p => p.GroupNum).Distinct().ToList();//可结分组
|
|
|
var grouplist = p_list.Select(p => p.GroupNum).Distinct().ToList();//可结分组
|
|
|
lsby.AddRange(grouplist); |
|
|
lsby.AddRange(grouplist); |
|
@ -1590,12 +1585,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
/// <param name="p_version">版本号</param>
|
|
|
/// <param name="p_version">版本号</param>
|
|
|
/// <param name="p_InvGroupNum">发票分组</param>
|
|
|
/// <param name="p_InvGroupNum">发票分组</param>
|
|
|
/// <param name="p_parentInvBillNum">原发票号</param>
|
|
|
/// <param name="p_parentInvBillNum">原发票号</param>
|
|
|
public async Task<List<string>> MakeInvoice<TDetail>(List<TDetail> details,List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType, bool p_first) where TDetail : SA_CAN_BASE |
|
|
public async Task<List<string>> MakeInvoice<TDetail>(List<TDetail> details, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType, bool p_first) where TDetail : SA_CAN_BASE |
|
|
{ |
|
|
{ |
|
|
List<string> _invls = new List<string>(); |
|
|
List<string> _invls = new List<string>(); |
|
|
var groups1 = dtos.GroupBy(p => new { p.PartCode,p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV |
|
|
var groups1 = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV |
|
|
{ |
|
|
{ |
|
|
PartCode=p.Key.PartCode, |
|
|
PartCode = p.Key.PartCode, |
|
|
LU = p.Key.LU, |
|
|
LU = p.Key.LU, |
|
|
Amt = p.Sum(itm => itm.Amt), |
|
|
Amt = p.Sum(itm => itm.Amt), |
|
|
Qty = p.Sum(itm => itm.Qty), |
|
|
Qty = p.Sum(itm => itm.Qty), |
|
@ -1604,9 +1599,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
BeginDate = p.Key.BeginDate, |
|
|
BeginDate = p.Key.BeginDate, |
|
|
EndDate = p.Key.EndDate |
|
|
EndDate = p.Key.EndDate |
|
|
}).ToList();//汇总记录不出现重复值
|
|
|
}).ToList();//汇总记录不出现重复值
|
|
|
var groups = dtos.GroupBy(p => new {p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV |
|
|
var groups = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV |
|
|
{ |
|
|
{ |
|
|
PartCode=p.Key.PartCode, |
|
|
PartCode = p.Key.PartCode, |
|
|
LU = p.Key.LU, |
|
|
LU = p.Key.LU, |
|
|
Amt = p.Sum(itm => itm.Amt), |
|
|
Amt = p.Sum(itm => itm.Amt), |
|
|
Qty = p.Sum(itm => itm.Qty), |
|
|
Qty = p.Sum(itm => itm.Qty), |
|
@ -1619,7 +1614,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
foreach (var group in groups) |
|
|
foreach (var group in groups) |
|
|
{ |
|
|
{ |
|
|
int i = groups1.Count(p => p.LU == group.LU |
|
|
int i = groups1.Count(p => p.LU == group.LU |
|
|
&& p.PartCode==group.PartCode |
|
|
&& p.PartCode == group.PartCode |
|
|
&& p.BeginDate == group.BeginDate |
|
|
&& p.BeginDate == group.BeginDate |
|
|
&& p.EndDate == group.EndDate |
|
|
&& p.EndDate == group.EndDate |
|
|
&& p.ContractDocID == group.ContractDocID |
|
|
&& p.ContractDocID == group.ContractDocID |
|
@ -1644,7 +1639,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
&& group.BeginDate == group1.BeginDate |
|
|
&& group.BeginDate == group1.BeginDate |
|
|
&& group.EndDate == group1.EndDate |
|
|
&& group.EndDate == group1.EndDate |
|
|
&& group1.ContractDocID == group.ContractDocID |
|
|
&& group1.ContractDocID == group.ContractDocID |
|
|
&& group1.PartCode== group1.PartCode |
|
|
&& group1.PartCode == group1.PartCode |
|
|
) |
|
|
) |
|
|
{ |
|
|
{ |
|
|
tempList.Add(group1); |
|
|
tempList.Add(group1); |
|
@ -1666,13 +1661,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
invoiceMap.Add(invoiceBillNum, tempList);//每张发票的明细记录
|
|
|
invoiceMap.Add(invoiceBillNum, tempList);//每张发票的明细记录
|
|
|
var query = from itm in groups1 |
|
|
var query = from itm in groups1 |
|
|
join itm1 in tempList |
|
|
join itm1 in tempList |
|
|
on new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID ,itm.PartCode} |
|
|
on new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID, itm.PartCode } |
|
|
equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID,itm1.PartCode } into temp |
|
|
equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode } into temp |
|
|
from tm in temp |
|
|
from tm in temp |
|
|
where tm == null |
|
|
where tm == null |
|
|
select new TMEP_INV |
|
|
select new TMEP_INV |
|
|
{ |
|
|
{ |
|
|
PartCode= itm.PartCode, |
|
|
PartCode = itm.PartCode, |
|
|
LU = itm.LU, |
|
|
LU = itm.LU, |
|
|
Amt = itm.Amt, |
|
|
Amt = itm.Amt, |
|
|
Qty = itm.Qty, |
|
|
Qty = itm.Qty, |
|
@ -1699,8 +1694,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
//更新结算记录更新
|
|
|
//更新结算记录更新
|
|
|
var query = from itm in dtos |
|
|
var query = from itm in dtos |
|
|
join itm1 in ls |
|
|
join itm1 in ls |
|
|
on new { LU=itm.LU,itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU,itm1.PartCode, itm1.BeginDate, itm1.EndDate } |
|
|
on new { LU = itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate } |
|
|
join itm2 in details on new { itm.LU,itm.PartCode,itm.PN, itm.SettleDate } equals new { itm2.LU,itm2.PartCode,itm2.PN,itm2.SettleDate } |
|
|
join itm2 in details on new { itm.LU, itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.LU, itm2.PartCode, itm2.PN, itm2.SettleDate } |
|
|
select itm2; |
|
|
select itm2; |
|
|
foreach (var itm in query) |
|
|
foreach (var itm in query) |
|
|
{ |
|
|
{ |
|
@ -1711,7 +1706,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
var query1 = from itm in dtos |
|
|
var query1 = from itm in dtos |
|
|
join itm1 in ls |
|
|
join itm1 in ls |
|
|
on new {LU= itm.LU,itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU,itm1.PartCode, itm1.BeginDate, itm1.EndDate } |
|
|
on new { LU = itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate } |
|
|
join itm2 in p_adjlist on new { itm.LU, itm.SettleDate } equals new { itm2.LU, itm2.SettleDate } |
|
|
join itm2 in p_adjlist on new { itm.LU, itm.SettleDate } equals new { itm2.LU, itm2.SettleDate } |
|
|
select itm2; |
|
|
select itm2; |
|
|
|
|
|
|
|
@ -1721,7 +1716,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
adjlist.Add(itm); |
|
|
adjlist.Add(itm); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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) |
|
|
{ |
|
|
{ |
|
@ -1740,8 +1734,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
extend2: string.Empty, |
|
|
extend2: string.Empty, |
|
|
beginDate: detail.BeginDate, |
|
|
beginDate: detail.BeginDate, |
|
|
endDate: detail.EndDate, |
|
|
endDate: detail.EndDate, |
|
|
partcode:detail.PartCode |
|
|
partcode: detail.PartCode |
|
|
|
|
|
|
|
|
)); |
|
|
)); |
|
|
} |
|
|
} |
|
|
if (_entityDetailList.Count > 0) |
|
|
if (_entityDetailList.Count > 0) |
|
@ -1766,10 +1759,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
invoiceBillState: InvoiceBillState.正常, |
|
|
invoiceBillState: InvoiceBillState.正常, |
|
|
tax: 0.13m, |
|
|
tax: 0.13m, |
|
|
parent: p_parentInvBillNum, |
|
|
parent: p_parentInvBillNum, |
|
|
preTaxDiff:0, |
|
|
preTaxDiff: 0, |
|
|
taxDiff:0, |
|
|
taxDiff: 0, |
|
|
clientCode:string.Empty, |
|
|
clientCode: string.Empty, |
|
|
realAmt:0 |
|
|
realAmt: 0 |
|
|
|
|
|
|
|
|
); |
|
|
); |
|
|
invbill.Site = dtos.FirstOrDefault().Site; |
|
|
invbill.Site = dtos.FirstOrDefault().Site; |
|
@ -1954,10 +1947,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
detailList.AddRange(_entityDetailList); |
|
|
detailList.AddRange(_entityDetailList); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
string site = dtos.FirstOrDefault().Site; |
|
|
string site = dtos.FirstOrDefault().Site; |
|
|
string clientCode = string.Empty; |
|
|
string clientCode = string.Empty; |
|
|
|
|
|
|
|
|
switch (site) |
|
|
switch (site) |
|
|
{ |
|
|
{ |
|
|
case "1040": |
|
|
case "1040": |
|
@ -1993,32 +1984,30 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
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) |
|
|
{ |
|
|
{ |
|
|
await _repository.DbContext.BulkUpdateAsync(salist); |
|
|
await _repository.DbContext.BulkUpdateAsync(salist); |
|
|
} |
|
|
} |
|
|
if (adjlist.Count > 0) |
|
|
if(adjlist.Count > 0) |
|
|
{ |
|
|
{ |
|
|
await _repository.DbContext.BulkUpdateAsync(adjlist); |
|
|
await _repository.DbContext.BulkUpdateAsync(adjlist); |
|
|
} |
|
|
} |
|
|
if (p_notlist.Count > 0) |
|
|
if(p_notlist.Count > 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var innotls = new List<INVOICE_NOT_SETTLE>(); |
|
|
var innotls = new List<INVOICE_NOT_SETTLE>(); |
|
|
var notls = p_notlist.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.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) |
|
|
foreach (var nitm in notls) |
|
|
{ |
|
|
{ |
|
|
innotls.Add(new INVOICE_NOT_SETTLE( |
|
|
innotls.Add(new INVOICE_NOT_SETTLE( |
|
|
guid: GuidGenerator.Create(), |
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
|
|
|
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, |
|
@ -2031,7 +2020,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
} |
|
|
} |
|
|
_invls = invlist.Select(p => p.InvbillNum).ToList(); |
|
|
_invls = invlist.Select(p => p.InvbillNum).ToList(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return _invls; |
|
|
return _invls; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -2099,9 +2087,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_repository.DbContext.BulkUpdate(new List<INVOICE_GRP> { inv }); |
|
|
_repository.DbContext.BulkUpdate(new List<INVOICE_GRP> { inv }); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -2198,7 +2183,6 @@ 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 }) |
|
|
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 |
|
|
{ |
|
|
{ |
|
@ -2213,7 +2197,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
EndDate = itm.Key.EndDate |
|
|
EndDate = itm.Key.EndDate |
|
|
}) |
|
|
}) |
|
|
.ToList(); |
|
|
.ToList(); |
|
|
|
|
|
|
|
|
var query = from inv1 in invdetails |
|
|
var query = from inv1 in invdetails |
|
|
join dto1 in dtos on |
|
|
join dto1 in dtos on |
|
|
new { inv1.LU,inv1.PartCode, inv1.PN,inv1.Id } equals new { dto1.LU,dto1.PartCode, dto1.PN ,dto1.Id |
|
|
new { inv1.LU,inv1.PartCode, inv1.PN,inv1.Id } equals new { dto1.LU,dto1.PartCode, dto1.PN ,dto1.Id |
|
|