|
@ -57,7 +57,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly ExChangeCenterDbContext _exChangeCenterDbContext; |
|
|
private readonly ExChangeCenterDbContext _exChangeCenterDbContext; |
|
|
private readonly GlobalConfigOptions _globalConfigOptions; |
|
|
private readonly GlobalConfigOptions _globalConfigOptions; |
|
|
|
|
|
|
|
|
private readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _repository; |
|
|
private readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _repository; |
|
|
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _wRepository; |
|
|
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _wRepository; |
|
|
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _sRepository; |
|
|
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _sRepository; |
|
@ -157,8 +156,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
select itm1; |
|
|
select itm1; |
|
|
invoiceGrpDetails = query.ToList(); |
|
|
invoiceGrpDetails = query.ToList(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (invoiceGrpDetails.Any()) |
|
|
if (invoiceGrpDetails.Any()) |
|
|
{ |
|
|
{ |
|
|
var tedSaInvs = new List<TED_SAS_INVOICE>(); |
|
|
var tedSaInvs = new List<TED_SAS_INVOICE>(); |
|
@ -211,14 +208,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
//}
|
|
|
//}
|
|
|
invdetials.Add(inv); |
|
|
invdetials.Add(inv); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
foreach (var itm in _detail) |
|
|
foreach (var itm in _detail) |
|
|
{ |
|
|
{ |
|
|
var inv = new INVOICE_WAIT_DETAIL(); |
|
|
var inv = new INVOICE_WAIT_DETAIL(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var first= invoiceGrpDetailsCopy.FirstOrDefault(p=>p.PartCode==itm.PartCode); |
|
|
var first= invoiceGrpDetailsCopy.FirstOrDefault(p=>p.PartCode==itm.PartCode); |
|
|
inv.InjectFrom(first); |
|
|
inv.InjectFrom(first); |
|
|
inv.LU = itm.LU; |
|
|
inv.LU = itm.LU; |
|
@ -237,10 +231,7 @@ 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]; |
|
@ -268,18 +259,28 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
LINE = (i + 1).ToString() |
|
|
LINE = (i + 1).ToString() |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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 invbefore = invoiceGrp.RealAmt + invoiceGrp.TaxDiff;//
|
|
|
|
|
|
var invafter = tedsaInvs1.Sum(p => p.InvoiceTaxAmount); |
|
|
|
|
|
var invdiff = invbefore - invafter; |
|
|
|
|
|
|
|
|
|
|
|
//invoiceGrp.RealAmt + invoiceGrp.TaxDiff-invafter;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var a = tedsaInvs1.Sum(p => p.InvoiceNetAmount); |
|
|
tedsaInvs1.FirstOrDefault().InvoiceTaxAmount += invdiff; |
|
|
|
|
|
|
|
|
var b=tedsaInvs1.Sum(p => p.InvoiceTaxAmount); |
|
|
|
|
|
var invafter = a + b; |
|
|
//var a = tedsaInvs1.Sum(p => p.InvoiceNetAmount);
|
|
|
var invdiff = invbefore - invafter; |
|
|
//var b= tedsaInvs1.Sum(p => p.InvoiceTaxAmount);
|
|
|
var line1 = tedsaInvs1.FirstOrDefault(p => p.LINE == "1"); |
|
|
//var invafter = a + b;
|
|
|
var line2 = tedsaInvs1.FirstOrDefault(p => p.LINE == "2"); |
|
|
//var invdiff = invbefore - invafter;
|
|
|
line2.InvoiceTaxAmount += invdiff; |
|
|
//var line1 = tedsaInvs1.FirstOrDefault(p => p.LINE == "1");
|
|
|
line1.InvoiceTaxAmount += invoiceGrp.TaxDiff; |
|
|
//var line2 = tedsaInvs1.FirstOrDefault(p => p.LINE == "2");
|
|
|
|
|
|
//line2.InvoiceTaxAmount += invdiff;
|
|
|
|
|
|
//line1.InvoiceTaxAmount += invoiceGrp.TaxDiff;
|
|
|
//红冲发票提交QAD
|
|
|
//红冲发票提交QAD
|
|
|
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) |
|
|
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) |
|
|
{ |
|
|
{ |
|
@ -381,7 +382,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
LINE = (i + 1).ToString() |
|
|
LINE = (i + 1).ToString() |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
tedSaInvs.FirstOrDefault().InvoiceTaxAmount += invoiceGrp.TaxDiff; |
|
|
|
|
|
|
|
|
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
|
|
|
//红冲发票提交QAD
|
|
|
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) |
|
|
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) |
|
|
{ |
|
|
{ |
|
@ -410,7 +418,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (p_detail != null && p_detail.Count > 0) |
|
|
if (p_detail != null && p_detail.Count > 0) |
|
|
{ |
|
|
{ |
|
|
var _detail = p_detail.ToList(); |
|
|
var _detail = p_detail.ToList(); |
|
@ -456,10 +463,6 @@ 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") |
|
|
{ |
|
|
{ |
|
@ -502,19 +505,30 @@ 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.RealAmt + invoiceGrp.TaxDiff;//
|
|
|
var invafter = tedsaInvs1.Sum(p => p.InvoiceNetAmount) + tedsaInvs1.Sum(p => p.InvoiceTaxAmount); |
|
|
var invafter = tedsaInvs1.Sum(p => p.InvoiceTaxAmount); |
|
|
var invdiff = invbefore - invafter; |
|
|
var invdiff = invbefore - invafter; |
|
|
var line1 = tedsaInvs1.FirstOrDefault(p => p.LINE == "1"); |
|
|
tedsaInvs1.FirstOrDefault().InvoiceTaxAmount += invdiff; |
|
|
var line2 = tedsaInvs1.FirstOrDefault(p => p.LINE == "2"); |
|
|
//invbefore= invafter +x;
|
|
|
line2.InvoiceTaxAmount += invdiff; |
|
|
//var line1 = tedsaInvs1.FirstOrDefault(p => p.LINE == "1");
|
|
|
line1.InvoiceTaxAmount += invoiceGrp.TaxDiff; |
|
|
//var line2 = tedsaInvs1.FirstOrDefault(p => p.LINE == "2");
|
|
|
|
|
|
////line2.InvoiceTaxAmount += invdiff;
|
|
|
|
|
|
//line1.InvoiceTaxAmount += invdiff;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//红冲发票提交QAD
|
|
|
//红冲发票提交QAD
|
|
|
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) |
|
|
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) |
|
|
{ |
|
|
{ |
|
|
await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum,_detail).ConfigureAwait(false); |
|
|
await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum,_detail).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false); |
|
|
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); |
|
|
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 }); |
|
@ -577,10 +591,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
//红冲发票提交QAD
|
|
|
//红冲发票提交QAD
|
|
|
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) |
|
|
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum).ConfigureAwait(false); |
|
|
await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
//await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false);
|
|
|
//await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false);
|
|
|
//await _exChangeCenterDbContext.Set<TED_SAS_INVOICE>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
|
|
|
//await _exChangeCenterDbContext.Set<TED_SAS_INVOICE>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
|
|
@ -610,10 +621,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
Site = teaTaskSub.Site, |
|
|
Site = teaTaskSub.Site, |
|
|
Customer = customer |
|
|
Customer = customer |
|
|
}; |
|
|
}; |
|
|
|
|
|
invoiceSyncQad.SetId(teaTaskSub.TaskID); |
|
|
invoiceSyncQad.SetId(teaTaskSub.TaskID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _settleAccountDbContext.BulkInsertAsync(new List<InvoiceSyncQad>() { invoiceSyncQad }); |
|
|
await _settleAccountDbContext.BulkInsertAsync(new List<InvoiceSyncQad>() { invoiceSyncQad }); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1255,13 +1263,24 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
var first = ls.FirstOrDefault(); |
|
|
var first = ls.FirstOrDefault(); |
|
|
foreach (var inv in invlist) |
|
|
foreach (var inv in invlist) |
|
|
{ |
|
|
{ |
|
|
var newinv1= result.Where(p => p.InvbillNum == inv.InvbillNum).FirstOrDefault(); |
|
|
var newinv1 = result.Where(p => p.InvbillNum == inv.InvbillNum).FirstOrDefault(); |
|
|
var newinv = ls.Where(p => p.InvbillNum == inv.InvbillNum).FirstOrDefault(); |
|
|
var newinv = ls.Where(p => p.InvbillNum == inv.InvbillNum).FirstOrDefault(); |
|
|
inv.Tax = 0.13m; |
|
|
if (inv.State == SettleBillState.红冲发票 && inv.InvoiceState == InvoiceBillState.正常) |
|
|
inv.RealnvBillNum = newinv.RealnvBillNum; |
|
|
{ |
|
|
inv.TaxDiff = newinv.PreTaxDiff; |
|
|
inv.RealnvBillNum = newinv.RealnvBillNum; |
|
|
inv.CreationTime = newinv1.InvoiceDate; |
|
|
} |
|
|
inv.FileName=newinv1.FileName; |
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
inv.Tax = 0.13m; |
|
|
|
|
|
inv.RealnvBillNum = newinv.RealnvBillNum; |
|
|
|
|
|
inv.TaxDiff = newinv.PreTaxDiff; |
|
|
|
|
|
inv.CreationTime = newinv1.InvoiceDate; |
|
|
|
|
|
inv.FileName = newinv1.FileName; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
await _repository.DbContext.BulkUpdateAsync(invlist).ConfigureAwait(false); |
|
|
await _repository.DbContext.BulkUpdateAsync(invlist).ConfigureAwait(false); |
|
|
await _repository.DbContext.BulkUpdateAsync(invdetail).ConfigureAwait(false); |
|
|
await _repository.DbContext.BulkUpdateAsync(invdetail).ConfigureAwait(false); |
|
|