Package org.internna.ossmoney.model

Examples of org.internna.ossmoney.model.Account


    }

    @RequestMapping("/{id}")
    public String investments(@PathVariable Long id, ModelMap modelMap) {
      modelMap.addAttribute("id", id);
      Account account = Account.findAccount(id);
      UserDetails user = UserDetails.findCurrentUser();
      if (account.belongsTo(user)) {
        modelMap.addAttribute("investments", account.getCurrentInvestments());
      }
      return "investment/performance";
    }
View Full Code Here


    @RequestMapping("/add/{id}")
    public String add(@PathVariable Long id, ModelMap modelMap) {
      UserDetails user = UserDetails.findCurrentUser();
      Collection<Account> accounts = user.getInvestmentAccounts();
      if (id != null) {
        Account account = Account.findAccount(id);
        if (account.belongsTo(user)) {
            modelMap.addAttribute("account", account);
            modelMap.addAttribute("currency", account.getCurrency());
          } else {
            modelMap.addAttribute("currency", CollectionUtils.isEmpty(accounts) ? "EUR" : accounts.iterator().next().getCurrency());
          }
      }
      modelMap.addAttribute("accounts", accounts);
View Full Code Here

    }

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public String add(InvestmentTransaction transaction, double commision, ModelMap modelMap) {
      UserDetails user = UserDetails.findCurrentUser();
      Account account = Account.findAccount(transaction.getAccountTransaction().getAccount().getId());
      if (account.belongsTo(user)) {
        cache.invalidate(user);
        investmentService.addInvestment(user, account, transaction, commision);
      }
      return "redirect:/financial/accounts/" + transaction.getAccountTransaction().getAccount().getId();
    }
View Full Code Here

    @RequestMapping("/view/{id}")
    public String view(@PathVariable Long id, ModelMap modelMap) {
      UserDetails user = UserDetails.findCurrentUser();
      InvestmentTransaction transaction = InvestmentTransaction.findInvestmentTransaction(id);
      Account account = transaction.getAccountTransaction().getAccount();
      if (account.belongsTo(user)) {
        modelMap.addAttribute("account", account);
        modelMap.addAttribute("transaction", transaction);
        modelMap.addAttribute("investments", Investment.findInvestmentsByOwner(user));
      }
      return "investment/view";
View Full Code Here

    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    public String edit(InvestmentTransaction transaction, ModelMap modelMap) {
      UserDetails user = UserDetails.findCurrentUser();
      InvestmentTransaction loaded = InvestmentTransaction.findInvestmentTransaction(transaction.getId());
      Account account = loaded.getAccountTransaction().getAccount();
      if (account.belongsTo(user)) {
        cache.invalidate(user);
        AccountTransaction accountTransaction = loaded.getAccountTransaction();
        if (transaction.getPrice() != null) {
          loaded.setQuantity(transaction.getQuantity());
          loaded.getPrice().setPrice(transaction.getPrice().getPrice());
          accountTransaction.setAmount(new BigDecimal(transaction.getQuantity() * transaction.getPrice().getPrice()));
        } else {
          loaded.setPrice(null);
          accountTransaction.setAmount(transaction.getAccountTransaction().getAmount());
        }
        Investment investment = Investment.findInvestment(transaction.getInvestment().getId());
        loaded.setInvestment(investment);
        loaded.getAccountTransaction().setPayee(investment)
        accountTransaction.setOperationDate(transaction.getAccountTransaction().getOperationDate());
        accountTransaction.setReferenceNumber(transaction.getAccountTransaction().getReferenceNumber());
        accountTransaction.setSubcategory(Subcategory.findBySubcategory(transaction.getAccountTransaction().getSubcategory().getCategory(), user));
        loaded.merge();
      }
      return "redirect:/financial/accounts/" + account.getId();
    }
View Full Code Here

      Long accountId = null;
      UserDetails user = UserDetails.findCurrentUser();
      InvestmentTransaction transaction  = InvestmentTransaction.findInvestmentTransaction(id);
      if (transaction != null) {
        AccountTransaction accountTransaction = transaction.getAccountTransaction();
        Account account = accountTransaction.getAccount();
        if (account.belongsTo(user)) {
          cache.invalidate(user);
          accountId = account.getId();
          accountTransaction.remove();
        }
      }
      return "redirect:/financial/accounts/" + (accountId != null ? accountId : "");
    }
View Full Code Here

        return user;
    }

    @SuppressWarnings("unchecked")
  protected void fillProvidedAccount(Long account, UserDetails user, ModelMap modelMap) {
        Account loaded = Account.findAccount(account);
        if ((loaded != null) && (loaded.belongsTo(user))) {
            modelMap.addAttribute("account", loaded);
            modelMap.addAttribute("currency",  loaded.getCurrency());
            List<Account> accounts = new ArrayList<Account>((List<Account>) modelMap.get("accounts"));
            accounts.remove(loaded);
            modelMap.addAttribute("accounts", accounts);
        }
    }
View Full Code Here

        return details(origin, modelMap);
    }

    @RequestMapping("/balance/{accountId}")
    public String balance(@PathVariable Long accountId, ModelMap modelMap) {
      Account account = Account.findAccount(accountId);
        if (account != null) {
            UserDetails user = UserDetails.findCurrentUser();
            if (account.belongsTo(user) && account.isCreditCard()) {
              modelMap.addAttribute("account", account);
              modelMap.addAttribute("origin", user.getBankAccounts());
              modelMap.addAttribute("transactions", AccountTransaction.findUnreconciledTransactions(account));
            }
        }
View Full Code Here

    }

    @RequestMapping(value = "/pay-balance", method = RequestMethod.POST)
    public String balance(Long accountId, Long originId, String transactions, Date operationDate, ModelMap modelMap) {
      if (hasText(transactions)) {
        Account origin = Account.findAccount(originId);
        Account account = Account.findAccount(accountId);
        if ((account != null) && (origin != null)) {
          UserDetails user = UserDetails.findCurrentUser();
          if (account.belongsTo(user) && origin.belongsTo(user)) {
            cache.invalidate(user);
            accountService.balance(user, account, origin, operationDate, transactions.split("-"));
          }
        }
      }
View Full Code Here

      return index(modelMap);
    }

    @RequestMapping("/view/{id}")
    public String view(@PathVariable Long id, ModelMap modelMap) {
      Account account = Account.findAccount(id);
      UserDetails user = UserDetails.findCurrentUser();
      modelMap.addAttribute("institutions", new TreeSet<FinancialInstitution>(user.getInstitutions()));
      if (account.belongsTo(user)) {
        modelMap.addAttribute("account", account);
      }
      return "accounts/view";
    }
View Full Code Here

TOP

Related Classes of org.internna.ossmoney.model.Account

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.