|
@ -959,8 +959,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
List<string> _invls = new List<string>(); |
|
|
List<string> _invls = new List<string>(); |
|
|
var groups1 = dtos.GroupBy(p => new { 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, |
|
|
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), |
|
@ -969,8 +970,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.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, |
|
|
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), |
|
@ -983,6 +985,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.BeginDate == group.BeginDate |
|
|
&& p.BeginDate == group.BeginDate |
|
|
&& p.EndDate == group.EndDate |
|
|
&& p.EndDate == group.EndDate |
|
|
&& p.ContractDocID == group.ContractDocID |
|
|
&& p.ContractDocID == group.ContractDocID |
|
@ -996,6 +999,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
foreach (var group1 in groups1) |
|
|
foreach (var group1 in groups1) |
|
|
{ |
|
|
{ |
|
|
if (group.LU == group1.LU |
|
|
if (group.LU == group1.LU |
|
|
|
|
|
&& group.PartCode == group1.PartCode |
|
|
&& group.BeginDate == group1.BeginDate |
|
|
&& group.BeginDate == group1.BeginDate |
|
|
&& group.EndDate == group1.EndDate |
|
|
&& group.EndDate == group1.EndDate |
|
|
&& group1.ContractDocID == group.ContractDocID |
|
|
&& group1.ContractDocID == group.ContractDocID |
|
@ -1020,12 +1024,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 } |
|
|
on new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID ,itm.PartCode} |
|
|
equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID } 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 |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
LU = itm.LU, |
|
|
LU = itm.LU, |
|
|
Amt = itm.Amt, |
|
|
Amt = itm.Amt, |
|
|
Qty = itm.Qty, |
|
|
Qty = itm.Qty, |
|
@ -1050,11 +1055,11 @@ 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 |
|
|
on new { itm.LU, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate } |
|
|
on new { itm.LU,itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU,itm1.PartCode, itm1.BeginDate, itm1.EndDate } |
|
|
join itm2 in p_list on new { itm.LU, itm.SettleDate } equals new { itm2.LU, itm2.SettleDate } |
|
|
join itm2 in p_list on new { itm.PartCode, itm.SettleDate } equals new { itm2.PartCode, itm2.SettleDate } |
|
|
select itm2; |
|
|
select itm2; |
|
|
foreach (var itm in query) |
|
|
foreach (var itm in query) |
|
|
{ |
|
|
{ |
|
@ -1063,10 +1068,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
} |
|
|
} |
|
|
if (!string.IsNullOrEmpty(p_parentInvBillNum)) |
|
|
if (!string.IsNullOrEmpty(p_parentInvBillNum)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
//反向查找调整数据
|
|
|
var query1 = from itm in dtos |
|
|
var query1 = from itm in dtos |
|
|
join itm1 in ls |
|
|
join itm1 in ls |
|
|
on new { itm.LU, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate } |
|
|
on new { itm.LU,itm.PartCode ,itm.BeginDate, itm.EndDate } equals new { itm1.LU,itm1.PartCode, itm1.BeginDate, itm1.EndDate } |
|
|
join itm2 in p_ajdlist on new { itm.LU, itm.SettleDate } equals new { itm2.LU, itm2.SettleDate } |
|
|
join itm2 in p_ajdlist on new { itm.PartCode, itm.SettleDate } equals new { itm2.PartCode, itm2.SettleDate } |
|
|
select itm2; |
|
|
select itm2; |
|
|
|
|
|
|
|
|
foreach (var itm in query1) |
|
|
foreach (var itm in query1) |
|
@ -1183,8 +1189,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
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.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, |
|
|
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), |
|
@ -1193,8 +1200,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.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, |
|
|
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), |
|
@ -1207,6 +1215,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.BeginDate == group.BeginDate |
|
|
&& p.BeginDate == group.BeginDate |
|
|
&& p.EndDate == group.EndDate |
|
|
&& p.EndDate == group.EndDate |
|
|
&& p.ContractDocID == group.ContractDocID |
|
|
&& p.ContractDocID == group.ContractDocID |
|
@ -1231,6 +1240,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 |
|
|
) |
|
|
) |
|
|
{ |
|
|
{ |
|
|
tempList.Add(group1); |
|
|
tempList.Add(group1); |
|
@ -1249,15 +1259,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
sum += group1.Amt; |
|
|
sum += group1.Amt; |
|
|
tempList.Add(group1); |
|
|
tempList.Add(group1); |
|
|
} |
|
|
} |
|
|
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 } |
|
|
on new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID ,itm.PartCode} |
|
|
equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID } 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, |
|
|
LU = itm.LU, |
|
|
LU = itm.LU, |
|
|
Amt = itm.Amt, |
|
|
Amt = itm.Amt, |
|
|
Qty = itm.Qty, |
|
|
Qty = itm.Qty, |
|
@ -1284,8 +1295,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 { itm.LU, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate } |
|
|
on new { LU=itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate } |
|
|
join itm2 in details on new { itm.LU, itm.SettleDate } equals new { itm2.LU, itm2.SettleDate } |
|
|
join itm2 in details on new { itm.LU,itm.PartCode, itm.SettleDate } equals new { itm2.LU,itm2.PartCode,itm2.SettleDate } |
|
|
select itm2; |
|
|
select itm2; |
|
|
foreach (var itm in query) |
|
|
foreach (var itm in query) |
|
|
{ |
|
|
{ |
|
@ -1296,7 +1307,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 { itm.LU, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate } |
|
|
on new {LU= itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, 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; |
|
|
|
|
|
|
|
@ -1477,6 +1488,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
var key = itm.Key;//发票票号
|
|
|
var key = itm.Key;//发票票号
|
|
|
var ls = itm.Value;//结算分组号列表
|
|
|
var ls = itm.Value;//结算分组号列表
|
|
|
|
|
|
//反向查找结算数据
|
|
|
var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList(); |
|
|
var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList(); |
|
|
foreach (var detail in invdetails) |
|
|
foreach (var detail in invdetails) |
|
|
{ |
|
|
{ |
|
@ -1485,6 +1497,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
} |
|
|
} |
|
|
if (!string.IsNullOrEmpty(p_parentInvBillNum)) |
|
|
if (!string.IsNullOrEmpty(p_parentInvBillNum)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
//反向查找调整数据
|
|
|
var adjdetails = p_adjlist.Where(p => ls.Contains(p.GroupNum)).ToList(); |
|
|
var adjdetails = p_adjlist.Where(p => ls.Contains(p.GroupNum)).ToList(); |
|
|
foreach (var detail in adjdetails) |
|
|
foreach (var detail in adjdetails) |
|
|
{ |
|
|
{ |
|
@ -1493,11 +1506,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.LU, 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 |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
InvGroupNum = itm.Key.InvGroupNum, |
|
|
InvGroupNum = itm.Key.InvGroupNum, |
|
|
LU = itm.Key.LU, |
|
|
LU = itm.Key.PartCode, |
|
|
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), |
|
@ -1537,6 +1551,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
invbillNum: key, |
|
|
invbillNum: key, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
lU: detail.LU, |
|
|
lU: detail.LU, |
|
|
|
|
|
|
|
|
qty: detail.Qty, |
|
|
qty: detail.Qty, |
|
|
bussiessType: businessType, |
|
|
bussiessType: businessType, |
|
|
amt: detail.Amt, |
|
|
amt: detail.Amt, |
|
|