Пример #1
0
        public Pecuniam GetCurrent(DateTime dt, float rate)
        {
            if (IsEmpty)
            {
                return(Pecuniam.Zero);
            }

            if (DataSet.All(x => x.AtTime > dt))
            {
                return(Pecuniam.Zero);
            }

            var prev = FirstTransaction;
            var rest = DataSet.Skip(1);

            var bal = prev.Cash.Amount;

            foreach (var t in rest)
            {
                var tAtTime = t.AtTime;

                //does dt fall between this transaction and the last
                if (t.AtTime > dt)
                {
                    tAtTime = dt;
                }
                //the interest from prev to next
                var days = (tAtTime - prev.AtTime).TotalDays;
                bal = bal.PerDiemInterest(rate, days, DaysPerYear);

                //the current transaction is after the dt so we just want the interest
                if (tAtTime == dt)
                {
                    break;
                }
                bal += t.Cash.Amount;
                prev = t;
            }

            //is there a gap in time between last recorded transaction and query dt
            if (LastTransaction.AtTime < dt)
            {
                //calc the interest for that number of days
                var days = (dt - LastTransaction.AtTime).TotalDays;
                bal = bal.PerDiemInterest(rate, days, DaysPerYear);
            }

            return(new Pecuniam(bal));
        }
Пример #2
0
 public bool All(Expression <Func <T, bool> > expression)
 {
     return(DataSet.All(expression));
 }
        private bool AllExamplesHaveSameClassification(DataSet ds)
        {
            string classification = ds.GetExample(0).TargetValue();

            return(ds.All(e => e.TargetValue().Equals(classification)));
        }