private Models.Blend.BLoan ConvertLoan(Models.Loan loan) { Models.Blend.BLoan result = new Models.Blend.BLoan(); result.SolutionSubType = Models.Blend.SolutionSubTypes.MORTGAGE.ToString(); result.Party = (Models.Blend.BParty)loan.Party; result.Property = (Models.Blend.BAddress)loan.PropertyAddress; result.ApplicationSource = new Models.Blend.ApplicationSource() { Name = DEFAULT_SOURCE_NAME, SourceSystemType = "CRM" }; Models.Blend.LoanPurposeTypes enumValue; if (Enum.TryParse <Models.Blend.LoanPurposeTypes>(loan.LoanPurposeType, out enumValue)) { result.LoanPurposeType = enumValue.ToString(); } Double amount; if (Double.TryParse(loan.LoanAmount, out amount)) { result.LoanAmount = amount; } if (Double.TryParse(loan.PropertyValue, out amount)) { result.Property.PropertyValue = amount; } result.SendEmailInvite = loan.SendEmailInvite; return(result); }
public ActionResult ReqLoan(Models.Loan lm)//view to verify if accountno avilable in database and to display message accordingly { using (var contex = new ProjectDBEntities()) { Issuccess = true; ViewBag.success = Issuccess; TempData["loan"] = lm; TempData.Keep(); bool isValid = contex.Accounts.Any(x => x.AccountID == lm.AccountID); if (isValid) { if (ViewBag.success) { return(Content("<script language='javascript' type='text/javascript'>alert('Your Loan Application has been Submitted.!');" + "window.location='Index';</script>"));//alertMessage for loan application submission } return(View()); } ModelState.AddModelError("", "You doesnot have Account in this bank or your Accont Number is wrong.Please check again!!"); return(View()); } }
public void OnGet() { StudentLoan = new Models.Loan { Amount = 600, Rate = .12M, LengthInMonths = 24 }; Message = "Your contact page."; }
private void LoadData() { DAL.UnitOfWork oUnitOfWork = new DAL.UnitOfWork(); Models.Loan oLoan = oUnitOfWork.LoanRepository .GetById(LoanId); MemberNameLabel.Content = oLoan.Member.FullName; StartDatelLabel.Content = oLoan.StartDate.ToPersianDate(); EndDatelLabel.Content = oLoan.EndDate.ToPersianDate(); LoanAmountLabel.Content = oLoan.LoanAmount.ToRial(); RefundAmountLabel.Content = oLoan.RefundAmount.ToRial(); InstallmentCountLabel.Content = oLoan.InstallmentsCount + " قسط "; var varData = oLoan.Installments .Where(current => current.IsPayed == true) .OrderByDescending(current => current.PaymentDate) .FirstOrDefault(); if (varData != null) { System.DateTime?oDateTime = varData.PaymentDate; LastPayedInstallmentLabel.Content = (oDateTime.HasValue == true) ? ((System.DateTime)oDateTime).ToPersianDate() : string.Empty; } else { LastPayedInstallmentLabel.Content = string.Empty; } PayedInstallmentCountLabel.Content = oLoan.Installments .Where(current => current.IsPayed == true) .Count() + " قسط"; UnpayedInstallmentCountLabel.Content = oLoan.Installments .Where(current => current.IsPayed == false) .Count() + " قسط"; SumOfPayedInstallmentsLabel.Content = oLoan.Installments .Where(current => current.IsPayed == true) .Select(current => current.PaymentAmount) .Sum() .ToRial(); SumOfUnpayedInstallmentsLabel.Content = oLoan.Installments .Where(current => current.IsPayed == false) .Select(current => current.PaymentAmount) .Sum() .ToRial(); }
public ViewModels.LoanViewModel PostLoanChanges([FromBody] Models.Loan loan) { // _loanRepository.Update(loan); _loanRepository.Insert(loan); _loanRepository.Save(); var result = _loanRepository.GetLoanById(loan.LoanId); return(null); //return result; }
private float InstalmentAmount(Models.Loan loan) { var regularAmount = loan.TotalAmount / loan.Instalments; var toRepay = loan.TotalAmount - loan.PaidAmount; if (regularAmount > toRepay) { return(toRepay); } return(regularAmount); }
private void InstallmentsOfLoan_Click(object sender, System.Windows.RoutedEventArgs e) { Models.Loan oLoan = LoansGridControl.SelectedItem as Models.Loan; if (oLoan != null) { Utility.CurrentLoan = oLoan; ShowInstallmentsListPerLoanWindow oShowInstallmentsListPerLoanWindow = new ShowInstallmentsListPerLoanWindow(); oShowInstallmentsListPerLoanWindow.ShowDialog(); } }
private void dgvLoans_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { Models.Loan loan = API.Controllers.Loans.FindById(dgvLoans[0, e.RowIndex].Value); Models.Account account = null; if (loan != null) { account = API.Controllers.Accounts.FetchByAccountNumber(loan.Account.Number); } Models.SimpleInterest si = new Models.SimpleInterest((decimal)loan.Principal, (decimal)loan.Rate, loan.Time, (decimal)loan.StandingCharge); si.Calculate(); SimpleInterestLoan sil = new SimpleInterestLoan(account, loan, si); sil.ShowDialog(); }
private void LoansTreeView_SelectedItemChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs <object> e) { Models.Loan oLoan = LoansTreeView.SelectedItem as Models.Loan; if (oLoan != null) { Utility.CurrentLoan = oLoan; RefreshInstallmentGridControl(); } else { return; } }
private IEnumerable <UserReportPortion> AggregateUserTransactions(Models.Loan loan, Transaction[] allTransactions, Granularity granularity) { var transactions = allTransactions.Where(t => t.PaymentId == loan.PaymentId).ToArray(); var withTimestamps = transactions.Select(t => new TransactionWithTimestamp { Timestamp = t.Timestamp.ToDateTime(), Transaction = t }); var portions = Aggregations.GroupByPeriods(granularity, withTimestamps); foreach (var portion in portions) { var debits = portion.Sum(p => (float?)p.Transaction.Amount) ?? 0; yield return(new UserReportPortion { Period = portion.Key, Debits = debits, Element = loan.Id }); } }
private void LoanOfInstallmentDetailsButton_Click(object sender, System.Windows.RoutedEventArgs e) { ViewModels.InstallmentViewModel oInstallmentViewModel = InstallmentPerLoanGridControl.SelectedItem as ViewModels.InstallmentViewModel; if (oInstallmentViewModel != null) { DAL.UnitOfWork oUnitOfWork = null; try { oUnitOfWork = new DAL.UnitOfWork(); System.Guid LoanId = oUnitOfWork.InstallmentRepository .GetById(oInstallmentViewModel.Id).LoanId; Models.Loan oLoan = oUnitOfWork.LoanRepository .GetById(LoanId); oUnitOfWork.Save(); LoanDetailsWindow oLoanDetailsWindow = new LoanDetailsWindow(oLoan.Id); oLoanDetailsWindow.ShowDialog(); } catch (System.Exception ex) { Infrastructure.MessageBox.Show(ex.Message); } finally { if (oUnitOfWork != null) { oUnitOfWork.Dispose(); oUnitOfWork = null; } } } }
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { System.Guid id = (System.Guid)value; DAL.UnitOfWork oUnitOfWork = new DAL.UnitOfWork(); Models.Loan oLoan = oUnitOfWork.LoanRepository .GetById(id); string result = string.Empty; if (oLoan != null) { result = string.Format("وام به مبلغ: {0} | بازپرداخت: {1} | اقساط: {2} قسط | تاریخ پرداخت: {3}", oLoan.LoanAmount.ToRialStringFormat(), oLoan.RefundAmount.ToRialStringFormat(), oLoan.InstallmentsCount, oLoan.StartDate.ToPersianDate() ); } return(result); }
private void OBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { DAL.UnitOfWork oUnitOfWork = null; try { oUnitOfWork = new DAL.UnitOfWork(); var varList = oUnitOfWork.InstallmentRepository .Get() .Where(current => current.LoanId == Utility.CurrentLoan.Id) .Where(current => current.IsPayed == false) .OrderBy(current => current.InstallmentDate) .ToList(); if (varList.Count != 0) { int count = varList.Count; int counter = 0; foreach (Models.Installment oInstallment in varList) { int progressBarPercent = System.Convert.ToInt32(((double)(counter + 1) / varList.Count) * 100); oInstallment.IsPayed = true; oInstallment.PaymentDate = System.DateTime.Now; oUnitOfWork.InstallmentRepository.Update(oInstallment); Models.Member oMember = oUnitOfWork.MemberRepository .GetById(oInstallment.Loan.Member.Id); oMember.Balance -= oInstallment.PaymentAmount; oUnitOfWork.MemberRepository.Update(oMember); Models.Fund oFund = oUnitOfWork.FundRepository .GetById(Utility.CurrentFund.Id); oFund.Balance += oInstallment.PaymentAmount; oUnitOfWork.FundRepository.Update(oFund); Utility.CurrentFund = oFund; Models.Transaction oTransaction = new Models.Transaction(); oTransaction.Amount = oInstallment.PaymentAmount; oTransaction.Balance = oFund.Balance; oTransaction.Date = System.DateTime.Now; oTransaction.Description = string.Format("پرداخت قسط به مبلغ {0} ریال از {1}", oInstallment.PaymentAmount, oInstallment.Loan.Member.FullName); oTransaction.TransactionType = Models.TransactionType.Installment; oTransaction.MemberId = oInstallment.Loan.Member.Id; oTransaction.FundId = oFund.Id; oTransaction.InstallmentId = oInstallment.Id; oUnitOfWork.TransactionRepository.Insert(oTransaction); Models.Reminder oReminder = oUnitOfWork.RemainderRepository .Get() .Where(current => current.InstallmentId == oInstallment.Id) .FirstOrDefault(); if (oReminder != null) { oUnitOfWork.RemainderRepository.Delete(oReminder); } oUnitOfWork.Save(); Models.Loan oLoan = oUnitOfWork.LoanRepository .Get() .Where(current => current.Id == oInstallment.LoanId) .Where(current => current.Installments.All(installment => installment.IsPayed == true)) .FirstOrDefault(); if (oLoan != null) { oLoan.IsPayed = true; oLoan.IsActive = false; oUnitOfWork.LoanRepository.Update(oLoan); oUnitOfWork.Save(); } (sender as System.ComponentModel.BackgroundWorker).ReportProgress(progressBarPercent); counter++; } } oUnitOfWork.Save(); } catch (System.Exception ex) { Infrastructure.MessageBox.Show(ex.Message); } finally { if (oUnitOfWork != null) { oUnitOfWork.Dispose(); oUnitOfWork = null; } } }
private void OBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { DAL.UnitOfWork oUnitOfWork = null; oUnitOfWork = new DAL.UnitOfWork(); Models.Member oMember = oUnitOfWork.MemberRepository .GetById(Utility.CurrentMember.Id); Models.Fund oFund = oUnitOfWork.FundRepository .GetById(Utility.CurrentFund.Id); Models.Loan oLoan = new Models.Loan(); this.Dispatcher.Invoke(() => { oLoan.LoanAmount = LoanAmountTextBox.Text.StringToMoney(); oLoan.IsActive = true; oLoan.IsPayed = false; oLoan.MemberId = Utility.CurrentMember.Id; oLoan.InstallmentsCount = System.Convert.ToInt32(InstallmentsCountTextBox.Text.Trim()); oLoan.RefundAmount = LoanAmountTextBox.Text.StringToMoney(); oLoan.StartDate = LoanDateTimeDatePicker.SelectedDateTime; oLoan.EndDate = LoanDateTimeDatePicker.SelectedDateTime; oLoan.Description = DescriptionTextBox.Text.Trim(); }); oUnitOfWork.LoanRepository.Insert(oLoan); oFund.Balance -= oLoan.LoanAmount; oUnitOfWork.FundRepository.Update(oFund); oUnitOfWork.Save(); Utility.CurrentFund = oFund; Models.Transaction oTransaction = new Models.Transaction(); oTransaction.Amount = oLoan.LoanAmount; oTransaction.Balance = oFund.Balance; oTransaction.Date = System.DateTime.Now; oTransaction.Description = string.Format("پرداخت وام به مبلغ {0} ریال به {1}", oLoan.LoanAmount, Utility.CurrentMember.FullName); oTransaction.FundId = Utility.CurrentFund.Id; oTransaction.TransactionType = Models.TransactionType.Loan; oTransaction.MemberId = Utility.CurrentMember.Id; oTransaction.LoanId = oLoan.Id; oUnitOfWork.TransactionRepository.Insert(oTransaction); int percent = 0; this.Dispatcher.Invoke(() => { percent = (CalculatePercentCheckBox.IsChecked == true) ? Utility.CurrentFund.Percent : 0; }); ViewModels.CreateLoanViewModel oCreateLoanViewModel = CalculateLoanParameters(oLoan.LoanAmount, oLoan.InstallmentsCount, percent); for (int index = 0; index < oLoan.InstallmentsCount; index++) { int progressBarPercent = System.Convert.ToInt32(((double)(index + 1) / oLoan.InstallmentsCount) * 100); Models.Installment oInstallment = new Models.Installment(); oInstallment.PaymentAmount = oCreateLoanViewModel.Installments.ElementAt(index); oInstallment.IsPayed = false; oInstallment.InstallmentDate = oLoan.StartDate.AddMonths(index + 1); oInstallment.PaymentDate = null; oInstallment.LoanId = oLoan.Id; oUnitOfWork.InstallmentRepository.Insert(oInstallment); Models.Reminder oReminder = new Models.Reminder(); FarsiLibrary.Utils.PersianDate oPersianDate = new FarsiLibrary.Utils.PersianDate(oInstallment.InstallmentDate); oReminder.DateTime = oInstallment.InstallmentDate; oReminder.PersianDate.Year = oPersianDate.Year; oReminder.PersianDate.Month = oPersianDate.Month; oReminder.PersianDate.Day = oPersianDate.Day; oReminder.EventType = Models.Event.Installment; oReminder.Description = string.Format("قسط {0} وام {1} به مبلغ {2}", FarsiLibrary.Utils.ToWords.ToString(index + 1), Utility.CurrentMember.FullName, oInstallment.PaymentAmount.ToRialStringFormat()); oReminder.InstallmentId = oInstallment.Id; oReminder.FundId = Utility.CurrentFund.Id; oUnitOfWork.RemainderRepository.Insert(oReminder); if (index == oLoan.InstallmentsCount - 1) { oLoan.EndDate = oInstallment.InstallmentDate; oLoan.RefundAmount = oCreateLoanViewModel.RefundAmount; oUnitOfWork.LoanRepository.Update(oLoan); } oUnitOfWork.Save(); (sender as System.ComponentModel.BackgroundWorker).ReportProgress(progressBarPercent); } Utility.CurrentLoan = oLoan; oMember.Balance += oLoan.LoanAmount; oUnitOfWork.MemberRepository.Update(oMember); oUnitOfWork.Save(); }
private void ODeleteLoanBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { DAL.UnitOfWork oUnitOfWork = null; try { oUnitOfWork = new DAL.UnitOfWork(); Models.Fund oFund = oUnitOfWork.FundRepository .GetById(Utility.CurrentFund.Id); var varList = oUnitOfWork.InstallmentRepository .Get() .Where(current => current.LoanId == Utility.CurrentLoan.Id) .ToList(); if (varList.Count != 0) { foreach (Models.Installment oInstallment in varList) { Models.Transaction oTransaction = oUnitOfWork.TransactionRepository .Get() .Where(current => current.InstallmentId == oInstallment.Id) .FirstOrDefault(); Models.Member oMember = oUnitOfWork.MemberRepository .GetById((System.Guid)oTransaction.MemberId); if (oInstallment.IsPayed == true) { oMember.Balance += oInstallment.PaymentAmount; oUnitOfWork.MemberRepository.Update(oMember); } if (oTransaction != null) { oUnitOfWork.TransactionRepository.Delete(oTransaction); } Models.Reminder oReminder = oUnitOfWork.RemainderRepository .Get() .Where(current => current.InstallmentId == oInstallment.Id) .FirstOrDefault(); if (oReminder != null) { oUnitOfWork.RemainderRepository.Delete(oReminder); } if (oFund != null) { oFund.Balance -= oInstallment.PaymentAmount; } oUnitOfWork.Save(); } oUnitOfWork.FundRepository.Update(oFund); oUnitOfWork.Save(); Utility.CurrentFund = oFund; } Models.Loan oLoan = oUnitOfWork.LoanRepository .GetById(Utility.CurrentLoan.Id); if (oLoan != null) { Models.Transaction oTransaction = oUnitOfWork.TransactionRepository .Get() .Where(current => current.LoanId == oLoan.Id) .FirstOrDefault(); Models.Member oMember = oUnitOfWork.MemberRepository .GetById(Utility.CurrentLoan.Member.Id); oUnitOfWork.LoanRepository.Delete(oLoan); if (oTransaction != null) { oUnitOfWork.TransactionRepository.Delete(oTransaction); } oUnitOfWork.Save(); oFund.Balance += oLoan.LoanAmount; oMember.Balance -= oLoan.LoanAmount; oUnitOfWork.FundRepository.Update(oFund); oUnitOfWork.MemberRepository.Update(oMember); } oUnitOfWork.Save(); Utility.CurrentFund = oFund; Utility.CurrentLoan = null; } catch (System.Exception ex) { Infrastructure.MessageBox.Show(ex.Message); } finally { if (oUnitOfWork != null) { oUnitOfWork.Dispose(); oUnitOfWork = null; } } }
private void PayInstallmentsButton_Click(object sender, System.Windows.RoutedEventArgs e) { ViewModels.InstallmentViewModel oViewModel = InstallmentPerLoanGridControl.SelectedItem as ViewModels.InstallmentViewModel; if (oViewModel != null) { DAL.UnitOfWork oUnitOfWork = null; try { oUnitOfWork = new DAL.UnitOfWork(); Models.Installment oInstallment = oUnitOfWork.InstallmentRepository .GetById(oViewModel.Id); var varList = oUnitOfWork.InstallmentRepository .Get() .Where(current => current.LoanId == oInstallment.LoanId) .Where(current => current.IsPayed == false) .Where(current => current.InstallmentDate < oInstallment.InstallmentDate) .OrderBy(current => current.InstallmentDate) .ToList(); if (varList.Count != 0) { Infrastructure.MessageBox.Show ( caption: Infrastructure.MessageBox.Caption.Error, text: string.Format("ابتدا بایست قسط تاریخ {0} پرداخت شود.", varList.Select(current => current.InstallmentDate).FirstOrDefault().ToPersianDate()) ); return; } oInstallment.IsPayed = true; oInstallment.PaymentDate = System.DateTime.Now; oUnitOfWork.InstallmentRepository.Update(oInstallment); Models.Member oMember = oUnitOfWork.MemberRepository .GetById(oInstallment.Loan.Member.Id); oMember.Balance -= oInstallment.PaymentAmount; oUnitOfWork.MemberRepository.Update(oMember); Models.Fund oFund = oUnitOfWork.FundRepository .GetById(Utility.CurrentFund.Id); oFund.Balance += oInstallment.PaymentAmount; oUnitOfWork.FundRepository.Update(oFund); Utility.CurrentFund = oFund; Models.Transaction oTransaction = new Models.Transaction(); oTransaction.Amount = oInstallment.PaymentAmount; oTransaction.Balance = oFund.Balance; oTransaction.Date = System.DateTime.Now; oTransaction.Description = string.Format("پرداخت قسط به مبلغ {0} ریال از {1}", oInstallment.PaymentAmount, oInstallment.Loan.Member.FullName); oTransaction.TransactionType = Models.TransactionType.Installment; oTransaction.MemberId = oInstallment.Loan.Member.Id; oTransaction.FundId = oFund.Id; oTransaction.InstallmentId = oInstallment.Id; oUnitOfWork.TransactionRepository.Insert(oTransaction); Models.Reminder oReminder = oUnitOfWork.RemainderRepository .Get() .Where(current => current.InstallmentId == oInstallment.Id) .FirstOrDefault(); if (oReminder != null) { oUnitOfWork.RemainderRepository.Delete(oReminder); } oUnitOfWork.Save(); Models.Loan oLoan = oUnitOfWork.LoanRepository .Get() .Where(current => current.Id == oInstallment.LoanId) .Where(current => current.Installments.All(installment => installment.IsPayed == true)) .FirstOrDefault(); if (oLoan != null) { oLoan.IsPayed = true; oLoan.IsActive = false; oUnitOfWork.LoanRepository.Update(oLoan); oUnitOfWork.Save(); } Utility.MainWindow.RefreshUserInterface(); (Utility.MainWindow.SthPanel.Children[0] as MainPanelContentUserControl).MiniPersianSchedulerReminder.RefreshMonth(); (Utility.MainWindow.SthPanel.Children[0] as MainPanelContentUserControl).RefreshSchedulerListBox(); } catch (System.Exception ex) { Infrastructure.MessageBox.Show(ex.Message);; } finally { if (oUnitOfWork != null) { oUnitOfWork.Dispose(); oUnitOfWork = null; } } RefreshInstallmentGridControl(); } }
public void Add(Models.Loan loan) { _context.Loans.Add(loan); }