获取汇率bug修复

usertest
嵇文龙 3 months ago
parent 0c3fd95f86
commit 0e25cef38e

@ -10,12 +10,12 @@ namespace DS.WMS.Core.Fee.Dtos
public class FeeStatItem
{
/// <summary>
/// 应收款总计
/// 应收款总计(人民币合计)
/// </summary>
public decimal ReceivableTotal { get; set; }
/// <summary>
/// 应付款总计
/// 应付款总计(人民币合计)
/// </summary>
public decimal PayableTotal { get; set; }
@ -25,7 +25,7 @@ namespace DS.WMS.Core.Fee.Dtos
public decimal ProfitTotal { get { return ReceivableTotal - PayableTotal; } }
/// <summary>
/// 利润率
/// 利润率(利润/应付)
/// </summary>
public string ProfitMargin
{
@ -34,8 +34,8 @@ namespace DS.WMS.Core.Fee.Dtos
if (PayableTotal == 0)
return string.Empty;
//利润率=利润÷成本×100%
return string.Concat(Math.Round(ReceivableTotal / PayableTotal * 100, 2, MidpointRounding.AwayFromZero), "%");
//利润率=利润÷应付/应收×100%
return string.Concat(Math.Round(ProfitTotal / PayableTotal * 100, 2, MidpointRounding.AwayFromZero), "%");
}
}

@ -400,8 +400,24 @@ namespace DS.WMS.Core.Fee.Entity
{
if (TaxRate == 0)
{
UnitPrice = TaxUnitPrice;
NoTaxAmount = Amount;
if (TaxUnitPrice == 0)
{
TaxUnitPrice = UnitPrice;
}
else if (UnitPrice == 0)
{
UnitPrice = TaxUnitPrice;
}
if (Amount == 0)
{
Amount = NoTaxAmount;
}
else if (NoTaxAmount == 0)
{
NoTaxAmount = Amount;
}
}
else
{

@ -1,9 +1,11 @@
using DS.Module.Core;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Sys.Dtos;
namespace DS.WMS.Core.Fee.Interface;
/// <summary>
/// 汇率服务
/// </summary>
public interface IFeeCurrencyExchangeService
{
/// <summary>
@ -34,4 +36,5 @@ public interface IFeeCurrencyExchangeService
/// <param name="exchange">币别信息</param>
/// <returns></returns>
Task<DataResult<ExchangeRate>> GetExchangeRateAsync(ExchangeRate exchange);
}

@ -465,7 +465,7 @@ namespace DS.WMS.Core.Fee.Method
}
/// <summary>
/// 获取业务相关联的费用统计
/// 获取业务费用统计
/// </summary>
/// <param name="id">业务ID</param>
/// <param name="businessType">业务类型</param>

@ -205,7 +205,7 @@ namespace DS.WMS.Core.Fee.Method
/// <returns></returns>
protected internal async Task FetchExchangeRateAsync(IEnumerable<FeeRecord> items)
{
var exRecords = items.Where(x => x.ExchangeRate == null && x.Currency != x.LocalCurrency);
var exRecords = items.Where(x => x.Currency != x.LocalCurrency);
if (exRecords.Any())
{
var exchanges = exRecords.GroupBy(x => new
@ -233,27 +233,6 @@ namespace DS.WMS.Core.Fee.Method
item.ExchangeRate = exchangeRates.Find(x => x.CurrencyFrom == item.Currency &&
x.CurrencyTo == item.LocalCurrency && x.FeeType == item.FeeType)?.Rate;
}
//var codes = exRecords.Select(x => x.Currency).Distinct().ToList();
//var currencies = await TenantDb.Queryable<FeeCurrency>().Where(x => codes.Contains(x.CodeName)).Includes(x => x.Exchanges).ToListAsync();
//DateTime dtNow = DateTime.Now;
//foreach (var item in exRecords)
//{
// var currency = currencies.Find(x => x.CodeName == item.Currency);
// if (currency != null)
// {
// item.ExchangeRate = currency.DefaultRate;
// if (currency.Exchanges != null && currency.Exchanges.Count > 0)
// {
// //取当前时间范围内的最新一条
// var exchange = currency.Exchanges.FindAll(x => x.Status == StatusEnum.Enable &&
// x.StartDate >= dtNow && x.EndDate <= dtNow).OrderByDescending(x => x.UpdateTime).FirstOrDefault();
// if (exchange != null)
// item.ExchangeRate = item.FeeType == FeeType.Receivable ? exchange.DRValue : exchange.CRValue;
// }
// }
//}
}
}

Loading…
Cancel
Save