public SubagentCommission(Modificants modificants) { Value = modificants.Value; RelativeValue = modificants.RelativeValue; Currency = modificants.Currency; CurrencyConverter = modificants.CurrencyConverter; }
/// <summary> /// Возврашает модификанту, входяшую в ограничения /// </summary> /// <param name="price"></param> /// <returns></returns> public virtual Modificants Normalize(Money price) { var result = new Modificants { Value = this.Value, RelativeValue = this.RelativeValue, Currency = this.Currency ?? price.Currency, CurrencyConverter = this.CurrencyConverter ?? price.CurrencyConverter }; if (result.Currency != price.Currency) { price = result.CurrencyConverter.Convert(price, result.Currency); } double currentProfit = base.Calc(price).Value; if (currentProfit < MinProfit) { result.Value += MinProfit - currentProfit; } if (currentProfit > MaxProfit) { result.Value -= currentProfit - MaxProfit; } return(result); }
/// <summary> /// Возврашает модификанту, входяшую в ограничения /// </summary> /// <param name="price"></param> /// <returns></returns> public virtual Modificants Normalize(Money price) { var result = new Modificants { Value = this.Value, RelativeValue = this.RelativeValue, Currency = this.Currency ?? price.Currency, CurrencyConverter = this.CurrencyConverter ?? price.CurrencyConverter }; if (result.Currency != price.Currency) price = result.CurrencyConverter.Convert(price, result.Currency); double currentProfit = base.Calc(price).Value; if (currentProfit < MinProfit) { result.Value += MinProfit - currentProfit; } if (currentProfit > MaxProfit) { result.Value -= currentProfit - MaxProfit; } return result; }
static Modificants() { MAX_VALUE = new Modificants { Value = Double.MaxValue, RelativeValue = Double.MaxValue }; MIN_VALUE = new Modificants { Value = Double.MinValue, RelativeValue = Double.MinValue }; }