Exemplo n.º 1
0
        public override ConsequenceResult Calculate(ConsequenceRequest request)
        {
            Money total = request.TriggerMode == TriggerType.OneTime ? request.InitialAmount : request.AmountAfter(TimeSpan.FromDays((Double)ConsequenceRequest.DaysPerUnit[TimeUnit.Year] * this.Years));

            return new ConsequenceResult(this,
                                         request,
                                         total * PercentAsDecimal(this.Amount),
                                         FormatCaption(this.Caption, new Dictionary<string,string> {
                {"Percentage", String.Format("{0}%", this.Amount)},
                {"Years", Years.ToString()}
            }),
                                         this.Image,
                                         true);
        }
Exemplo n.º 2
0
        public override ConsequenceResult Calculate(ConsequenceRequest request)
        {
            if (Cost == 0m)
                return null;

            if (request.TriggerMode == TriggerType.OneTime)
                return null;

            decimal perYear = request.AmountAfter (oneYear);
            decimal units = perYear / Cost;

            if (units >= LowerResultLimit && units <= UpperResultLimit)
                return new ConsequenceResult (this,
                                              request,
                                              new Units(units),
                                              FormatCaption (this.Caption, new Dictionary<string,string> {
                        {"Cost", this.Cost.ToString ()}
                    }),
                                              this.ImageName);
            else
                return null;
        }
        public override ConsequenceResult Calculate(ConsequenceRequest request)
        {
            if (Threshold == 0m)
                return null;

            decimal upper = Threshold + (Threshold * 0.10m);
            decimal lower = Threshold - (Threshold * 0.10m);

            if (request.InitialAmount >= lower && request.InitialAmount <= upper)
                return new ConsequenceResult (this, Threshold, this.Caption, this.ImageName);

            for (int i = 1; i <= Limit; i++) {
                decimal accumilated = request.AmountAfter (TimeSpan.FromDays (30 * i));
                if (accumilated >= lower && accumilated <= upper)
                    return new ConsequenceResult (this, Threshold, this.FormatCaption (this.Caption, new Dictionary<string,string> {
                        {"Months", i.ToString ()},
                        {"Threshold", this.Threshold.ToString ()}
                    }),
                                                  this.ImageName);
            }

            return null;
        }