mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
add account list page for desktop
This commit is contained in:
@@ -10,6 +10,82 @@ export function getAccountCategoryInfo(categoryId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getAccountOrSubAccountId(account, subAccountId) {
|
||||
if (account.type === accountConstants.allAccountTypes.SingleAccount) {
|
||||
return account.id;
|
||||
} else if (account.type === accountConstants.allAccountTypes.MultiSubAccounts && !subAccountId) {
|
||||
return account.id;
|
||||
} else if (account.type === accountConstants.allAccountTypes.MultiSubAccounts && subAccountId) {
|
||||
if (!account.subAccounts || !account.subAccounts.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let i = 0; i < account.subAccounts.length; i++) {
|
||||
const subAccount = account.subAccounts[i];
|
||||
|
||||
if (subAccountId && subAccountId === subAccount.id) {
|
||||
return subAccount.id;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function getAccountOrSubAccountComment(account, subAccountId) {
|
||||
if (account.type === accountConstants.allAccountTypes.SingleAccount) {
|
||||
return account.comment;
|
||||
} else if (account.type === accountConstants.allAccountTypes.MultiSubAccounts && !subAccountId) {
|
||||
return account.comment;
|
||||
} else if (account.type === accountConstants.allAccountTypes.MultiSubAccounts && subAccountId) {
|
||||
if (!account.subAccounts || !account.subAccounts.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let i = 0; i < account.subAccounts.length; i++) {
|
||||
const subAccount = account.subAccounts[i];
|
||||
|
||||
if (subAccountId && subAccountId === subAccount.id) {
|
||||
return subAccount.comment;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function getSubAccountCurrencies(account, showHidden, subAccountId) {
|
||||
if (!account.subAccounts || !account.subAccounts.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const subAccountCurrenciesMap = {};
|
||||
const subAccountCurrencies = [];
|
||||
|
||||
for (let i = 0; i < account.subAccounts.length; i++) {
|
||||
const subAccount = account.subAccounts[i];
|
||||
|
||||
if (!showHidden && subAccount.hidden) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (subAccountId && subAccountId === subAccount.id) {
|
||||
return [subAccount.currency];
|
||||
} else {
|
||||
if (!subAccountCurrenciesMap[subAccount.currency]) {
|
||||
subAccountCurrenciesMap[subAccount.currency] = true;
|
||||
subAccountCurrencies.push(subAccount.currency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return subAccountCurrencies;
|
||||
}
|
||||
|
||||
export function getCategorizedAccounts(allAccounts) {
|
||||
const ret = {};
|
||||
|
||||
|
||||
@@ -726,6 +726,16 @@ function getDisplayCurrency(value, currencyCode, options, translateFn) {
|
||||
}
|
||||
}
|
||||
|
||||
function joinMultiText(textArray, translateFn) {
|
||||
if (!textArray || !textArray.length) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const separator = translateFn('format.misc.multiTextJoinSeparator');
|
||||
|
||||
return textArray.join(separator);
|
||||
}
|
||||
|
||||
function getLocalizedError(error) {
|
||||
if (error.errorCode === apiNotFoundErrorCode && specifiedApiNotFoundErrors[error.path]) {
|
||||
return {
|
||||
@@ -948,6 +958,7 @@ export function i18nFunctions(i18nGlobal) {
|
||||
getAllDisplayExchangeRates: (exchangeRatesData) => getAllDisplayExchangeRates(exchangeRatesData, i18nGlobal.t),
|
||||
getEnableDisableOptions: () => getEnableDisableOptions(i18nGlobal.t),
|
||||
getDisplayCurrency: (value, currencyCode, options) => getDisplayCurrency(value, currencyCode, options, i18nGlobal.t),
|
||||
joinMultiText: (textArray) => joinMultiText(textArray, i18nGlobal.t),
|
||||
setLanguage: (locale, force) => setLanguage(i18nGlobal, locale, force),
|
||||
initLocale: (lastUserLanguage, timezone) => initLocale(i18nGlobal, lastUserLanguage, timezone)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user