Ejemplo n.º 1
0
        public PaymentSummary(LoanCalculationInput input, FeeOptions feeOptions)
        {
            PaymentItems = new List <PaymentItem>();

            VehiclePrice           = input.VehiclePrice.Value;
            DepositAmount          = input.DepositAmount.Value;
            LoanAmount             = VehiclePrice - DepositAmount;
            RateOfInterest         = 0;
            MaximumRepaymentPeriod = input.FinanceYear.Value * 12;
            MonthlyPayment         = CalculateMonthlyPayment(input);
            DeliveryDate           = input.DeliveryDate.Value;
            ArrangementFee         = feeOptions.ArrangementFee;
            CompletionFee          = feeOptions.CompletionFee;

            decimal totalPayment = 0;

            for (int index = 0; index < MaximumRepaymentPeriod; index++)
            {
                decimal paymentAmount = MonthlyPayment;
                totalPayment += paymentAmount;

                if (index == 0)
                {
                    paymentAmount += ArrangementFee;
                }

                if (index == MaximumRepaymentPeriod - 1)
                {
                    paymentAmount += CompletionFee;
                }

                DateTime deliveryMonth = DeliveryDate.AddMonths(index + 1);
                PaymentItems.Add(new PaymentItem(GetFirstMonday(new DateTime(deliveryMonth.Year, deliveryMonth.Month, 1)), paymentAmount, LoanAmount - totalPayment));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Withdrawal([Bind(Include = "TransactionID,TransactionDate,Amount,Description")] Transaction transaction, FeeOptions SelectedFee, int IRAccountID)
        {
            if (ModelState.IsValid)
            {
                transaction.TransactionType  = "Withdrawal";
                transaction.isBeingDisputed  = false;
                transaction.EmployeeComments = "";
                transaction.isPending        = false;
                if (transaction.Description == null)
                {
                    transaction.Description = "";
                }
                IRAccount IRAAccountToChange = db.IRAccounts.Find(IRAccountID);
                if (IRAAccountToChange.Balance < 0)
                {
                    return(View("Error", new string[] { "You can't withdraw from an overdrawn account." }));
                }
                if (transaction.Amount > IRAAccountToChange.Balance)
                {
                    return(View("Error", new string[] { "You don't have enough funds to withdraw that much money." }));
                }
                if (IRAAccountToChange.isQualified == false)
                {
                    if (transaction.Amount > 3000)
                    {
                        return(View("Error", new string[] { "You cannot withdraw more than $3,000." }));
                    }


                    switch (SelectedFee)
                    {
                    case FeeOptions.IncludeFee:
                        IRAAccountToChange.Balance -= transaction.Amount;
                        transaction.Amount         -= 30;
                        Transaction transactionIncludeFee = new Transaction();
                        transactionIncludeFee.TransactionType   = "Fee";
                        transactionIncludeFee.TransactionDate   = DateTime.Now;
                        transactionIncludeFee.Amount            = 30;
                        transactionIncludeFee.isBeingDisputed   = false;
                        transactionIncludeFee.EmployeeComments  = "";
                        transactionIncludeFee.Description       = "";
                        transactionIncludeFee.isPending         = false;
                        transactionIncludeFee.IRAccountAffected = IRAAccountToChange;
                        IRAAccountToChange.Transactions.Add(transactionIncludeFee);
                        db.Transactions.Add(transactionIncludeFee);



                        transaction.IRAccountAffected = IRAAccountToChange;
                        IRAAccountToChange.Transactions.Add(transaction);
                        db.Transactions.Add(transaction);
                        db.SaveChanges();

                        break;

                    case FeeOptions.AdditionalFee:
                        IRAAccountToChange.Balance -= (transaction.Amount + 30);
                        Transaction transactionAddFee = new Transaction();
                        transactionAddFee.TransactionType   = "Fee";
                        transactionAddFee.TransactionDate   = DateTime.Now;
                        transactionAddFee.Amount            = 30;
                        transactionAddFee.isBeingDisputed   = false;
                        transactionAddFee.EmployeeComments  = "";
                        transactionAddFee.Description       = "";
                        transactionAddFee.isPending         = false;
                        transactionAddFee.IRAccountAffected = IRAAccountToChange;
                        IRAAccountToChange.Transactions.Add(transactionAddFee);
                        db.Transactions.Add(transactionAddFee);

                        transaction.IRAccountAffected = IRAAccountToChange;
                        IRAAccountToChange.Transactions.Add(transaction);
                        db.Transactions.Add(transaction);
                        db.SaveChanges();

                        break;
                    }

                    return(RedirectToAction("MyBankAccounts", "Account"));
                }
            }

            AppUser user = db.Users.Find(User.Identity.GetUserId());

            //setting up viewbag so an IRAccount is chosen for sure
            ViewBag.iRAccounts = GetIRAccounts();
            return(View(transaction));
        }