code refactor
This commit is contained in:
@@ -25,6 +25,32 @@ export function categoryTypeToTransactionType(categoryType) {
|
||||
}
|
||||
}
|
||||
|
||||
export function getTransactionPrimaryCategoryName(categoryId, allCategories) {
|
||||
for (let i = 0; i < allCategories.length; i++) {
|
||||
for (let j = 0; j < allCategories[i].subCategories.length; j++) {
|
||||
const subCategory = allCategories[i].subCategories[j];
|
||||
if (subCategory.id === categoryId) {
|
||||
return allCategories[i].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
export function getTransactionSecondaryCategoryName(categoryId, allCategories) {
|
||||
for (let i = 0; i < allCategories.length; i++) {
|
||||
for (let j = 0; j < allCategories[i].subCategories.length; j++) {
|
||||
const subCategory = allCategories[i].subCategories[j];
|
||||
if (subCategory.id === categoryId) {
|
||||
return subCategory.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
export function allVisibleTransactionCategories(allTransactionCategories) {
|
||||
const ret = {};
|
||||
|
||||
|
||||
@@ -78,6 +78,8 @@ import {
|
||||
import {
|
||||
transactionTypeToCategoryType,
|
||||
categoryTypeToTransactionType,
|
||||
getTransactionPrimaryCategoryName,
|
||||
getTransactionSecondaryCategoryName,
|
||||
allVisibleTransactionCategories,
|
||||
} from './category.js'
|
||||
|
||||
@@ -165,6 +167,8 @@ export default {
|
||||
// category.js
|
||||
transactionTypeToCategoryType,
|
||||
categoryTypeToTransactionType,
|
||||
getTransactionPrimaryCategoryName,
|
||||
getTransactionSecondaryCategoryName,
|
||||
allVisibleTransactionCategories,
|
||||
|
||||
// account.js
|
||||
|
||||
@@ -953,28 +953,10 @@ export default {
|
||||
return this.$locale.getDisplayCurrency(amount);
|
||||
},
|
||||
getPrimaryCategoryName(categoryId, allCategories) {
|
||||
for (let i = 0; i < allCategories.length; i++) {
|
||||
for (let j = 0; j < allCategories[i].subCategories.length; j++) {
|
||||
const subCategory = allCategories[i].subCategories[j];
|
||||
if (subCategory.id === categoryId) {
|
||||
return allCategories[i].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
return this.$utilities.getTransactionPrimaryCategoryName(categoryId, allCategories);
|
||||
},
|
||||
getSecondaryCategoryName(categoryId, allCategories) {
|
||||
for (let i = 0; i < allCategories.length; i++) {
|
||||
for (let j = 0; j < allCategories[i].subCategories.length; j++) {
|
||||
const subCategory = allCategories[i].subCategories[j];
|
||||
if (subCategory.id === categoryId) {
|
||||
return subCategory.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
return this.$utilities.getTransactionSecondaryCategoryName(categoryId, allCategories);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user