|
@ -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,7 +723,12 @@ 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 }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (partlist is List<BBAC_CAN_SA_DETAIL>)
|
|
|
|
|
|
//{
|
|
|
|
|
|
var partlist1 = partlist as List<BBAC_CAN_SA_DETAIL>; |
|
|
|
|
|
var sq = partlist1.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 }); |
|
|
.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) |
|
|
foreach (var sitm in sq) |
|
|
{ |
|
|
{ |
|
@ -808,63 +817,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
invbill.LastModificationTime = DateTime.Now; |
|
|
invbill.LastModificationTime = DateTime.Now; |
|
|
invlist.Add(invbill); |
|
|
invlist.Add(invbill); |
|
|
#endregion
|
|
|
#endregion
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
smalllist = smalllist.OrderBy(p => p.Amt).ToList(); |
|
|
|
|
|
_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();
|
|
|
|
|
|
|
|
|
|
|
|
// foreach (var entity in entityList)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// entity.InvbillNum = inv.InvBillNum;
|
|
|
|
|
|
//}
|
|
|
//}
|
|
|
|
|
|
//else
|
|
|
// salist.AddRange(entityList);
|
|
|
|
|
|
|
|
|
|
|
|
// 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(
|
|
|
// var sq = partlist.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum })
|
|
|
// 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 });
|
|
|
// .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)
|
|
|
// foreach (var sitm in sq)
|
|
|
// {
|
|
|
// {
|
|
@ -878,7 +836,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
// extend1: "可结算",
|
|
|
// extend1: "可结算",
|
|
|
// extend2: string.Empty,
|
|
|
// extend2: string.Empty,
|
|
|
// qty: sitm.Qty,
|
|
|
// qty: sitm.Qty,
|
|
|
// p_invbillnum: sitm.InvBillNum
|
|
|
// p_invbillnum: inv.InvBillNum
|
|
|
// ));
|
|
|
// ));
|
|
|
// }
|
|
|
// }
|
|
|
// if (innotls.Count > 0)
|
|
|
// if (innotls.Count > 0)
|
|
@ -886,9 +844,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
// notDetialList.AddRange(innotls);
|
|
|
// notDetialList.AddRange(innotls);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// #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 partlist)
|
|
|
// foreach (var detail in detailDtos)
|
|
|
// {
|
|
|
// {
|
|
|
// _entityDetailList.Add(
|
|
|
// _entityDetailList.Add(
|
|
|
// new INVOICE_WAIT_DETAIL(
|
|
|
// new INVOICE_WAIT_DETAIL(
|
|
@ -903,8 +861,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
// pRICE: detail.Price,
|
|
|
// pRICE: detail.Price,
|
|
|
// extend1: detail.ContactDocID,
|
|
|
// extend1: detail.ContactDocID,
|
|
|
// extend2: string.Empty,
|
|
|
// extend2: string.Empty,
|
|
|
// beginDate: detail.BeginDate.Value,
|
|
|
// beginDate: detail.BeginDate,
|
|
|
// endDate: detail.EndDate.Value,
|
|
|
// endDate: detail.EndDate,
|
|
|
// partcode: detail.PartCode
|
|
|
// partcode: detail.PartCode
|
|
|
// ));
|
|
|
// ));
|
|
|
// }
|
|
|
// }
|
|
@ -912,6 +870,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
// {
|
|
|
// {
|
|
|
// detailList.AddRange(_entityDetailList);
|
|
|
// detailList.AddRange(_entityDetailList);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
// #region 发票
|
|
|
// var invbill = new INVOICE_GRP
|
|
|
// var invbill = new INVOICE_GRP
|
|
|
// (
|
|
|
// (
|
|
|
// guid: GuidGenerator.Create(),
|
|
|
// guid: GuidGenerator.Create(),
|
|
@ -950,51 +910,34 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
// invbill.CreationTime = DateTime.MinValue;
|
|
|
// invbill.CreationTime = DateTime.MinValue;
|
|
|
// invbill.LastModificationTime = DateTime.Now;
|
|
|
// invbill.LastModificationTime = DateTime.Now;
|
|
|
// invlist.Add(invbill);
|
|
|
// invlist.Add(invbill);
|
|
|
|
|
|
// #endregion
|
|
|
//}
|
|
|
//}
|
|
|
//}
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
_dbcontext.BulkInsert(invlist); |
|
|
|
|
|
_dbcontext.BulkInsert(groupList); |
|
|
|
|
|
_dbcontext.BulkInsert(detailList); |
|
|
|
|
|
|
|
|
|
|
|
if (adjlist.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_dbcontext.BulkInsert(adjlist); |
|
|
|
|
|
} |
|
|
|
|
|
if (notDetialList.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_dbcontext.BulkInsert(notDetialList); |
|
|
|
|
|
} |
|
|
|
|
|
_invls = invlist.Select(p => p.InvbillNum).ToList(); |
|
|
|
|
|
|
|
|
//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();
|
|
|
if (smalllist.Count > 0) |
|
|
// foreach (var itm in detailext)
|
|
|
{ |
|
|
// {
|
|
|
smalllist = smalllist.OrderBy(p => p.Amt).ToList(); |
|
|
// itm.SetId(GuidGenerator.Create());
|
|
|
_invls = GenSecInvoice(smalllist, p_list, p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); |
|
|
// itm.CreationTime = DateTime.Now;
|
|
|
} |
|
|
// }
|
|
|
|
|
|
// _dbcontext.BulkInsert(detailext);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
//_dbcontext.BulkInsert(invlist);
|
|
|
|
|
|
//_dbcontext.BulkInsert(groupList);
|
|
|
|
|
|
//_dbcontext.BulkInsert(detailList);
|
|
|
|
|
|
|
|
|
|
|
|
//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,6 +1001,40 @@ 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>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (entityList is List<BBAC_CAN_SA_DETAIL>) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var entityList1 = entityList as List<BBAC_CAN_SA_DETAIL>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sq = entityList1.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum,p.ContractDocID }) |
|
|
|
|
|
.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 }); |
|
|
|
|
|
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: sitm.SA, |
|
|
|
|
|
qty: sitm.Qty, |
|
|
|
|
|
p_invbillnum: sitm.InvBillNum |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
if (innotls.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
notDetialList.AddRange(innotls); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
var sq = entityList.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum }) |
|
|
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 }); |
|
|
.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) |
|
|
foreach (var sitm in sq) |
|
@ -1081,6 +1058,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>(); |
|
|
foreach (var detail in partlist) |
|
|
foreach (var detail in partlist) |
|
|
{ |
|
|
{ |
|
|