开票支持双币别

dev
嵇文龙 3 weeks ago
parent 58eb8ee764
commit 1125973808

@ -10,11 +10,6 @@
/// </summary> /// </summary>
public long ApplicationId { get; set; } public long ApplicationId { get; set; }
/// <summary>
/// 发票申请币别
/// </summary>
public string Currency { get; set; }
/// <summary> /// <summary>
/// 本次RMB开票金额 /// 本次RMB开票金额
/// </summary> /// </summary>

@ -316,32 +316,20 @@ namespace DS.WMS.Core.Invoice.Method
Currency = invoice.Currency, Currency = invoice.Currency,
OriginalCurrency = item.Currency, OriginalCurrency = item.Currency,
ApplyAmount = item.ApplyAmount - item.ProcessedAmount, ApplyAmount = item.ApplyAmount - item.ProcessedAmount,
OriginalAmount = item.OriginalAmount - item.OriginalProcessedAmount OriginalAmount = item.OriginalAmount - item.OriginalProcessedAmount,
ExchangeRate = 1
}; };
var app = request.Applications.Find(x => x.ApplicationId == item.ApplicationId); var app = request.Applications.Find(x => x.ApplicationId == item.ApplicationId);
if (app != null) if (app != null) //设置汇率
{ {
if (app.Currency == invoice.Currency) var er = app.ExchangeRates?.FirstOrDefault(x => x.Currency == detail.OriginalCurrency);
if (er != null)
{ {
detail.ExchangeRate = 1m; detail.ExchangeRate = er.ExchangeRate;
}
else if (string.IsNullOrEmpty(app.Currency)) //原币申请
{
detail.ExchangeRate = app.ExchangeRates.FirstOrDefault(x => x.Currency == item.Currency)?.ExchangeRate;
}
else
{
detail.ExchangeRate = app.ExchangeRates.FirstOrDefault(x => x.Currency == invoice.Currency)?.ExchangeRate;
} }
} }
if (!detail.ExchangeRate.HasValue)
detail.ExchangeRate = 1m;
if (detail.ExchangeRate.HasValue)
detail.ApplyAmount *= detail.ExchangeRate.Value;
invoice.Details.Add(detail); invoice.Details.Add(detail);
} }
@ -598,20 +586,22 @@ namespace DS.WMS.Core.Invoice.Method
if (invoiceAmount == 0) if (invoiceAmount == 0)
return DataResult.Failed("开票金额不能为零"); return DataResult.Failed("开票金额不能为零");
var totalRMB = details.Sum(x => x.ApplyAmount); var totalAmount = details.Sum(x => x.OriginalAmount);
if (Math.Abs(invoiceAmount) > totalRMB) if (Math.Abs(invoiceAmount) > totalAmount)
return DataResult.Failed("申请开票金额不能大于剩余开票金额"); return DataResult.Failed("申请开票金额不能大于剩余开票金额");
if (totalRMB != invoiceAmount) //非全额开票 if (totalAmount != invoiceAmount) //非全额开票
{ {
var rest = totalRMB - invoiceAmount; var rest = totalAmount - invoiceAmount;
foreach (var detail in details) foreach (var detail in details)
{ {
if (rest == 0) if (rest == 0)
break; break;
detail.ApplyAmount = detail.ApplyAmount - rest; detail.OriginalAmount = detail.OriginalAmount - rest;
rest = detail.ApplyAmount - rest; rest = detail.OriginalAmount - rest;
detail.ApplyAmount = detail.OriginalAmount * detail.ExchangeRate.GetValueOrDefault();
} }
} }

@ -34,12 +34,12 @@ namespace DS.WMS.Core.TaskInteraction.Method
DataResult result = DataResult.Success; DataResult result = DataResult.Success;
var tasks = tasksList.FindAll(x => x.TaskStatus == TaskStatusEnum.Create); var tasks = tasksList.FindAll(x => x.TaskStatus == TaskStatusEnum.Create);
var task2 = tasksList.FindAll(x => x.TaskStatus == TaskStatusEnum.Complete); //var task2 = tasksList.FindAll(x => x.TaskStatus == TaskStatusEnum.Complete);
await TenantDb.Ado.BeginTranAsync(); await TenantDb.Ado.BeginTranAsync();
try try
{ {
//状态待审核的任务 //状态待审核的任务
if (tasks.Count > 0) if (tasksList.Count > 0)
{ {
var flowIds = tasks.Select(x => x.FlowId.Value); var flowIds = tasks.Select(x => x.FlowId.Value);
var flowInstances = await Db.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync(); var flowInstances = await Db.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync();
@ -72,21 +72,21 @@ namespace DS.WMS.Core.TaskInteraction.Method
} }
} }
//已完成审核的任务 ////已完成审核的任务
if (task2.Count > 0) //if (task2.Count > 0)
{ //{
switch (request.TaskType) // switch (request.TaskType)
{ // {
case TaskBaseTypeEnum.APPLICATION_PAYMENT_AUDIT: // case TaskBaseTypeEnum.APPLICATION_PAYMENT_AUDIT:
break; // break;
case TaskBaseTypeEnum.APPLICATION_INVOICE_AUDIT: // case TaskBaseTypeEnum.APPLICATION_INVOICE_AUDIT:
break; // break;
default: // default:
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); // return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
} // }
} //}
await TenantDb.Ado.CommitTranAsync(); await TenantDb.Ado.CommitTranAsync();
return result; return result;

Loading…
Cancel
Save