Browse Source

[CI SKIP]-[168]添加已扣减发票提交到QAD接口

master
mahao 1 year ago
parent
commit
727619f733
  1. 98
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs

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

@ -64,7 +64,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
private readonly WMSBJBMPTDbContext _wmsBJBMPTContext;
/// <summary>
/// 数据中心S数据上下文
/// 数据中心数据上下文
/// </summary>
private readonly ExChangeCenterDbContext _exChangeCenterDbContext;
@ -118,6 +118,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
/// <remarks>
/// 已扣减发票提交到QAD
/// 查询状态为已扣减的数据
/// 判断ParentInvbillNum是否有数据
/// 有数据查询出对应发票数据状态为已提交QAD(置换成负数据)需要提交到QAD
/// 已扣减的数据提交到QAD
/// 成功提交后修改状态为已提交QAD
/// </remarks>
[HttpPost]
@ -161,18 +165,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BillTo = y.ClientCode,
InvoiceDate = y.CreationTime,
Site = "BJ02",
TYPE = default,
PartNumber = x.LU,
InvoiceQuatity = x.Qty,
Price = x.PRICE,
Supplier = default,
Remark = default,
InvoiceNetAmount = x.Amt,
InvoiceTaxAmount = x.Amt * 0.13m,
InvoiceTaxAmount = Math.Round(x.Amt * 0.13m, 2),
TaxRate = 0.13m,
Location = $"C{y.ClientCode}",
InvoiceNet = default,
InvoiceTax = default,
begintime = x.BeginDate,
endtime = x.EndDate,
Domain = "BJBMPT"
@ -185,27 +184,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
GUID = GuidGenerator.Create(),
TaskID = taskId,
UID = default,
InvoiceNumber = t.RealnvBillNum,
SASInvoiceNumber = t.InvbillNum,
Customer = t.ClientCode,
BillTo = t.ClientCode,
InvoiceDate = t.CreationTime,
Site = "BJ02",
TYPE = default,
PartNumber = default,
InvoiceQuatity = default,
Price = default,
Supplier = default,
Remark = default,
InvoiceNetAmount = default,
InvoiceTaxAmount = default,
TaxRate = 0.13m,
Location = $"C{t.ClientCode}",
InvoiceNet = t.Amt,
InvoiceTax = default,
begintime = default,
endtime = default,
InvoiceTax = t.Amt,
Domain = "BJBMPT"
};
});
@ -213,10 +200,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
tedSaInvs.AddRange(invoiceGrpTedSaInvs);
if (tedSaInvs.Any())
{
//红冲发票提交QAD
await SubmitToQadHongChong(invoiceGrps.Select(t => t.ParentInvbillNum).ToList()).ConfigureAwait(false);
await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false);
await _exChangeCenterDbContext.Set<TED_SA_INV>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false);
invoiceGrps.ForEach(t => t.State = SettleBillState.QAD);
await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false);
await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false);
}
@ -224,6 +215,69 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
return new OkResult();
}
/// <summary>
/// 红冲发票提交到QAD
/// </summary>
private async Task SubmitToQadHongChong(List<string> invbillNums)
{
var invoiceGrps = _settleAccountDbContext.Set<INVOICE_GRP>()
.Where(t => t.State == SettleBillState.QAD)
.Where(t => invbillNums.Contains(t.InvbillNum))
.ToList();
invbillNums = invoiceGrps.Select(t => t.InvbillNum).ToList();
var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>()
.Where(t => invbillNums.Contains(t.InvbillNum))
.ToList();
var taskId = GuidGenerator.Create();
var teaTaskSub = new TEA_TASK_SUB()
{
GUID = taskId,
TaskState = 0,
TaskID = taskId,
TableName = "TED_SA_INV",
Creator = "SAS",
Subscriber = "QAD",
Domain = "BJBMPT",
Site = "BJ02",
CreateTime = DateTime.Now,
UpdateTime = DateTime.Now,
};
var tedSaInvs = invoiceGrpDetails.Join(invoiceGrps, x => x.InvbillNum, y => y.InvbillNum, (x, y) =>
{
return new TED_SA_INV()
{
GUID = GuidGenerator.Create(),
TaskID = taskId,
InvoiceNumber = y.RealnvBillNum,
SASInvoiceNumber = y.InvbillNum,
Customer = y.ClientCode,
BillTo = y.ClientCode,
InvoiceDate = y.CreationTime,
Site = "BJ02",
PartNumber = x.LU,
InvoiceQuatity = -x.Qty,
Price = x.PRICE,
InvoiceNetAmount = x.Amt,
InvoiceTaxAmount = Math.Round(x.Amt * 0.13m, 2),
TaxRate = 0.13m,
Location = $"C{y.ClientCode}",
begintime = x.BeginDate,
endtime = x.EndDate,
Domain = "BJBMPT"
};
}).ToList();
if (tedSaInvs.Any())
{
await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false);
await _exChangeCenterDbContext.Set<TED_SA_INV>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
}
}
/// <summary>
/// 通过审核
/// </summary>
@ -599,7 +653,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
IExporter _csv = new CsvExporter();
ExcelExporter _excel = new ExcelExporter();
// var materialList = await _baseservice.GetMaterialList().ConfigureAwait(false);
// var materialList = await _baseservice.GetMaterialList().ConfigureAwait(false);
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false);
var first = entities.FirstOrDefault();
var dtoDetails = ObjectMapper.Map<List<INVOICE_GRP>, List<INVOICE_GRP_EXP_DTO>>(entities);

Loading…
Cancel
Save