public static Money <TCurrency> FromMinor <TCurrency>(decimal minor, IRoundingAdjuster adjuster) where TCurrency : Currency <TCurrency> { var major = Money <TCurrency> .UnderlyingUnit.ConvertToMajor(minor); return(FromMajor <TCurrency>(major, adjuster)); }
public Money <TCurrency> Normalize(IRoundingAdjuster adjuster) { if (IsNormalized) { return(this); } return(MoneyFactory.FromMajor <TCurrency>(Amount, adjuster)); }
public Money Normalize(IRoundingAdjuster adjuster) { if (IsNormalized) { return(this); } return(FromMajor(Amount, Currency, adjuster)); }
public static Money <TCurrency> FromMajor <TCurrency>(decimal amount, IRoundingAdjuster adjuster) where TCurrency : Currency <TCurrency> { Require.NotNull(adjuster, nameof(adjuster)); var unit = Money <TCurrency> .UnderlyingUnit; decimal major = unit.HasFixedDecimalPlaces ? adjuster.Round(amount, unit.DecimalPlaces) : amount; return(new Money <TCurrency>(major, true)); }
public RoundingMoneyAllocator(IRoundingAdjuster adjuster) { Require.NotNull(adjuster, nameof(adjuster)); RoundingAdjuster = adjuster; }
public static IEnumerable <Money> Allocate(this Money @this, RatioArray ratios, IRoundingAdjuster adjuster) => new RoundingMoneyAllocator(adjuster).Allocate(@this, ratios);
public static IEnumerable <Money> Allocate(this Money @this, int count, IRoundingAdjuster adjuster) => new RoundingMoneyAllocator(adjuster).Allocate(@this, count);