|
|
@ -57,7 +57,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
/// </summary>
|
|
|
|
private readonly ExChangeCenterDbContext _exChangeCenterDbContext; |
|
|
|
private readonly GlobalConfigOptions _globalConfigOptions; |
|
|
|
|
|
|
|
private readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _repository; |
|
|
|
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _wRepository; |
|
|
|
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _sRepository; |
|
|
@ -157,8 +156,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
select itm1; |
|
|
|
invoiceGrpDetails = query.ToList(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (invoiceGrpDetails.Any()) |
|
|
|
{ |
|
|
|
var tedSaInvs = new List<TED_SAS_INVOICE>(); |
|
|
@ -210,14 +207,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
// 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); |
|
|
@ -237,10 +231,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
inv.Extend2 = "CC11"; |
|
|
|
} |
|
|
|
invdetials.Add(inv); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (var i = 0; i < invdetials.Count; i++) |
|
|
|
{ |
|
|
|
var invoiceGrpDetail = invdetials[i]; |
|
|
@ -268,18 +259,28 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
LINE = (i + 1).ToString() |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var tedsaInvs1 = JsonConvert.DeserializeObject<List<TED_SAS_INVOICE>>(JsonConvert.SerializeObject(tedSaInvs)); |
|
|
|
var invbefore = invoiceGrp.TaxAmt + invoiceGrp.TaxDiff; |
|
|
|
|
|
|
|
var a = tedsaInvs1.Sum(p => p.InvoiceNetAmount); |
|
|
|
//var invbefore = invoiceGrp.TaxAmt + invoiceGrp.TaxDiff;
|
|
|
|
|
|
|
|
var b=tedsaInvs1.Sum(p => p.InvoiceTaxAmount); |
|
|
|
var invafter = a + b; |
|
|
|
var invdiff = invbefore - invafter; |
|
|
|
var line1 = tedsaInvs1.FirstOrDefault(p => p.LINE == "1"); |
|
|
|
var line2 = tedsaInvs1.FirstOrDefault(p => p.LINE == "2"); |
|
|
|
line2.InvoiceTaxAmount += invdiff; |
|
|
|
line1.InvoiceTaxAmount += 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; |
|
|
|
|
|
|
|
|
|
|
|
//var a = tedsaInvs1.Sum(p => p.InvoiceNetAmount);
|
|
|
|
//var b= tedsaInvs1.Sum(p => p.InvoiceTaxAmount);
|
|
|
|
//var invafter = a + b;
|
|
|
|
//var invdiff = invbefore - invafter;
|
|
|
|
//var line1 = tedsaInvs1.FirstOrDefault(p => p.LINE == "1");
|
|
|
|
//var line2 = tedsaInvs1.FirstOrDefault(p => p.LINE == "2");
|
|
|
|
//line2.InvoiceTaxAmount += invdiff;
|
|
|
|
//line1.InvoiceTaxAmount += invoiceGrp.TaxDiff;
|
|
|
|
//红冲发票提交QAD
|
|
|
|
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) |
|
|
|
{ |
|
|
@ -381,7 +382,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
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
|
|
|
|
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) |
|
|
|
{ |
|
|
@ -410,7 +418,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (p_detail != null && p_detail.Count > 0) |
|
|
|
{ |
|
|
|
var _detail = p_detail.ToList(); |
|
|
@ -456,10 +463,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
inv.Qty = itm.Qty - first.Qty;//发票总数中去除
|
|
|
|
inv.Amt = Math.Round(itm.Qty * itm.PRICE, 2); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inv.BussiessType = EnumBusinessType.MaiDanJianBBAC; |
|
|
|
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 invbefore = invoiceGrp.TaxAmt + invoiceGrp.TaxDiff; |
|
|
|
var invafter = tedsaInvs1.Sum(p => p.InvoiceNetAmount) + tedsaInvs1.Sum(p => p.InvoiceTaxAmount); |
|
|
|
var invbefore = invoiceGrp.RealAmt + invoiceGrp.TaxDiff;//
|
|
|
|
var invafter = tedsaInvs1.Sum(p => p.InvoiceTaxAmount); |
|
|
|
var invdiff = invbefore - invafter; |
|
|
|
var line1 = tedsaInvs1.FirstOrDefault(p => p.LINE == "1"); |
|
|
|
var line2 = tedsaInvs1.FirstOrDefault(p => p.LINE == "2"); |
|
|
|
line2.InvoiceTaxAmount += invdiff; |
|
|
|
line1.InvoiceTaxAmount += invoiceGrp.TaxDiff; |
|
|
|
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
|
|
|
|
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) |
|
|
|
{ |
|
|
|
await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum,_detail).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); |
|
|
|
invoiceGrp.State = SettleBillState.已提交QAD; |
|
|
|
await _repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp }); |
|
|
@ -577,10 +591,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
//红冲发票提交QAD
|
|
|
|
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<TED_SAS_INVOICE>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
|
|
|
@ -610,10 +621,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
Site = teaTaskSub.Site, |
|
|
|
Customer = customer |
|
|
|
}; |
|
|
|
|
|
|
|
invoiceSyncQad.SetId(teaTaskSub.TaskID); |
|
|
|
|
|
|
|
|
|
|
|
invoiceSyncQad.SetId(teaTaskSub.TaskID); |
|
|
|
await _settleAccountDbContext.BulkInsertAsync(new List<InvoiceSyncQad>() { invoiceSyncQad }); |
|
|
|
} |
|
|
|
|
|
|
@ -1255,13 +1263,24 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
var first = ls.FirstOrDefault(); |
|
|
|
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(); |
|
|
|
inv.Tax = 0.13m; |
|
|
|
inv.RealnvBillNum = newinv.RealnvBillNum; |
|
|
|
inv.TaxDiff = newinv.PreTaxDiff; |
|
|
|
inv.CreationTime = newinv1.InvoiceDate; |
|
|
|
inv.FileName=newinv1.FileName; |
|
|
|
if (inv.State == SettleBillState.红冲发票 && inv.InvoiceState == InvoiceBillState.正常) |
|
|
|
{ |
|
|
|
inv.RealnvBillNum = newinv.RealnvBillNum; |
|
|
|
} |
|
|
|
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(invdetail).ConfigureAwait(false); |
|
|
|