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