Package org.internna.ossmoney.model.budget

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


      }
      return manage(modelMap);
    }

    protected void createBudget(UserDetails user, String locale, int month, double amount, Subcategory category) {
      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


      return user.getBudget().getMonthlyBudget(month);
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public @ResponseBody Boolean update(long id, double value) {
      CategoryBudget budget = getBudget(id);
      if (budget != null) {
        budget.setExpectedAmount(new BigDecimal(value));
        budget.merge();
      }
      return budget != null && budget.getExpectedAmount().doubleValue() == value;
    }
View Full Code Here

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public @ResponseBody Boolean delete(Long id) {
      boolean deleted = false;
      try {
        CategoryBudget budget = getBudget(id);
        if (budget != null) {
          budget.remove();
          deleted = true;
        }
      } catch (Exception ex) {
        logger.warn("Error deleting category [" + id + "]", ex);
      }
View Full Code Here

      return deleted;
    }

    private CategoryBudget getBudget(long id) {
      UserDetails user = UserDetails.findCurrentUser();
      CategoryBudget budget = CategoryBudget.findCategoryBudget(id);
      return budget != null && user != null && budget.getMonthlyBudget().getBudget().getOwner().equals(user) ? budget : null;
    }
View Full Code Here

  @Override public int compareTo(MonthlyBudget other) {
    return other == null ? 1 : budgetedMonth == null ? other.budgetedMonth == null ? 0 : -1 : other.budgetedMonth == null ? 1 : budgetedMonth.compareTo(other.budgetedMonth);
  }

  public final CategoryBudget getBudget(Locale locale, Subcategory subcategory) {
    CategoryBudget budget = null;
    if ((locale != null) & (subcategory != null)) {
      for (CategoryBudget categoryBudget : budgets) {
        if (categoryBudget.getLocale().equals(locale) & categoryBudget.getCategory().equals(subcategory)) {
          budget = categoryBudget;
        }
View Full Code Here

    }
    return budget;
  }

  public final BigDecimal getAlloted(Locale locale, Subcategory subcategory) {
    CategoryBudget budget = getBudget(locale, subcategory);
    return budget == null ? BigDecimal.ZERO : budget.getExpectedAmount();
  }
View Full Code Here

TOP

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

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.