Esempio n. 1
0
        static void TermAction(TermDeposit acc, string actionType)
        {
            switch (actionType.ToLower())
            {
            case "withdraw":
                Console.WriteLine("enter withdraw amount");
                double withdraw = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter withdraw year");
                int year = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter withdraw month");
                int month = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter withdraw day");
                int      day = Convert.ToInt32(Console.ReadLine());
                DateTime end = new DateTime(year, month, day);

                acc.Withdraw(withdraw, end);
                break;

            case "transfer":
                Console.WriteLine("enter 2nd customer id ");
                int custid = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter 2nd account id");
                int    accId    = Convert.ToInt32(Console.ReadLine());
                var    acc2     = CustomerBL.GetAccount(custid, accId);
                double transfer = Convert.ToInt32(Console.ReadLine());
                acc.Transfer(acc, acc2, transfer);
                break;

            default:
                break;
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("AccountId,UserId,Type,InterestRate,OverDraft,Balance,LoanAmount,StartDate,EndDate")] TermDeposit termDeposit)
        {
            if (id != termDeposit.AccountId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(termDeposit);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TermDepositExists(termDeposit.AccountId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Set <ApplicationUser>(), "Id", "Id", termDeposit.UserId);
            return(View(termDeposit));
        }
Esempio n. 3
0
        public static void CreateTermDeposit()
        {
            try
            {
                Console.WriteLine("enter your customer ID");
                int id = Convert.ToInt32(Console.ReadLine());

                var cust = CustomerBL.GetCust(id);

                Console.WriteLine("enter your new TermDeposit account name");
                var name = Console.ReadLine();

                Console.WriteLine("enter your deposit amount");
                double amount = Convert.ToDouble(Console.ReadLine());

                Console.WriteLine("enter your deposit time (in days)");
                int days = Convert.ToInt32(Console.ReadLine());

                var acc = new TermDeposit(name, amount, days);

                CustomerBL.AddTermDeposit(cust, acc);
                Console.WriteLine($"TermDeposit account of  {acc.Name} is created");
            }
            catch (Exception ex)
            {
                Console.WriteLine("registeration fail, please try again");
            }
        }
        public void WithDraw(Account account, MyClientDbContext _context, double amount)
        {
            double previous = account.AccountBalance;

            if (account.AccountType == "Business")
            {
                BusinessAccount ba = new BusinessAccount();
                ba.WithDraw(account, amount);
            }
            else if (account.AccountType == "Checking")
            {
                CheckingAccount ca = new CheckingAccount();
                ca.WithDraw(account, amount);
            }
            else if (account.AccountType == "Loan")
            {
                Loan loan = new Loan();
                loan.WithDraw(account, amount);
            }
            else if (account.AccountType == "Term")
            {
                TermDeposit term = new TermDeposit();
                term.WithDraw(account, amount);
            }

            _context.Accounts.Update(account);
            _context.SaveChanges();
            createTransaction(account, previous, account.AccountBalance, amount, "WithDraw", _context);
        }
Esempio n. 5
0
        public static void OpenSelectedAccount(Customer customer)
        {
            Console.WriteLine("What kind of account you want to open?" +
                              "\nex: checking account, business account, loan account, term deposit.");
            //Account a = new CheckingAccount();
            string act = Console.ReadLine();

            if (act.Equals("Checking account", StringComparison.OrdinalIgnoreCase))
            {
                CheckingAccount ck = new CheckingAccount();
                OpenAccount(customer, ck);
                ck.PrintInfor();
            }
            else if (act.Equals("Business account", StringComparison.OrdinalIgnoreCase))
            {
                BusinessAccount ba = new BusinessAccount();
                OpenAccount(customer, ba);
                ba.PrintInfor();
            }
            else if (act.Equals("Term deposit", StringComparison.OrdinalIgnoreCase))
            {
                TermDeposit tm = new TermDeposit();
                OpenAccount(customer, tm);
                tm.PrintInfor();
            }
            else
            {
                Console.WriteLine("Invalid account!");
            }
        }
Esempio n. 6
0
        public async Task <IActionResult> CreateTermDeposit([Bind("Balance", "DateClosed")] TermDeposit account)
        {
            account.CustomerId    = _context.Users.Where(x => x.Email == User.Identity.Name).FirstOrDefault().Id;
            account.AccountNumber = NumberGenerator.rnd.Next(100000000, 1000000000);
            account.Interest      = 0.06;
            account.IsActive      = true;
            account.AccountType   = "TermDeposit";
            account.DateOpened    = DateTime.Now;

            if (ModelState.IsValid)
            {
                _context.Add(account);
                await _context.SaveChangesAsync();

                Transaction tran = new Transaction()
                {
                    AccId     = account.Id,
                    Operation = "Open",
                    Amount    = account.Balance,
                    Date      = account.DateOpened
                };
                _context.Add(tran);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(GetTermDeposit)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Set <ApplicationUser>(), "Id", "Id", account.CustomerId);
            return(View(account));
        }
Esempio n. 7
0
        }// end of CalculateInterest Method

        //withdraw GET
        public ActionResult Withdraw(int?id)
        {
            TermDeposit td = db.TermDeposits.Find(id);

            TempData["tdAmount"] = td.Amount;
            return(View(td));
        } //end of Withdraw
