|
@ -142,6 +142,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>().AsNoTracking() |
|
|
var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>().AsNoTracking() |
|
|
.Where(t => t.InvbillNum == invbillNum) |
|
|
.Where(t => t.InvbillNum == invbillNum) |
|
|
.ToList(); |
|
|
.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()) |
|
|
if (invoiceGrpDetails.Any()) |
|
|
{ |
|
|
{ |
|
|
var tedSaInvs = new List<TED_SAS_INVOICE>(); |
|
|
var tedSaInvs = new List<TED_SAS_INVOICE>(); |
|
@ -177,11 +194,38 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
if (itm.Qty > first.Qty) |
|
|
if (itm.Qty >= first.Qty) |
|
|
{ |
|
|
{ |
|
|
inv.Qty = itm.Qty - first.Qty;//发票总数中去除
|
|
|
inv.Qty = itm.Qty - first.Qty;//发票总数中去除
|
|
|
inv.Amt = Math.Round(itm.Qty * itm.PRICE, 2); |
|
|
inv.Amt = Math.Round((itm.Qty - first.Qty) * itm.PRICE, 2); |
|
|
|
|
|
} |
|
|
|
|
|
//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.RealPartCode; |
|
|
|
|
|
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; |
|
|
inv.BussiessType = EnumBusinessType.MaiDanJianBBAC; |
|
|
if (invoiceGrp.Site == "1046") |
|
|
if (invoiceGrp.Site == "1046") |
|
|
{ |
|
|
{ |
|
@ -192,9 +236,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
inv.Extend2 = "CC11"; |
|
|
inv.Extend2 = "CC11"; |
|
|
} |
|
|
} |
|
|
invdetials.Add(inv); |
|
|
invdetials.Add(inv); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (var i = 0; i < invdetials.Count; i++) |
|
|
for (var i = 0; i < invdetials.Count; i++) |
|
|
{ |
|
|
{ |
|
|
var invoiceGrpDetail = invdetials[i]; |
|
|
var invoiceGrpDetail = invdetials[i]; |
|
@ -224,7 +269,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
} |
|
|
} |
|
|
var tedsaInvs1 = JsonConvert.DeserializeObject<List<TED_SAS_INVOICE>>(JsonConvert.SerializeObject(tedSaInvs)); |
|
|
var tedsaInvs1 = JsonConvert.DeserializeObject<List<TED_SAS_INVOICE>>(JsonConvert.SerializeObject(tedSaInvs)); |
|
|
var invbefore = invoiceGrp.TaxAmt + invoiceGrp.TaxDiff; |
|
|
var invbefore = invoiceGrp.TaxAmt + invoiceGrp.TaxDiff; |
|
|
var invafter = tedsaInvs1.Sum(p => p.InvoiceNetAmount) + tedsaInvs1.Sum(p => p.InvoiceTaxAmount); |
|
|
|
|
|
|
|
|
var a = tedsaInvs1.Sum(p => p.InvoiceNetAmount); |
|
|
|
|
|
|
|
|
|
|
|
var b=tedsaInvs1.Sum(p => p.InvoiceTaxAmount); |
|
|
|
|
|
var invafter = a + b; |
|
|
var invdiff = invbefore - invafter; |
|
|
var invdiff = invbefore - invafter; |
|
|
var line1 = tedsaInvs1.FirstOrDefault(p => p.LINE == "1"); |
|
|
var line1 = tedsaInvs1.FirstOrDefault(p => p.LINE == "1"); |
|
|
var line2 = tedsaInvs1.FirstOrDefault(p => p.LINE == "2"); |
|
|
var line2 = tedsaInvs1.FirstOrDefault(p => p.LINE == "2"); |
|
@ -239,7 +288,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
await _exChangeCenterDbContext.BulkInsertAsync(tedsaInvs1).ConfigureAwait(false); |
|
|
await _exChangeCenterDbContext.BulkInsertAsync(tedsaInvs1).ConfigureAwait(false); |
|
|
invoiceGrp.State = SettleBillState.已提交QAD; |
|
|
invoiceGrp.State = SettleBillState.已提交QAD; |
|
|
await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp }); |
|
|
await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp }); |
|
|
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false); |
|
|
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode, invoiceGrp.CreationTime).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
//await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false);
|
|
|
//await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false);
|
|
|
// var retryPolicyAsync = Policy.Handle<Exception>().WaitAndRetryAsync(new[] {
|
|
|
// var retryPolicyAsync = Policy.Handle<Exception>().WaitAndRetryAsync(new[] {
|
|
@ -299,6 +348,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
{ |
|
|
{ |
|
|
invoiceGrpDetail.SetProperty("ErpToLoc", $"C{invoiceGrp.ClientCode}"); |
|
|
invoiceGrpDetail.SetProperty("ErpToLoc", $"C{invoiceGrp.ClientCode}"); |
|
|
} |
|
|
} |
|
|
|
|
|
if (invoiceGrpDetail.BussiessType == EnumBusinessType.ZhiGongJianHBPO) |
|
|
|
|
|
{ |
|
|
|
|
|
invoiceGrpDetail.SetProperty("ErpToLoc", $"C{invoiceGrp.ClientCode}"); |
|
|
|
|
|
} |
|
|
if (invoiceGrpDetail.BussiessType == EnumBusinessType.YinDuJian) |
|
|
if (invoiceGrpDetail.BussiessType == EnumBusinessType.YinDuJian) |
|
|
{ |
|
|
{ |
|
|
invoiceGrpDetail.SetProperty("ErpToLoc", "CC001"); |
|
|
invoiceGrpDetail.SetProperty("ErpToLoc", "CC001"); |
|
@ -337,7 +390,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false); |
|
|
await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false); |
|
|
invoiceGrp.State = SettleBillState.已提交QAD; |
|
|
invoiceGrp.State = SettleBillState.已提交QAD; |
|
|
await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp }); |
|
|
await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp }); |
|
|
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false); |
|
|
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode, invoiceGrp.CreationTime).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -402,6 +455,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
inv.Qty = itm.Qty - first.Qty;//发票总数中去除
|
|
|
inv.Qty = itm.Qty - first.Qty;//发票总数中去除
|
|
|
inv.Amt = Math.Round(itm.Qty * itm.PRICE, 2); |
|
|
inv.Amt = Math.Round(itm.Qty * itm.PRICE, 2); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inv.BussiessType = EnumBusinessType.MaiDanJianBBAC; |
|
|
inv.BussiessType = EnumBusinessType.MaiDanJianBBAC; |
|
|
if (invoiceGrp.Site == "1046") |
|
|
if (invoiceGrp.Site == "1046") |
|
|
{ |
|
|
{ |
|
@ -460,7 +517,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
await _exChangeCenterDbContext.BulkInsertAsync(tedsaInvs1).ConfigureAwait(false); |
|
|
await _exChangeCenterDbContext.BulkInsertAsync(tedsaInvs1).ConfigureAwait(false); |
|
|
invoiceGrp.State = SettleBillState.已提交QAD; |
|
|
invoiceGrp.State = SettleBillState.已提交QAD; |
|
|
await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp }); |
|
|
await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp }); |
|
|
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false); |
|
|
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode,invoiceGrp.CreationTime).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
@ -533,7 +590,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false); |
|
|
await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false); |
|
|
invoiceGrp.State = SettleBillState.已提交QAD; |
|
|
invoiceGrp.State = SettleBillState.已提交QAD; |
|
|
await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp }); |
|
|
await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp }); |
|
|
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false); |
|
|
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode,invoiceGrp.CreationTime).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -542,9 +599,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 构建发票同步Qad状态表数据
|
|
|
/// 构建发票同步Qad状态表数据
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private async Task BindInvoiceSyncQadAsync(TEA_TASK_SUB teaTaskSub, string invoiceNumber, string sasInvoiceNumber, string customer) |
|
|
private async Task BindInvoiceSyncQadAsync(TEA_TASK_SUB teaTaskSub, string invoiceNumber, string sasInvoiceNumber, string customer,DateTime dateTime) |
|
|
{ |
|
|
{ |
|
|
var invoiceSyncQad = new InvoiceSyncQad(teaTaskSub.TaskID, invoiceNumber, sasInvoiceNumber) |
|
|
var invoiceSyncQad = new InvoiceSyncQad(teaTaskSub.TaskID, invoiceNumber, sasInvoiceNumber,dateTime) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
TableName = teaTaskSub.TableName, |
|
|
TableName = teaTaskSub.TableName, |
|
|