code refactor
This commit is contained in:
@@ -63,6 +63,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapStores } from 'pinia';
|
||||||
|
import { useSettingsStore } from '@/stores/setting.js';
|
||||||
|
|
||||||
import { isString, appendThousandsSeparator } from '@/lib/common.js';
|
import { isString, appendThousandsSeparator } from '@/lib/common.js';
|
||||||
import { numericCurrencyToString, stringCurrencyToNumeric } from '@/lib/currency.js';
|
import { numericCurrencyToString, stringCurrencyToNumeric } from '@/lib/currency.js';
|
||||||
|
|
||||||
@@ -87,9 +90,13 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapStores(useSettingsStore),
|
||||||
|
isEnableThousandsSeparator() {
|
||||||
|
return this.settingsStore.appSettings.thousandsSeparator;
|
||||||
|
},
|
||||||
currentDisplay() {
|
currentDisplay() {
|
||||||
const previousValue = appendThousandsSeparator(this.previousValue);
|
const previousValue = appendThousandsSeparator(this.previousValue, this.isEnableThousandsSeparator);
|
||||||
const currentValue = appendThousandsSeparator(this.currentValue);
|
const currentValue = appendThousandsSeparator(this.currentValue, this.isEnableThousandsSeparator);
|
||||||
|
|
||||||
if (this.currentSymbol) {
|
if (this.currentSymbol) {
|
||||||
return `${previousValue} ${this.currentSymbol} ${currentValue}`;
|
return `${previousValue} ${this.currentSymbol} ${currentValue}`;
|
||||||
@@ -118,7 +125,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getStringValue(value) {
|
getStringValue(value) {
|
||||||
let str = numericCurrencyToString(value);
|
let str = numericCurrencyToString(value, this.isEnableThousandsSeparator);
|
||||||
|
|
||||||
if (str.indexOf(',')) {
|
if (str.indexOf(',')) {
|
||||||
str = str.replaceAll(/,/g, '');
|
str = str.replaceAll(/,/g, '');
|
||||||
|
|||||||
@@ -77,6 +77,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapStores } from 'pinia';
|
||||||
|
import { useSettingsStore } from '@/stores/setting.js';
|
||||||
|
|
||||||
import colorConstants from '@/consts/color.js';
|
import colorConstants from '@/consts/color.js';
|
||||||
import { formatPercent } from '@/lib/common.js';
|
import { formatPercent } from '@/lib/common.js';
|
||||||
|
|
||||||
@@ -124,6 +127,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapStores(useSettingsStore),
|
||||||
validItems: function () {
|
validItems: function () {
|
||||||
let totalValidValue = 0;
|
let totalValidValue = 0;
|
||||||
|
|
||||||
@@ -154,7 +158,7 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
finalItem.displayPercent = formatPercent(finalItem.percent, 2, '<0.01');
|
finalItem.displayPercent = formatPercent(finalItem.percent, 2, '<0.01');
|
||||||
finalItem.displayValue = this.$locale.getDisplayCurrency(finalItem.value, (finalItem.currency || this.defaultCurrency));
|
finalItem.displayValue = this.getDisplayCurrency(finalItem.value, (finalItem.currency || this.defaultCurrency));
|
||||||
|
|
||||||
validItems.push(finalItem);
|
validItems.push(finalItem);
|
||||||
}
|
}
|
||||||
@@ -281,6 +285,12 @@ export default {
|
|||||||
|
|
||||||
const allPreviousLength = allPreviousPercent * this.circumference;
|
const allPreviousLength = allPreviousPercent * this.circumference;
|
||||||
return this.circumference - allPreviousLength + offset;
|
return this.circumference - allPreviousLength + offset;
|
||||||
|
},
|
||||||
|
getDisplayCurrency(value, currencyCode) {
|
||||||
|
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
||||||
|
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
||||||
|
enableThousandsSeparator: this.settingsStore.appSettings.thousandsSeparator
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -1,5 +1,3 @@
|
|||||||
import { isEnableThousandsSeparator } from './settings.js';
|
|
||||||
|
|
||||||
export function isFunction(val) {
|
export function isFunction(val) {
|
||||||
return typeof(val) === 'function';
|
return typeof(val) === 'function';
|
||||||
}
|
}
|
||||||
@@ -79,8 +77,8 @@ export function isEquals(obj1, obj2) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function appendThousandsSeparator(value) {
|
export function appendThousandsSeparator(value, enable) {
|
||||||
if (!isEnableThousandsSeparator() || value.length <= 3) {
|
if (!enable || value.length <= 3) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import { isNumber, appendThousandsSeparator } from './common.js';
|
import { isNumber, appendThousandsSeparator } from './common.js';
|
||||||
|
|
||||||
export function numericCurrencyToString(num) {
|
export function numericCurrencyToString(num, enableThousandsSeparator) {
|
||||||
let str = num.toString();
|
let str = num.toString();
|
||||||
const negative = str.charAt(0) === '-';
|
const negative = str.charAt(0) === '-';
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ export function numericCurrencyToString(num) {
|
|||||||
let integer = str.substring(0, str.length - 2);
|
let integer = str.substring(0, str.length - 2);
|
||||||
let decimals = str.substring(str.length - 2);
|
let decimals = str.substring(str.length - 2);
|
||||||
|
|
||||||
integer = appendThousandsSeparator(integer);
|
integer = appendThousandsSeparator(integer, enableThousandsSeparator);
|
||||||
|
|
||||||
str = `${integer}.${decimals}`;
|
str = `${integer}.${decimals}`;
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-6
@@ -26,7 +26,6 @@ import {
|
|||||||
} from './currency.js';
|
} from './currency.js';
|
||||||
|
|
||||||
import logger from './logger.js';
|
import logger from './logger.js';
|
||||||
import { getCurrencyDisplayMode } from './settings.js';
|
|
||||||
import services from './services.js';
|
import services from './services.js';
|
||||||
|
|
||||||
const apiNotFoundErrorCode = 100001;
|
const apiNotFoundErrorCode = 100001;
|
||||||
@@ -516,7 +515,7 @@ function getAllWeekDays(translateFn) {
|
|||||||
return allWeekDays;
|
return allWeekDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDisplayCurrency(value, currencyCode, notConvertValue, translateFn) {
|
function getDisplayCurrency(value, currencyCode, options, translateFn) {
|
||||||
if (!isNumber(value) && !isString(value)) {
|
if (!isNumber(value) && !isString(value)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -525,21 +524,25 @@ function getDisplayCurrency(value, currencyCode, notConvertValue, translateFn) {
|
|||||||
value = value.toString();
|
value = value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!notConvertValue) {
|
if (!options) {
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options.notConvertValue) {
|
||||||
const hasIncompleteFlag = isString(value) && value.charAt(value.length - 1) === '+';
|
const hasIncompleteFlag = isString(value) && value.charAt(value.length - 1) === '+';
|
||||||
|
|
||||||
if (hasIncompleteFlag) {
|
if (hasIncompleteFlag) {
|
||||||
value = value.substring(0, value.length - 1);
|
value = value.substring(0, value.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
value = numericCurrencyToString(value);
|
value = numericCurrencyToString(value, options.enableThousandsSeparator);
|
||||||
|
|
||||||
if (hasIncompleteFlag) {
|
if (hasIncompleteFlag) {
|
||||||
value = value + '+';
|
value = value + '+';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const currencyDisplayMode = getCurrencyDisplayMode();
|
const currencyDisplayMode = options.currencyDisplayMode;
|
||||||
|
|
||||||
if (currencyCode && currencyDisplayMode === currency.allCurrencyDisplayModes.Symbol) {
|
if (currencyCode && currencyDisplayMode === currency.allCurrencyDisplayModes.Symbol) {
|
||||||
const currencyInfo = currency.all[currencyCode];
|
const currencyInfo = currency.all[currencyCode];
|
||||||
@@ -776,7 +779,7 @@ export function i18nFunctions(i18nGlobal) {
|
|||||||
getAllTimezones: (includeSystemDefault) => getAllTimezones(includeSystemDefault, i18nGlobal.t),
|
getAllTimezones: (includeSystemDefault) => getAllTimezones(includeSystemDefault, i18nGlobal.t),
|
||||||
getAllCurrencies: () => getAllCurrencies(i18nGlobal.t),
|
getAllCurrencies: () => getAllCurrencies(i18nGlobal.t),
|
||||||
getAllWeekDays: () => getAllWeekDays(i18nGlobal.t),
|
getAllWeekDays: () => getAllWeekDays(i18nGlobal.t),
|
||||||
getDisplayCurrency: (value, currencyCode, notConvertValue) => getDisplayCurrency(value, currencyCode, notConvertValue, i18nGlobal.t),
|
getDisplayCurrency: (value, currencyCode, options) => getDisplayCurrency(value, currencyCode, options, i18nGlobal.t),
|
||||||
setLanguage: (locale, force) => setLanguage(i18nGlobal, locale, force),
|
setLanguage: (locale, force) => setLanguage(i18nGlobal, locale, force),
|
||||||
initLocale: (lastUserLanguage, timezone) => initLocale(i18nGlobal, lastUserLanguage, timezone)
|
initLocale: (lastUserLanguage, timezone) => initLocale(i18nGlobal, lastUserLanguage, timezone)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapStores } from 'pinia';
|
import { mapStores } from 'pinia';
|
||||||
|
import { useSettingsStore } from '@/stores/setting.js';
|
||||||
import { useUserStore } from '@/stores/user.js';
|
import { useUserStore } from '@/stores/user.js';
|
||||||
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
||||||
|
|
||||||
@@ -102,7 +103,10 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapStores(useUserStore, useExchangeRatesStore),
|
...mapStores(useSettingsStore, useUserStore, useExchangeRatesStore),
|
||||||
|
isEnableThousandsSeparator() {
|
||||||
|
return this.settingsStore.appSettings.thousandsSeparator;
|
||||||
|
},
|
||||||
exchangeRatesData() {
|
exchangeRatesData() {
|
||||||
return this.exchangeRatesStore.latestExchangeRates.data;
|
return this.exchangeRatesStore.latestExchangeRates.data;
|
||||||
},
|
},
|
||||||
@@ -196,7 +200,7 @@ export default {
|
|||||||
const rateStr = this.getConvertedAmount(toExchangeRate).toString();
|
const rateStr = this.getConvertedAmount(toExchangeRate).toString();
|
||||||
|
|
||||||
if (rateStr.indexOf('.') < 0) {
|
if (rateStr.indexOf('.') < 0) {
|
||||||
return appendThousandsSeparator(rateStr);
|
return appendThousandsSeparator(rateStr, this.isEnableThousandsSeparator);
|
||||||
} else {
|
} else {
|
||||||
let firstNonZeroPos = 0;
|
let firstNonZeroPos = 0;
|
||||||
|
|
||||||
@@ -208,7 +212,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const trimmedRateStr = rateStr.substring(0, Math.max(6, Math.max(firstNonZeroPos, rateStr.indexOf('.') + 2)));
|
const trimmedRateStr = rateStr.substring(0, Math.max(6, Math.max(firstNonZeroPos, rateStr.indexOf('.') + 2)));
|
||||||
return appendThousandsSeparator(trimmedRateStr);
|
return appendThousandsSeparator(trimmedRateStr, this.isEnableThousandsSeparator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,12 +151,6 @@ export default {
|
|||||||
this.settingsStore.setShowAmountInHomePage(value);
|
this.settingsStore.setShowAmountInHomePage(value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isEnableThousandsSeparator() {
|
|
||||||
return this.settingsStore.appSettings.thousandsSeparator;
|
|
||||||
},
|
|
||||||
currencyDisplayMode() {
|
|
||||||
return this.settingsStore.appSettings.currencyDisplayMode;
|
|
||||||
},
|
|
||||||
defaultCurrency() {
|
defaultCurrency() {
|
||||||
return this.userStore.currentUserDefaultCurrency;
|
return this.userStore.currentUserDefaultCurrency;
|
||||||
},
|
},
|
||||||
@@ -218,12 +212,18 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getDisplayCurrency(value, currencyCode) {
|
||||||
|
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
||||||
|
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
||||||
|
enableThousandsSeparator: this.settingsStore.appSettings.thousandsSeparator
|
||||||
|
});
|
||||||
|
},
|
||||||
getDisplayAmount(amount, incomplete) {
|
getDisplayAmount(amount, incomplete) {
|
||||||
if (!this.showAmountInHomePage) {
|
if (!this.showAmountInHomePage) {
|
||||||
return this.$locale.getDisplayCurrency('***', this.defaultCurrency);
|
return this.getDisplayCurrency('***', this.defaultCurrency);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.$locale.getDisplayCurrency(amount, this.defaultCurrency) + (incomplete ? '+' : '');
|
return this.getDisplayCurrency(amount, this.defaultCurrency) + (incomplete ? '+' : '');
|
||||||
},
|
},
|
||||||
getDisplayIncomeAmount(category) {
|
getDisplayIncomeAmount(category) {
|
||||||
return this.getDisplayAmount(category.incomeAmount, category.incompleteIncomeAmount);
|
return this.getDisplayAmount(category.incomeAmount, category.incompleteIncomeAmount);
|
||||||
|
|||||||
@@ -143,6 +143,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapStores } from 'pinia';
|
import { mapStores } from 'pinia';
|
||||||
import { useRootStore } from '@/stores/index.js';
|
import { useRootStore } from '@/stores/index.js';
|
||||||
|
import { useSettingsStore } from '@/stores/setting.js';
|
||||||
import { useUserStore } from '@/stores/user.js';
|
import { useUserStore } from '@/stores/user.js';
|
||||||
|
|
||||||
import {appendThousandsSeparator, isEquals} from '@/lib/common.js';
|
import {appendThousandsSeparator, isEquals} from '@/lib/common.js';
|
||||||
@@ -182,7 +183,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapStores(useRootStore, useUserStore),
|
...mapStores(useRootStore, useSettingsStore, useUserStore),
|
||||||
|
isEnableThousandsSeparator() {
|
||||||
|
return this.settingsStore.appSettings.thousandsSeparator;
|
||||||
|
},
|
||||||
displayDataStatistics() {
|
displayDataStatistics() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
@@ -191,10 +195,10 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
totalAccountCount: appendThousandsSeparator(self.dataStatistics.totalAccountCount),
|
totalAccountCount: appendThousandsSeparator(self.dataStatistics.totalAccountCount, self.isEnableThousandsSeparator),
|
||||||
totalTransactionCategoryCount: appendThousandsSeparator(self.dataStatistics.totalTransactionCategoryCount),
|
totalTransactionCategoryCount: appendThousandsSeparator(self.dataStatistics.totalTransactionCategoryCount, self.isEnableThousandsSeparator),
|
||||||
totalTransactionTagCount: appendThousandsSeparator(self.dataStatistics.totalTransactionTagCount),
|
totalTransactionTagCount: appendThousandsSeparator(self.dataStatistics.totalTransactionTagCount, self.isEnableThousandsSeparator),
|
||||||
totalTransactionCount: appendThousandsSeparator(self.dataStatistics.totalTransactionCount)
|
totalTransactionCount: appendThousandsSeparator(self.dataStatistics.totalTransactionCount, self.isEnableThousandsSeparator)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
isDataExportingEnabled() {
|
isDataExportingEnabled() {
|
||||||
|
|||||||
@@ -91,12 +91,17 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapStores } from 'pinia';
|
import { mapStores } from 'pinia';
|
||||||
|
import { useSettingsStore } from '@/stores/setting.js';
|
||||||
import { useUserStore } from '@/stores/user.js';
|
import { useUserStore } from '@/stores/user.js';
|
||||||
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
||||||
|
|
||||||
import transactionConstants from '@/consts/transaction.js';
|
import transactionConstants from '@/consts/transaction.js';
|
||||||
import { isNumber, appendThousandsSeparator } from '@/lib/common.js';
|
import { isNumber, appendThousandsSeparator } from '@/lib/common.js';
|
||||||
import { stringCurrencyToNumeric, getExchangedAmount } from '@/lib/currency.js';
|
import {
|
||||||
|
numericCurrencyToString,
|
||||||
|
stringCurrencyToNumeric,
|
||||||
|
getExchangedAmount,
|
||||||
|
} from '@/lib/currency.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -111,7 +116,10 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapStores(useUserStore, useExchangeRatesStore),
|
...mapStores(useSettingsStore, useUserStore, useExchangeRatesStore),
|
||||||
|
isEnableThousandsSeparator() {
|
||||||
|
return this.settingsStore.appSettings.thousandsSeparator;
|
||||||
|
},
|
||||||
exchangeRatesData() {
|
exchangeRatesData() {
|
||||||
return this.exchangeRatesStore.latestExchangeRates.data;
|
return this.exchangeRatesStore.latestExchangeRates.data;
|
||||||
},
|
},
|
||||||
@@ -143,7 +151,7 @@ export default {
|
|||||||
return availableExchangeRates;
|
return availableExchangeRates;
|
||||||
},
|
},
|
||||||
displayBaseAmount() {
|
displayBaseAmount() {
|
||||||
return this.$locale.getDisplayCurrency(this.baseAmount);
|
return numericCurrencyToString(this.baseAmount, this.isEnableThousandsSeparator);
|
||||||
},
|
},
|
||||||
baseAmountFontSizeClass() {
|
baseAmountFontSizeClass() {
|
||||||
if (this.baseAmount >= 100000000 || this.baseAmount <= -100000000) {
|
if (this.baseAmount >= 100000000 || this.baseAmount <= -100000000) {
|
||||||
@@ -231,7 +239,7 @@ export default {
|
|||||||
const rateStr = this.getConvertedAmount(toExchangeRate).toString();
|
const rateStr = this.getConvertedAmount(toExchangeRate).toString();
|
||||||
|
|
||||||
if (rateStr.indexOf('.') < 0) {
|
if (rateStr.indexOf('.') < 0) {
|
||||||
return appendThousandsSeparator(rateStr);
|
return appendThousandsSeparator(rateStr, this.isEnableThousandsSeparator);
|
||||||
} else {
|
} else {
|
||||||
let firstNonZeroPos = 0;
|
let firstNonZeroPos = 0;
|
||||||
|
|
||||||
@@ -243,7 +251,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const trimmedRateStr = rateStr.substring(0, Math.max(6, Math.max(firstNonZeroPos, rateStr.indexOf('.') + 2)));
|
const trimmedRateStr = rateStr.substring(0, Math.max(6, Math.max(firstNonZeroPos, rateStr.indexOf('.') + 2)));
|
||||||
return appendThousandsSeparator(trimmedRateStr);
|
return appendThousandsSeparator(trimmedRateStr, this.isEnableThousandsSeparator);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setAsBaseline(currency, amount) {
|
setAsBaseline(currency, amount) {
|
||||||
|
|||||||
@@ -212,12 +212,6 @@ export default {
|
|||||||
this.settingsStore.setShowAmountInHomePage(value);
|
this.settingsStore.setShowAmountInHomePage(value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isEnableThousandsSeparator() {
|
|
||||||
return this.settingsStore.appSettings.thousandsSeparator;
|
|
||||||
},
|
|
||||||
currencyDisplayMode() {
|
|
||||||
return this.settingsStore.appSettings.currencyDisplayMode;
|
|
||||||
},
|
|
||||||
defaultCurrency() {
|
defaultCurrency() {
|
||||||
return this.userStore.currentUserDefaultCurrency;
|
return this.userStore.currentUserDefaultCurrency;
|
||||||
},
|
},
|
||||||
@@ -301,12 +295,18 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getDisplayCurrency(value, currencyCode) {
|
||||||
|
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
||||||
|
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
||||||
|
enableThousandsSeparator: this.settingsStore.appSettings.thousandsSeparator
|
||||||
|
});
|
||||||
|
},
|
||||||
getDisplayAmount(amount, incomplete) {
|
getDisplayAmount(amount, incomplete) {
|
||||||
if (!this.showAmountInHomePage) {
|
if (!this.showAmountInHomePage) {
|
||||||
return this.$locale.getDisplayCurrency('***', this.defaultCurrency);
|
return this.getDisplayCurrency('***', this.defaultCurrency);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.$locale.getDisplayCurrency(amount, this.defaultCurrency) + (incomplete ? '+' : '');
|
return this.getDisplayCurrency(amount, this.defaultCurrency) + (incomplete ? '+' : '');
|
||||||
},
|
},
|
||||||
getDisplayIncomeAmount(category) {
|
getDisplayIncomeAmount(category) {
|
||||||
return this.getDisplayAmount(category.incomeAmount, category.incompleteIncomeAmount);
|
return this.getDisplayAmount(category.incomeAmount, category.incompleteIncomeAmount);
|
||||||
|
|||||||
@@ -421,6 +421,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapStores } from 'pinia';
|
import { mapStores } from 'pinia';
|
||||||
|
import { useSettingsStore } from '@/stores/setting.js';
|
||||||
import { useUserStore } from '@/stores/user.js';
|
import { useUserStore } from '@/stores/user.js';
|
||||||
import { useAccountsStore } from '@/stores/account.js';
|
import { useAccountsStore } from '@/stores/account.js';
|
||||||
|
|
||||||
@@ -467,7 +468,7 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapStores(useUserStore, useAccountsStore),
|
...mapStores(useSettingsStore, useUserStore, useAccountsStore),
|
||||||
title() {
|
title() {
|
||||||
if (!this.editAccountId) {
|
if (!this.editAccountId) {
|
||||||
return 'Add Account';
|
return 'Add Account';
|
||||||
@@ -720,7 +721,13 @@ export default {
|
|||||||
return this.$t(categoryName);
|
return this.$t(categoryName);
|
||||||
},
|
},
|
||||||
getAccountBalance(account) {
|
getAccountBalance(account) {
|
||||||
return this.$locale.getDisplayCurrency(account.balance, account.currency)
|
return this.getDisplayCurrency(account.balance, account.currency);
|
||||||
|
},
|
||||||
|
getDisplayCurrency(value, currencyCode) {
|
||||||
|
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
||||||
|
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
||||||
|
enableThousandsSeparator: this.settingsStore.appSettings.thousandsSeparator
|
||||||
|
});
|
||||||
},
|
},
|
||||||
chooseSuitableIcon(oldCategory, newCategory) {
|
chooseSuitableIcon(oldCategory, newCategory) {
|
||||||
for (let i = 0; i < this.allAccountCategories.length; i++) {
|
for (let i = 0; i < this.allAccountCategories.length; i++) {
|
||||||
|
|||||||
@@ -223,15 +223,15 @@ export default {
|
|||||||
},
|
},
|
||||||
netAssets() {
|
netAssets() {
|
||||||
const netAssets = this.accountsStore.getNetAssets(this.showAccountBalance);
|
const netAssets = this.accountsStore.getNetAssets(this.showAccountBalance);
|
||||||
return this.$locale.getDisplayCurrency(netAssets, this.defaultCurrency);
|
return this.getDisplayCurrency(netAssets, this.defaultCurrency);
|
||||||
},
|
},
|
||||||
totalAssets() {
|
totalAssets() {
|
||||||
const totalAssets = this.accountsStore.getTotalAssets(this.showAccountBalance);
|
const totalAssets = this.accountsStore.getTotalAssets(this.showAccountBalance);
|
||||||
return this.$locale.getDisplayCurrency(totalAssets, this.defaultCurrency);
|
return this.getDisplayCurrency(totalAssets, this.defaultCurrency);
|
||||||
},
|
},
|
||||||
totalLiabilities() {
|
totalLiabilities() {
|
||||||
const totalLiabilities = this.accountsStore.getTotalLiabilities(this.showAccountBalance);
|
const totalLiabilities = this.accountsStore.getTotalLiabilities(this.showAccountBalance);
|
||||||
return this.$locale.getDisplayCurrency(totalLiabilities, this.defaultCurrency);
|
return this.getDisplayCurrency(totalLiabilities, this.defaultCurrency);
|
||||||
},
|
},
|
||||||
showAccountBalance: {
|
showAccountBalance: {
|
||||||
get: function () {
|
get: function () {
|
||||||
@@ -305,11 +305,11 @@ export default {
|
|||||||
},
|
},
|
||||||
accountBalance(account) {
|
accountBalance(account) {
|
||||||
const balance = this.accountsStore.getAccountBalance(this.showAccountBalance, account);
|
const balance = this.accountsStore.getAccountBalance(this.showAccountBalance, account);
|
||||||
return this.$locale.getDisplayCurrency(balance, account.currency);
|
return this.getDisplayCurrency(balance, account.currency);
|
||||||
},
|
},
|
||||||
accountCategoryTotalBalance(accountCategory) {
|
accountCategoryTotalBalance(accountCategory) {
|
||||||
const totalBalance = this.accountsStore.getAccountCategoryTotalBalance(this.showAccountBalance, accountCategory);
|
const totalBalance = this.accountsStore.getAccountCategoryTotalBalance(this.showAccountBalance, accountCategory);
|
||||||
return this.$locale.getDisplayCurrency(totalBalance, this.defaultCurrency);
|
return this.getDisplayCurrency(totalBalance, this.defaultCurrency);
|
||||||
},
|
},
|
||||||
setSortable() {
|
setSortable() {
|
||||||
if (this.sortable) {
|
if (this.sortable) {
|
||||||
@@ -427,6 +427,12 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getDisplayCurrency(value, currencyCode) {
|
||||||
|
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
||||||
|
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
||||||
|
enableThousandsSeparator: this.settingsStore.appSettings.thousandsSeparator
|
||||||
|
});
|
||||||
|
},
|
||||||
getAccountDomId(account) {
|
getAccountDomId(account) {
|
||||||
return 'account_' + account.id;
|
return 'account_' + account.id;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -164,7 +164,10 @@ export default {
|
|||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
getDisplayAmount(value) {
|
getDisplayAmount(value) {
|
||||||
return this.$locale.getDisplayCurrency(value, this.userStore.currentUserDefaultCurrency);
|
return this.$locale.getDisplayCurrency(value, this.userStore.currentUserDefaultCurrency, {
|
||||||
|
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
||||||
|
enableThousandsSeparator: this.settingsStore.appSettings.thousandsSeparator
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -714,7 +714,7 @@ export default {
|
|||||||
container.scrollTop(targetPos);
|
container.scrollTop(targetPos);
|
||||||
},
|
},
|
||||||
getDisplayAmount(amount, currency, textLimit) {
|
getDisplayAmount(amount, currency, textLimit) {
|
||||||
amount = this.$locale.getDisplayCurrency(amount, currency);
|
amount = this.getDisplayCurrency(amount, currency);
|
||||||
|
|
||||||
if (!this.showAccountBalance
|
if (!this.showAccountBalance
|
||||||
&& (this.query.chartDataType === this.allChartDataTypes.AccountTotalAssets.type
|
&& (this.query.chartDataType === this.allChartDataTypes.AccountTotalAssets.type
|
||||||
@@ -729,6 +729,12 @@ export default {
|
|||||||
|
|
||||||
return amount;
|
return amount;
|
||||||
},
|
},
|
||||||
|
getDisplayCurrency(value, currencyCode) {
|
||||||
|
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
||||||
|
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
||||||
|
enableThousandsSeparator: this.settingsStore.appSettings.thousandsSeparator
|
||||||
|
});
|
||||||
|
},
|
||||||
getDisplayPercent(value, precision, lowPrecisionValue) {
|
getDisplayPercent(value, precision, lowPrecisionValue) {
|
||||||
return formatPercent(value, precision, lowPrecisionValue);
|
return formatPercent(value, precision, lowPrecisionValue);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -503,9 +503,9 @@ export default {
|
|||||||
const account = accountCategory.accounts[i];
|
const account = accountCategory.accounts[i];
|
||||||
|
|
||||||
if (this.showAccountBalance && account.isAsset) {
|
if (this.showAccountBalance && account.isAsset) {
|
||||||
account.displayBalance = this.$locale.getDisplayCurrency(account.balance, account.currency);
|
account.displayBalance = this.getDisplayCurrency(account.balance, account.currency);
|
||||||
} else if (this.showAccountBalance && account.isLiability) {
|
} else if (this.showAccountBalance && account.isLiability) {
|
||||||
account.displayBalance = this.$locale.getDisplayCurrency(-account.balance, account.currency);
|
account.displayBalance = this.getDisplayCurrency(-account.balance, account.currency);
|
||||||
} else {
|
} else {
|
||||||
account.displayBalance = '***';
|
account.displayBalance = '***';
|
||||||
}
|
}
|
||||||
@@ -544,7 +544,7 @@ export default {
|
|||||||
totalBalance = totalBalance + '+';
|
totalBalance = totalBalance + '+';
|
||||||
}
|
}
|
||||||
|
|
||||||
accountCategory.displayBalance = this.$locale.getDisplayCurrency(totalBalance, this.defaultCurrency);
|
accountCategory.displayBalance = this.getDisplayCurrency(totalBalance, this.defaultCurrency);
|
||||||
} else {
|
} else {
|
||||||
accountCategory.displayBalance = '***';
|
accountCategory.displayBalance = '***';
|
||||||
}
|
}
|
||||||
@@ -1067,10 +1067,16 @@ export default {
|
|||||||
},
|
},
|
||||||
getDisplayAmount(amount, hideAmount) {
|
getDisplayAmount(amount, hideAmount) {
|
||||||
if (hideAmount) {
|
if (hideAmount) {
|
||||||
return this.$locale.getDisplayCurrency('***');
|
return this.getDisplayCurrency('***');
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.$locale.getDisplayCurrency(amount);
|
return this.getDisplayCurrency(amount);
|
||||||
|
},
|
||||||
|
getDisplayCurrency(value, currencyCode) {
|
||||||
|
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
||||||
|
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
||||||
|
enableThousandsSeparator: this.settingsStore.appSettings.thousandsSeparator
|
||||||
|
});
|
||||||
},
|
},
|
||||||
getPrimaryCategoryName(categoryId, allCategories) {
|
getPrimaryCategoryName(categoryId, allCategories) {
|
||||||
return getTransactionPrimaryCategoryName(categoryId, allCategories);
|
return getTransactionPrimaryCategoryName(categoryId, allCategories);
|
||||||
|
|||||||
@@ -842,15 +842,21 @@ export default {
|
|||||||
},
|
},
|
||||||
getDisplayAmount(amount, currency, hideAmount) {
|
getDisplayAmount(amount, currency, hideAmount) {
|
||||||
if (hideAmount) {
|
if (hideAmount) {
|
||||||
return this.$locale.getDisplayCurrency('***', currency);
|
return this.getDisplayCurrency('***', currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.$locale.getDisplayCurrency(amount, currency);
|
return this.getDisplayCurrency(amount, currency);
|
||||||
},
|
},
|
||||||
getDisplayMonthTotalAmount(amount, currency, symbol, incomplete) {
|
getDisplayMonthTotalAmount(amount, currency, symbol, incomplete) {
|
||||||
const displayAmount = this.$locale.getDisplayCurrency(amount, currency);
|
const displayAmount = this.getDisplayCurrency(amount, currency);
|
||||||
return symbol + displayAmount + (incomplete ? '+' : '');
|
return symbol + displayAmount + (incomplete ? '+' : '');
|
||||||
},
|
},
|
||||||
|
getDisplayCurrency(value, currencyCode) {
|
||||||
|
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
||||||
|
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
||||||
|
enableThousandsSeparator: this.settingsStore.appSettings.thousandsSeparator
|
||||||
|
});
|
||||||
|
},
|
||||||
getTransactionTypeName(type, defaultName) {
|
getTransactionTypeName(type, defaultName) {
|
||||||
switch (type){
|
switch (type){
|
||||||
case this.allTransactionTypes.ModifyBalance:
|
case this.allTransactionTypes.ModifyBalance:
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapStores } from 'pinia';
|
import { mapStores } from 'pinia';
|
||||||
import { useRootStore } from '@/stores/index.js';
|
import { useRootStore } from '@/stores/index.js';
|
||||||
|
import { useSettingsStore } from '@/stores/setting.js';
|
||||||
import { useUserStore } from '@/stores/user.js';
|
import { useUserStore } from '@/stores/user.js';
|
||||||
|
|
||||||
import { appendThousandsSeparator } from '@/lib/common.js';
|
import { appendThousandsSeparator } from '@/lib/common.js';
|
||||||
@@ -81,7 +82,10 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapStores(useRootStore, useUserStore),
|
...mapStores(useRootStore, useSettingsStore, useUserStore),
|
||||||
|
isEnableThousandsSeparator() {
|
||||||
|
return this.settingsStore.appSettings.thousandsSeparator;
|
||||||
|
},
|
||||||
displayDataStatistics() {
|
displayDataStatistics() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
@@ -90,10 +94,10 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
totalAccountCount: appendThousandsSeparator(self.dataStatistics.totalAccountCount),
|
totalAccountCount: appendThousandsSeparator(self.dataStatistics.totalAccountCount, self.isEnableThousandsSeparator),
|
||||||
totalTransactionCategoryCount: appendThousandsSeparator(self.dataStatistics.totalTransactionCategoryCount),
|
totalTransactionCategoryCount: appendThousandsSeparator(self.dataStatistics.totalTransactionCategoryCount, self.isEnableThousandsSeparator),
|
||||||
totalTransactionTagCount: appendThousandsSeparator(self.dataStatistics.totalTransactionTagCount),
|
totalTransactionTagCount: appendThousandsSeparator(self.dataStatistics.totalTransactionTagCount, self.isEnableThousandsSeparator),
|
||||||
totalTransactionCount: appendThousandsSeparator(self.dataStatistics.totalTransactionCount)
|
totalTransactionCount: appendThousandsSeparator(self.dataStatistics.totalTransactionCount, self.isEnableThousandsSeparator)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
isDataExportingEnabled() {
|
isDataExportingEnabled() {
|
||||||
|
|||||||
Reference in New Issue
Block a user