Esempio n. 8
0
        public async Task <bool> Add(TermDeposit termDeposit)
        {
            _context.Add(termDeposit);
            await _context.SaveChangesAsync();

            return(true);
        }
Esempio n. 9
0
        public void calculateProduction()
        {
            dto.Retention = 0;
            createRatesTable();
            InvSystem invSystem;

            if (dto.InvestmentSystem == InvestmentType.AGREEDRATE)
            {
                invSystem = new AgreedRate(dto.Name, dto.InvestedAmount, dto.TotalTerms, dto.Currency, dto.RatesTable);
            }
            else if (dto.InvestmentSystem == InvestmentType.CURRENT)
            {
                invSystem = new Current(dto.Name, dto.InvestedAmount, dto.TotalTerms, dto.Currency, dto.RatesTable);
            }
            else if (dto.InvestmentSystem == InvestmentType.TERMDEPOSIT)
            {
                invSystem = new TermDeposit(dto.Name, dto.InvestedAmount, dto.TotalTerms, dto.Currency, dto.RatesTable);
            }
            else
            {
                throw new Exception("Invalid investment type");
            }
            invSystem.calculateProduction(dto);

            xmlLogger.log(dto.ToString());
            csvLogger.log(dto.ToString());
        }
Esempio n. 10
0
        public ActionResult DeleteConfirmed(int id)
        {
            TermDeposit termDeposit = db.TermDeposits.Find(id);

            db.TermDeposits.Remove(termDeposit);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 11
0
        // GET: TermDeposits/Create
        public ActionResult Create(int?id)
        {
            // ViewBag.CustomerId = new SelectList(db.Customers, "Id", "FirstName");
            var termDeposit = new TermDeposit();

            termDeposit.CustomerId = (int)id;
            return(View(termDeposit));
        }
Esempio n. 12
0
        public async Task <bool> Withdraw(TermDeposit termDeposit)
        {
            TDBL.Withdraw(termDeposit);
            _context.Update(termDeposit);
            await _context.SaveChangesAsync();

            return(true);
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Bsb != null)
         {
             hashCode = hashCode * 59 + Bsb.GetHashCode();
         }
         if (AccountNumber != null)
         {
             hashCode = hashCode * 59 + AccountNumber.GetHashCode();
         }
         if (BundleName != null)
         {
             hashCode = hashCode * 59 + BundleName.GetHashCode();
         }
         if (SpecificAccountUType != null)
         {
             hashCode = hashCode * 59 + SpecificAccountUType.GetHashCode();
         }
         if (TermDeposit != null)
         {
             hashCode = hashCode * 59 + TermDeposit.GetHashCode();
         }
         if (CreditCard != null)
         {
             hashCode = hashCode * 59 + CreditCard.GetHashCode();
         }
         if (Loan != null)
         {
             hashCode = hashCode * 59 + Loan.GetHashCode();
         }
         if (Features != null)
         {
             hashCode = hashCode * 59 + Features.GetHashCode();
         }
         if (Fees != null)
         {
             hashCode = hashCode * 59 + Fees.GetHashCode();
         }
         if (DepositRates != null)
         {
             hashCode = hashCode * 59 + DepositRates.GetHashCode();
         }
         if (LendingRates != null)
         {
             hashCode = hashCode * 59 + LendingRates.GetHashCode();
         }
         if (Address != null)
         {
             hashCode = hashCode * 59 + Address.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 14
0
        public static void AddTermDeposit(Customer customer, TermDeposit account)
        {
            Customer cust = FindCust(customer.CustId);

            if (cust != null)
            {
                cust.TermDeposits.Add(account);
            }
        }
Esempio n. 15
0
 public ActionResult Edit([Bind(Include = "DepositId,CustomerId,Amount,Months,Rate,Interest,total_amt")] TermDeposit termDeposit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(termDeposit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(termDeposit));
 }
        //-------------------------------------------------------------------------
        public TermDepositTrade toTrade(TradeInfo tradeInfo, LocalDate startDate, LocalDate endDate, BuySell buySell, double notional, double rate)
        {
            Optional <LocalDate> tradeDate = tradeInfo.TradeDate;

            if (tradeDate.Present)
            {
                ArgChecker.inOrderOrEqual(tradeDate.get(), startDate, "tradeDate", "startDate");
            }
            return(TermDepositTrade.builder().info(tradeInfo).product(TermDeposit.builder().buySell(buySell).currency(currency).notional(notional).startDate(startDate).endDate(endDate).businessDayAdjustment(businessDayAdjustment).rate(rate).dayCount(dayCount).build()).build());
        }
Esempio n. 17
0
 public ActionResult Edit([Bind(Include = "TermDepositID,Deposit,TermCreation")] TermDeposit termDeposit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(termDeposit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(termDeposit));
 }
Esempio n. 18
0
 public ActionResult Edit([Bind(Include = "Id,DateOpened,Amount,InterestRate")] TermDeposit termDeposit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(termDeposit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(termDeposit));
 }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(TermDepositTrade trade, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            TermDeposit product  = trade.Product;
            Currency    currency = product.Currency;

            // use lookup to build requirements
            RatesMarketDataLookup ratesLookup = parameters.getParameter(typeof(RatesMarketDataLookup));

            return(ratesLookup.requirements(currency));
        }
Esempio n. 20
0
        public ActionResult Create([Bind(Include = "TermDepositID,Deposit,TermCreation")] TermDeposit termDeposit)
        {
            if (ModelState.IsValid)
            {
                db.termDeposits.Add(termDeposit);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(termDeposit));
        }
Esempio n. 21
0
        public void CreateTermDeposit(double amount)
        {
            TermDeposit newTD = new TermDeposit()
            {
                ID       = new IDgenerator().GenerateID(),
                Amount   = Math.Round(amount * 1.1),
                Maturity = DateTime.Now.AddDays(4)
            };

            current.TDList.Add(newTD);
            dal.SaveFile();
        }
Esempio n. 22
0
        public ActionResult Create([Bind(Include = "DepositId,CustomerId,Amount,Months,Rate,Interest,total_amt")] TermDeposit termDeposit)
        {
            if (ModelState.IsValid)
            {
                termDeposit.Interest  = Math.Pow(1 + termDeposit.Rate, termDeposit.Months) - 1;
                termDeposit.total_amt = termDeposit.Amount * termDeposit.Interest;

                return(RedirectToAction("Index"));
            }

            return(View(termDeposit));
        }
Esempio n. 23
0
        public ActionResult Create(TermDeposit termDeposit)
        {
            if (ModelState.IsValid)
            {
                termDeposit.DateOpened = DateTime.Now;
                db.TermDeposits.Add(termDeposit);
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = termDeposit.CustomerId }));
            }

            ViewBag.CustomerId = new SelectList(db.Customers, "Id", "FirstName", termDeposit.CustomerId);
            return(View(termDeposit));
        }
