示例#1
0
        /// <summary>
        ///     Creates an PaymentViewModel based on the recurring PaymentViewModel.
        /// </summary>
        /// <param name="recurringPayment">The recurring PaymentViewModel the new PaymentViewModel shall be based on.</param>
        /// <returns>The new created PaymentViewModel</returns>
        public static PaymentViewModel GetPaymentFromRecurring(RecurringPayment recurringPayment)
        {
            var date        = DateTime.Today;
            var recurringVm = new RecurringPaymentViewModel(recurringPayment);

            //If the PaymentViewModel is monthly we want it on the same day of month again.
            if (recurringVm.Recurrence == PaymentRecurrence.Monthly)
            {
                date = DateTime.Today.AddDays(recurringVm.StartDate.Day - DateTime.Today.Day);
            }

            return(new PaymentViewModel
            {
                ChargedAccount = recurringVm.ChargedAccount,
                TargetAccount = recurringVm.TargetAccount,
                Date = date,
                IsRecurring = true,
                Amount = recurringVm.Amount,
                Category = recurringVm.Category,
                Type = recurringVm.Type,
                RecurringPayment = recurringVm.GetRecurringPayment(),
                Note = recurringVm.Note
            });
        }