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