Esempio n. 24
0
        public ActionResult CalculateTotalInterest(TdInterestViewModel model, int id)
        {
            TermDeposit td        = db.TermDeposits.Find(id);
            var         principal = (double)td.Amount;
            var         duration  = td.Duration_Months;
            var         interest  = 0.0;

            if (duration < 12)
            {
                interest = 1.25;
            }
            else if (duration < 24)
            {
                interest = 2.05;
            }
            else if (duration < 36)
            {
                interest = 2.25;
            }
            else if (duration < 48)
            {
                interest = 2.35;
            }
            else if (duration < 60)
            {
                interest = 2.5;
            }
            else if (duration < 72)
            {
                interest = 2.95;
            }
            else
            {
                interest = 3.00;
            }

            var rateOfInterest = interest / 100;
            var years          = (double)duration / 12;

            //Calculate total with simple interest formula: Total = P(1+rt)
            var totalAmount = principal * (1 + (rateOfInterest * years));
            //Calculate amount earned from interest
            var interestEarned = totalAmount - principal;

            model.InterestRate  = (decimal)interest;
            model.Duration      = duration;
            model.TotalAmount   = (decimal)totalAmount;
            model.TotalInterest = (decimal)interestEarned;

            return(View(model));
        }
Esempio n. 25
0
        public virtual void test_trade()
        {
            TermDepositCurveNode node          = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            double           rate              = 0.035;
            MarketData       marketData        = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, rate).build();
            TermDepositTrade trade             = node.trade(1d, marketData, REF_DATA);
            LocalDate        startDateExpected = PLUS_TWO_DAYS.adjust(VAL_DATE, REF_DATA);
            LocalDate        endDateExpected   = startDateExpected.plus(DEPOSIT_PERIOD);
            TermDeposit      depositExpected   = TermDeposit.builder().buySell(BuySell.BUY).currency(EUR).dayCount(ACT_360).startDate(startDateExpected).endDate(endDateExpected).notional(1.0d).businessDayAdjustment(BDA_MOD_FOLLOW).rate(rate + SPREAD).build();
            TradeInfo        tradeInfoExpected = TradeInfo.builder().tradeDate(VAL_DATE).build();

            assertEquals(trade.Product, depositExpected);
            assertEquals(trade.Info, tradeInfoExpected);
        }
