Package org.internna.ossmoney.model.budget

Examples of org.internna.ossmoney.model.budget.MonthlyBudget


      CategoryBudget categoryBudget = new CategoryBudget();
      categoryBudget.setCategory(category);
      String[] locales = locale.split("_");
      categoryBudget.setLocale(new Locale(locales[0], locales[1], ""));
      categoryBudget.setExpectedAmount(new BigDecimal(amount));
      MonthlyBudget monthlyBudget = obtainMonthlyBudget(user, month);
      categoryBudget.setMonthlyBudget(monthlyBudget);
      categoryBudget.persist();
      monthlyBudget.getBudgets().add(categoryBudget);
      monthlyBudget.merge();
    }
View Full Code Here


    public String widget(@PathVariable String expanded, ModelMap modelMap) {
      BigDecimal budgeted = BigDecimal.ZERO;
      BigDecimal expended = BigDecimal.ZERO;
      UserDetails user = UserDetails.findCurrentUser();
      Interval monthToDate = new Interval(Interval.Intervals.MONTH_TO_DATE);
      MonthlyBudget budget = user.getBudget().getMonthlyBudget(Calendar.getInstance().get(Calendar.MONTH));
      for (CategoryBudget categoryBudget : budget.getBudgets()) {
        budgeted = budgeted.add(categoryBudget.getExpectedAmount());
        BigDecimal expendedInCategory = accountService.getExpenses(user, categoryBudget.getLocale(), categoryBudget.getCategory(), monthToDate);
        expended = expended.add(expendedInCategory);
        categoryBudget.setExpended(expendedInCategory);
      }
      modelMap.addAttribute("expanded", expanded);
    modelMap.addAttribute("categories", budget.getBudgets());
      modelMap.addAttribute("totals", new NameValuePair<Double, Double>(expended.doubleValue(), budgeted.doubleValue()));
      return "budget/widget";
    }
View Full Code Here

  protected Budget createBudget(UserDetails user) {
    Budget budget = new Budget();
    budget.setOwner(user);
    budget.persist();
    for (int i = 0; i < 12; i++) {
      MonthlyBudget monthlyBudget = new MonthlyBudget();
      monthlyBudget.setBudget(budget);
      monthlyBudget.setBudgetedMonth(i);
      monthlyBudget.persist();
      budget.getMonthlyBudgets().add(monthlyBudget);
    }
    budget.merge();
    return budget;
  }
View Full Code Here

TOP

Related Classes of org.internna.ossmoney.model.budget.MonthlyBudget

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.