|
@ -1007,150 +1007,115 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
/// <param name="p_parentInvBillNum">原发票号</param>
|
|
|
/// <param name="p_parentInvBillNum">原发票号</param>
|
|
|
[UnitOfWork(false)] |
|
|
[UnitOfWork(false)] |
|
|
public async Task<List<string>> SecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_ajdlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType, List<TEMP_NOT_SA_DETAIL> p_notlist = null) |
|
|
public async Task<List<string>> SecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_ajdlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType, List<TEMP_NOT_SA_DETAIL> p_notlist = null) |
|
|
where TDetail : SA_CAN_BASE |
|
|
where TDetail : SA_CAN_BASE,new() |
|
|
{ |
|
|
{ |
|
|
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 groupDtos = dtos.GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID, p.LU })//明细
|
|
|
{ |
|
|
.Select(itm => new GroupPartCode |
|
|
PartCode = p.Key.PartCode, |
|
|
|
|
|
LU = p.Key.LU, |
|
|
|
|
|
Amt = p.Sum(itm => itm.Amt), |
|
|
|
|
|
Qty = p.Sum(itm => itm.Qty), |
|
|
|
|
|
ContractDocID = p.Key.ContractDocID, |
|
|
|
|
|
Price = p.Key.Price, |
|
|
|
|
|
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 |
|
|
|
|
|
{ |
|
|
|
|
|
PartCode = p.Key.PartCode, |
|
|
|
|
|
LU = p.Key.LU, |
|
|
|
|
|
Amt = p.Sum(itm => itm.Amt), |
|
|
|
|
|
Qty = p.Sum(itm => itm.Qty), |
|
|
|
|
|
Price = p.Key.Price, |
|
|
|
|
|
ContractDocID = p.Key.ContractDocID, |
|
|
|
|
|
BeginDate = p.Key.BeginDate, |
|
|
|
|
|
EndDate = p.Key.EndDate |
|
|
|
|
|
}).ToList();//汇总记录不出现重复值
|
|
|
|
|
|
Dictionary<string, List<TMEP_INV>> invoiceMap = new Dictionary<string, List<TMEP_INV>>();//发票和发票明细关系
|
|
|
|
|
|
foreach (var group in groups) |
|
|
|
|
|
{ |
|
|
{ |
|
|
int i = groups1.Count(p => p.LU == group.LU |
|
|
PartCode = itm.Key.PartCode, |
|
|
&& p.PartCode == group.PartCode |
|
|
InvGroupNum = itm.Key.InvGroupNum, |
|
|
&& p.BeginDate == group.BeginDate |
|
|
LU = itm.Key.LU, |
|
|
&& p.EndDate == group.EndDate |
|
|
ContactDocID = itm.Key.ContractDocID, |
|
|
&& p.ContractDocID == group.ContractDocID |
|
|
Price = itm.Key.Price, |
|
|
); |
|
|
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税前
|
|
|
if (i > 0) |
|
|
Tax = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2),//税
|
|
|
{ |
|
|
TaxAmt = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2) + Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税后进
|
|
|
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV"); |
|
|
Qty = itm.Sum(k => k.Qty), |
|
|
List<TMEP_INV> tempList = new List<TMEP_INV>(); |
|
|
BeginDate = itm.Key.BeginDate, |
|
|
decimal sum = group.Amt;//初始合计金额
|
|
|
EndDate = itm.Key.EndDate |
|
|
int partCount = 0; |
|
|
}).ToList(); |
|
|
foreach (var group1 in groups1) |
|
|
|
|
|
{ |
|
|
List<GroupPartCode> biglist = new List<GroupPartCode>(); |
|
|
if (group.LU == group1.LU |
|
|
List<GroupPartCode> smalllist = new List<GroupPartCode>(); |
|
|
&& group.PartCode == group1.PartCode |
|
|
foreach (var itm in groupDtos)//分类1000W以上或1000W以下
|
|
|
&& group.BeginDate == group1.BeginDate |
|
|
|
|
|
&& group.EndDate == group1.EndDate |
|
|
|
|
|
&& group1.ContractDocID == group.ContractDocID |
|
|
|
|
|
&& group1.Price == group.Price |
|
|
|
|
|
&& group1.Qty == group.Qty |
|
|
|
|
|
&& group1.Amt == group.Amt |
|
|
|
|
|
) |
|
|
|
|
|
{ |
|
|
{ |
|
|
tempList.Add(group1); |
|
|
if (itm.Amt > 10000000) |
|
|
partCount++;//符合条件加入到零件中
|
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
sum += group1.Amt; |
|
|
|
|
|
if (sum > 10000000) |
|
|
|
|
|
{ |
|
|
{ |
|
|
break; |
|
|
biglist.Add(itm); |
|
|
} |
|
|
} |
|
|
tempList.Add(group1); |
|
|
else |
|
|
} |
|
|
|
|
|
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, itm.Qty, itm.Price, itm.Amt } |
|
|
|
|
|
equals |
|
|
|
|
|
new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode, itm1.Qty, itm1.Price, itm1.Amt } |
|
|
|
|
|
into temp |
|
|
|
|
|
from tm in temp.DefaultIfEmpty() |
|
|
|
|
|
where tm == null |
|
|
|
|
|
select new TMEP_INV |
|
|
|
|
|
{ |
|
|
{ |
|
|
LU = itm.LU, |
|
|
smalllist.Add(itm); |
|
|
Amt = itm.Amt, |
|
|
|
|
|
Qty = itm.Qty, |
|
|
|
|
|
Price = itm.Price, |
|
|
|
|
|
BeginDate = itm.BeginDate, |
|
|
|
|
|
ContractDocID = itm.ContractDocID, |
|
|
|
|
|
EndDate = itm.EndDate, |
|
|
|
|
|
PartCode = itm.PartCode, |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
groups1 = query.ToList(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (invoiceMap.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>(); |
|
|
int count = invoiceMap.Keys.Count;//计算第几张发票计数器
|
|
|
foreach (var big in biglist)//单条大于1000W的开票
|
|
|
int i = 1; |
|
|
{ |
|
|
foreach (var group in invoiceMap) |
|
|
var list = p_list.Where(p => p.InvGroupNum == big.InvGroupNum && p.PartCode == big.PartCode && p.Price == big.Price && p.LU == big.LU); |
|
|
|
|
|
var gener = new InvoiceGeneratorPUB<TDetail>(); |
|
|
|
|
|
gener.GenerateInvoices(p_list); |
|
|
|
|
|
var invList = gener.Invoices; |
|
|
|
|
|
foreach (var inv in invList) |
|
|
|
|
|
{ |
|
|
|
|
|
var partlist = inv.Parts; |
|
|
|
|
|
if (partlist.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = from itm in p_list |
|
|
|
|
|
join itm1 in dtos on itm.Id equals itm1.Id |
|
|
|
|
|
select itm1; |
|
|
|
|
|
var Dtos = query.ToList(); |
|
|
|
|
|
var detailDtos = Dtos.GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID, p.LU })//明细
|
|
|
|
|
|
.Select(itm => new |
|
|
{ |
|
|
{ |
|
|
var key = group.Key;//发票票号
|
|
|
PartCode = itm.Key.PartCode, |
|
|
var ls = group.Value;//发票明细
|
|
|
InvGroupNum = itm.Key.InvGroupNum, |
|
|
//反向查找结算数据
|
|
|
LU = itm.Key.LU, |
|
|
var query = from itm in dtos |
|
|
ContactDocID = itm.Key.ContractDocID, |
|
|
join itm1 in ls |
|
|
Price = itm.Key.Price, |
|
|
on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate, itm.ContractDocID } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID } |
|
|
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税前
|
|
|
join itm2 in p_list on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } |
|
|
Tax = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2),//税
|
|
|
select itm2;//反向更新可计算数据
|
|
|
TaxAmt = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2) + Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税后进
|
|
|
foreach (var itm in query) |
|
|
Qty = itm.Sum(k => k.Qty), |
|
|
|
|
|
BeginDate = itm.Key.BeginDate, |
|
|
|
|
|
EndDate = itm.Key.EndDate |
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
decimal amt = detailDtos.Sum(k => k.Amt);//金额
|
|
|
|
|
|
decimal txtAmt = detailDtos.Sum(k => k.TaxAmt);//税后金额
|
|
|
|
|
|
decimal realAmt = detailDtos.Sum(k => k.Tax);//税额
|
|
|
|
|
|
|
|
|
|
|
|
var invoicegrup = partlist.Select(p => p.GroupNum); |
|
|
|
|
|
var mapList = new List<INVOICE_MAP_GROUP>(); |
|
|
|
|
|
foreach (var groupnum in invoicegrup) |
|
|
{ |
|
|
{ |
|
|
itm.InvbillNum = key; |
|
|
mapList.Add(new INVOICE_MAP_GROUP( |
|
|
salist.Add(itm); |
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
version: p_version, |
|
|
|
|
|
invbillNum: inv.InvBillNum, |
|
|
|
|
|
invGroupNum: p_InvGroupNum, |
|
|
|
|
|
settleGroupNum: groupnum, |
|
|
|
|
|
amt: 0, |
|
|
|
|
|
extend1: string.Empty, |
|
|
|
|
|
extend2: string.Empty |
|
|
|
|
|
) |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
if (!string.IsNullOrEmpty(p_parentInvBillNum)) |
|
|
if (mapList.Count > 0) |
|
|
{ |
|
|
|
|
|
//反向查找调整数据
|
|
|
|
|
|
var query1 = from itm in dtos |
|
|
|
|
|
join itm1 in ls |
|
|
|
|
|
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.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } |
|
|
|
|
|
select itm2; |
|
|
|
|
|
foreach (var itm in query1) |
|
|
|
|
|
{ |
|
|
{ |
|
|
itm.InvBillNum = key; |
|
|
groupList.AddRange(mapList); |
|
|
adjlist.Add(itm); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
#region 发票明细
|
|
|
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 detailDtos) |
|
|
{ |
|
|
{ |
|
|
_entityDetailList.Add( |
|
|
_entityDetailList.Add( |
|
|
new INVOICE_WAIT_DETAIL( |
|
|
new INVOICE_WAIT_DETAIL( |
|
|
guid: GuidGenerator.Create(), |
|
|
guid: GuidGenerator.Create(), |
|
|
version: p_version, |
|
|
version: p_version, |
|
|
invbillNum: key, |
|
|
invbillNum: inv.InvBillNum, |
|
|
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, |
|
|
pRICE: detail.Price, |
|
|
pRICE: detail.Price, |
|
|
extend1: detail.ContractDocID, |
|
|
extend1: detail.ContactDocID, |
|
|
extend2: string.Empty, |
|
|
extend2: string.Empty, |
|
|
beginDate: detail.BeginDate, |
|
|
beginDate: detail.BeginDate, |
|
|
endDate: detail.EndDate, |
|
|
endDate: detail.EndDate, |
|
@ -1161,104 +1126,123 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
detailList.AddRange(_entityDetailList); |
|
|
detailList.AddRange(_entityDetailList); |
|
|
} |
|
|
} |
|
|
#region 发票不能结算的明细
|
|
|
#endregion
|
|
|
var innotls = new List<INVOICE_NOT_SETTLE>(); |
|
|
#region 发票
|
|
|
var sq = query.GroupBy(p => new { p.LU, p.GroupNum }) |
|
|
var invbill = new INVOICE_GRP |
|
|
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = group.Key, GroupNum = p.Key.GroupNum }); |
|
|
( |
|
|
foreach (var sitm in sq) |
|
|
|
|
|
{ |
|
|
|
|
|
innotls.Add(new INVOICE_NOT_SETTLE( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
guid: GuidGenerator.Create(), |
|
|
version: p_version, |
|
|
realnvBillNum: string.Empty, |
|
|
|
|
|
invbillNum: inv.InvBillNum, |
|
|
|
|
|
amt: amt, |
|
|
|
|
|
taxAmt: txtAmt, |
|
|
|
|
|
fileName: string.Empty, |
|
|
|
|
|
businessType: businessType, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
settleGroupNum: sitm.GroupNum, |
|
|
state: SettleBillState.已开票, |
|
|
lU: sitm.LU, |
|
|
invoiceBillState: InvoiceBillState.正常, |
|
|
lU1: sitm.LU, |
|
|
tax: 0.13m, |
|
|
extend1: "可结算", |
|
|
parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty, |
|
|
extend2: string.Empty, |
|
|
preTaxDiff: 0, |
|
|
qty: sitm.Qty, |
|
|
taxDiff: 0, |
|
|
p_invbillnum: group.Key |
|
|
clientCode: string.Empty, |
|
|
)); |
|
|
realAmt: realAmt |
|
|
} |
|
|
); |
|
|
if (innotls.Count > 0) |
|
|
string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site; |
|
|
|
|
|
string clientCode = string.Empty; |
|
|
|
|
|
switch (site) |
|
|
{ |
|
|
{ |
|
|
notDetialList.AddRange(innotls); |
|
|
case "1040": |
|
|
|
|
|
clientCode = "C001"; |
|
|
|
|
|
break; |
|
|
|
|
|
case "1046": |
|
|
|
|
|
clientCode = "C171"; |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
clientCode = "C004"; |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
if (p_notlist != null && p_notlist.Count > 0) |
|
|
invbill.ClientCode = clientCode; |
|
|
|
|
|
invbill.Site = dtos.FirstOrDefault().Site; |
|
|
|
|
|
invbill.CreationTime = DateTime.MinValue; |
|
|
|
|
|
invbill.LastModificationTime = DateTime.Now; |
|
|
|
|
|
invlist.Add(invbill); |
|
|
|
|
|
#endregion
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
smalllist = smalllist.OrderBy(p => p.Amt).ToList(); |
|
|
|
|
|
var gener1 = new InvoiceGeneratorDiff(); |
|
|
|
|
|
gener1.GenerateInvoices(smalllist); |
|
|
|
|
|
var invList1 = gener1.Invoices; |
|
|
|
|
|
foreach (var inv in invList1)//小于1000W的开票
|
|
|
{ |
|
|
{ |
|
|
var innotls1 = new List<INVOICE_NOT_SETTLE>(); |
|
|
var partlist = inv.Parts; |
|
|
|
|
|
var query = from part in p_list |
|
|
|
|
|
join part1 in partlist on |
|
|
|
|
|
new { part.InvGroupNum, part.PartCode, part.LU, part.Price } equals new { part1.InvGroupNum, part1.PartCode, part1.LU, part1.Price } |
|
|
|
|
|
select part; |
|
|
|
|
|
|
|
|
var grouplist = query.Select(p => p.GroupNum).ToList(); |
|
|
var entityList = query.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
salist.AddRange(entityList); |
|
|
|
|
|
|
|
|
var notlist = p_notlist.Where(p => grouplist.Contains(p.GroupNum)); |
|
|
if (partlist.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
decimal amt = partlist.Sum(k => k.Amt);//金额
|
|
|
|
|
|
decimal txtAmt = partlist.Sum(k => k.TaxAmt);//税后金额
|
|
|
|
|
|
decimal realAmt = partlist.Sum(k => k.Tax);//税额
|
|
|
|
|
|
|
|
|
foreach (var nitm in notlist) |
|
|
var invoicegroupls = entityList.Select(p => p.GroupNum); |
|
|
|
|
|
var mapList = new List<INVOICE_MAP_GROUP>(); |
|
|
|
|
|
foreach (var groupnum in invoicegroupls) |
|
|
{ |
|
|
{ |
|
|
innotls1.Add(new INVOICE_NOT_SETTLE( |
|
|
mapList.Add(new INVOICE_MAP_GROUP( |
|
|
guid: GuidGenerator.Create(), |
|
|
guid: GuidGenerator.Create(), |
|
|
version: p_version, |
|
|
version: p_version, |
|
|
|
|
|
invbillNum: inv.InvBillNum, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
settleGroupNum: nitm.GroupNum, |
|
|
settleGroupNum: groupnum, |
|
|
lU: nitm.LU, |
|
|
amt: 0, |
|
|
lU1: nitm.LU, |
|
|
extend1: string.Empty, |
|
|
extend1: "不可结算", |
|
|
extend2: string.Empty |
|
|
extend2: string.Empty, |
|
|
) |
|
|
qty: nitm.Qty, |
|
|
); |
|
|
p_invbillnum: group.Key |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
} |
|
|
if (innotls.Count > 0) |
|
|
if (mapList.Count > 0) |
|
|
{ |
|
|
{ |
|
|
notDetialList.AddRange(innotls1); |
|
|
groupList.AddRange(mapList); |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
|
|
|
decimal amt = ls.Sum(k => k.Amt);//金额
|
|
|
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|
decimal txtAmt = Math.Round(amt * 0.13m, 2);//税后金额
|
|
|
foreach (var detail in partlist) |
|
|
decimal readAmt = amt + Math.Round(amt * 0.13m, 2);//税额
|
|
|
{ |
|
|
|
|
|
_entityDetailList.Add( |
|
|
//var contractList = ls.Select(p => p.ContractDocID).Distinct();
|
|
|
new INVOICE_WAIT_DETAIL( |
|
|
var _groupList = query.GroupBy(p => new { p.GroupNum }) |
|
|
|
|
|
.Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => Math.Round(itm.Qty * itm.Price, 2)) }).Distinct(); |
|
|
|
|
|
List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>(); |
|
|
|
|
|
foreach (var en in _groupList) |
|
|
|
|
|
{ |
|
|
|
|
|
group1.Add( |
|
|
|
|
|
new INVOICE_MAP_GROUP( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
guid: GuidGenerator.Create(), |
|
|
version: p_version, |
|
|
version: p_version, |
|
|
invbillNum: key, |
|
|
invbillNum: inv.InvBillNum, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
settleGroupNum: en.GroupNum, |
|
|
lU: detail.LU, |
|
|
amt: en.Amt, |
|
|
qty: detail.Qty, |
|
|
extend1: string.Empty, |
|
|
bussiessType: businessType, |
|
|
extend2: string.Empty)); |
|
|
amt: detail.Amt, |
|
|
} |
|
|
pRICE: detail.Price, |
|
|
if (group1.Count > 0) |
|
|
extend1: detail.ContactDocID, |
|
|
{ |
|
|
extend2: string.Empty, |
|
|
groupList.AddRange(group1); |
|
|
beginDate: detail.BeginDate.Value, |
|
|
|
|
|
endDate: detail.EndDate.Value, |
|
|
|
|
|
partcode: detail.PartCode |
|
|
|
|
|
)); |
|
|
} |
|
|
} |
|
|
var lst = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).ToList(); |
|
|
if (_entityDetailList.Count > 0) |
|
|
string site = lst.FirstOrDefault().Site; |
|
|
|
|
|
string clientCode = string.Empty; |
|
|
|
|
|
switch (site) |
|
|
|
|
|
{ |
|
|
{ |
|
|
case "1040": |
|
|
detailList.AddRange(_entityDetailList); |
|
|
clientCode = "C001"; |
|
|
|
|
|
break; |
|
|
|
|
|
case "1046": |
|
|
|
|
|
clientCode = "C171"; |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
clientCode = "C004"; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
var invbill = new INVOICE_GRP |
|
|
var invbill = new INVOICE_GRP |
|
|
(guid: GuidGenerator.Create(), |
|
|
( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
realnvBillNum: string.Empty, |
|
|
realnvBillNum: string.Empty, |
|
|
invbillNum: key, |
|
|
invbillNum: inv.InvBillNum, |
|
|
amt: amt, |
|
|
amt: amt, |
|
|
taxAmt: txtAmt, |
|
|
taxAmt: txtAmt, |
|
|
fileName: string.Empty, |
|
|
fileName: string.Empty, |
|
@ -1267,53 +1251,56 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
state: SettleBillState.已开票, |
|
|
state: SettleBillState.已开票, |
|
|
invoiceBillState: InvoiceBillState.正常, |
|
|
invoiceBillState: InvoiceBillState.正常, |
|
|
tax: 0.13m, |
|
|
tax: 0.13m, |
|
|
parent: p_parentInvBillNum, |
|
|
parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty, |
|
|
preTaxDiff: 0, |
|
|
preTaxDiff: 0, |
|
|
taxDiff: 0, |
|
|
taxDiff: 0, |
|
|
clientCode: string.Empty, |
|
|
clientCode: string.Empty, |
|
|
realAmt: readAmt |
|
|
realAmt: realAmt |
|
|
); |
|
|
); |
|
|
|
|
|
string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site; |
|
|
|
|
|
string clientCode = string.Empty; |
|
|
|
|
|
switch (site) |
|
|
|
|
|
{ |
|
|
|
|
|
case "1040": |
|
|
|
|
|
clientCode = "C001"; |
|
|
|
|
|
break; |
|
|
|
|
|
case "1046": |
|
|
|
|
|
clientCode = "C171"; |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
clientCode = "C004"; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
invbill.ClientCode = clientCode; |
|
|
invbill.ClientCode = clientCode; |
|
|
|
|
|
invbill.Site = dtos.FirstOrDefault().Site; |
|
|
invbill.CreationTime = DateTime.MinValue; |
|
|
invbill.CreationTime = DateTime.MinValue; |
|
|
invbill.LastModificationTime = DateTime.Now; |
|
|
invbill.LastModificationTime = DateTime.Now; |
|
|
invbill.Site = dtos.FirstOrDefault().Site; |
|
|
|
|
|
invlist.Add(invbill); |
|
|
invlist.Add(invbill); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var dbcontxt = await _repository.GetDbContextAsync().ConfigureAwait(false); |
|
|
var _dbcontext=await _repository.GetDbContextAsync().ConfigureAwait(false); |
|
|
//_dbcontext.BulkInsert(invlist);
|
|
|
|
|
|
//_dbcontext.BulkInsert(groupList);
|
|
|
|
|
|
//_dbcontext.BulkInsert(detailList);
|
|
|
|
|
|
//_dbcontext.BulkInsert(notDetialList);
|
|
|
|
|
|
//if (salist.Count > 0)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// _dbcontext.BulkUpdate(salist);
|
|
|
|
|
|
//}
|
|
|
|
|
|
//if (adjlist.Count > 0)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// _dbcontext.BulkUpdate(adjlist);
|
|
|
|
|
|
//}
|
|
|
|
|
|
await dbcontxt.BulkInsertAsync(invlist).ConfigureAwait(false); |
|
|
|
|
|
await dbcontxt.BulkInsertAsync(groupList).ConfigureAwait(false); |
|
|
|
|
|
await dbcontxt.BulkInsertAsync(detailList).ConfigureAwait(false); |
|
|
|
|
|
await dbcontxt.BulkInsertAsync(notDetialList).ConfigureAwait(false); |
|
|
|
|
|
if (salist.Count > 0) |
|
|
if (salist.Count > 0) |
|
|
{ |
|
|
{ |
|
|
await dbcontxt.BulkUpdateAsync(salist).ConfigureAwait(false); |
|
|
_dbcontext.BulkUpdate(salist); |
|
|
} |
|
|
} |
|
|
|
|
|
_dbcontext.BulkInsert(invlist); |
|
|
|
|
|
_dbcontext.BulkInsert(groupList); |
|
|
|
|
|
_dbcontext.BulkInsert(detailList); |
|
|
if (adjlist.Count > 0) |
|
|
if (adjlist.Count > 0) |
|
|
{ |
|
|
{ |
|
|
await dbcontxt.BulkUpdateAsync(adjlist).ConfigureAwait(false); |
|
|
_dbcontext.BulkInsert(adjlist); |
|
|
} |
|
|
} |
|
|
//await _repository.DbContext.BulkInsertAsync(notDetialList);
|
|
|
if (notDetialList.Count > 0) |
|
|
_invls = invlist.Select(p => p.InvbillNum).ToList(); |
|
|
{ |
|
|
|
|
|
_dbcontext.BulkInsert(notDetialList); |
|
|
} |
|
|
} |
|
|
|
|
|
_invls = invlist.Select(p => p.InvbillNum).ToList(); |
|
|
return _invls; |
|
|
return _invls; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//public async Task<List<string>> SecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_ajdlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
|
|
|
|
|
|
// 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
|
|
|
//{
|
|
|
//{
|
|
@ -1325,7 +1312,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
// Price = p.Key.Price,
|
|
|
// Price = p.Key.Price,
|
|
|
// 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
|
|
|
//{
|
|
|
//{
|
|
@ -1337,6 +1323,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
// ContractDocID = p.Key.ContractDocID,
|
|
|
// ContractDocID = p.Key.ContractDocID,
|
|
|
// BeginDate = p.Key.BeginDate,
|
|
|
// BeginDate = p.Key.BeginDate,
|
|
|
// EndDate = p.Key.EndDate
|
|
|
// EndDate = p.Key.EndDate
|
|
|
|
|
|
|
|
|
//}).ToList();//汇总记录不出现重复值
|
|
|
//}).ToList();//汇总记录不出现重复值
|
|
|
//Dictionary<string, List<TMEP_INV>> invoiceMap = new Dictionary<string, List<TMEP_INV>>();//发票和发票明细关系
|
|
|
//Dictionary<string, List<TMEP_INV>> invoiceMap = new Dictionary<string, List<TMEP_INV>>();//发票和发票明细关系
|
|
|
//foreach (var group in groups)
|
|
|
//foreach (var group in groups)
|
|
@ -1360,39 +1347,49 @@ 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.Price == group.Price
|
|
|
|
|
|
// && group1.Qty == group.Qty
|
|
|
|
|
|
// && group1.Amt == group.Amt
|
|
|
// )
|
|
|
// )
|
|
|
// {
|
|
|
// {
|
|
|
// tempList.Add(group1);
|
|
|
// tempList.Add(group1);
|
|
|
// partCount++;//符合条件加入到零件中
|
|
|
// partCount++;//符合条件加入到零件中
|
|
|
// continue;
|
|
|
// continue;
|
|
|
// }
|
|
|
// }
|
|
|
// //partCount++;
|
|
|
// sum += group1.Amt;
|
|
|
// //if (partCount > 30)
|
|
|
|
|
|
// //{
|
|
|
|
|
|
// // continue;
|
|
|
|
|
|
// //}
|
|
|
|
|
|
// if (sum > 10000000)
|
|
|
// if (sum > 10000000)
|
|
|
// {
|
|
|
// {
|
|
|
// break;
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
// 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, itm.PartCode }
|
|
|
// on
|
|
|
// equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode } into temp
|
|
|
// new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID, itm.PartCode, itm.Qty, itm.Price, itm.Amt }
|
|
|
// from tm in temp
|
|
|
// equals
|
|
|
|
|
|
// new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode, itm1.Qty, itm1.Price, itm1.Amt }
|
|
|
|
|
|
// into temp
|
|
|
|
|
|
// from tm in temp.DefaultIfEmpty()
|
|
|
// 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,
|
|
|
|
|
|
// Price = itm.Price,
|
|
|
// BeginDate = itm.BeginDate,
|
|
|
// BeginDate = itm.BeginDate,
|
|
|
// ContractDocID = itm.ContractDocID,
|
|
|
// ContractDocID = itm.ContractDocID,
|
|
|
// EndDate = itm.EndDate
|
|
|
// EndDate = itm.EndDate,
|
|
|
|
|
|
// PartCode = itm.PartCode,
|
|
|
|
|
|
|
|
|
// };
|
|
|
// };
|
|
|
// groups1 = query.ToList();
|
|
|
// groups1 = query.ToList();
|
|
|
// }
|
|
|
// }
|
|
@ -1405,6 +1402,8 @@ 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>();
|
|
|
|
|
|
// int count = invoiceMap.Keys.Count;//计算第几张发票计数器
|
|
|
|
|
|
// int i = 1;
|
|
|
// foreach (var group in invoiceMap)
|
|
|
// foreach (var group in invoiceMap)
|
|
|
// {
|
|
|
// {
|
|
|
// var key = group.Key;//发票票号
|
|
|
// var key = group.Key;//发票票号
|
|
@ -1412,9 +1411,9 @@ 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.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate }
|
|
|
// on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate, itm.ContractDocID } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID }
|
|
|
// join itm2 in p_list on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate }
|
|
|
// join itm2 in p_list on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate }
|
|
|
// select itm2;
|
|
|
// select itm2;//反向更新可计算数据
|
|
|
// foreach (var itm in query)
|
|
|
// foreach (var itm in query)
|
|
|
// {
|
|
|
// {
|
|
|
// itm.InvbillNum = key;
|
|
|
// itm.InvbillNum = key;
|
|
@ -1431,7 +1430,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
// foreach (var itm in query1)
|
|
|
// foreach (var itm in query1)
|
|
|
// {
|
|
|
// {
|
|
|
// itm.InvBillNum = key;
|
|
|
// itm.InvBillNum = key;
|
|
|
// itm.InvGroupNum = dtos.FirstOrDefault().InvGroupNum;
|
|
|
|
|
|
// adjlist.Add(itm);
|
|
|
// adjlist.Add(itm);
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
@ -1460,30 +1458,67 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
// {
|
|
|
// {
|
|
|
// detailList.AddRange(_entityDetailList);
|
|
|
// detailList.AddRange(_entityDetailList);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// #region 发票不能结算的明细
|
|
|
// List<tempAmt1> amtList = new List<tempAmt1>();
|
|
|
// var innotls = new List<INVOICE_NOT_SETTLE>();
|
|
|
// foreach (var itm in detailList)
|
|
|
// var sq = query.GroupBy(p => new { p.LU, p.GroupNum })
|
|
|
|
|
|
// .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = group.Key, GroupNum = p.Key.GroupNum });
|
|
|
|
|
|
// foreach (var sitm in sq)
|
|
|
// {
|
|
|
// {
|
|
|
// amtList.Add(new tempAmt1()
|
|
|
// 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: "可结算",
|
|
|
|
|
|
// extend2: string.Empty,
|
|
|
|
|
|
// qty: sitm.Qty,
|
|
|
|
|
|
// p_invbillnum: group.Key
|
|
|
|
|
|
// ));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (innotls.Count > 0)
|
|
|
// {
|
|
|
// {
|
|
|
// Amt = itm.Amt,
|
|
|
// notDetialList.AddRange(innotls);
|
|
|
// Tax = Math.Round(itm.Amt * 0.13m, 2),
|
|
|
|
|
|
// TaxAmt = itm.Amt + Math.Round(itm.Amt * 0.13m, 2)
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
// }
|
|
|
// decimal amt = amtList.Sum(k => k.Amt);//金额
|
|
|
// if (p_notlist != null && p_notlist.Count > 0)
|
|
|
// decimal txtAmt = amtList.Sum(k => k.TaxAmt);//税后金额
|
|
|
// {
|
|
|
// decimal readAmt = amtList.Sum(k => k.Tax);//税额
|
|
|
// var innotls1 = new List<INVOICE_NOT_SETTLE>();
|
|
|
|
|
|
|
|
|
// //decimal amt = detailList.Sum(k => k.Amt);//金额
|
|
|
// var grouplist = query.Select(p => p.GroupNum).ToList();
|
|
|
// //decimal txtAmt = detailList.Sum(k => k.Amt) + Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税后金额
|
|
|
|
|
|
// //decimal readAmt = Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税额
|
|
|
|
|
|
|
|
|
|
|
|
// var contractList = ls.Select(p => p.ContractDocID).Distinct();
|
|
|
|
|
|
// var _groupList = dtos.Where(p => contractList.Contains(p.ContractDocID)).GroupBy(p => new { p.GroupNum })
|
|
|
|
|
|
// .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
|
|
|
|
|
|
// List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var notlist = p_notlist.Where(p => grouplist.Contains(p.GroupNum));
|
|
|
|
|
|
|
|
|
|
|
|
// foreach (var nitm in notlist)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// innotls1.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: group.Key
|
|
|
|
|
|
// ));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (innotls.Count > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// notDetialList.AddRange(innotls1);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
// decimal amt = ls.Sum(k => k.Amt);//金额
|
|
|
|
|
|
// decimal txtAmt = Math.Round(amt * 0.13m, 2);//税后金额
|
|
|
|
|
|
// decimal readAmt = amt + Math.Round(amt * 0.13m, 2);//税额
|
|
|
|
|
|
|
|
|
|
|
|
// //var contractList = ls.Select(p => p.ContractDocID).Distinct();
|
|
|
|
|
|
// var _groupList = query.GroupBy(p => new { p.GroupNum })
|
|
|
|
|
|
// .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => Math.Round(itm.Qty * itm.Price, 2)) }).Distinct();
|
|
|
|
|
|
// List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>();
|
|
|
// foreach (var en in _groupList)
|
|
|
// foreach (var en in _groupList)
|
|
|
// {
|
|
|
// {
|
|
|
// group1.Add(
|
|
|
// group1.Add(
|
|
@ -1501,7 +1536,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
// {
|
|
|
// {
|
|
|
// groupList.AddRange(group1);
|
|
|
// groupList.AddRange(group1);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
// var lst = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).ToList();
|
|
|
// var lst = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).ToList();
|
|
|
// string site = lst.FirstOrDefault().Site;
|
|
|
// string site = lst.FirstOrDefault().Site;
|
|
|
// string clientCode = string.Empty;
|
|
|
// string clientCode = string.Empty;
|
|
@ -1538,27 +1572,35 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
// );
|
|
|
// );
|
|
|
// invbill.ClientCode = clientCode;
|
|
|
// invbill.ClientCode = clientCode;
|
|
|
// invbill.CreationTime = DateTime.MinValue;
|
|
|
// invbill.CreationTime = DateTime.MinValue;
|
|
|
// invbill.Site = dtos.FirstOrDefault().Site;
|
|
|
|
|
|
// invbill.LastModificationTime = DateTime.Now;
|
|
|
// invbill.LastModificationTime = DateTime.Now;
|
|
|
|
|
|
// invbill.Site = dtos.FirstOrDefault().Site;
|
|
|
// invlist.Add(invbill);
|
|
|
// invlist.Add(invbill);
|
|
|
// }
|
|
|
// }
|
|
|
// await _repository.DbContext.BulkInsertAsync(invlist).ConfigureAwait(false);
|
|
|
// var dbcontxt = await _repository.GetDbContextAsync().ConfigureAwait(false);
|
|
|
// await _repository.DbContext.BulkInsertAsync(groupList).ConfigureAwait(false);
|
|
|
|
|
|
// await _repository.DbContext.BulkInsertAsync(detailList).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// await dbcontxt.BulkInsertAsync(invlist).ConfigureAwait(false);
|
|
|
|
|
|
// await dbcontxt.BulkInsertAsync(groupList).ConfigureAwait(false);
|
|
|
|
|
|
// await dbcontxt.BulkInsertAsync(detailList).ConfigureAwait(false);
|
|
|
|
|
|
// await dbcontxt.BulkInsertAsync(notDetialList).ConfigureAwait(false);
|
|
|
// if (salist.Count > 0)
|
|
|
// if (salist.Count > 0)
|
|
|
// {
|
|
|
// {
|
|
|
// await _repository.DbContext.BulkUpdateAsync(salist).ConfigureAwait(false);
|
|
|
// await dbcontxt.BulkUpdateAsync(salist).ConfigureAwait(false);
|
|
|
// }
|
|
|
// }
|
|
|
// if (adjlist.Count > 0)
|
|
|
// if (adjlist.Count > 0)
|
|
|
// {
|
|
|
// {
|
|
|
// await _repository.DbContext.BulkUpdateAsync(adjlist).ConfigureAwait(false);
|
|
|
// await dbcontxt.BulkUpdateAsync(adjlist).ConfigureAwait(false);
|
|
|
// }
|
|
|
// }
|
|
|
// //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;
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
[UnitOfWork(false)] |
|
|
[UnitOfWork(false)] |
|
|
public async Task<List<string>> FirstInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) |
|
|
public async Task<List<string>> FirstInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) |
|
|
where TDetail : SA_CAN_BASE |
|
|
where TDetail : SA_CAN_BASE |
|
@ -2762,7 +2804,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="BusinessException"></exception>
|
|
|
/// <exception cref="BusinessException"></exception>
|
|
|
public async Task<bool> ReissueSecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, string p_OldInvBillNum, int p_version) |
|
|
public async Task<bool> ReissueSecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, string p_OldInvBillNum, int p_version) |
|
|
where TDetail : SA_CAN_BASE |
|
|
where TDetail : SA_CAN_BASE, new() |
|
|
{ |
|
|
{ |
|
|
if (!string.IsNullOrEmpty(p_OldInvBillNum)) |
|
|
if (!string.IsNullOrEmpty(p_OldInvBillNum)) |
|
|
{ |
|
|
{ |
|
|