public ActionResult Create(LoanTransaction loantransaction, string accountNO) { ViewBag.AccountNo = accountNO; var CustomerAccount = db.Customers.Where(m => m.AccountNo == loantransaction.AccountNo); if (ModelState.IsValid) { if (CustomerAccount.Count() != 0) { loantransaction.DateCreated = DateTime.Now.ToShortDateString(); loantransaction.amount = 0; loantransaction.createdby = User.Identity.Name.ToString(); db.LoanTransactions.Add(loantransaction); db.SaveChanges(); return(Redirect("~/LoanTransaction/Details/" + loantransaction.id)); } else { return(Redirect("~/CustomerSavings/AccountNotFound")); } } return(View(loantransaction)); }
private LoanStatusRow CreateLoanStatusRowFromTransaction(LoanTransaction loanTransaction) { var currentRow = new LoanStatusRow { PostDate = loanTransaction.PostDate, Description = loanTransaction.Description, Fees = FormatNumberWithDash(loanTransaction.Fees) }; var pacnetTransaction = loanTransaction as PacnetTransaction; if (pacnetTransaction == null) { var paypointTransaction = loanTransaction as PaypointTransaction; if (paypointTransaction == null) { return(null); } currentRow.Type = "Payment"; currentRow.Interest = FormatNumberWithDash(paypointTransaction.Interest); currentRow.Principal = FormatNumberWithDash(paypointTransaction.LoanRepayment); currentRow.Total = FormatNumberWithDash(paypointTransaction.LoanRepayment + paypointTransaction.Interest + loanTransaction.Fees); currentRow.Status = paypointTransaction.Status.ToString(); } else { currentRow.Type = "Loan"; currentRow.Interest = "-"; currentRow.Principal = "-"; currentRow.Total = "-"; currentRow.Status = pacnetTransaction.Status.ToString(); } return(currentRow); }
private void GenerateMockData() { var jewelry = new Jewelry(); jewelry.JewelryId = "00000001"; jewelry.JewelryType = "Ring"; jewelry.JewelryQuality = "10k"; jewelry.CrystalWeight = 1.5; jewelry.Weight = 6; jewelry.Description = "Few scratches, slightly used"; var loanTransaction = new LoanTransaction(); loanTransaction.Customer = SelectedCustomer; loanTransaction.JewelryCollateral = jewelry; loanTransaction.TransactionDate = DateTime.UtcNow; SelectedCustomer.LoanTransactions.Add(loanTransaction); var paymentTransaction = new PaymentTransaction(); paymentTransaction.Loan = loanTransaction; paymentTransaction.JewelryCollateral = jewelry; paymentTransaction.PaymentDate = new DateTime(2019, 04, 19); paymentTransaction.PaymentAmount = 1000; loanTransaction.PaymentTransactions.Add(paymentTransaction); double payments = 0; foreach (var p in loanTransaction.PaymentTransactions) { payments = payments + p.PaymentAmount; } loanTransaction.RemainingBalance = loanTransaction.ToBePaid - payments; }
/// <summary> /// Adds loan transaction /// </summary> /// <param name="transaction">The transaction.</param> /// <returns>Transaction creation status</returns> public async Task <Transaction> AddTransaction(LoanTransaction transaction) { return(await AddTransaction <Transaction>(transaction, r => { r.AddIfNotEmpty("borrowedBy", transaction.BorrowedBy); r.AddIfNotEmpty("loanedBy", transaction.LoanedBy); })); }
public void CreateTransaction(LoanTransaction model) { using (var ctx = new MicrozayimContext()) { ctx.LoanTransactions.Add(model); ctx.SaveChanges(); } }
public ActionResult DeleteConfirmed(int id) { LoanTransaction loantransaction = db.LoanTransactions.Find(id); string CustomerAccountNo = (from s in db.LoanTransactions where s.id == id select s.AccountNo).FirstOrDefault(); db.LoanTransactions.Remove(loantransaction); db.SaveChanges(); return(Redirect("/Loan/CheckLoanStatus?accountno=" + CustomerAccountNo)); }
public ActionResult Edit(LoanTransaction loantransaction) { if (ModelState.IsValid) { db.Entry(loantransaction).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loantransaction)); }
// // GET: /LoanTransaction/Edit/5 public ActionResult Edit(int id = 0) { LoanTransaction loantransaction = db.LoanTransactions.Find(id); if (loantransaction == null) { return(HttpNotFound()); } return(View(loantransaction)); }
public ActionResult CreditLoan(LoanTransaction loan) { var customerAccount = _context.CustomerSavings.Where(m => m.AccountNo == loan.AccountNo); if (ModelState.IsValid) { foreach (var item in customerAccount) { if (item.AccountNo == null) { return(Redirect("~/CustomerSavings/AccountNotFound")); } } loan.DateCreated = DateTime.Now.ToShortDateString(); loan.createdby = User.Identity.Name.ToString(); _context.LoanTransactions.Add(loan); _context.SaveChanges(); } return(View("LoanCreditSuccess")); }
public List <LoanTransaction> PopulateTransactions(LoanInput userInput) { List <LoanTransaction> Loantransactions = new List <LoanTransaction>(Convert.ToInt32(Math.Ceiling(userInput.NoOfInstallments * 12))); LoanTransaction FirstTransaction = new LoanTransaction { Opening = userInput.LoanAmount, emi = userInput.emi, Interest = userInput.LoanAmount * userInput.MonthlyRateOfInterest }; FirstTransaction.Principal = userInput.emi - FirstTransaction.Interest; FirstTransaction.Closing = Math.Round(FirstTransaction.Opening, 2) - Math.Round(FirstTransaction.Principal, 2); FirstTransaction.CummulativeInterest = FirstTransaction.Interest; FirstTransaction.InstallmentNo = 1; Loantransactions.Add(FirstTransaction); for (int i = 1; i < Convert.ToInt32(Math.Ceiling(userInput.NoOfInstallments * 12)); i++) { LoanTransaction transaction = new LoanTransaction { InstallmentNo = i + 1, emi = userInput.emi, Opening = Loantransactions[i - 1].Opening - Loantransactions[i - 1].Principal }; //transaction.Interest = transaction.Opening * userInput.MonthlyRateOfInterest; //transaction.Principal = transaction.emi - transaction.Interest; //transaction.Closing = transaction.Opening - transaction.Principal; //transaction.CummulativeInterest = userInput.emi * (i + 1); transaction.Interest = transaction.Opening * userInput.MonthlyRateOfInterest; transaction.Principal = userInput.emi - transaction.Interest; transaction.Closing = Math.Round(transaction.Opening, 2) - Math.Round(transaction.Principal, 2); transaction.CummulativeInterest = Loantransactions[i - 1].CummulativeInterest + transaction.Interest; Loantransactions.Add(transaction); } return(Loantransactions); }
private void AddNewLoanTransactionProc() { if (NewJewelryCrystalWeight >= NewJewelryWeight) { MessageBox.Show("The crystal's weight cannot be more than the jewelry's weight.", "Error", MessageBoxButton.OK); } else { var newJewelry = new Jewelry(); newJewelry.JewelryId = $"0000000{(int.Parse(_mainTransactionWindowViewModel.SelectedCustomer.LoanTransactions.LastOrDefault().JewelryCollateral.JewelryId) + 1)}"; newJewelry.JewelryQuality = NewJewelryQuality; newJewelry.JewelryType = NewJewelryType; if (NewJewelryCrystalWeight != null) { newJewelry.CrystalWeight = (double)NewJewelryCrystalWeight; } if (NewJewelryWeight != null) { newJewelry.Weight = (double)NewJewelryWeight; } newJewelry.Description = NewJewelryDescription; var newLoanTransaction = new LoanTransaction(); newLoanTransaction.JewelryCollateral = newJewelry; newLoanTransaction.Customer = _mainTransactionWindowViewModel.SelectedCustomer; newLoanTransaction.TransactionDate = DateTime.UtcNow; newLoanTransaction.RemainingBalance = newLoanTransaction.ToBePaid; _mainTransactionWindowViewModel.SelectedCustomer.LoanTransactions.Add(newLoanTransaction); MessageBox.Show("Loan Successful!", "Transaction Alert", MessageBoxButton.OK); NewJewelryType = null; NewJewelryQuality = null; NewJewelryWeight = null; NewJewelryCrystalWeight = null; NewJewelryDescription = null; } }
/// <summary> /// Displays the item information and item data information /// for the given loan itemSummary. /// </summary> /// <param name="itemSummary">an itemSummary whose containerType is 'loan'</param> public void displayLoanDataForItem(ItemSummary itemSummary) { System.Console.WriteLine(""); String containerType = itemSummary.contentServiceInfo.containerInfo.containerName; if (!containerType.Equals(ContainerTypes.LOAN)) { throw new Exception("DisplayLoanDataForItem called with invalid container type" + containerType); } DisplayItemInfo displayItemInfo = new DisplayItemInfo(); displayItemInfo.displayItemSummaryInfo(itemSummary); // Get ItemData ItemData1 itemData = itemSummary.itemData; if (itemData == null) { System.Console.WriteLine("\tItemData is null"); } else { // LoanLoginAccountData object[] accounts = itemData.accounts; if (accounts == null || accounts.Length == 0) { System.Console.WriteLine("\tNo accounts"); } else { System.Console.WriteLine("\n\t\t**LoanLoginAccountData**"); for (int i = 0; i < accounts.Length; i++) { LoanLoginAccountData llad = (LoanLoginAccountData)accounts[i]; System.Console.WriteLine("\t\tLoanLoginAccountData.loanAccountNumber: " + llad.loanAccountNumber); System.Console.WriteLine("\t\tLoanLoginAccountData.loanAccountNumber: " + UtcToDateTime(llad.lastUpdated.Value)); // Loan object[] loans = llad.loans; if (loans == null || loans.Length == 0) { System.Console.WriteLine("\t\tNo Loans."); } else { System.Console.WriteLine("\t\t\t**Loan**"); for (int j = 0; j < loans.Length; j++) { Loan loan = (Loan)loans[j]; System.Console.WriteLine("\t\t\tLoan.accountName: " + loan.accountName); System.Console.WriteLine("\t\t\tLoan.accountNumber: " + loan.accountNumber); System.Console.WriteLine("\t\t\tLoan.interestRate: " + loan.interestRate); // LoanPayOffs object[] loanPayOffs = loan.loanPayOffs; if (loanPayOffs == null || loanPayOffs.Length == 0) { System.Console.WriteLine("\t\t\tNo loanPayOffs"); } else { System.Console.WriteLine("\t\t\t\t**LoanPayoff**"); for (int u = 0; u < loanPayOffs.Length; u++) { LoanPayoff loanPayOff = (LoanPayoff)loanPayOffs[u]; System.Console.WriteLine("\t\t\t\tLoanPayoff.payoffAmount: " + loanPayOff.payoffAmount.amount); System.Console.WriteLine("\t\t\t\tLoan Pay By Date: " + loanPayOff.payByDate.date); } } // End LoanPayOffs // LoanPayMentDues object[] loanPaymentDues = loan.loanPaymentDues; if (loanPaymentDues == null || loanPaymentDues.Length == 0) { System.Console.WriteLine("\t\t\tNo loanPaymentDues"); } else { System.Console.WriteLine("\t\t\t\t**LoanPaymentDue**"); for (int u = 0; u < loanPaymentDues.Length; u++) { LoanPaymentDue lpd = (LoanPaymentDue)loanPaymentDues[u]; System.Console.WriteLine("\t\t\t\tLoanPaymentDue.interestAmount: " + lpd.interestAmount.amount); System.Console.WriteLine("\t\t\t\tLoanPaymentDue.principalAmount: " + lpd.principalAmount.amount); // Bill Bill bill = lpd.bill; if (bill == null) { System.Console.WriteLine("\t\t\t\t\tNo Bill"); } else { System.Console.WriteLine("\t\t\t\tBill.dueDate: " + bill.dueDate.date); System.Console.WriteLine("\t\t\t\tBill.minPayment: " + bill.minPayment.amount); } // end Bill } } // End LoanPayMentDues // LoanTransaction object[] loanTransactions = loan.loanTransactions; if (loanTransactions == null || loanTransactions.Length == 0) { System.Console.WriteLine("\t\tNo loan tranactions"); } else { System.Console.WriteLine("\t\t\t**LoanTransaction**"); for (int u = 0; u < loanTransactions.Length; u++) { LoanTransaction trans = (LoanTransaction)loanTransactions[u]; System.Console.WriteLine("\t\t\t\tTranaction.amount: " + trans.amount.amount); System.Console.WriteLine("\t\t\t\tTranaction.transDate : " + (trans.transactionDate.month + '-' + trans.transactionDate.dayOfMonth + '-' + trans.transactionDate.year)); System.Console.WriteLine("\t\t\t\tTransaction.description: " + trans.description); System.Console.WriteLine("\t\t\t\tTranaction.transactionType : " + trans.transactionType); } } // End LoanTransaction } } // End Loan } } // End LoanLoginAccountData } /*// Get AccountHistory * object[] acctHistories = itemData.accountHistory; * if(acctHistories == null || acctHistories.Length == 0) * { * System.Console.WriteLine("\tNo Account History"); * } * else * { * System.Console.WriteLine("\n\t**Account History**"); * for(int i = 0; i < acctHistories.Length; i++) * { * AccountHistory acctHistory = (AccountHistory)acctHistories[i]; * * System.Console.WriteLine("\tAccount ID: {0}", acctHistory.accountId ); * * // Get History * object[] histories = acctHistory.history; * if(histories == null || histories.Length == 0) * { * System.Console.WriteLine("\t\tNo History"); * } * else * { * System.Console.WriteLine("\t\t**History**"); * for(int j = 0; j < histories.Length; j++) * { * LoanLoginAccountData llad = (LoanLoginAccountData) histories[j]; * System.Console.WriteLine("\t\tLoanLoginAccountData.loanAccountNumber: "+ llad.loanAccountNumber ); * System.Console.WriteLine("\t\tLoanLoginAccountData.loanAccountNumber: " + UtcToDateTime(llad.lastUpdated.Value) ); * * // Loan * object[] loans = llad.loans; * if (loans == null || loans.Length == 0) * { * System.Console.WriteLine("\t\tNo Loans."); * } * else * { * System.Console.WriteLine("\t\t\t**Loan**"); * for (int u = 0; u < loans.Length; u++) * { * Loan loan = (Loan) loans[u]; * System.Console.WriteLine("\t\t\tLoan.accountName: " + loan.accountName ); * System.Console.WriteLine("\t\t\tLoan.accountNumber: " + loan.accountNumber ); * System.Console.WriteLine("\t\t\tLoan.interestRate: " + loan.interestRate ); * * } * } * } * } * } * } * // end AccountHistory * */ }
public ActionResult Create(Loan loan, HttpPostedFileBase fileAgreement, HttpPostedFileBase fileIrrevocable, HttpPostedFileBase fileGuarantors) { if (ModelState.IsValid) { #region Validate File Type string fileAgreementName, fileIrrevocableName, fileGuarantorsName, extension; if (fileAgreement != null && fileAgreement.ContentLength > 0) { extension = Path.GetExtension(fileAgreement.FileName); if (extension != ".jpg" && extension != ".jpeg" && extension != ".png") { ModelState.AddModelError("Invalid Image", "Please upload .jpg or .png image."); return(View(loan)); } fileAgreementName = Guid.NewGuid() + extension; loan.ImgAgreementUrl = ConfigurationManager.AppSettings["Azure:StorageUrl"] + BlobContainer.loan.ToString() + "/" + fileAgreementName; } else { ModelState.AddModelError("Invalid Image", "Please upload image for signed agreement form."); return(View(loan)); } if (fileIrrevocable != null && fileIrrevocable.ContentLength > 0) { extension = Path.GetExtension(fileIrrevocable.FileName); if (extension != ".jpg" && extension != ".jpeg" && extension != ".png") { ModelState.AddModelError("Invalid Image", "Please upload .jpg or .png image."); return(View(loan)); } fileIrrevocableName = Guid.NewGuid() + extension; loan.ImgIrrevocableUrl = ConfigurationManager.AppSettings["Azure:StorageUrl"] + BlobContainer.loan.ToString() + "/" + fileIrrevocableName; } else { ModelState.AddModelError("Invalid Image", "Please upload image for signed irrevocable authority form."); return(View(loan)); } if (fileGuarantors != null && fileGuarantors.ContentLength > 0) { extension = Path.GetExtension(fileGuarantors.FileName); if (extension != ".jpg" && extension != ".jpeg" && extension != ".png") { ModelState.AddModelError("Invalid Image", "Please upload .jpg or .png image."); return(View(loan)); } fileGuarantorsName = Guid.NewGuid() + extension; loan.ImgGuarantorsUrl = ConfigurationManager.AppSettings["Azure:StorageUrl"] + BlobContainer.loan.ToString() + "/" + fileGuarantorsName; } else { ModelState.AddModelError("Invalid Image", "Please upload image for signed irrevocable authority form."); return(View(loan)); } #endregion if (!_context.Customers.Any(x => x.AccountNo == loan.AccountNo)) { ModelState.AddModelError("Account Not Exists", "Account does not exists."); return(View(loan)); } var deposit = _context.CustomerSavings.Where(x => x.AccountNo == loan.AccountNo).Sum(x => x.Credit - x.Debit); var percent = loan.amount * Convert.ToDecimal(0.10); if (deposit <= percent) { ModelState.AddModelError("No 10% Deposit", "This customer has no 10% deposit in his/her account."); return(View(loan)); } loan.LoanStatus = "active"; //set loan status to active loan.Customername = (from s in _context.Customers where s.AccountNo == loan.AccountNo select s.Name).FirstOrDefault(); if (loan.Customername == null || loan.Customername == "") { //return customer not registered errorr:09256A return(Redirect("~/Error/ErrorCode?ErrorCode=09256A")); } //if we get here customer has been enrolled loan.createdby = User.Identity.Name.ToString(); //loan.DateCreated = DateTime.Now.ToShortDateString(); loan.DateCreated = DateTime.Now; //DateTime completionDate = DateTime.Parse(loan.DateOfCommencement).AddMonths(Int32.Parse(loan.Duration)); DateTime completionDate = loan.DateOfCommencement.AddMonths(Int32.Parse(loan.Duration)); //loan.DateOfTermination = completionDate.ToShortDateString(); loan.DateOfTermination = completionDate; //save amount borrowed var amountBorred = new Borrowed { DateCreated = DateTime.Now.ToShortDateString(), accountNo = loan.AccountNo, amountborrowed = loan.amount }; //create a loan transaction record var loanTransaction = new LoanTransaction { DateCreated = DateTime.Now.ToShortDateString(), AccountNo = loan.AccountNo, amount = loan.amount, refund = decimal.Parse("0"),//credit createdby = User.Identity.Name.ToString() }; //customer must pay 10% of loan upfront. create loan interest record. var loanInterest = new LoanInterest { accountNo = loan.AccountNo, intrestAmount = Decimal.Parse("0.1") * loan.amount, }; _context.LoanInterests.Add(loanInterest); _context.Borrows.Add(amountBorred); _context.Loans.Add(loan); _context.LoanTransactions.Add(loanTransaction); _context.SaveChanges(); #region Save Images if (fileAgreement != null && fileAgreement.ContentLength > 0) { FileHelper.UploadImage(fileAgreement.InputStream, fileAgreementName, BlobContainer.loan); } if (fileIrrevocable != null && fileIrrevocable.ContentLength > 0) { FileHelper.UploadImage(fileIrrevocable.InputStream, fileIrrevocableName, BlobContainer.loan); } if (fileGuarantors != null && fileGuarantors.ContentLength > 0) { FileHelper.UploadImage(fileGuarantors.InputStream, fileGuarantorsName, BlobContainer.loan); } #endregion return(RedirectToAction("Index")); } return(View(loan)); }