Package org.internna.ossmoney.model

Examples of org.internna.ossmoney.model.Category


      categoryData.put(transaction.getSubcategory(), amount);
    }

    protected final Map<Subcategory, BigDecimal> getOrCreateCategoryData(final AccountTransaction transaction, final Map<Category, Map<Subcategory, BigDecimal>> data) {
      Subcategory subcategory = transaction.getSubcategory();
      Category category = subcategory.getParentCategory();
      Map<Subcategory, BigDecimal> categoryData = data.get(category);
      if (categoryData == null) {
        categoryData = new HashMap<Subcategory, BigDecimal>();
        data.put(category, categoryData);
      }
View Full Code Here


    }

    @RequestMapping(value = "/createSubcategory", method = RequestMethod.POST)
    public String subcategory(Long id, String name, ModelMap modelMap) {
      UserDetails user = UserDetails.findCurrentUser();
      Category category = Category.findCategory(id);
      if (category != null) {
        Subcategory.createInstance(name, category, user);
      }
        return subcategory(modelMap);
    }
View Full Code Here

    user.merge();
    return user;
  }

  protected void createSubcategories(UserDetails user) {
    Category transferIn = Category.findCategory(2L);
    Category transferOut = Category.findCategory(1L);
    Category investmentIn = Category.findCategory(4L);
    Category investmentOut = Category.findCategory(3L);
    Category financial = Category.findByCategory("category.financial");
    Category household = Category.findByCategory("category.household");
    Category leisure = Category.findByCategory("category.leisure");
    Category salary = Category.findByCategory("category.salary");
    Category automobile = Category.findByCategory("category.automobile");
    Category bills = Category.findByCategory("category.bills");
    Category healthcare = Category.findByCategory("category.healthcare");
    Category taxesIn = Category.findCategory(13L);
    Category taxesOut = Category.findCategory(12L);
    Category travel = Category.findByCategory("category.travel");
    Category sporadic = Category.findByCategory("category.sporadic");
    Category personal = Category.findByCategory("category.personal");
    Category children = Category.findByCategory("category.children");
    Category pet = Category.findByCategory("category.pet");

    Subcategory.createInstance("category.transfer.out", transferOut, user);
    Subcategory.createInstance("category.transfer.in", transferIn, user);
    Subcategory.createInstance("category.cc.payment.out", transferOut, user);
    Subcategory.createInstance("category.cc.payment.in", transferIn, user);
View Full Code Here

  }

  protected Subcategory getOrCreateSubcategory(UserDetails user, Register register) {
    Subcategory subcategory = Subcategory.findBySubcategory(register.getSubcategory(), user);
    if (subcategory == null) {
      Category category = Category.findByCategory(register.getCategory());
      if (category == null) {
        category = new Category();
        category.setCategory(register.getCategory());
        category.setIncome(register.getAmount() > 0 ? Boolean.TRUE : Boolean.FALSE);
        category.persist();
      }
      subcategory = new Subcategory();
      subcategory.setOwner(user);
      subcategory.setParentCategory(category);
      subcategory.setCategory(register.getSubcategory());
View Full Code Here

    assertNotNull("Cache updated", cache.getExpensesByCategory(user, "last_quarter"));
  }

    @Test
    public void testOrganizeByCategory() {
        Category income = new Category();
        income.setIncome(Boolean.TRUE);
        Subcategory fooIncome = new Subcategory();
        fooIncome.setParentCategory(income);
        Category expense = new Category();
        expense.setIncome(Boolean.FALSE);
        Subcategory fooExpense = new Subcategory();
        fooExpense.setId(1L);
        fooExpense.setParentCategory(expense);
        fooExpense.setCategory("fooExpense");
        Account account = new Account();
        account.setLocale(Locale.GERMANY);
        Account usAccount = new Account();
        usAccount.setLocale(Locale.US);
        List<AccountTransaction> transactions = null;
        Map<Currency, Map<Subcategory, BigDecimal>> data = controller.organizeByCategory(transactions);
        assertEquals("No data organized", 0, data.size());
        transactions = new ArrayList<AccountTransaction>();
        AccountTransaction transaction = new AccountTransaction();
        transaction.setAccount(account);
        transaction.setOperationDate(new Date());
        transaction.setAmount(BigDecimal.TEN);
        transaction.setSubcategory(fooIncome);
        transactions.add(transaction);
        data = controller.organizeByCategory(transactions);
        assertEquals("No expense data", 0, data.size());
        AccountTransaction expensetransaction = new AccountTransaction();
        expensetransaction.setAccount(account);
        expensetransaction.setOperationDate(new Date());
        expensetransaction.setAmount(new BigDecimal(-75));
        expensetransaction.setSubcategory(fooExpense);
        transactions.add(expensetransaction);
        data = controller.organizeByCategory(transactions);
        assertEquals("Some expense data", 1, data.size());
        assertEquals("Some categories", 1, data.get(Currency.getInstance(account.getLocale())).size());
        assertEquals("Some total amount", new BigDecimal(75), data.get(Currency.getInstance(account.getLocale())).get(fooExpense));
        AccountTransaction otherExpenseInCategory = new AccountTransaction();
        otherExpenseInCategory.setAccount(account);
        otherExpenseInCategory.setOperationDate(new Date());
        otherExpenseInCategory.setAmount(new BigDecimal(-75));
        otherExpenseInCategory.setSubcategory(fooExpense);
        transactions.add(otherExpenseInCategory);
        data = controller.organizeByCategory(transactions);
        assertEquals("Same categories", 1, data.get(Currency.getInstance(account.getLocale())).size());
        assertEquals("Added total amount", new BigDecimal(150), data.get(Currency.getInstance(account.getLocale())).get(fooExpense));
        AccountTransaction otherExpense = new AccountTransaction();
        otherExpense.setAccount(usAccount);
        otherExpense.setOperationDate(new Date());
        otherExpense.setAmount(new BigDecimal(-75));
        otherExpense.setSubcategory(fooExpense);
        transactions.add(otherExpense);
        data = controller.organizeByCategory(transactions);
        assertEquals("Two currencies", 2, data.size());
        assertEquals("Added total amount", new BigDecimal(75), data.get(Currency.getInstance(usAccount.getLocale())).get(fooExpense));
        Category expense2 = new Category();
        expense2.setIncome(Boolean.FALSE);
        Subcategory fooExpense2 = new Subcategory();
        fooExpense2.setId(2L);
        fooExpense2.setParentCategory(expense2);
        fooExpense2.setCategory("fooExpense2");
        AccountTransaction otherExpenseInNewCategory = new AccountTransaction();
View Full Code Here

    controller.setCache(cache);
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DAY_OF_YEAR, -1);
    date = calendar.getTime();
    calendar.add(Calendar.DAY_OF_YEAR, 1);
    Category category = new Category();
    category.setIncome(Boolean.TRUE);
    category.setCategory("category");
    Subcategory subcategory = new Subcategory();
    subcategory.setParentCategory(category);
    subcategory.setCategory("subcategory");
    transaction = new AccountTransaction();
    transaction.setAmount(BigDecimal.TEN);
View Full Code Here

  private Subcategory subcategory, otherSubcategory, thirdSubcategory;
  private MessageSource messageSource = new StaticMessageSource();

  @Before
  public void init() {
    category = new Category();
    category.setId(100L);
    category.setIncome(Boolean.TRUE);
    category.setCategory("category");
    subcategory = new Subcategory();
    subcategory.setId(1000L);
    subcategory.setCategory("subcategory");
    subcategory.setParentCategory(category);
    otherSubcategory = new Subcategory();
    otherSubcategory.setId(1001L);
    otherSubcategory.setParentCategory(category);
    otherSubcategory.setCategory("otherSubcategory");
    otherCategory = new Category();
    otherCategory.setId(101L);
    otherCategory.setIncome(Boolean.TRUE);
    otherCategory.setCategory("otherCategory");
    thirdSubcategory = new Subcategory();
    thirdSubcategory.setId(1002L);
View Full Code Here

TOP

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

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.