diff --git a/app/src/main/java/com/money/manager/ex/budget/BudgetAdapter.java b/app/src/main/java/com/money/manager/ex/budget/BudgetAdapter.java index 9c112ab318..efa1d6389f 100644 --- a/app/src/main/java/com/money/manager/ex/budget/BudgetAdapter.java +++ b/app/src/main/java/com/money/manager/ex/budget/BudgetAdapter.java @@ -203,12 +203,15 @@ public void setBudgetYearId(long budgetYearId) { private double getActualAmount(boolean hasSubcategory, Cursor cursor) { double actual; + // wolfsolver since category can be neested we need to consider always category as master + // probabily until we don't handle third and other level actual value does not count correctlry if (!hasSubcategory) { int categoryId = cursor.getInt(cursor.getColumnIndex(BudgetQuery.CATEGID)); actual = getAmountForCategory(categoryId); } else { int subCategoryId = cursor.getInt(cursor.getColumnIndex(BudgetQuery.SUBCATEGID)); - actual = getAmountForSubCategory(subCategoryId); + actual = getAmountForCategory(subCategoryId); +// actual = getAmountForSubCategory(subCategoryId); } return actual; } @@ -270,6 +273,7 @@ private double loadTotalFor(String where) { } try { + // wolfsolver todo adapt query for nested category String query = prepareQuery(where); Cursor cursor = databaseLazy.get().query(query); if (cursor == null) return 0; diff --git a/app/src/main/java/com/money/manager/ex/budget/BudgetPeriods.java b/app/src/main/java/com/money/manager/ex/budget/BudgetPeriods.java index fc22fedf81..2fc8d47977 100644 --- a/app/src/main/java/com/money/manager/ex/budget/BudgetPeriods.java +++ b/app/src/main/java/com/money/manager/ex/budget/BudgetPeriods.java @@ -47,6 +47,7 @@ public static BudgetPeriodEnum getEnum(String periodString) { periodEnumLookup.put("Bi-Weekly" , BudgetPeriodEnum.BI_WEEKLY); periodEnumLookup.put("Monthly" , BudgetPeriodEnum.MONTHLY); periodEnumLookup.put("Bi-Monthly" , BudgetPeriodEnum.BI_MONTHLY); + periodEnumLookup.put("Every 2 Months" , BudgetPeriodEnum.BI_MONTHLY); // wolfsolver adapt periods periodEnumLookup.put("Quarterly" , BudgetPeriodEnum.QUARTERLY); periodEnumLookup.put("Half-Yearly", BudgetPeriodEnum.HALF_YEARLY); periodEnumLookup.put("Yearly" , BudgetPeriodEnum.YEARLY); diff --git a/app/src/main/java/com/money/manager/ex/datalayer/BudgetEntryRepository.java b/app/src/main/java/com/money/manager/ex/datalayer/BudgetEntryRepository.java index a1872b45d9..cb32bd57bc 100644 --- a/app/src/main/java/com/money/manager/ex/datalayer/BudgetEntryRepository.java +++ b/app/src/main/java/com/money/manager/ex/datalayer/BudgetEntryRepository.java @@ -70,7 +70,14 @@ public BudgetEntry load(int id) { * @return */ public static String getKeyForCategories(int categoryId, int subCategoryId) { - return categoryId + "_" + subCategoryId; + // Wolfsolver - adapt budget for category & sub category. + if (categoryId < 0 ) { + return "_"+subCategoryId; + } + if ( subCategoryId < 0 ) { + return "_" + categoryId; + } + return "_" + subCategoryId; } public HashMap loadForYear(long budgetYearId) { @@ -99,11 +106,16 @@ public HashMap loadForYear(long budgetYearId) { if (category == null) { continue; } - if (category.getParentId() > 0) { - budgetEntryHashMap.put(getKeyForCategories(categoryId, category.getParentId()), budgetEntry); - } else { - budgetEntryHashMap.put(getKeyForCategories(categoryId, categoryId), budgetEntry); - } + // wolfsolver - GetKeyForCatgories has 2 parametrs: + // (int categoryId, int subCategoryId) + // it's wrong to user getParentId for subcategory, need to switch parameterd + // also delegate to GetKeyForCategory logic for handle -1 +// if (category.getParentId() > 0) { +// budgetEntryHashMap.put(getKeyForCategories(categoryId, category.getParentId()), budgetEntry); +// } else { +// budgetEntryHashMap.put(getKeyForCategories(categoryId, categoryId), budgetEntry); +// } + budgetEntryHashMap.put(getKeyForCategories(category.getParentId(), categoryId), budgetEntry); } cursor.close();