开票支持双币别

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

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

@ -316,32 +316,20 @@ namespace DS.WMS.Core.Invoice.Method
Currency = invoice.Currency,
OriginalCurrency = item.Currency,
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);
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;
}
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;
detail.ExchangeRate = er.ExchangeRate;
}
}
if (!detail.ExchangeRate.HasValue)
detail.ExchangeRate = 1m;
if (detail.ExchangeRate.HasValue)
detail.ApplyAmount *= detail.ExchangeRate.Value;
invoice.Details.Add(detail);
}
@ -598,20 +586,22 @@ namespace DS.WMS.Core.Invoice.Method
if (invoiceAmount == 0)
return DataResult.Failed("开票金额不能为零");
var totalRMB = details.Sum(x => x.ApplyAmount);
if (Math.Abs(invoiceAmount) > totalRMB)
var totalAmount = details.Sum(x => x.OriginalAmount);
if (Math.Abs(invoiceAmount) > totalAmount)
return DataResult.Failed("申请开票金额不能大于剩余开票金额");
if (totalRMB != invoiceAmount) //非全额开票
if (totalAmount != invoiceAmount) //非全额开票
{
var rest = totalRMB - invoiceAmount;
var rest = totalAmount - invoiceAmount;
foreach (var detail in details)
{
if (rest == 0)
break;
detail.ApplyAmount = detail.ApplyAmount - rest;
rest = detail.ApplyAmount - rest;
detail.OriginalAmount = detail.OriginalAmount - 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;
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();
try
{
//状态待审核的任务
if (tasks.Count > 0)
if (tasksList.Count > 0)
{
var flowIds = tasks.Select(x => x.FlowId.Value);
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)
{
switch (request.TaskType)
{
case TaskBaseTypeEnum.APPLICATION_PAYMENT_AUDIT:
break;
////已完成审核的任务
//if (task2.Count > 0)
//{
// switch (request.TaskType)
// {
// case TaskBaseTypeEnum.APPLICATION_PAYMENT_AUDIT:
// break;
case TaskBaseTypeEnum.APPLICATION_INVOICE_AUDIT:
break;
// case TaskBaseTypeEnum.APPLICATION_INVOICE_AUDIT:
// break;
default:
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
// default:
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
// }
//}
await TenantDb.Ado.CommitTranAsync();
return result;

Loading…
Cancel
Save