|
@ -671,6 +671,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
foreach (var inv in invList) |
|
|
foreach (var inv in invList) |
|
|
{ |
|
|
{ |
|
|
var partlist = inv.Parts; |
|
|
var partlist = inv.Parts; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (partlist.Count > 0) |
|
|
if (partlist.Count > 0) |
|
|
{ |
|
|
{ |
|
|
var query = from itm in partlist |
|
|
var query = from itm in partlist |
|
@ -719,282 +723,221 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
groupList.AddRange(mapList); |
|
|
groupList.AddRange(mapList); |
|
|
} |
|
|
} |
|
|
var innotls = new List<INVOICE_NOT_SETTLE>(); |
|
|
var innotls = new List<INVOICE_NOT_SETTLE>(); |
|
|
var sq = partlist.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum }) |
|
|
|
|
|
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, 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: "可结算", |
|
|
|
|
|
extend2: string.Empty, |
|
|
|
|
|
qty: sitm.Qty, |
|
|
|
|
|
p_invbillnum: inv.InvBillNum |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
if (innotls.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
notDetialList.AddRange(innotls); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 发票明细
|
|
|
|
|
|
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|
//if (partlist is List<BBAC_CAN_SA_DETAIL>)
|
|
|
foreach (var detail in detailDtos) |
|
|
//{
|
|
|
{ |
|
|
var partlist1 = partlist as List<BBAC_CAN_SA_DETAIL>; |
|
|
_entityDetailList.Add( |
|
|
var sq = partlist1.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum}) |
|
|
new INVOICE_WAIT_DETAIL( |
|
|
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum }); |
|
|
guid: GuidGenerator.Create(), |
|
|
foreach (var sitm in sq) |
|
|
version: p_version, |
|
|
{ |
|
|
invbillNum: inv.InvBillNum, |
|
|
innotls.Add(new INVOICE_NOT_SETTLE( |
|
|
invGroupNum: p_InvGroupNum, |
|
|
guid: GuidGenerator.Create(), |
|
|
lU: detail.LU, |
|
|
version: p_version, |
|
|
qty: detail.Qty, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
bussiessType: businessType, |
|
|
settleGroupNum: sitm.GroupNum, |
|
|
amt: detail.Amt, |
|
|
lU: sitm.LU, |
|
|
pRICE: detail.Price, |
|
|
lU1: sitm.LU, |
|
|
extend1: detail.ContactDocID, |
|
|
extend1: "可结算", |
|
|
extend2: string.Empty, |
|
|
extend2: string.Empty, |
|
|
beginDate: detail.BeginDate, |
|
|
qty: sitm.Qty, |
|
|
endDate: detail.EndDate, |
|
|
p_invbillnum: inv.InvBillNum |
|
|
partcode: detail.PartCode |
|
|
)); |
|
|
)); |
|
|
} |
|
|
} |
|
|
if (innotls.Count > 0) |
|
|
if (_entityDetailList.Count > 0) |
|
|
{ |
|
|
{ |
|
|
notDetialList.AddRange(innotls); |
|
|
detailList.AddRange(_entityDetailList); |
|
|
} |
|
|
} |
|
|
|
|
|
#endregion
|
|
|
#region 发票明细
|
|
|
#region 发票
|
|
|
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|
var invbill = new INVOICE_GRP |
|
|
foreach (var detail in detailDtos) |
|
|
( |
|
|
{ |
|
|
guid: GuidGenerator.Create(), |
|
|
_entityDetailList.Add( |
|
|
realnvBillNum: string.Empty, |
|
|
new INVOICE_WAIT_DETAIL( |
|
|
invbillNum: inv.InvBillNum, |
|
|
guid: GuidGenerator.Create(), |
|
|
amt: amt, |
|
|
version: p_version, |
|
|
taxAmt: txtAmt, |
|
|
invbillNum: inv.InvBillNum, |
|
|
fileName: string.Empty, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
businessType: businessType, |
|
|
lU: detail.LU, |
|
|
invGroupNum: p_InvGroupNum, |
|
|
qty: detail.Qty, |
|
|
state: SettleBillState.已开票, |
|
|
bussiessType: businessType, |
|
|
invoiceBillState: InvoiceBillState.正常, |
|
|
amt: detail.Amt, |
|
|
tax: 0.13m, |
|
|
pRICE: detail.Price, |
|
|
parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty, |
|
|
extend1: detail.ContactDocID, |
|
|
preTaxDiff: 0, |
|
|
extend2: string.Empty, |
|
|
taxDiff: 0, |
|
|
beginDate: detail.BeginDate, |
|
|
clientCode: string.Empty, |
|
|
endDate: detail.EndDate, |
|
|
realAmt: realAmt |
|
|
partcode: detail.PartCode |
|
|
); |
|
|
)); |
|
|
string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site; |
|
|
} |
|
|
string clientCode = string.Empty; |
|
|
if (_entityDetailList.Count > 0) |
|
|
switch (site) |
|
|
{ |
|
|
{ |
|
|
detailList.AddRange(_entityDetailList); |
|
|
case "1040": |
|
|
} |
|
|
clientCode = "C001"; |
|
|
#endregion
|
|
|
break; |
|
|
#region 发票
|
|
|
case "1046": |
|
|
var invbill = new INVOICE_GRP |
|
|
clientCode = "C171"; |
|
|
( |
|
|
break; |
|
|
guid: GuidGenerator.Create(), |
|
|
default: |
|
|
realnvBillNum: string.Empty, |
|
|
clientCode = "C004"; |
|
|
invbillNum: inv.InvBillNum, |
|
|
break; |
|
|
amt: amt, |
|
|
} |
|
|
taxAmt: txtAmt, |
|
|
invbill.ClientCode = clientCode; |
|
|
fileName: string.Empty, |
|
|
invbill.Site = dtos.FirstOrDefault().Site; |
|
|
businessType: businessType, |
|
|
invbill.CreationTime = DateTime.MinValue; |
|
|
invGroupNum: p_InvGroupNum, |
|
|
invbill.LastModificationTime = DateTime.Now; |
|
|
state: SettleBillState.已开票, |
|
|
invlist.Add(invbill); |
|
|
invoiceBillState: InvoiceBillState.正常, |
|
|
#endregion
|
|
|
tax: 0.13m, |
|
|
|
|
|
parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty, |
|
|
|
|
|
preTaxDiff: 0, |
|
|
|
|
|
taxDiff: 0, |
|
|
|
|
|
clientCode: string.Empty, |
|
|
|
|
|
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.Site = dtos.FirstOrDefault().Site; |
|
|
|
|
|
invbill.CreationTime = DateTime.MinValue; |
|
|
|
|
|
invbill.LastModificationTime = DateTime.Now; |
|
|
|
|
|
invlist.Add(invbill); |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var sq = partlist.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum })
|
|
|
|
|
|
// .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, 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: "可结算",
|
|
|
|
|
|
// extend2: string.Empty,
|
|
|
|
|
|
// qty: sitm.Qty,
|
|
|
|
|
|
// p_invbillnum: inv.InvBillNum
|
|
|
|
|
|
// ));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (innotls.Count > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// notDetialList.AddRange(innotls);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// #region 发票明细
|
|
|
|
|
|
// List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
|
|
|
|
|
|
// foreach (var detail in detailDtos)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// _entityDetailList.Add(
|
|
|
|
|
|
// new INVOICE_WAIT_DETAIL(
|
|
|
|
|
|
// guid: GuidGenerator.Create(),
|
|
|
|
|
|
// version: p_version,
|
|
|
|
|
|
// invbillNum: inv.InvBillNum,
|
|
|
|
|
|
// invGroupNum: p_InvGroupNum,
|
|
|
|
|
|
// lU: detail.LU,
|
|
|
|
|
|
// qty: detail.Qty,
|
|
|
|
|
|
// bussiessType: businessType,
|
|
|
|
|
|
// amt: detail.Amt,
|
|
|
|
|
|
// pRICE: detail.Price,
|
|
|
|
|
|
// extend1: detail.ContactDocID,
|
|
|
|
|
|
// extend2: string.Empty,
|
|
|
|
|
|
// beginDate: detail.BeginDate,
|
|
|
|
|
|
// endDate: detail.EndDate,
|
|
|
|
|
|
// partcode: detail.PartCode
|
|
|
|
|
|
// ));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (_entityDetailList.Count > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// detailList.AddRange(_entityDetailList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
// #region 发票
|
|
|
|
|
|
// var invbill = new INVOICE_GRP
|
|
|
|
|
|
// (
|
|
|
|
|
|
// guid: GuidGenerator.Create(),
|
|
|
|
|
|
// realnvBillNum: string.Empty,
|
|
|
|
|
|
// invbillNum: inv.InvBillNum,
|
|
|
|
|
|
// amt: amt,
|
|
|
|
|
|
// taxAmt: txtAmt,
|
|
|
|
|
|
// fileName: string.Empty,
|
|
|
|
|
|
// businessType: businessType,
|
|
|
|
|
|
// invGroupNum: p_InvGroupNum,
|
|
|
|
|
|
// state: SettleBillState.已开票,
|
|
|
|
|
|
// invoiceBillState: InvoiceBillState.正常,
|
|
|
|
|
|
// tax: 0.13m,
|
|
|
|
|
|
// parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty,
|
|
|
|
|
|
// preTaxDiff: 0,
|
|
|
|
|
|
// taxDiff: 0,
|
|
|
|
|
|
// clientCode: string.Empty,
|
|
|
|
|
|
// 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.Site = dtos.FirstOrDefault().Site;
|
|
|
|
|
|
// invbill.CreationTime = DateTime.MinValue;
|
|
|
|
|
|
// invbill.LastModificationTime = DateTime.Now;
|
|
|
|
|
|
// invlist.Add(invbill);
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
//}
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
_dbcontext.BulkInsert(invlist); |
|
|
|
|
|
_dbcontext.BulkInsert(groupList); |
|
|
smalllist = smalllist.OrderBy(p => p.Amt).ToList(); |
|
|
_dbcontext.BulkInsert(detailList); |
|
|
_invls= GenSecInvoice(smalllist, p_list, p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//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 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 entityList = query.ToList();
|
|
|
if (adjlist.Count > 0) |
|
|
|
|
|
{ |
|
|
// foreach (var entity in entityList)
|
|
|
_dbcontext.BulkInsert(adjlist); |
|
|
// {
|
|
|
} |
|
|
// entity.InvbillNum = inv.InvBillNum;
|
|
|
if (notDetialList.Count > 0) |
|
|
// }
|
|
|
{ |
|
|
|
|
|
_dbcontext.BulkInsert(notDetialList); |
|
|
// salist.AddRange(entityList);
|
|
|
} |
|
|
|
|
|
_invls = invlist.Select(p => p.InvbillNum).ToList(); |
|
|
// 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);//税额
|
|
|
|
|
|
|
|
|
|
|
|
// var invoicegroupls = entityList.Select(p => p.GroupNum);
|
|
|
|
|
|
// var mapList = new List<INVOICE_MAP_GROUP>();
|
|
|
|
|
|
// foreach (var groupnum in invoicegroupls)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// mapList.Add(new INVOICE_MAP_GROUP(
|
|
|
|
|
|
// guid: GuidGenerator.Create(),
|
|
|
|
|
|
// version: p_version,
|
|
|
|
|
|
// invbillNum: inv.InvBillNum,
|
|
|
|
|
|
// invGroupNum: p_InvGroupNum,
|
|
|
|
|
|
// settleGroupNum: groupnum,
|
|
|
|
|
|
// amt: 0,
|
|
|
|
|
|
// extend1: string.Empty,
|
|
|
|
|
|
// extend2: string.Empty
|
|
|
|
|
|
// )
|
|
|
|
|
|
// );
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (mapList.Count > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// groupList.AddRange(mapList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// var innotls = new List<INVOICE_NOT_SETTLE>();
|
|
|
|
|
|
// var sq = entityList.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum })
|
|
|
|
|
|
// .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, 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: "可结算",
|
|
|
|
|
|
// extend2: string.Empty,
|
|
|
|
|
|
// qty: sitm.Qty,
|
|
|
|
|
|
// p_invbillnum: sitm.InvBillNum
|
|
|
|
|
|
// ));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (innotls.Count > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// notDetialList.AddRange(innotls);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
|
|
|
|
|
|
// foreach (var detail in partlist)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// _entityDetailList.Add(
|
|
|
|
|
|
// new INVOICE_WAIT_DETAIL(
|
|
|
|
|
|
// guid: GuidGenerator.Create(),
|
|
|
|
|
|
// version: p_version,
|
|
|
|
|
|
// invbillNum: inv.InvBillNum,
|
|
|
|
|
|
// invGroupNum: p_InvGroupNum,
|
|
|
|
|
|
// lU: detail.LU,
|
|
|
|
|
|
// qty: detail.Qty,
|
|
|
|
|
|
// bussiessType: businessType,
|
|
|
|
|
|
// amt: detail.Amt,
|
|
|
|
|
|
// pRICE: detail.Price,
|
|
|
|
|
|
// extend1: detail.ContactDocID,
|
|
|
|
|
|
// extend2: string.Empty,
|
|
|
|
|
|
// beginDate: detail.BeginDate.Value,
|
|
|
|
|
|
// endDate: detail.EndDate.Value,
|
|
|
|
|
|
// partcode: detail.PartCode
|
|
|
|
|
|
// ));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (_entityDetailList.Count > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// detailList.AddRange(_entityDetailList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// var invbill = new INVOICE_GRP
|
|
|
|
|
|
// (
|
|
|
|
|
|
// guid: GuidGenerator.Create(),
|
|
|
|
|
|
// realnvBillNum: string.Empty,
|
|
|
|
|
|
// invbillNum: inv.InvBillNum,
|
|
|
|
|
|
// amt: amt,
|
|
|
|
|
|
// taxAmt: txtAmt,
|
|
|
|
|
|
// fileName: string.Empty,
|
|
|
|
|
|
// businessType: businessType,
|
|
|
|
|
|
// invGroupNum: p_InvGroupNum,
|
|
|
|
|
|
// state: SettleBillState.已开票,
|
|
|
|
|
|
// invoiceBillState: InvoiceBillState.正常,
|
|
|
|
|
|
// tax: 0.13m,
|
|
|
|
|
|
// parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty,
|
|
|
|
|
|
// preTaxDiff: 0,
|
|
|
|
|
|
// taxDiff: 0,
|
|
|
|
|
|
// clientCode: string.Empty,
|
|
|
|
|
|
// 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.Site = dtos.FirstOrDefault().Site;
|
|
|
|
|
|
// invbill.CreationTime = DateTime.MinValue;
|
|
|
|
|
|
// invbill.LastModificationTime = DateTime.Now;
|
|
|
|
|
|
// invlist.Add(invbill);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (salist.Count > 0)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// _dbcontext.BulkUpdate(salist);
|
|
|
|
|
|
// var detailext = salist.GroupBy(p => new { p.InvbillNum, p.InvGroupNum, p.PartCode, p.LU, p.Price, p.ErpLoc, p.BusinessType })
|
|
|
|
|
|
// .Select(p => new INVOICE_DETAIL_EXT
|
|
|
|
|
|
// {
|
|
|
|
|
|
// Version = p_version,
|
|
|
|
|
|
// InvbillNum = p.Key.InvbillNum,
|
|
|
|
|
|
// InvGroupNum = p.Key.InvGroupNum,
|
|
|
|
|
|
// PartCode = p.Key.PartCode,
|
|
|
|
|
|
// PRICE = p.Key.Price,
|
|
|
|
|
|
// ErpLoc = p.Key.ErpLoc,
|
|
|
|
|
|
// Qty = p.Sum(k => k.Qty),
|
|
|
|
|
|
// BussiessType = p.Key.BusinessType,
|
|
|
|
|
|
// Amt = Math.Round(p.Sum(k => k.Qty) * p.Key.Price, 2),//税前
|
|
|
|
|
|
// LU = p.Key.LU
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
// ).ToList();
|
|
|
|
|
|
// foreach (var itm in detailext)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// itm.SetId(GuidGenerator.Create());
|
|
|
|
|
|
// itm.CreationTime = DateTime.Now;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// _dbcontext.BulkInsert(detailext);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
} |
|
|
//_dbcontext.BulkInsert(invlist);
|
|
|
if (smalllist.Count > 0) |
|
|
//_dbcontext.BulkInsert(groupList);
|
|
|
{ |
|
|
//_dbcontext.BulkInsert(detailList);
|
|
|
smalllist = smalllist.OrderBy(p => p.Amt).ToList(); |
|
|
|
|
|
_invls = GenSecInvoice(smalllist, p_list, p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (adjlist.Count > 0)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// _dbcontext.BulkInsert(adjlist);
|
|
|
|
|
|
//}
|
|
|
|
|
|
//if (notDetialList.Count > 0)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// _dbcontext.BulkInsert(notDetialList);
|
|
|
|
|
|
//}
|
|
|
|
|
|
//_invls = invlist.Select(p => p.InvbillNum).ToList();
|
|
|
|
|
|
} |
|
|
} |
|
|
return _invls; |
|
|
return _invls; |
|
|
} |
|
|
} |
|
@ -1058,26 +1001,64 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
groupList.AddRange(mapList); |
|
|
groupList.AddRange(mapList); |
|
|
} |
|
|
} |
|
|
var innotls = new List<INVOICE_NOT_SETTLE>(); |
|
|
var innotls = new List<INVOICE_NOT_SETTLE>(); |
|
|
var sq = entityList.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum }) |
|
|
|
|
|
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum }); |
|
|
|
|
|
foreach (var sitm in sq) |
|
|
|
|
|
|
|
|
if (entityList is List<BBAC_CAN_SA_DETAIL>) |
|
|
{ |
|
|
{ |
|
|
innotls.Add(new INVOICE_NOT_SETTLE( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
version: p_version, |
|
|
var entityList1 = entityList as List<BBAC_CAN_SA_DETAIL>; |
|
|
invGroupNum: p_InvGroupNum, |
|
|
|
|
|
settleGroupNum: sitm.GroupNum, |
|
|
|
|
|
lU: sitm.LU, |
|
|
var sq = entityList1.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum,p.ContractDocID }) |
|
|
lU1: sitm.LU, |
|
|
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum,SA=p.Key.ContractDocID }); |
|
|
extend1: "可结算", |
|
|
foreach (var sitm in sq) |
|
|
extend2: string.Empty, |
|
|
{ |
|
|
qty: sitm.Qty, |
|
|
innotls.Add(new INVOICE_NOT_SETTLE( |
|
|
p_invbillnum: sitm.InvBillNum |
|
|
guid: GuidGenerator.Create(), |
|
|
)); |
|
|
version: p_version, |
|
|
|
|
|
invGroupNum: p_InvGroupNum, |
|
|
|
|
|
settleGroupNum: sitm.GroupNum, |
|
|
|
|
|
lU: sitm.LU, |
|
|
|
|
|
lU1: sitm.LU, |
|
|
|
|
|
extend1: "可结算", |
|
|
|
|
|
extend2: sitm.SA, |
|
|
|
|
|
qty: sitm.Qty, |
|
|
|
|
|
p_invbillnum: sitm.InvBillNum |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
if (innotls.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
notDetialList.AddRange(innotls); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
if (innotls.Count > 0) |
|
|
else |
|
|
{ |
|
|
{ |
|
|
notDetialList.AddRange(innotls); |
|
|
var sq = entityList.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum }) |
|
|
|
|
|
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, 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: "可结算", |
|
|
|
|
|
extend2: string.Empty, |
|
|
|
|
|
qty: sitm.Qty, |
|
|
|
|
|
p_invbillnum: sitm.InvBillNum |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
if (innotls.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
notDetialList.AddRange(innotls); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|