Esempio n. 26
0
        // GET: TermDeposits/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TermDeposit termDeposit = db.TermDeposits.Find(id);

            if (termDeposit == null)
            {
                return(HttpNotFound());
            }
            return(View(termDeposit));
        }
Esempio n. 27
0
        public virtual void test_createTrade()
        {
            TermDepositTemplate template       = TermDepositTemplate.of(DEPOSIT_PERIOD, CONVENTION);
            LocalDate           tradeDate      = LocalDate.of(2015, 1, 23);
            BuySell             buy            = BuySell.BUY;
            double           notional          = 2_000_000d;
            double           rate              = 0.0125;
            TermDepositTrade trade             = template.createTrade(tradeDate, buy, notional, rate, REF_DATA);
            TradeInfo        tradeInfoExpected = TradeInfo.of(tradeDate);
            LocalDate        startDateExpected = PLUS_TWO_DAYS.adjust(tradeDate, REF_DATA);
            LocalDate        endDateExpected   = startDateExpected.plus(DEPOSIT_PERIOD);
            TermDeposit      productExpected   = TermDeposit.builder().buySell(buy).currency(EUR).notional(notional).businessDayAdjustment(BDA_MOD_FOLLOW).startDate(startDateExpected).endDate(endDateExpected).rate(rate).dayCount(ACT_360).build();

            assertEquals(trade.Info, tradeInfoExpected);
            assertEquals(trade.Product, productExpected);
        }
Esempio n. 28
0
        public async Task <IActionResult> CreateTermDeposit([Bind("AccountNumId,User,Balance,IsActive")] TermDeposit account)
        {
            if (ModelState.IsValid)
            {
                account.TermEndedDate = DateTime.Today.AddDays(1);
                var user = await _context.Users.FirstOrDefaultAsync(m => m.UserName == HttpContext.User.Identity.Name);

                var customer = await _context.customers.FirstOrDefaultAsync(m => m.UserRef == user.Id);

                account.customer = customer;
                _context.Accounts.Add(account);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(account));
        }
Esempio n. 29
0
        public async Task <IActionResult> Create([Bind("Id,Amount,TermYears")] TermDeposit termDeposit)
        {
            if (ModelState.IsValid)
            {
                termDeposit.WithdrawlAmount = (termDeposit.Amount * TermDeposit.TDInterestRate) + termDeposit.Amount;
                for (int i = 1; i < termDeposit.TermYears; i++)
                {
                    termDeposit.WithdrawlAmount += termDeposit.WithdrawlAmount * TermDeposit.TDInterestRate;
                }
                termDeposit.DateCreated = DateTime.Now;
                termDeposit.AppUserId   = UserManager.GetUserId(User);
                await _TermDepositRepo.Add(termDeposit);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(termDeposit));
        }
Esempio n. 30
0
        //-------------------------------------------------------------------------
        public virtual void test_toTrade()
        {
            TermDepositConvention convention     = ImmutableTermDepositConvention.builder().name("EUR-Dep").businessDayAdjustment(BDA_MOD_FOLLOW).currency(EUR).dayCount(ACT_360).spotDateOffset(PLUS_TWO_DAYS).build();
            LocalDate             tradeDate      = LocalDate.of(2015, 1, 22);
            Period           period3M            = Period.ofMonths(3);
            BuySell          buy                 = BuySell.BUY;
            double           notional            = 2_000_000d;
            double           rate                = 0.0125;
            TermDepositTrade trade               = convention.createTrade(tradeDate, period3M, buy, notional, rate, REF_DATA);
            LocalDate        startDateExpected   = PLUS_TWO_DAYS.adjust(tradeDate, REF_DATA);
            LocalDate        endDateExpected     = startDateExpected.plus(period3M);
            TermDeposit      termDepositExpected = TermDeposit.builder().buySell(buy).currency(EUR).notional(notional).startDate(startDateExpected).endDate(endDateExpected).businessDayAdjustment(BDA_MOD_FOLLOW).rate(rate).dayCount(ACT_360).build();
            TradeInfo        tradeInfoExpected   = TradeInfo.of(tradeDate);

            assertEquals(trade.Product, termDepositExpected);
            assertEquals(trade.Info, tradeInfoExpected);
        }