Browse Source

更新版本

master
学 赵 12 months ago
parent
commit
44f96ae2ab
  1. 235
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  2. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs

235
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs

@ -311,7 +311,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//红冲发票提交QAD
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum))
{
await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum).ConfigureAwait(false);
if (invoiceGrp.BusinessType == EnumBusinessType.JisBBAC)
{
await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum).ConfigureAwait(false);
}
else
{
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);
@ -324,11 +332,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
_repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp });
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false);
// await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false);
// var retryPolicyAsync = Policy.Handle<Exception>().WaitAndRetryAsync(new[] {
// TimeSpan.FromSeconds(1),
@ -353,7 +356,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// <summary>
/// 红冲发票提交到QAD
/// </summary>
private async Task SubmitToQadHongChongAsync(string invbillNum)
private async Task SubmitToQadHongChongAsync(string invbillNum, List<BBAC_CAN_SA_DETAIL> p_detail = null)
{
var invoiceGrp = _settleAccountDbContext.Set<INVOICE_GRP>()
.Where(t => t.State == SettleBillState.)
@ -363,59 +366,189 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
return;
}
var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>()
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,
};
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,
domain = "BJBMPT",
LINE = (i + 1).ToString()
});
}
if (invoiceGrpDetails.Any())
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 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))
{
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;
_repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp });
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false);
}
}
else
{
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,
};
for (var i = 0; i < invoiceGrpDetails.Count; i++)
var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>()
.Where(t => t.InvbillNum == invbillNum)
.ToList();
if (invoiceGrpDetails.Any())
{
var invoiceGrpDetail = invoiceGrpDetails[i];
tedSaInvs.Add(new TED_SAS_INVOICE()
var tedSaInvs = new List<TED_SAS_INVOICE>();
var taskId = GuidGenerator.Create();
var teaTaskSub = new TEA_TASK_SUB()
{
GUID = GuidGenerator.Create(),
Dataid = GuidGenerator.Create(),
Taskid = taskId,
invoiceNumber = invoiceGrp.RealnvBillNum,
sasInvoiceNumber = invoiceGrp.InvbillNum,
Customer = invoiceGrp.ClientCode,
BillTo = invoiceGrp.ClientCode,
InvoiceDate = invoiceGrp.CreationTime,
GUID = taskId,
TaskState = 0,
TaskID = taskId,
TableName = "TED_SAS_INVOICE",
Creator = "SAS",
Subscriber = "QAD",
Domain = "BJBMPT",
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 = $"C{invoiceGrp.ClientCode}",
begintime = invoiceGrpDetail.BeginDate,
endtime = invoiceGrpDetail.EndDate,
domain = "BJBMPT",
LINE = (i + 1).ToString()
});
CreateTime = DateTime.Now,
UpdateTime = DateTime.Now,
};
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 = invoiceGrpDetail.BeginDate,
endtime = invoiceGrpDetail.EndDate,
domain = "BJBMPT",
LINE = (i + 1).ToString()
});
}
tedSaInvs.FirstOrDefault().InvoiceTaxAmount += invoiceGrp.TaxDiff;
//红冲发票提交QAD
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum))
{
if (invoiceGrp.BusinessType == EnumBusinessType.JisBBAC)
{
await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum).ConfigureAwait(false);
}
else
{
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);
//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);
await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false);
invoiceGrp.State = SettleBillState.QAD;
_repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp });
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false);
}
await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false);
await _exChangeCenterDbContext.Set<TED_SAS_INVOICE>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
//构建发票同步Qad状态表数据
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false);
}
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs

@ -276,7 +276,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
else if (p_billtime >= lastYear.AddMonths(10) && p_billtime <= lastYear.AddMonths(11))
{ version = $"{before.ToString()}11"; }
else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <=
DateTime.ParseExact(string.Format("{0}-01-{1} 07:59:59", next.ToString(), 01), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)
DateTime.ParseExact(string.Format("{0}-01-{1} 07:59:59", next.ToString(), "01"), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)
)
{
version = $"{before.ToString()}12";

Loading…
Cancel
Save