예제 #1
0
 public OperationSet(RecurrenceFamily recurrence, DateTime period, decimal initialBalance)
 {
     Recurrence     = recurrence;
     Period         = period;
     InitialBalance = initialBalance;
     Balance        = initialBalance;
     Operations     = new List <UnifiedAccountOperation>();
 }
예제 #2
0
        private static List <OperationSet> AggregateOperations(
            decimal initialBalance,
            DateRange range,
            RecurrenceFamily recurrence,
            IEnumerable <UnifiedAccountOperation> orderedOperations)
        {
            var result = new List <OperationSet>();

            var start = recurrence.GetPeriod(range.Min);

            var currentBpd = new OperationSet(recurrence, start, initialBalance);

            result.Add(currentBpd);

            using (var operationEnumerator = orderedOperations.GetEnumerator())
            {
                while (operationEnumerator.MoveNext())
                {
                    var operation = operationEnumerator.Current;
                    if (operation == null)
                    {
                        continue;
                    }

                    var operationPeriod = recurrence.GetPeriod(operation.ExecutionDate);

                    while (currentBpd.Period < operationPeriod)
                    {
                        currentBpd = OperationSet.CreateForNextStep(currentBpd);
                        result.Add(currentBpd);
                    }

                    currentBpd.Add(operation);
                }
            }

            start = currentBpd.Period;
            var end = recurrence.GetPeriod(range.Max);

            while (start < end)
            {
                currentBpd = OperationSet.CreateForNextStep(currentBpd);
                result.Add(currentBpd);
                start = currentBpd.Period;
            }

            return(result);
        }
예제 #3
0
        public static DateTime GetNextPeriod(this RecurrenceFamily recurrence, DateTime day)
        {
            switch (recurrence)
            {
            case RecurrenceFamily.Daily:
                return(GetPeriod(recurrence, day).AddDays(1));

            case RecurrenceFamily.Monthly:
                return(GetPeriod(recurrence, day).AddMonths(1));

            case RecurrenceFamily.Yearly:
                return(GetPeriod(recurrence, day).AddYears(1));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #4
0
        public static DateTime GetPeriod(this RecurrenceFamily recurrence, DateTime day)
        {
            switch (recurrence)
            {
            case RecurrenceFamily.Daily:
                return(new DateTime(day.Year, day.Month, day.Day));

            case RecurrenceFamily.Monthly:
                return(new DateTime(day.Year, day.Month, 1));

            case RecurrenceFamily.Yearly:
                return(new DateTime(day.Year, 1, 1));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #5
0
        public static string Format(this RecurrenceFamily recurrence, DateTime day)
        {
            switch (recurrence)
            {
            case RecurrenceFamily.Daily:
                return(day.ToString("d"));

            case RecurrenceFamily.Monthly:
                return(day.ToString("yyyy-MM"));

            case RecurrenceFamily.Yearly:
                return(day.ToString("yyyy"));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #6
0
        public DashboardViewModel(BusyIndicatorViewModel busyIndicator)
        {
            _busyIndicator = busyIndicator;

            RefreshPivotEvolutionCommand = new AsyncCommand(RefreshPivotEvolution, () => !_busyIndicator.IsBusy);
            Filter = new DashboardFilterViewModel();
            Filter.FilterInvalidated += async(sender, arg) => { await Refresh(sender); };

            _asyncMessageReceiver = new AsyncMessageReceiver(MessengerInstance);
            _asyncMessageReceiver.RegisterAsync <AccountsViewModelLoaded>(this, OnAccountsViewModelLoaded);

            PlotController = new PlotController();
            // show tooltip on mouse over, instead of on click
            PlotController.UnbindMouseDown(OxyMouseButton.Left);
            PlotController.BindMouseEnter(PlotCommands.HoverSnapTrack);

            _selectionHandlers = new List <PlotModelRangeSelectionHandler>();

            _pivotEvolutionMainMetric = nameof(CompareCellModel.Balance);
            _pivotEvolutionPeriod     = RecurrenceFamily.Yearly;
        }
예제 #7
0
        private static List <GroupedOperationSet> AggregateOperationsByCategory(DateRange range, RecurrenceFamily recurrence, IEnumerable <UnifiedAccountOperation> operations)
        {
            var categoryGroups = operations.GroupBy(op => op.GetCategoryByLevel(0));
            var result         = categoryGroups.Select(grp => new GroupedOperationSet
            {
                Key = grp.Key,
                PeriodicOperations = AggregateOperations(0, range, recurrence, grp)
            }).ToList();

            return(result);
        }
예제 #8
0
 public OperationSetGroup(List <GroupedOperationSet> operations, DateRange range, RecurrenceFamily recurrence)
     : base(operations)
 {
     Range      = range;
     Recurrence = recurrence;
 }