public static Income Populate(this Income income, ApplicationUser user) { if (income.IncomePayments != null && income.IncomePayments.Any()) { IncomePayment lastPayment = income.IncomePayments.OrderBy(x => x.Date).LastOrDefault(); if (lastPayment != null) { income.LastPaymentDate = lastPayment.Date; income.LastPaymentAmount = lastPayment.Amount; } income.MinYear = income.IncomePayments.Min(x => x.Date.Year); income.MaxYear = income.IncomePayments.Max(x => x.Date.Year); if (income.PaymentFrequency == PaymentFrequency.SemiMonthly && income.SecondDate < income.Date) { income.UseSecond = true; } } double dueInDays = ((income.UseSecond ? income.SecondDate : income.Date) - new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)).TotalDays; bool isPastDue = dueInDays < 0; income.DueIn = GetDueIn(income.IsActive, isPastDue, dueInDays); income.Classes = GetClasses(income.IsActive, isPastDue, dueInDays); return(income); }
public DashboardIncomeItem(IncomePayment payment) { Id = payment.Income.ID; Name = payment.Income.Name; Date = payment.Date; Amount = payment.Amount; Type = "Income"; IsPaid = true; }