mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 00:12:11 +08:00
code refactor
This commit is contained in:
+8
-3
@@ -277,6 +277,10 @@ function getDefaultFirstDayOfWeek(translateFn) {
|
|||||||
return translateFn('default.firstDayOfWeek');
|
return translateFn('default.firstDayOfWeek');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCurrencyName(currencyCode, translateFn) {
|
||||||
|
return translateFn(`currency.${currencyCode}`);
|
||||||
|
}
|
||||||
|
|
||||||
function getAllLongMonthNames(translateFn) {
|
function getAllLongMonthNames(translateFn) {
|
||||||
return [
|
return [
|
||||||
translateFn('datetime.January.long'),
|
translateFn('datetime.January.long'),
|
||||||
@@ -516,7 +520,7 @@ function getAllCurrencies(translateFn) {
|
|||||||
|
|
||||||
allCurrencies.push({
|
allCurrencies.push({
|
||||||
code: currencyCode,
|
code: currencyCode,
|
||||||
displayName: translateFn(`currency.${currencyCode}`)
|
displayName: getCurrencyName(currencyCode, translateFn)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -639,7 +643,7 @@ function getAllDisplayExchangeRates(exchangeRatesData, translateFn) {
|
|||||||
|
|
||||||
availableExchangeRates.push({
|
availableExchangeRates.push({
|
||||||
currencyCode: exchangeRate.currency,
|
currencyCode: exchangeRate.currency,
|
||||||
currencyDisplayName: translateFn(`currency.${exchangeRate.currency}`),
|
currencyDisplayName: getCurrencyName(exchangeRate.currency, translateFn),
|
||||||
rate: exchangeRate.rate
|
rate: exchangeRate.rate
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -707,7 +711,7 @@ function getDisplayCurrency(value, currencyCode, options, translateFn) {
|
|||||||
} else if (currencyCode && currencyDisplayMode === currency.allCurrencyDisplayModes.Code) {
|
} else if (currencyCode && currencyDisplayMode === currency.allCurrencyDisplayModes.Code) {
|
||||||
return `${value} ${currencyCode}`;
|
return `${value} ${currencyCode}`;
|
||||||
} else if (currencyCode && currencyDisplayMode === currency.allCurrencyDisplayModes.Name) {
|
} else if (currencyCode && currencyDisplayMode === currency.allCurrencyDisplayModes.Name) {
|
||||||
const currencyName = translateFn(`currency.${currencyCode}`);
|
const currencyName = getCurrencyName(currencyCode, translateFn);
|
||||||
return `${value} ${currencyName}`;
|
return `${value} ${currencyName}`;
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
@@ -898,6 +902,7 @@ export function i18nFunctions(i18nGlobal) {
|
|||||||
getCurrentLanguageInfo: () => getCurrentLanguageInfo(i18nGlobal),
|
getCurrentLanguageInfo: () => getCurrentLanguageInfo(i18nGlobal),
|
||||||
getDefaultCurrency: () => getDefaultCurrency(i18nGlobal.t),
|
getDefaultCurrency: () => getDefaultCurrency(i18nGlobal.t),
|
||||||
getDefaultFirstDayOfWeek: () => getDefaultFirstDayOfWeek(i18nGlobal.t),
|
getDefaultFirstDayOfWeek: () => getDefaultFirstDayOfWeek(i18nGlobal.t),
|
||||||
|
getCurrencyName: (currencyCode) => getCurrencyName(currencyCode, i18nGlobal.t),
|
||||||
getAllLongMonthNames: () => getAllLongMonthNames(i18nGlobal.t),
|
getAllLongMonthNames: () => getAllLongMonthNames(i18nGlobal.t),
|
||||||
getAllShortMonthNames: () => getAllShortMonthNames(i18nGlobal.t),
|
getAllShortMonthNames: () => getAllShortMonthNames(i18nGlobal.t),
|
||||||
getAllLongWeekdayNames: () => getAllLongWeekdayNames(i18nGlobal.t),
|
getAllLongWeekdayNames: () => getAllLongWeekdayNames(i18nGlobal.t),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
>
|
>
|
||||||
<template #title>
|
<template #title>
|
||||||
<div class="no-padding no-margin">
|
<div class="no-padding no-margin">
|
||||||
<span>{{ $t(`currency.${baseCurrency}`) }} </span>
|
<span>{{ getCurrencyName(baseCurrency) }} </span>
|
||||||
<small class="smaller">{{ baseCurrency }}</small>
|
<small class="smaller">{{ baseCurrency }}</small>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -207,6 +207,9 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getCurrencyName(currencyCode) {
|
||||||
|
return this.$locale.getCurrencyName(currencyCode);
|
||||||
|
},
|
||||||
getConvertedAmount(toExchangeRate) {
|
getConvertedAmount(toExchangeRate) {
|
||||||
const fromExchangeRate = this.exchangeRatesStore.latestExchangeRateMap[this.baseCurrency];
|
const fromExchangeRate = this.exchangeRatesStore.latestExchangeRateMap[this.baseCurrency];
|
||||||
return getConvertedAmount(this.baseAmount / 100, fromExchangeRate, toExchangeRate);
|
return getConvertedAmount(this.baseAmount / 100, fromExchangeRate, toExchangeRate);
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
>
|
>
|
||||||
<template #title>
|
<template #title>
|
||||||
<f7-block class="no-padding no-margin">
|
<f7-block class="no-padding no-margin">
|
||||||
<span>{{ $t(`currency.${user.defaultCurrency}`) }} </span>
|
<span>{{ getCurrencyName(user.defaultCurrency) }} </span>
|
||||||
<small class="smaller">{{ user.defaultCurrency }}</small>
|
<small class="smaller">{{ user.defaultCurrency }}</small>
|
||||||
</f7-block>
|
</f7-block>
|
||||||
</template>
|
</template>
|
||||||
@@ -399,6 +399,9 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getCurrencyName(currencyCode) {
|
||||||
|
return this.$locale.getCurrencyName(currencyCode);
|
||||||
|
},
|
||||||
getCategoryTypeName(categoryType) {
|
getCategoryTypeName(categoryType) {
|
||||||
switch (categoryType) {
|
switch (categoryType) {
|
||||||
case categoryConstants.allCategoryTypes.Income.toString():
|
case categoryConstants.allCategoryTypes.Income.toString():
|
||||||
|
|||||||
@@ -164,7 +164,7 @@
|
|||||||
>
|
>
|
||||||
<template #title>
|
<template #title>
|
||||||
<div class="no-padding no-margin">
|
<div class="no-padding no-margin">
|
||||||
<span>{{ $t(`currency.${account.currency}`) }} </span>
|
<span>{{ getCurrencyName(account.currency) }} </span>
|
||||||
<small class="smaller">{{ account.currency }}</small>
|
<small class="smaller">{{ account.currency }}</small>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -357,7 +357,7 @@
|
|||||||
>
|
>
|
||||||
<template #title>
|
<template #title>
|
||||||
<div class="no-padding no-margin">
|
<div class="no-padding no-margin">
|
||||||
<span>{{ $t(`currency.${subAccount.currency}`) }} </span>
|
<span>{{ getCurrencyName(subAccount.currency) }} </span>
|
||||||
<small class="smaller">{{ subAccount.currency }}</small>
|
<small class="smaller">{{ subAccount.currency }}</small>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -712,6 +712,9 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getCurrencyName(currencyCode) {
|
||||||
|
return this.$locale.getCurrencyName(currencyCode);
|
||||||
|
},
|
||||||
getAccountTypeName(accountType) {
|
getAccountTypeName(accountType) {
|
||||||
const typeName = getNameByKeyValue(this.allAccountTypesArray, accountType, 'id', 'name');
|
const typeName = getNameByKeyValue(this.allAccountTypesArray, accountType, 'id', 'name');
|
||||||
return this.$t(typeName);
|
return this.$t(typeName);
|
||||||
|
|||||||
@@ -129,7 +129,7 @@
|
|||||||
>
|
>
|
||||||
<template #title>
|
<template #title>
|
||||||
<f7-block class="no-padding no-margin">
|
<f7-block class="no-padding no-margin">
|
||||||
<span>{{ $t(`currency.${newProfile.defaultCurrency}`) }} </span>
|
<span>{{ getCurrencyName(newProfile.defaultCurrency) }} </span>
|
||||||
<small class="smaller">{{ newProfile.defaultCurrency }}</small>
|
<small class="smaller">{{ newProfile.defaultCurrency }}</small>
|
||||||
</f7-block>
|
</f7-block>
|
||||||
</template>
|
</template>
|
||||||
@@ -456,6 +456,9 @@ export default {
|
|||||||
getNameByKeyValue(src, value, keyField, nameField, defaultName) {
|
getNameByKeyValue(src, value, keyField, nameField, defaultName) {
|
||||||
return getNameByKeyValue(src, value, keyField, nameField, defaultName);
|
return getNameByKeyValue(src, value, keyField, nameField, defaultName);
|
||||||
},
|
},
|
||||||
|
getCurrencyName(currencyCode) {
|
||||||
|
return this.$locale.getCurrencyName(currencyCode);
|
||||||
|
},
|
||||||
setCurrentUserProfile(profile) {
|
setCurrentUserProfile(profile) {
|
||||||
this.oldProfile.email = profile.email;
|
this.oldProfile.email = profile.email;
|
||||||
this.oldProfile.nickname = profile.nickname;
|
this.oldProfile.nickname = profile.nickname;
|
||||||
|
|||||||
Reference in New Issue
Block a user