mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 08:14:25 +08:00
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
|
||||
|
||||
Reference in New Issue
Block a user