Package org.internna.ossmoney.model

Examples of org.internna.ossmoney.model.Account


    @Test
    public void testCalculateWealth() {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.MONTH, -3);
        Account account = new Account();
        account.setLocale(Locale.GERMANY);
        account.setOpened(calendar.getTime());
        account.setInitialBalance(BigDecimal.TEN);
        Account usAccount = new Account();
        usAccount.setLocale(Locale.US);
        usAccount.setOpened(calendar.getTime());
        usAccount.setInitialBalance(BigDecimal.ONE);
        Set<Account> accounts = new java.util.HashSet<Account>(2);
        accounts.add(account);
        accounts.add(usAccount);
        calendar.add(Calendar.MONTH, 1);
        AccountTransaction transaction = new AccountTransaction();
View Full Code Here


    assertNotNull("Cache updated", cache.getIncomeVsExpensesOverTime(user, 11));
  }

    @Test
    public void testCalculateIncomeVsExpensesOverTime() {
        Account account = Account.findAccount(1L);
        Set<Account> accounts = new java.util.HashSet<Account>(2);
        accounts.add(account);
        Date[] dates = new Date[1];
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MONTH, 10);
        calendar.set(Calendar.YEAR, 2010);
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
        dates[0] = calendar.getTime();
        Map<Currency, Map<Date, IncomeExpense>> data = controller.calculateIncomeVsExpensesOverTime(dates, accounts);
        assertEquals("One currency only", 1, data.size());
        assertEquals("Income calculated", new Double(785D), new Double(data.get(Currency.getInstance(account.getLocale())).get(dates[0]).getKey().doubleValue()));
        assertEquals("Expenses calculated", new Double(126D), new Double(data.get(Currency.getInstance(account.getLocale())).get(dates[0]).getValue().doubleValue()));
    }
View Full Code Here

    subcategory.setCategory("subcategory");
    transaction = new AccountTransaction();
    transaction.setAmount(BigDecimal.TEN);
    transaction.setSubcategory(subcategory);
    transaction.setOperationDate(date);
    Account account = new Account();
    account.setLocale(Locale.US);
    account.addTransaction(transaction);
    calendar.add(Calendar.MONTH, -2);
    interval = new Interval(calendar.getTime(), new Date());
    SecurityUtils.authenticate(authenticationManager, "jose", "jose");
  }
View Full Code Here

public class InvestmentStatusTest {

  @Test
  @SuppressWarnings("deprecation")
  public void testGetAsJSONString() {
    Account account = Account.findAccount(1L);
    AccountTransaction transaction = new AccountTransaction();
    transaction.setAccount(account);
    Subcategory subcategory = Subcategory.findBySubcategory("category.investment.buy", account.getOwner());
    transaction.setSubcategory(subcategory);
    transaction.setAmount(BigDecimal.TEN.negate());
    transaction.setOperationDate(new Date(100, 10, 20));
    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);
    investmentSellTransaction.setAccountTransaction(sellTransaction);
    sellTransaction.setInvestment(investmentSellTransaction);
    sellTransaction.setOperationDate(new Date(100, 10, 21));
    investmentStatus.add(sellTransaction);
    assertEquals("JSON (buy & sell)", "{operationDate:'', id: 5, label: 'Investment', buy: '10,00 €', sell: '1,50 €', interest: '', gainLoss: '5,00 €', pctg: '50%', quantity: '9', price: '1,50 €', operations: [{id: 999914, label: '', buy: '10,00 €', sell: '', interest: '', quantity: '10', price: '1,00 €', gainLoss: '', pctg: '', quant: 10.0, operationDate: '2000-11-20'},{id: 999915, label: '', buy: '', sell: '1,50 €', interest: '', quantity: '1', price: '1,50 €', gainLoss: '', pctg: '', quant: 1.0, operationDate: '2000-11-21'}], quant: 9.0}", investmentStatus.getAsJSONString());
    Investment amountedInvestment = new Investment();
    amountedInvestment.setName("Investment (amount)");
    amountedInvestment.setOwner(account.getOwner());
    amountedInvestment.setProductType("deposit");
    amountedInvestment.persist();
    InvestmentStatus amountedInvestmentStatus = new InvestmentStatus(account, amountedInvestment);
    InvestmentTransaction amountedInvestmentTransaction = new InvestmentTransaction();
    amountedInvestmentTransaction.setId(26L);
    amountedInvestmentTransaction.setQuantity(0D);
    amountedInvestmentTransaction.setInvestment(amountedInvestment);
    AccountTransaction amountedTransaction = new AccountTransaction();
    amountedTransaction.setAccount(account);
    amountedTransaction.setSubcategory(subcategory);
    amountedTransaction.setAmount(BigDecimal.TEN.negate());
    amountedTransaction.setOperationDate(new Date(100, 10, 22));
    amountedInvestmentTransaction.setAccountTransaction(amountedTransaction);
    amountedTransaction.setInvestment(amountedInvestmentTransaction);
    amountedInvestmentStatus.add(amountedTransaction);
    assertEquals("No quantity, no gain/loss", "{operationDate:'', id: 6, label: 'Investment (amount)', buy: '10,00 €', sell: '', interest: '', gainLoss: '', pctg: '0%', quantity: '', price: '', operations: [{id: 999926, label: '', buy: '10,00 €', sell: '', interest: '', quantity: '', price: '', gainLoss: '', pctg: '', quant: 0.0, operationDate: '2000-11-22'}], quant: 0.0}", amountedInvestmentStatus.getAsJSONString());
    InvestmentTransaction amountedInvestmentInterestTransaction = new InvestmentTransaction();
    amountedInvestmentInterestTransaction.setId(29L);
    amountedInvestmentInterestTransaction.setQuantity(0D);
    amountedInvestmentInterestTransaction.setInvestment(amountedInvestment);
    AccountTransaction amountedInterestTransaction = new AccountTransaction();
    amountedInterestTransaction.setAccount(account);
    amountedInterestTransaction.setOperationDate(new Date(100, 10, 23));
    Subcategory interest = Subcategory.findBySubcategory("category.investment.interest", account.getOwner());
    amountedInterestTransaction.setSubcategory(interest);
    amountedInterestTransaction.setAmount(BigDecimal.TEN);
    amountedInvestmentInterestTransaction.setAccountTransaction(amountedInterestTransaction);
    amountedInterestTransaction.setInvestment(amountedInvestmentInterestTransaction);
    amountedInvestmentStatus.add(amountedInterestTransaction);
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.