public ActionResult AddPayment(LoanHistory collection) { using (LinkToDBDataContext context = new LinkToDBDataContext()) { try { LoanHistory history = new LoanHistory(); history.CreationDate = DateTime.Now; history.ModifyDate = DateTime.Now; history.Version = 1; history.LoanId = collection.Id; history.DatePaid = collection.DatePaid; history.BasicPayment = collection.BasicPayment; history.AddPayment = collection.AddPayment; history.Interest = collection.Interest; history.Escrow = collection.Escrow; history.PaymentTypeId = collection.PaymentTypeId; Loan loan = context.GetLoan(history.LoanId); loan.LoanHistories.Add(history); context.SubmitChanges(); return RedirectToAction("Edit", new { id = history.LoanId }); } catch { return View(collection); } } }
public DashboardItem(LoanHistory history) { Id = history.LoanId; Name = history.Loan.Name; Date = history.DatePaid; Amount = history.Payment; IsShared = false; Type = "Loan"; IsPaid = true; }
public DashboardItem(LoanHistory history) { Id = history.LoanId; Name = history.Loan.Name; Date = history.DatePaid; Amount = history.Payment; IsPastDue = false; IsShared = false; Type = "Loan"; IsPaid = true; }
/* ========================= * Loan History Functions * ========================= */ public ActionResult AddPayment(int id) { using (LinkToDBDataContext context = new LinkToDBDataContext()) { Loan loan = context.GetLoan(id); LoanOutlook outlook = loan.LoanOutlook.FirstOrDefault(); LoanHistory history = new LoanHistory(); history.LoanId = loan.Id; history.BasicPayment = outlook.BaseAmount; history.AddPayment = outlook.AddAmount; history.Interest = outlook.InterestAmount; history.Escrow = outlook.EscrowAmount; history.DatePaid = outlook.Date; history.PaymentTypeId = loan.PaymentTypeId; history.Loan = loan; return View(history); } }
public static Loan LoadLoan(this Loan loan) { loan.Principal = loan.LoanAmount; loan.LastPaidDate = loan.FirstPaymentDate; loan.LoanHistory = loan.GetLoanHistory(); LoanHistory lastHistory = loan.LoanHistory.OrderBy(x => x.DatePaid).Reverse().FirstOrDefault(); if (lastHistory != null) { loan.LastPaidDate = lastHistory.DatePaid; loan.LastPaidAmount = lastHistory.Payment; loan.Principal = lastHistory.Principal; } if (loan.LoanHistory.Count() > 0) { loan.HistoryMinYear = loan.LoanHistory.Min(x => x.DatePaid.Year); loan.HistoryMaxYear = loan.LoanHistory.Max(x => x.DatePaid.Year); loan.HistoryNumberOfPayments = loan.LoanHistory.Count(); loan.HistoryPaymentTotal = loan.LoanHistory.Sum(x => x.Payment); loan.HistoryBaseTotal = loan.LoanHistory.Sum(x => x.BasicPayment); loan.HistoryAdditionalTotal = loan.LoanHistory.Sum(x => x.AddPayment); loan.HistoryEscrowTotal = loan.LoanHistory.Sum(x => x.Escrow); loan.HistoryInterestTotal = loan.LoanHistory.Sum(x => x.Interest); loan.HistoryPaymentAverage = loan.LoanHistory.Average(x => x.Payment); loan.HistoryBaseAverage = loan.LoanHistory.Average(x => x.BasicPayment); loan.HistoryAdditionalAverage = loan.LoanHistory.Average(x => x.AddPayment); loan.HistoryEscrowAverage = loan.LoanHistory.Average(x => x.Escrow); loan.HistoryInterestAverage = loan.LoanHistory.Average(x => x.Interest); loan.LastPayemnt = loan.LoanHistory.LastOrDefault(); } if (loan.IsActive) { loan.LoanOutlook = loan.GetLoanOutlook(); loan.PaymentsRemaining = loan.LoanOutlook.Count(); loan.OutlookMinYear = loan.LoanOutlook.Min(x => x.Date.Year); loan.OutlookMaxYear = loan.LoanOutlook.Max(x => x.Date.Year); loan.OutlookNumberOfPayments = loan.LoanOutlook.Count(); loan.OutlookPaymentTotal = loan.LoanOutlook.Sum(x => x.Payment); loan.OutlookBaseTotal = loan.LoanOutlook.Sum(x => x.BaseAmount); loan.OutlookAdditionalTotal = loan.LoanOutlook.Sum(x => x.AddAmount); loan.OutlookEscrowTotal = loan.LoanOutlook.Sum(x => x.EscrowAmount); loan.OutlookInterestTotal = loan.LoanOutlook.Sum(x => x.InterestAmount); loan.OutlookPaymentAverage = loan.LoanOutlook.Average(x => x.Payment); loan.OutlookBaseAverage = loan.LoanOutlook.Average(x => x.BaseAmount); loan.OutlookAdditionalAverage = loan.LoanOutlook.Average(x => x.AddAmount); loan.OutlookEscrowAverage = loan.LoanOutlook.Average(x => x.EscrowAmount); loan.OutlookInterestAverage = loan.LoanOutlook.Average(x => x.InterestAmount); loan.LifeNumberOfPayments = loan.HistoryNumberOfPayments + loan.OutlookNumberOfPayments; loan.LifePaymentTotal = loan.HistoryPaymentTotal + loan.OutlookPaymentTotal; loan.LifeBaseTotal = loan.HistoryBaseTotal + loan.OutlookBaseTotal; loan.LifeAdditionalTotal = loan.HistoryAdditionalTotal + loan.OutlookAdditionalTotal; loan.LifeEscrowTotal = loan.HistoryEscrowTotal + loan.OutlookEscrowTotal; loan.LifeInterestTotal = loan.HistoryInterestTotal + loan.OutlookInterestTotal; loan.LifePaymentAverage = loan.LifePaymentTotal / loan.LifeNumberOfPayments; loan.LifeBaseAverage = loan.LifeBaseTotal / loan.LifeNumberOfPayments; loan.LifeAdditionalAverage = loan.LifeAdditionalTotal / loan.LifeNumberOfPayments; loan.LifeEscrowAverage = loan.LifeEscrowTotal / loan.LifeNumberOfPayments; loan.LifeInterestAverage = loan.LifeInterestTotal / loan.LifeNumberOfPayments; loan.NextPayment = new LoanHistory(loan); } return(loan); }
partial void DeleteLoanHistory(LoanHistory instance);
partial void UpdateLoanHistory(LoanHistory instance);
partial void InsertLoanHistory(LoanHistory instance);
private void detach_LoanHistories(LoanHistory entity) { this.SendPropertyChanging(); entity.PaymentType = null; }
private void attach_LoanHistories(LoanHistory entity) { this.SendPropertyChanging(); entity.Loan = this; }