Пример #1
0
        private void CreateBillsForDateRange()
        {
            var    days     = (EndDate - StartDate).TotalDays;
            double dayCount = 0.0;

            var spacings = 0;   //weeks, months, fortnights, 4weeks etc

            NewBills.Clear();
            switch (DueDateFrequency)
            {
            case DueDateFrequencies.OneWeek:
                while (dayCount <= days)
                {
                    dayCount = (StartDate.AddDays((spacings + 1) * 7) - StartDate).TotalDays;
                    spacings++;
                }
                for (int i = 0; i < spacings; i++)
                {
                    NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddDays(7 * i)));
                }
                break;

            case DueDateFrequencies.TwoWeek:
                while (dayCount <= days)
                {
                    dayCount = (StartDate.AddDays((spacings + 1) * 14) - StartDate).TotalDays;
                    spacings++;
                }
                for (int i = 0; i < spacings; i++)
                {
                    NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddDays(14 * i)));
                }
                break;

            case DueDateFrequencies.FourWeek:
                while (dayCount <= days)
                {
                    dayCount = (StartDate.AddDays((spacings + 1) * 28) - StartDate).TotalDays;
                    spacings++;
                }
                for (int i = 0; i < spacings; i++)
                {
                    NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddDays(28 * i)));
                }
                break;

            case DueDateFrequencies.Monthly:
                while (dayCount <= days)
                {
                    dayCount = (StartDate.AddMonths(spacings + 1) - StartDate).TotalDays;
                    spacings++;
                }
                for (int i = 0; i < spacings; i++)
                {
                    NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddMonths(i)));
                }
                break;

            case DueDateFrequencies.Quarterly:
                while (dayCount <= days)
                {
                    dayCount = (StartDate.AddMonths(3 * (spacings + 1)) - StartDate).TotalDays;
                    spacings++;
                }
                for (int i = 0; i < spacings; i++)
                {
                    NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddMonths(3 * i)));
                }
                break;

            case DueDateFrequencies.SemiAnnually:
                while (dayCount <= days)
                {
                    dayCount = (StartDate.AddMonths(6 * (spacings + 1)) - StartDate).TotalDays;
                    spacings++;
                }
                for (int i = 0; i < spacings; i++)
                {
                    NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddMonths(6 * i)));
                }
                break;

            case DueDateFrequencies.Yearly:
                while (dayCount <= days)
                {
                    dayCount = (StartDate.AddYears(spacings + 1) - StartDate).TotalDays;
                    spacings++;
                }
                for (int i = 0; i < spacings; i++)
                {
                    NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddYears(i)));
                }
                break;

            default:
                break;
            }
            RaisePropertyChanged(nameof(BillCount));
        }
Пример #2
0
 private void ResetNewBillsToSingle()
 {
     NewBills.Clear();
     NewBills.Add(new NewBillViewModel(StartDate));
 }