public BracketedRateTemplate(BracketedRateTemplate <TBound, TRate> original)
 {
     this.LowerBound = original.LowerBound;
     this.UpperBound = original.UpperBound;
     this.SeqNo      = original.SeqNo;
     this.Rate       = original.Rate;
 }
        public virtual Money ApplyRate(TimeDuration duration, Money amount, Rounding <Money> rounding,
                                       out BracketedRateTemplate <TimeDuration, float> bracket)
        {
            bracket = this.GetBracket(duration);
            Money ratedAmount;

            if (null == bracket)
            {
                ratedAmount = null;
            }
            else
            {
                switch (rounding.Target)
                {
                case RoundingTarget.RoundAmount:
                    ratedAmount = rounding.Round(amount) * bracket.Rate / 100d;
                    break;

                default:     //round output
                    ratedAmount = rounding.Round(amount * bracket.Rate / 100d);
                    break;
                }
            }
            return(ratedAmount);
        }
Beispiel #3
0
 public virtual Money ApplyRate(Money amount, Rounding <Money> rounding,
                                out BracketedRateTemplate <Money, Money> bracket)
 {
     bracket = (BracketedRateTemplate <Money, Money>) this.GetBracket(amount);
     if (null == bracket)
     {
         return(null);
     }
     else
     {
         return(bracket.Rate);
     }
 }
 public virtual Money ApplyRate(int amount, Rounding <Money> rounding,
                                out BracketedRateTemplate <int, MoneyPerItemRate> bracket)
 {
     bracket = (BracketedRateTemplate <int, MoneyPerItemRate>) this.GetBracket(amount);
     if (null == bracket)
     {
         return(null);
     }
     else if (this.ApplyRateToAmountOverBracketLowerBound)
     {
         return(bracket.Rate.Apply(amount - bracket.LowerBound, rounding));
     }
     else
     {
         return(bracket.Rate.Apply(amount, rounding));
     }
 }