@ -241,485 +241,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//[UnitOfWork(false)]
/// <summary>
/// 提交到QAD
/// </summary>
//private async Task SubmitToQadSingle(string invbillNum)
//{
// var invoiceGrp = _settleAccountDbContext.Set<INVOICE_GRP>()
// .Where(t => t.InvbillNum == invbillNum)
// .Where(t => t.State == SettleBillState.已扣减)
// .FirstOrDefault();
// if (invoiceGrp.BusinessType == EnumBusinessType.JisBBAC)
// {
// var _detail = await _bbacMng.GetDetailAsync(invbillNum, EnumBusinessType.MaiDanJianBBAC).ConfigureAwait(false);//查出买单数量
// var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>().AsNoTracking()
// .Where(t => t.InvbillNum == invbillNum)
// .ToList();
// var invoiceGrpDetailsCopy = JsonConvert.DeserializeObject<List<INVOICE_WAIT_DETAIL>>(JsonConvert.SerializeObject(invoiceGrpDetails));
// var invmaidanlist= await _bbacMng.GetOnlyMaiDanAsync(invbillNum);
// if (invmaidanlist != null && invmaidanlist.Count() > 0)
// {
// var query = from itm1 in invoiceGrpDetails
// join itm2 in invmaidanlist
// on new { PartCode = itm1.PartCode, ContractDocID = itm1.Extend1 }
// equals new { PartCode = itm2.PartCode, itm2.ContractDocID }
// into temp
// from j in temp.DefaultIfEmpty()
// where j == null
// select itm1;
// invoiceGrpDetails = query.ToList();
// }
// if (invoiceGrpDetails.Any())
// {
// var tedSaInvs = new List<TED_SAS_INVOICE>();
// var taskId = GuidGenerator.Create();
// var teaTaskSub = new TEA_TASK_SUB()
// {
// GUID = taskId,
// TaskState = 0,
// TaskID = taskId,
// TableName = "TED_SAS_INVOICE",
// Creator = "SAS",
// Subscriber = "QAD",
// Domain = "BJBMPT",
// Site = "BJ02",
// CreateTime = DateTime.Now,
// UpdateTime = DateTime.Now,
// Remark=string.IsNullOrEmpty(invoiceGrp.FileName)?string.Empty:invoiceGrp.FileName
// };
// List<INVOICE_WAIT_DETAIL> invdetials = new List<INVOICE_WAIT_DETAIL>();
// var invoiceGrpDetails1 = JsonConvert.DeserializeObject<List<INVOICE_WAIT_DETAIL>>(JsonConvert.SerializeObject(invoiceGrpDetails));
// foreach (var itm in invoiceGrpDetails1)
// {
// var inv = new INVOICE_WAIT_DETAIL();//添加买单件
// inv.InjectFrom(itm);
// var first = _detail.FirstOrDefault(p => p.ContractDocID == itm.Extend1 && p.PartCode == itm.PartCode);
// if (first == null)
// {
// inv.Extend2= $"C{invoiceGrp.ClientCode}";
// invdetials.Add(inv);//添加发票明细
// continue;
// }
// else
// {
// if (itm.Qty >= first.Qty)
// {
// inv.Qty = itm.Qty - first.Qty;//发票总数中去除
// inv.Amt = Math.Round((itm.Qty - first.Qty) * itm.PRICE, 2);
// inv.Extend2 = $"C{invoiceGrp.ClientCode}";
// }
// //inv.BussiessType = EnumBusinessType.MaiDanJianBBAC;
// //if (invoiceGrp.Site == "1046")
// //{
// // inv.Extend2 = "CC16";
// //}
// //if (invoiceGrp.Site == "1040")
// //{
// // inv.Extend2 ="CC11";
// //}
// invdetials.Add(inv);
// }
// }
// foreach (var itm in _detail)
// {
// var inv = new INVOICE_WAIT_DETAIL();
// var first= invoiceGrpDetailsCopy.FirstOrDefault(p=>p.PartCode==itm.PartCode);
// inv.InjectFrom(first);
// inv.LU = itm.LU;
// inv.PartCode = itm.PartCode;
// inv.Qty = itm.Qty;
// inv.PRICE = first.PRICE;
// inv.Amt = Math.Round(itm.Qty * first.PRICE, 2);
// inv.Extend1 = itm.ContractDocID;
// inv.BussiessType = EnumBusinessType.MaiDanJianBBAC;
// if (invoiceGrp.Site == "1046")
// {
// inv.Extend2 = "CC16";
// }
// if (invoiceGrp.Site == "1040")
// {
// inv.Extend2 = "CC11";
// }
// invdetials.Add(inv);
// }
// for (var i = 0; i < invdetials.Count; i++)
// {
// var invoiceGrpDetail = invdetials[i];
// tedSaInvs.Add(new TED_SAS_INVOICE()
// {
// GUID = GuidGenerator.Create(),
// Dataid = GuidGenerator.Create(),
// Taskid = taskId,
// invoiceNumber = invoiceGrp.RealnvBillNum,
// sasInvoiceNumber = invoiceGrp.InvbillNum,
// Customer = invoiceGrp.ClientCode,
// BillTo = invoiceGrp.ClientCode,
// InvoiceDate = invoiceGrp.CreationTime,
// Site = "BJ02",
// PartNumber = invoiceGrpDetail.PartCode,
// InvoiceQuatity = invoiceGrpDetail.Qty,
// Price = invoiceGrpDetail.PRICE,
// InvoiceNetAmount = invoiceGrpDetail.Amt,
// InvoiceTaxAmount = Math.Round(invoiceGrpDetail.Amt * 0.13m, 2),
// TaxRate = 0.13m,
// Remark = string.IsNullOrEmpty(invoiceGrp.FileName) ? string.Empty : invoiceGrp.FileName,
// Location = invoiceGrpDetail.Extend2,
// begintime = invoiceGrpDetail.BeginDate,
// endtime = invoiceGrpDetail.EndDate,
// domain = "BJBMPT",
// LINE = (i + 1).ToString()
// });
// }
// var tedsaInvs1 = JsonConvert.DeserializeObject<List<TED_SAS_INVOICE>>(JsonConvert.SerializeObject(tedSaInvs));
// //var invbefore = invoiceGrp.TaxAmt + invoiceGrp.TaxDiff;
// var invbefore = invoiceGrp.RealAmt + invoiceGrp.TaxDiff;//
// var invafter = tedsaInvs1.Sum(p => p.InvoiceTaxAmount);
// var invdiff = invbefore - invafter;
// //invoiceGrp.RealAmt + invoiceGrp.TaxDiff-invafter;
// tedsaInvs1.FirstOrDefault().InvoiceTaxAmount += invdiff;
// //红冲发票提交QAD
// if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum))
// {
// await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum).ConfigureAwait(false);
// }
// await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false);
// await _exChangeCenterDbContext.BulkInsertAsync(tedsaInvs1).ConfigureAwait(false);
// invoiceGrp.State = SettleBillState.已提交QAD;
// await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp });
// await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode, invoiceGrp.CreationTime).ConfigureAwait(false);
// }
// }
// else
// {
// var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>()
// .Where(t => t.InvbillNum == invbillNum)
// .ToList();
// if (invoiceGrpDetails.Any())
// {
// var tedSaInvs = new List<TED_SAS_INVOICE>();
// var taskId = GuidGenerator.Create();
// var teaTaskSub = new TEA_TASK_SUB()
// {
// GUID = taskId,
// TaskState = 0,
// TaskID = taskId,
// TableName = "TED_SAS_INVOICE",
// Creator = "SAS",
// Subscriber = "QAD",
// Domain = "BJBMPT",
// Site = "BJ02",
// CreateTime = DateTime.Now,
// UpdateTime = DateTime.Now,
// Remark = string.IsNullOrEmpty(invoiceGrp.FileName) ? string.Empty : invoiceGrp.FileName
// };
// for (var i = 0; i < invoiceGrpDetails.Count; i++)
// {
// var invoiceGrpDetail = invoiceGrpDetails[i];
// if (invoiceGrpDetail.BussiessType == EnumBusinessType.MaiDanJianHBPO)
// {
// invoiceGrpDetail.SetProperty("ErpToLoc", "CC14");
// }
// if (invoiceGrpDetail.BussiessType == EnumBusinessType.BeiJian)
// {
// invoiceGrpDetail.SetProperty("ErpToLoc", "CC005");
// }
// if (invoiceGrpDetail.BussiessType == EnumBusinessType.JisHBPO)
// {
// invoiceGrpDetail.SetProperty("ErpToLoc", $"C{invoiceGrp.ClientCode}");
// }
// if (invoiceGrpDetail.BussiessType == EnumBusinessType.ZhiGongJianBBAC)
// {
// invoiceGrpDetail.SetProperty("ErpToLoc", $"C{invoiceGrp.ClientCode}");
// }
// if (invoiceGrpDetail.BussiessType == EnumBusinessType.ZhiGongJianHBPO)
// {
// invoiceGrpDetail.SetProperty("ErpToLoc", $"C{invoiceGrp.ClientCode}");
// }
// if (invoiceGrpDetail.BussiessType == EnumBusinessType.YinDuJian)
// {
// invoiceGrpDetail.SetProperty("ErpToLoc", "CC001");
// }
// tedSaInvs.Add(new TED_SAS_INVOICE()
// {
// GUID = GuidGenerator.Create(),
// Dataid = GuidGenerator.Create(),
// Taskid = taskId,
// invoiceNumber = invoiceGrp.RealnvBillNum,
// sasInvoiceNumber = invoiceGrp.InvbillNum,
// Customer = invoiceGrp.ClientCode,
// BillTo = invoiceGrp.ClientCode,
// InvoiceDate = invoiceGrp.CreationTime,
// Site = "BJ02",
// PartNumber = invoiceGrpDetail.PartCode,
// InvoiceQuatity = invoiceGrpDetail.Qty,
// Price = invoiceGrpDetail.PRICE,
// InvoiceNetAmount = invoiceGrpDetail.Amt,
// InvoiceTaxAmount = Math.Round(invoiceGrpDetail.Amt * 0.13m, 2),
// TaxRate = 0.13m,
// Location = invoiceGrpDetail.GetProperty("ErpToLoc", string.Empty),
// begintime = invoiceGrpDetail.BeginDate,
// endtime = invoiceGrpDetail.EndDate,
// domain = "BJBMPT",
// LINE = (i + 1).ToString()
// });
// }
// var invbefore = invoiceGrp.RealAmt + invoiceGrp.TaxDiff;//
// var invafter = tedSaInvs.Sum(p => p.InvoiceTaxAmount);
// var invdiff = invbefore - invafter;
// tedSaInvs.FirstOrDefault().InvoiceTaxAmount += invdiff;
// //tedSaInvs.FirstOrDefault().InvoiceTaxAmount += invoiceGrp.TaxDiff;
// //红冲发票提交QAD
// if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum))
// {
// await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum).ConfigureAwait(false);
// }
// await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false);
// await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false);
// invoiceGrp.State = SettleBillState.已提交QAD;
// await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp });
// await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode, invoiceGrp.CreationTime).ConfigureAwait(false);
// }
// }
//}
/// <summary>
/// 红冲发票提交到QAD
/// </summary>
//private async Task SubmitToQadHongChongAsync(string invbillNum, List<BBAC_CAN_SA_DETAIL> p_detail = null)
//{
// var invoiceGrp = await _settleAccountDbContext.Set<INVOICE_GRP>()
// .Where(t => t.State == SettleBillState.红冲发票)
// .Where(t => t.InvbillNum == invbillNum)
// .FirstOrDefaultAsync().ConfigureAwait(false);
// List<PriceList> priceList = new List<PriceList>();
// if (first.BusinessType == EnumBusinessType.BeiJian)
// {
// var priceListbj = _pricebjRepository.Where(p => p.IsCancel == false).ToList(); //价格单
// foreach (var itm in priceListbj)
// {
// priceList.Add(new PriceList() { LU = itm.LU, BeginTime = itm.BeginDate, EndTime = itm.EndDate, Price = itm.Price, ClientCode = itm.ClientCode });
// }
// }
// else if (first.BusinessType == EnumBusinessType.YinDuJian)
// {
// var priceListyd = _priceydRepository.Where(p => p.IsCancel == false).ToList(); //价格单
// foreach (var itm in priceListyd)
// {
// priceList.Add(new PriceList() { LU = itm.LU, BeginTime = itm.BeginDate, EndTime = itm.EndDate, Price = itm.Price, ClientCode = itm.ClientCode });
// }
// }
// else
// {
// priceList = _priceRepository.Where(p => p.IsCancel == false).ToList();//价格单
// }
// if (invoiceGrp == null)
// {
// return;
// }
// if (p_detail != null && p_detail.Count > 0)
// {
// var _detail = p_detail.ToList();
// var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>().AsNoTracking()
// .Where(t => t.InvbillNum == invbillNum)
// .ToList();
// if (invoiceGrpDetails.Any())
// {
// var tedSaInvs = new List<TED_SAS_INVOICE>();
// var taskId = GuidGenerator.Create();
// var teaTaskSub = new TEA_TASK_SUB()
// {
// GUID = taskId,
// TaskState = 0,
// TaskID = taskId,
// TableName = "TED_SAS_INVOICE",
// Creator = "SAS",
// Subscriber = "QAD",
// Domain = "BJBMPT",
// Site = "BJ02",
// CreateTime = DateTime.Now,
// UpdateTime = DateTime.Now,
// Remark = string.IsNullOrEmpty(invoiceGrp.FileName) ? string.Empty : invoiceGrp.FileName
// };
// List<INVOICE_WAIT_DETAIL> invdetials = new List<INVOICE_WAIT_DETAIL>();
// var invoiceGrpDetails1 = JsonConvert.DeserializeObject<List<INVOICE_WAIT_DETAIL>>(JsonConvert.SerializeObject(invoiceGrpDetails));
// foreach (var itm in invoiceGrpDetails1)
// {
// var inv = new INVOICE_WAIT_DETAIL();//添加买单件
// inv.InjectFrom(itm);
// var first = _detail.FirstOrDefault(p => p.ContractDocID == itm.Extend1 && p.PartCode == itm.PartCode);
// if (first == null)
// {
// inv.SetProperty("ErpToLoc", $"C{invoiceGrp.ClientCode}");
// invdetials.Add(itm);//添加发票明细
// continue;
// }
// else
// {
// if (itm.Qty > first.Qty)
// {
// inv.Qty = itm.Qty - first.Qty;//发票总数中去除
// inv.Amt = Math.Round(itm.Qty * itm.PRICE, 2);
// }
// inv.BussiessType = EnumBusinessType.MaiDanJianBBAC;
// if (invoiceGrp.Site == "1046")
// {
// inv.SetProperty("ErpToLoc", "CC16");
// }
// if (invoiceGrp.Site == "1040")
// {
// inv.SetProperty("ErpToLoc", "CC11");
// }
// invdetials.Add(inv);
// }
// }
// for (var i = 0; i < invdetials.Count; i++)
// {
// var invoiceGrpDetail = invdetials[i];
// tedSaInvs.Add(new TED_SAS_INVOICE()
// {
// GUID = GuidGenerator.Create(),
// Dataid = GuidGenerator.Create(),
// Taskid = taskId,
// invoiceNumber = invoiceGrp.RealnvBillNum,
// sasInvoiceNumber = invoiceGrp.InvbillNum,
// Customer = invoiceGrp.ClientCode,
// BillTo = invoiceGrp.ClientCode,
// InvoiceDate = invoiceGrp.CreationTime,
// Site = "BJ02",
// PartNumber = invoiceGrpDetail.PartCode,
// InvoiceQuatity = invoiceGrpDetail.Qty,
// Price = invoiceGrpDetail.PRICE,
// InvoiceNetAmount = invoiceGrpDetail.Amt,
// InvoiceTaxAmount = Math.Round(invoiceGrpDetail.Amt * 0.13m, 2),
// TaxRate = 0.13m,
// Location = invoiceGrpDetail.GetProperty("ErpToLoc", string.Empty),
// begintime = invoiceGrpDetail.BeginDate,
// endtime = invoiceGrpDetail.EndDate,
// Remark = string.IsNullOrEmpty(invoiceGrp.FileName) ? string.Empty : invoiceGrp.FileName,
// domain = "BJBMPT",
// LINE = (i + 1).ToString()
// });
// }
// var tedsaInvs1 = JsonConvert.DeserializeObject<List<TED_SAS_INVOICE>>(JsonConvert.SerializeObject(tedSaInvs));
// var invbefore = invoiceGrp.RealAmt + invoiceGrp.TaxDiff;//
// var invafter = tedsaInvs1.Sum(p => p.InvoiceTaxAmount);
// var invdiff = invbefore - invafter;
// tedsaInvs1.FirstOrDefault().InvoiceTaxAmount += invdiff;
// //invbefore= invafter +x;
// //var line1 = tedsaInvs1.FirstOrDefault(p => p.LINE == "1");
// //var line2 = tedsaInvs1.FirstOrDefault(p => p.LINE == "2");
// ////line2.InvoiceTaxAmount += invdiff;
// //line1.InvoiceTaxAmount += invdiff;
// //红冲发票提交QAD
// await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false);
// foreach (var itm in tedsaInvs1)
// {
// itm.InvoiceQuatity = -itm.InvoiceQuatity;
// itm.InvoiceNetAmount = -itm.InvoiceNetAmount;
// itm.InvoiceTaxAmount = -itm.InvoiceTaxAmount;
// }
// await _exChangeCenterDbContext.BulkInsertAsync(tedsaInvs1).ConfigureAwait(false);
// invoiceGrp.State = SettleBillState.已提交QAD;
// await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp });
// await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode, invoiceGrp.CreationTime).ConfigureAwait(false);
// }
// }
// else
// {
// var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>()
// .Where(t => t.InvbillNum == invbillNum)
// .ToList();
// if (invoiceGrpDetails.Any())
// {
// var tedSaInvs = new List<TED_SAS_INVOICE>();
// var taskId = GuidGenerator.Create();
// var teaTaskSub = new TEA_TASK_SUB()
// {
// GUID = taskId,
// TaskState = 0,
// TaskID = taskId,
// TableName = "TED_SAS_INVOICE",
// Creator = "SAS",
// Subscriber = "QAD",
// Domain = "BJBMPT",
// Site = "BJ02",
// CreateTime = DateTime.Now,
// UpdateTime = DateTime.Now,
// Remark = string.IsNullOrEmpty(invoiceGrp.FileName) ? string.Empty : invoiceGrp.FileName
// };
// for (var i = 0; i < invoiceGrpDetails.Count; i++)
// {
// var invoiceGrpDetail = invoiceGrpDetails[i];
// tedSaInvs.Add(new TED_SAS_INVOICE()
// {
// GUID = GuidGenerator.Create(),
// Dataid = GuidGenerator.Create(),
// Taskid = taskId,
// invoiceNumber = invoiceGrp.RealnvBillNum,
// sasInvoiceNumber = invoiceGrp.InvbillNum,
// Customer = invoiceGrp.ClientCode,
// BillTo = invoiceGrp.ClientCode,
// InvoiceDate = invoiceGrp.CreationTime,
// Site = "BJ02",
// PartNumber = invoiceGrpDetail.PartCode,
// InvoiceQuatity = invoiceGrpDetail.Qty,
// Price = invoiceGrpDetail.PRICE,
// InvoiceNetAmount = invoiceGrpDetail.Amt,
// InvoiceTaxAmount = Math.Round(invoiceGrpDetail.Amt * 0.13m, 2),
// TaxRate = 0.13m,
// Location = invoiceGrp.GetProperty("ErpToLoc", string.Empty),
// begintime = DateTime.Now,
// endtime = DateTime.Now,
// domain = "BJBMPT",
// LINE = (i + 1).ToString()
// });
// }
// var invbefore = invoiceGrp.RealAmt + invoiceGrp.TaxDiff;//
// var invafter = tedSaInvs.Sum(p => p.InvoiceTaxAmount);
// var invdiff = invbefore - invafter;
// tedSaInvs.FirstOrDefault().InvoiceTaxAmount += invdiff;
// //await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false);
// //await _exChangeCenterDbContext.Set<TED_SAS_INVOICE>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
// //invoiceGrp.State = SettleBillState.已提交QAD;
// ////构建发票同步Qad状态表数据
// //await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false);
// await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false);
// foreach (var itm in tedSaInvs)
// {
// itm.InvoiceQuatity = -itm.InvoiceQuatity;
// itm.InvoiceNetAmount = -itm.InvoiceNetAmount;
// itm.InvoiceTaxAmount = -itm.InvoiceTaxAmount;
// }
// await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false);
// invoiceGrp.State = SettleBillState.已提交QAD;
// await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp });
// await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode, invoiceGrp.CreationTime).ConfigureAwait(false);
// }
// }
//}
/// <summary>
/// 构建发票同步Qad状态表数据
/// </summary>
@ -898,7 +419,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private async Task CreateBBACTaskAsync ( List < string > invoiceGrps )
{
var invDetails = await _ settleAccountDbContext . Set < BBAC_CAN_SA_DETAIL > ( ) . Where ( p = > invoiceGrps . Contains ( p . InvbillNum ) ) . AsNoTracking ( ) . ToListAsync ( ) . ConfigureAwait ( false ) ;
var invDetails = await _ settleAccountDbContext . Set < INVOICE_DETAIL_EXT > ( ) . Where ( p = > invoiceGrps . Contains ( p . InvbillNum ) ) . AsNoTracking ( ) . ToListAsync ( ) . ConfigureAwait ( false ) ;
// var invDetails = await _settleAccountDbContext.Set<BBAC_CAN_SA_DETAIL>().Where(p => invoiceGrps.Contains(p.InvbillNum)).AsNoTracking().ToListAsync().ConfigureAwait(false);
foreach ( var itm in invoiceGrps )
{
var ls = invDetails . Where ( p = > p . InvbillNum = = itm ) . ToList ( ) ;
@ -906,17 +429,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var adj = await _ settleAccountDbContext . Set < PUB_ADJ_DETAIL > ( ) . Where ( p = > p . InvBillNum = = itm ) . AsNoTracking ( ) . ToListAsync ( ) . ConfigureAwait ( false ) ; //调整数量
if ( ls . Any ( ) & & invoice ! = null )
{
if ( adj . Any ( ) ) //假如存在调整单
{
var adjlist = await ChangedPrice < BBAC_CAN_SA_DETAIL > ( invoice . BusinessType , invoice . Site , adj ) . ConfigureAwait ( false ) ;
ls . AddRange ( adjlist ) ;
}
//if (adj.Any()) //假如存在调整单
//{
// var adjlist = await ChangedPrice<INVOICE_DETAIL_EXT>(invoice.BusinessType, invoice.Site, adj).ConfigureAwait(false);
// ls.AddRange(adjlist);
//}
foreach ( var itm1 in ls )
{
if ( string . IsNullOrEmpty ( itm1 . ErpLoc ) & & invoice . Site = = "1046" )
{
if ( itm1 . Busin essType = = EnumBusinessType . MaiDanJianBBAC )
if ( itm1 . Buss iessType = = EnumBusinessType . MaiDanJianBBAC )
{
itm1 . ErpLoc = "CC16" ;
}
@ -927,7 +450,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
if ( string . IsNullOrEmpty ( itm1 . ErpLoc ) & & invoice . Site = = "1040" )
{
if ( itm1 . Busin essType = = EnumBusinessType . MaiDanJianBBAC )
if ( itm1 . Buss iessType = = EnumBusinessType . MaiDanJianBBAC )
{
itm1 . ErpLoc = "CC11" ;
}
@ -937,8 +460,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
}
}
var details = ls . GroupBy ( p = > new { p . ErpLoc , p . PartCode , p . BusinessType , p . Price } )
. Select ( p = > new { Erploc = p . Key . ErpLoc , p . Key . PartCode , p . Key . BusinessType , Amt = Math . Round ( p . Sum ( t = > t . Qty * t . Price ) , 2 ) , Price = p . Key . Price , Qty = p . Sum ( t = > t . Qty ) } ) . ToList ( ) ;
var details = ls ;
//.GroupBy(p => new { p.ErpLoc, p.PartCode, p.BusinessType, p.Price })
//.Select(p => new { Erploc = p.Key.ErpLoc, p.Key.PartCode, p.Key.BusinessType, Amt = Math.Round(p.Sum(t => t.Qty * t.Price), 2), Price = p.Key.Price, Qty = p.Sum(t => t.Qty) }).ToList();
var tedSaInvs = new List < TED_SAS_INVOICE > ( ) ;
var taskId = GuidGenerator . Create ( ) ;
var teaTaskSub = new TEA_TASK_SUB ( )
@ -971,17 +495,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
Site = "BJ02" ,
PartNumber = invoiceGrpDetail . PartCode ,
InvoiceQuatity = invoiceGrpDetail . Qty ,
Price = invoiceGrpDetail . Price ,
Price = invoiceGrpDetail . PRICE ,
InvoiceNetAmount = invoiceGrpDetail . Amt ,
InvoiceTaxAmount = Math . Round ( invoiceGrpDetail . Amt * 0.13 m , 2 ) ,
TaxRate = 0.13 m ,
Location = invoiceGrpDetail . Erpl oc ,
Location = invoiceGrpDetail . ErpL oc ,
begintime = DateTime . Now ,
endtime = DateTime . Now ,
domain = "BJBMPT" ,
LINE = ( i + 1 ) . ToString ( ) ,
Remark = string . IsNullOrEmpty ( invoice . FileName ) ? string . Empty : invoice . FileName
} ) ;
}
var invbefore = invoice . RealAmt + invoice . TaxDiff ; //
@ -1003,7 +526,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private async Task CreateHBPOTaskAsync ( List < string > invoiceGrps )
{
var invDetails = await _ settleAccountDbContext . Set < HBPO_CAN_SA_DETAIL > ( ) . Where ( p = > invoiceGrps . Contains ( p . InvbillNum ) ) . AsNoTracking ( ) . ToListAsync ( ) . ConfigureAwait ( false ) ;
var invDetails = await _ settleAccountDbContext . Set < INVOICE_DETAIL_EXT > ( ) . Where ( p = > invoiceGrps . Contains ( p . InvbillNum ) ) . AsNoTracking ( ) . ToListAsync ( ) . ConfigureAwait ( false ) ;
// var invDetails=await _settleAccountDbContext.Set<HBPO_CAN_SA_DETAIL>().Where(p =>invoiceGrps.Contains(p.InvbillNum)).AsNoTracking().ToListAsync().ConfigureAwait(false);
foreach ( var itm in invoiceGrps )
{
var ls = invDetails . Where ( p = > p . InvbillNum = = itm ) . ToList ( ) ;
@ -1011,11 +536,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var adj = await _ settleAccountDbContext . Set < PUB_ADJ_DETAIL > ( ) . Where ( p = > p . InvBillNum = = itm ) . AsNoTracking ( ) . ToListAsync ( ) . ConfigureAwait ( false ) ; //调整数量
if ( ls . Any ( ) & & invoice ! = null )
{
if ( adj . Any ( ) ) //假如存在调整单
{
var adjlist = await ChangedPrice < HBPO_CAN_SA_DETAIL > ( invoice . BusinessType , invoice . Site , adj ) . ConfigureAwait ( false ) ;
ls . AddRange ( adjlist ) ;
}
//if (adj.Any()) //假如存在调整单
//{
// var adjlist = await ChangedPrice<HBPO_CAN_SA_DETAIL>(invoice.BusinessType, invoice.Site, adj).ConfigureAwait(false);
// ls.AddRange(adjlist);
//}
foreach ( var itm1 in ls )
{
if ( string . IsNullOrEmpty ( itm1 . ErpLoc ) )
@ -1023,8 +548,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
itm1 . ErpLoc = $"C{invoice.ClientCode}" ;
}
}
var details = ls . GroupBy ( p = > new { p . ErpLoc , p . PartCode , p . BusinessType , p . Price } )
. Select ( p = > new { Erploc = p . Key . ErpLoc , p . Key . PartCode , p . Key . BusinessType , Amt = Math . Round ( p . Sum ( t = > t . Qty * t . Price ) , 2 ) , Price = p . Key . Price , Qty = p . Sum ( t = > t . Qty ) } ) . ToList ( ) ;
var details = ls ;
//.GroupBy(p => new { p.ErpLoc, p.PartCode, p.BusinessType, p.Price })
//.Select(p => new { Erploc = p.Key.ErpLoc, p.Key.PartCode, p.Key.BusinessType, Amt = Math.Round(p.Sum(t => t.Qty * t.Price), 2), Price = p.Key.Price, Qty = p.Sum(t => t.Qty) }).ToList();
var tedSaInvs = new List < TED_SAS_INVOICE > ( ) ;
var taskId = GuidGenerator . Create ( ) ;
@ -1058,11 +584,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
Site = "BJ02" ,
PartNumber = invoiceGrpDetail . PartCode ,
InvoiceQuatity = invoiceGrpDetail . Qty ,
Price = invoiceGrpDetail . Price ,
Price = invoiceGrpDetail . PRICE ,
InvoiceNetAmount = invoiceGrpDetail . Amt ,
InvoiceTaxAmount = Math . Round ( invoiceGrpDetail . Amt * 0.13 m , 2 ) ,
TaxRate = 0.13 m ,
Location = invoiceGrpDetail . Erpl oc ,
Location = invoiceGrpDetail . ErpL oc ,
begintime = DateTime . Now ,
endtime = DateTime . Now ,
domain = "BJBMPT" ,