Skip to content

Open source personal finance application

chore: update names

ilkome57646d270ce1
diff --git a/components/categories/getCategories.ts b/components/categories/getCategories.ts
index 7b01d46e..66c901fb 100644
--- a/components/categories/getCategories.ts
+++ b/components/categories/getCategories.ts
@@ -1,11 +1,11 @@
import type { CategoryID } from '~/components/categories/types'
// TODO: add typings
-export function getCatsIds(catsIds: CategoryID[], catsItems) {
+export function getCategoriesIds(catsIds: CategoryID[], categoriesItems) {
const ids = []
for (const catId of catsIds) {
- const category = catsItems[catId]
+ const category = categoriesItems[catId]
category?.childIds
? ids.push(...category.childIds)
: ids.push(catId)
diff --git a/components/stat/History.vue b/components/stat/History.vue
index 01144843..8688d78c 100644
--- a/components/stat/History.vue
+++ b/components/stat/History.vue
@@ -1,16 +1,21 @@
<script setup lang="ts">
-import { getCatsIds } from '~/components/categories/getCategories'
+import { getCategoriesIds } from '~/components/categories/getCategories'
import { getTrnsIds } from '~/components/trns/getTrns'
const { $store } = useNuxtApp()
-const catsItems = computed(() => $store.state.categories.items)
+const categoriesItems = computed(() => $store.state.categories.items)
const trnsItems = computed(() => $store.state.trns.items)
const storeFilter = computed(() => $store.state.filter)
const filterTrnType = ref(null)
const trnsIds = computed(() => {
- const categoriesIds = storeFilter.value.catsIds.length > 0 ? getCatsIds(storeFilter.value.catsIds, catsItems.value) : null
- const walletsIds = storeFilter.value.walletsIds.length > 0 ? storeFilter.value.walletsIds : null
+ // TODO: move it to a separate function getFilterParams
+ const categoriesIds = storeFilter.value.catsIds.length > 0
+ ? getCategoriesIds(storeFilter.value.catsIds, categoriesItems.value)
+ : null
+ const walletsIds = storeFilter.value.walletsIds.length > 0
+ ? storeFilter.value.walletsIds
+ : null
return getTrnsIds({
categoriesIds,
diff --git a/components/stat/chart/View.vue b/components/stat/chart/View.vue
index 5f0fef98..5c6b3108 100644
--- a/components/stat/chart/View.vue
+++ b/components/stat/chart/View.vue
@@ -3,7 +3,7 @@ import { Chart } from 'highcharts-vue'
import chartOptions from '~/components/stat/chart/chartOptions'
import useChart from '~/components/chart/useChart'
import useFilter from '~/modules/filter/useFilter'
-import { getCatsIds, getTransferCategoriesIds } from '~/components/categories/getCategories'
+import { getCategoriesIds, getTransferCategoriesIds } from '~/components/categories/getCategories'
import { getTotal } from '~/components/amount/getTotal'
import { getTrnsIds } from '~/components/trns/getTrns'
@@ -108,7 +108,7 @@ export default defineComponent({
// count total period
const periodDate = this.$day().startOf(periodName).subtract(index, periodName).valueOf()
- const categoriesIds = storeFilter.catsIds.length > 0 ? getCatsIds(storeFilter.catsIds, categoriesItems) : null
+ const categoriesIds = storeFilter.catsIds.length > 0 ? getCategoriesIds(storeFilter.catsIds, categoriesItems) : null
const walletsIds = storeFilter.walletsIds.length > 0 ? storeFilter.walletsIds : null
const trnsIds = getTrnsIds({
diff --git a/components/trns/pages/History.vue b/components/trns/pages/History.vue
index a0aaae22..f680c7f8 100644
--- a/components/trns/pages/History.vue
+++ b/components/trns/pages/History.vue
@@ -1,18 +1,23 @@
<script setup lang="ts">
-import { getCatsIds } from '~/components/categories/getCategories'
+import { getCategoriesIds } from '~/components/categories/getCategories'
import { getTrnsIds } from '~/components/trns/getTrns'
import useStatPage from '~/components/stat/useStatPage'
const { $store } = useNuxtApp()
const { statPage } = useStatPage()
-const catsItems = computed(() => $store.state.categories.items)
+const categoriesItems = computed(() => $store.state.categories.items)
const trnsItems = computed(() => $store.state.trns.items)
const storeFilter = computed(() => $store.state.filter)
const filterTrnType = ref(null)
const trnsIds = computed(() => {
- const categoriesIds = storeFilter.value.catsIds.length > 0 ? getCatsIds(storeFilter.value.catsIds, catsItems.value) : null
- const walletsIds = storeFilter.value.walletsIds.length > 0 ? storeFilter.value.walletsIds : null
+ // TODO: move it to a separate function getFilterParams
+ const categoriesIds = storeFilter.value.catsIds.length > 0
+ ? getCategoriesIds(storeFilter.value.catsIds, categoriesItems.value)
+ : null
+ const walletsIds = storeFilter.value.walletsIds.length > 0
+ ? storeFilter.value.walletsIds
+ : null
return getTrnsIds({
categoriesIds,
diff --git a/store/stat/getters.ts b/store/stat/getters.ts
index 5b4173bb..e0c029da 100644
--- a/store/stat/getters.ts
+++ b/store/stat/getters.ts
@@ -1,5 +1,5 @@
import dayjs from 'dayjs'
-import { getCatsIds, getTransferCategoriesIds } from '~/components/categories/getCategories'
+import { getCategoriesIds, getTransferCategoriesIds } from '~/components/categories/getCategories'
import { getTotal } from '~/components/amount/getTotal'
import { getTrnsIds } from '~/components/trns/getTrns'
@@ -16,8 +16,9 @@ export default {
const storeFilter = rootState.filter
const transferCategoriesIds = getTransferCategoriesIds(categoriesItems)
+ // TODO: move it to a separate function getFilterParams
const categoriesIds = rootState.filter.catsIds.length > 0
- ? getCatsIds(rootState.filter.catsIds, categoriesItems)
+ ? getCategoriesIds(rootState.filter.catsIds, categoriesItems)
: null
const walletsIds = storeFilter.walletsIds.length > 0
? storeFilter.walletsIds
@@ -38,7 +39,7 @@ export default {
return trnCategoryParentId || trnCategoryId
}
- function getCatsIdsWithTrnsIds() {
+ function getCategoriesIdsWithTrnsIds() {
const filterCategoryId = rootState.filter.categoryId
const categoriesWithTrnsIds = {}
@@ -63,7 +64,7 @@ export default {
return categoriesWithTrnsIds
}
- const categoriesWithTrnsIds = getCatsIdsWithTrnsIds()
+ const categoriesWithTrnsIds = getCategoriesIdsWithTrnsIds()
const total = getTotal({
baseCurrencyCode,
diff --git a/store/trns/getters.js b/store/trns/getters.js
index 66947306..15de9cc3 100644
--- a/store/trns/getters.js
+++ b/store/trns/getters.js
@@ -1,5 +1,5 @@
import dayjs from 'dayjs'
-import { getCatsIds, getTransferCategoriesIds } from '~/components/categories/getCategories'
+import { getCategoriesIds, getTransferCategoriesIds } from '~/components/categories/getCategories'
import { getTrnsIds } from '~/components/trns/getTrns'
export default {
@@ -45,17 +45,17 @@ export default {
return trnsIds[0]
},
- // TODO: should use components/trns/getTrns when its compatible
selectedTrnsIds(_state, getters, rootState) {
if (!getters.hasTrns)
return []
const trnsItems = rootState.trns.items
- const catsItems = rootState.categories.items
+ const categoriesItems = rootState.categories.items
const storeFilter = rootState.filter
+ // TODO: move it to a separate function getFilterParams
const categoriesIds = rootState.filter.catsIds.length > 0
- ? getCatsIds(rootState.filter.catsIds, catsItems)
+ ? getCategoriesIds(rootState.filter.catsIds, categoriesItems)
: null
const walletsIds = storeFilter.walletsIds.length > 0
? storeFilter.walletsIds