Examples of InvestmentPrice


Examples of org.internna.ossmoney.model.InvestmentPrice

    protected void fill(Set<InvestmentPrice> prices) {
      if ((prices != null) && (prices.size() > 1)) {
        Collection<InvestmentPrice> dated = new ArrayList<InvestmentPrice>();
        Iterator<InvestmentPrice> it = prices.iterator();
        InvestmentPrice target, origin = it.next();
        while (it.hasNext()) {
          target = it.next();
          fill(dated, origin, target);
          origin = target;
        }
View Full Code Here

Examples of org.internna.ossmoney.model.InvestmentPrice

    }

    protected void fill(Collection<InvestmentPrice> prices, InvestmentPrice origin, InvestmentPrice target) {
      Date[] dates = DateUtils.interval(origin.getUpdateTime(), target.getUpdateTime());
      for (Date date :  dates) {
        InvestmentPrice price = new InvestmentPrice();
        price.setUpdateTime(date);
        price.setPrice(origin.getPrice());
        prices.add(price);
      }
    }
View Full Code Here

Examples of org.internna.ossmoney.model.InvestmentPrice

    @RequestMapping(value = "/prices", method = RequestMethod.POST)
    public String setPrice(Long investmentId, Long priceId, Date operationDate, Double amount, ModelMap modelMap) {
      UserDetails user = UserDetails.findCurrentUser();
      Investment investment = Investment.findInvestment(investmentId);
      InvestmentPrice price = InvestmentPrice.findInvestmentPrice(priceId);
      if (price == null) {
        price = new InvestmentPrice();
        investment.addPrice(price);
      }
      if ((investment != null) && investment.belongsTo(user) && price.belongsTo(investment)) {
        price.setPrice(amount);
        price.setUpdateTime(operationDate);
        if (price.getId() != null) {
          price.merge();
        } else {
          price.persist();
        }
      }
      return getPrices(investmentId, modelMap);
    }
View Full Code Here

Examples of org.internna.ossmoney.model.InvestmentPrice

    public final Double getCurrentPrice() {
        return getPrice(new Date());
    }

    public final Double getPrice(Date date) {
        InvestmentPrice price = InvestmentPrice.findInvestmentPrice(this, date);
        return price == null ? 0D : price.getPrice();
    }
View Full Code Here

Examples of org.internna.ossmoney.model.InvestmentPrice

    investment.persist();
    InvestmentTransaction transaction = new InvestmentTransaction();
    transaction.setQuantity(5D);
    transaction.setInvestment(new Investment());
    transaction.getInvestment().setId(investment.getId());
    transaction.setPrice(new InvestmentPrice());
    transaction.getPrice().setPrice(2D);
    transaction.setAccountTransaction(new AccountTransaction());
    transaction.getAccountTransaction().setAccount(new Account());
    transaction.getAccountTransaction().getAccount().setId(1L);
    transaction.getAccountTransaction().setAmount(BigDecimal.TEN);
View Full Code Here

Examples of org.internna.ossmoney.model.InvestmentPrice

        transaction.setPayee(investment);
        InvestmentTransaction investmentTransaction = new InvestmentTransaction();
        investment.addInvestment(investmentTransaction);
        investmentTransaction.setAccountTransaction(transaction);
        if (register.getPrice() != null) {
          investmentTransaction.setPrice(new InvestmentPrice());
          investmentTransaction.getPrice().setInvestment(investment);
          investmentTransaction.getPrice().setPrice(register.getPrice());
          investmentTransaction.getPrice().setUpdateTime(transaction.getOperationDate());
          investmentTransaction.setQuantity(register.getQuantity());
        } else {
View Full Code Here

Examples of org.internna.ossmoney.model.InvestmentPrice

    Investment investment = new Investment();
    investment.setName("Investment");
    investment.setProductType("stocks");
    investment.setOwner(account.getOwner());
    investment.persist();
    InvestmentPrice price = new InvestmentPrice();
    price.setPrice(1D);
    price.setInvestment(investment);
    price.setUpdateTime(DateUtils.getMidnight(new Date()));
    price.persist();
    InvestmentTransaction investmentTransaction = new InvestmentTransaction();
    investmentTransaction.setId(14L);
    investmentTransaction.setPrice(price);
    investmentTransaction.setQuantity(10D);
    investmentTransaction.setInvestment(investment);
    investmentTransaction.setAccountTransaction(transaction);
    transaction.setInvestment(investmentTransaction);
    InvestmentStatus investmentStatus = new InvestmentStatus(account, investment);
    investmentStatus.add(transaction);
    assertEquals("JSON", "{operationDate:'', id: 5, label: 'Investment', buy: '10,00 €', sell: '', interest: '', gainLoss: '', pctg: '0%', quantity: '10', price: '1,00 €', operations: [{id: 999914, label: '', buy: '10,00 €', sell: '', interest: '', quantity: '10', price: '1,00 €', gainLoss: '', pctg: '', quant: 10.0, operationDate: '2000-11-20'}], quant: 10.0}", investmentStatus.getAsJSONString());
    AccountTransaction sellTransaction = new AccountTransaction();
    sellTransaction.setAccount(account);
    Subcategory sellSubcategory = Subcategory.findBySubcategory("category.investment.sell", account.getOwner());
    sellTransaction.setSubcategory(sellSubcategory);
    sellTransaction.setAmount(new BigDecimal(1.5));
    InvestmentPrice updatedPrice = new InvestmentPrice();
    updatedPrice.setPrice(1.5D);
    updatedPrice.setUpdateTime(DateUtils.nextDate(DateUtils.getMidnight(new Date())));
    updatedPrice.setInvestment(investment);
    updatedPrice.persist();
    InvestmentTransaction investmentSellTransaction = new InvestmentTransaction();
    investmentSellTransaction.setId(15L);
    investmentSellTransaction.setQuantity(1D);
    investmentSellTransaction.setPrice(updatedPrice);
    investmentSellTransaction.setInvestment(investment);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.