mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 07:27:33 +08:00
code refactor
This commit is contained in:
@@ -2,43 +2,36 @@ const allAccountCategories = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Cash',
|
||||
isAsset: true,
|
||||
defaultAccountIconId: '1'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Debit Card',
|
||||
isAsset: true,
|
||||
defaultAccountIconId: '100'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Credit Card',
|
||||
isLiability: true,
|
||||
defaultAccountIconId: '100'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'Virtual Account',
|
||||
isAsset: true,
|
||||
defaultAccountIconId: '500'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'Debt Account',
|
||||
isLiability: true,
|
||||
defaultAccountIconId: '600'
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: 'Receivables',
|
||||
isAsset: true,
|
||||
defaultAccountIconId: '700'
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: 'Investment Account',
|
||||
isAsset: true,
|
||||
defaultAccountIconId: '800'
|
||||
}
|
||||
];
|
||||
|
||||
+8
-3
@@ -106,21 +106,21 @@ function getAccountByAccountId(categorizedAccounts, accountId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function getAllFilteredAccountsBalance(categorizedAccounts, accountCategoryFilter) {
|
||||
function getAllFilteredAccountsBalance(categorizedAccounts, accountFilter) {
|
||||
const allAccountCategories = accountConstants.allCategories;
|
||||
const ret = [];
|
||||
|
||||
for (let categoryIdx = 0; categoryIdx < allAccountCategories.length; categoryIdx++) {
|
||||
const accountCategory = allAccountCategories[categoryIdx];
|
||||
|
||||
if (!accountCategoryFilter(accountCategory) || !categorizedAccounts[accountCategory.id]) {
|
||||
if (!categorizedAccounts[accountCategory.id]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let accountIdx = 0; accountIdx < categorizedAccounts[accountCategory.id].length; accountIdx++) {
|
||||
const account = categorizedAccounts[accountCategory.id][accountIdx];
|
||||
|
||||
if (account.hidden) {
|
||||
if (account.hidden || !accountFilter(account)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -132,6 +132,11 @@ function getAllFilteredAccountsBalance(categorizedAccounts, accountCategoryFilte
|
||||
} else if (account.type === accountConstants.allAccountTypes.MultiSubAccounts) {
|
||||
for (let subAccountIdx = 0; subAccountIdx < account.subAccounts.length; subAccountIdx++) {
|
||||
const subAccount = account.subAccounts[subAccountIdx];
|
||||
|
||||
if (subAccount.hidden || !accountFilter(subAccount)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push({
|
||||
balance: subAccount.balance,
|
||||
currency: subAccount.currency
|
||||
|
||||
@@ -243,7 +243,7 @@ export default {
|
||||
return '***';
|
||||
}
|
||||
|
||||
const accountsBalance = this.$utilities.getAllFilteredAccountsBalance(this.accounts, category => category.isAsset);
|
||||
const accountsBalance = this.$utilities.getAllFilteredAccountsBalance(this.accounts, account => account.isAsset);
|
||||
let totalAssets = 0;
|
||||
let hasUnCalculatedAmount = false;
|
||||
|
||||
@@ -273,7 +273,7 @@ export default {
|
||||
return '***';
|
||||
}
|
||||
|
||||
const accountsBalance = this.$utilities.getAllFilteredAccountsBalance(this.accounts, category => category.isLiability);
|
||||
const accountsBalance = this.$utilities.getAllFilteredAccountsBalance(this.accounts, account => account.isLiability);
|
||||
let totalLiabilities = 0;
|
||||
let hasUnCalculatedAmount = false;
|
||||
|
||||
@@ -404,7 +404,7 @@ export default {
|
||||
return '***';
|
||||
}
|
||||
|
||||
const accountsBalance = this.$utilities.getAllFilteredAccountsBalance(this.accounts, category => category.id === accountCategory.id);
|
||||
const accountsBalance = this.$utilities.getAllFilteredAccountsBalance(this.accounts, account => account.category === accountCategory.id);
|
||||
let totalBalance = 0;
|
||||
let hasUnCalculatedAmount = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user