Exemple #1
0
        public static IEnumerable <Operation> Create(Goal goal, TimeInterval timeInterval)
        {
            if (timeInterval < TimeInterval.Dialy)
            {
                timeInterval = TimeInterval.Monthly;
            }

            var shares = DateHelper.GetIntervalsInTime(goal.StartDate, goal.EndDate,
                                                       (int)timeInterval);

            //  instances
            var operations = new Collection <Operation>();

            var partAmount = goal.Amount / shares;
            var initDate   = goal.StartDate.AddDays(-1);        // ¿substract one day? Yes: 1-15, No: 1-16

            //  construct
            for (var i = 0; i < shares; i++)
            {
                initDate = DateHelper.AggregateValidDate(timeInterval, initDate);
                var item = new Operation()
                {
                    IntervalTypeId = timeInterval,
                    ExpValue       = partAmount,
                    InputDate      = initDate,
                    RealValue      = null,
                    EffectedDate   = null
                };
                operations.Add(item);
            }

            //  joining
            return(operations);
        }
Exemple #2
0
        public static IEnumerable <Operation> CreateRecurrent(DateTime startDate, DateTime endDate, Double amount, TimeInterval timeInterval)
        {
            if (timeInterval < TimeInterval.Dialy)
            {
                timeInterval = TimeInterval.Monthly;
            }

            var initDate = startDate.AddDays(0);          // ¿substract one day? Yes: 1-15, No: 1-16

            var shares = DateHelper.GetIntervalsInTime(startDate, endDate, (int)timeInterval);

            //  instances
            var operations = new Collection <Operation>();

            //assignment
            for (var i = 0; i <= shares; i++)
            {
                var item = new Operation()
                {
                    IntervalTypeId = timeInterval,
                    ExpValue       = amount,
                    InputDate      = initDate,
                    RealValue      = null,
                    EffectedDate   = null
                };
                operations.Add(item);
                initDate = DateHelper.AggregateValidDate(timeInterval, initDate);
            }

            return(operations);
        }