mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 00:34:28 +08:00
support changing numeral system
This commit is contained in:
@@ -556,8 +556,17 @@ const props = defineProps<{
|
||||
f7router: Router.Router;
|
||||
}>();
|
||||
|
||||
const { tt, getAllCurrencies, getCurrencyName, formatUnixTimeToLongDate, formatUnixTimeToLongTime, formatAmountWithCurrency } = useI18n();
|
||||
const {
|
||||
tt,
|
||||
getAllCurrencies,
|
||||
getCurrencyName,
|
||||
formatUnixTimeToLongDate,
|
||||
formatUnixTimeToLongTime,
|
||||
formatAmountToLocalizedNumeralsWithCurrency
|
||||
} = useI18n();
|
||||
|
||||
const { showAlert, showToast, routeBackOnError } = useI18nUIComponents();
|
||||
|
||||
const {
|
||||
editAccountId,
|
||||
clientSessionId,
|
||||
@@ -604,7 +613,7 @@ const allCurrencies = computed<LocalizedCurrencyInfo[]>(() => getAllCurrencies()
|
||||
|
||||
function formatAccountDisplayBalance(selectedAccount: Account): string {
|
||||
const balance = account.value.isLiability ? -selectedAccount.balance : selectedAccount.balance;
|
||||
return formatAmountWithCurrency(balance, selectedAccount.currency);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(balance, selectedAccount.currency);
|
||||
}
|
||||
|
||||
function formatAccountBalanceDate(account: Account): string {
|
||||
|
||||
@@ -76,8 +76,8 @@
|
||||
|
||||
<f7-list strong inset dividers class="margin-vertical" v-if="finishQuery && !loading">
|
||||
<f7-list-item :title="tt('Total Transactions')"
|
||||
:after="reconciliationStatements?.transactions.length"
|
||||
v-if="reconciliationStatements?.transactions.length"></f7-list-item>
|
||||
:after="formatNumberToLocalizedNumerals(reconciliationStatements.transactions.length)"
|
||||
v-if="reconciliationStatements && reconciliationStatements.transactions"></f7-list-item>
|
||||
<f7-list-item :title="tt('Total Inflows')" :after="displayTotalInflows"></f7-list-item>
|
||||
<f7-list-item :title="tt('Total Outflows')" :after="displayTotalOutflows"></f7-list-item>
|
||||
<f7-list-item :title="tt('Net Cash Flow')" :after="displayTotalBalance"></f7-list-item>
|
||||
@@ -386,7 +386,7 @@ const props = defineProps<{
|
||||
f7router: Router.Router;
|
||||
}>();
|
||||
|
||||
const { tt, getAllDateRanges, formatUnixTimeToLongDateTime } = useI18n();
|
||||
const { tt, getAllDateRanges, formatUnixTimeToLongDateTime, formatNumberToLocalizedNumerals } = useI18n();
|
||||
const { showAlert, showToast, routeBackOnError } = useI18nUIComponents();
|
||||
|
||||
const {
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<f7-list strong inset dividers class="margin-vertical" v-if="exchangeRatesData && exchangeRatesData.exchangeRates && exchangeRatesData.exchangeRates.length">
|
||||
<f7-list-item swipeout
|
||||
:id="getExchangeRateDomId(exchangeRate)"
|
||||
:after="getFinalConvertedAmount(exchangeRate)"
|
||||
:after="getFinalConvertedAmount(exchangeRate, true)"
|
||||
:key="baseCurrencyChangedTime + '_' + exchangeRate.currencyCode" v-for="exchangeRate in availableExchangeRates"
|
||||
@swipeout:closed="onExchangeRateSwipeoutClosed()">
|
||||
<template #title>
|
||||
@@ -70,7 +70,7 @@
|
||||
<f7-swipeout-button color="primary" close
|
||||
:text="tt('Set as Base')"
|
||||
:class="{ 'disabled': exchangeRate.currencyCode === baseCurrency }"
|
||||
@click="setAsBaseline(exchangeRate.currencyCode, getFinalConvertedAmount(exchangeRate)); settingBaseLine = true"
|
||||
@click="setAsBaseline(exchangeRate.currencyCode, getFinalConvertedAmount(exchangeRate, false)); settingBaseLine = true"
|
||||
v-if="settingBaseLine || exchangeRate.currencyCode !== baseCurrency"></f7-swipeout-button>
|
||||
<f7-swipeout-button color="red" class="padding-left padding-right"
|
||||
@click="remove(exchangeRate, false)"
|
||||
@@ -134,6 +134,7 @@ import { useExchangeRatesPageBase } from '@/views/base/ExchangeRatesPageBase.ts'
|
||||
|
||||
import { useExchangeRatesStore } from '@/stores/exchangeRates.ts';
|
||||
|
||||
import { NumeralSystem } from '@/core/numeral.ts';
|
||||
import { TRANSACTION_MIN_AMOUNT, TRANSACTION_MAX_AMOUNT } from '@/consts/transaction.ts';
|
||||
|
||||
import type { LocalizedLatestExchangeRate } from '@/models/exchange_rate.ts';
|
||||
@@ -146,8 +147,16 @@ const props = defineProps<{
|
||||
f7router: Router.Router;
|
||||
}>();
|
||||
|
||||
const { tt, getCurrencyName, formatAmount, formatExchangeRateAmount } = useI18n();
|
||||
const {
|
||||
tt,
|
||||
getCurrentNumeralSystemType,
|
||||
getCurrencyName,
|
||||
formatAmountToLocalizedNumerals,
|
||||
formatExchangeRateAmountToWesternArabicNumerals
|
||||
} = useI18n();
|
||||
|
||||
const { showAlert, showToast } = useI18nUIComponents();
|
||||
|
||||
const {
|
||||
baseCurrency,
|
||||
baseAmount,
|
||||
@@ -171,7 +180,7 @@ const showBaseAmountSheet = ref<boolean>(false);
|
||||
const customExchangeRateToDelete = ref<LocalizedLatestExchangeRate | null>(null);
|
||||
const showDeleteActionSheet = ref<boolean>(false);
|
||||
|
||||
const displayBaseAmount = computed<string>(() => formatAmount(baseAmount.value, baseCurrency.value));
|
||||
const displayBaseAmount = computed<string>(() => formatAmountToLocalizedNumerals(baseAmount.value, baseCurrency.value));
|
||||
const baseAmountFontSizeClass = computed<string>(() => {
|
||||
if (baseAmount.value >= 100000000 || baseAmount.value <= -100000000) {
|
||||
return 'ebk-small-amount';
|
||||
@@ -260,15 +269,26 @@ function remove(customExchangeRate: LocalizedLatestExchangeRate | null, confirm:
|
||||
});
|
||||
}
|
||||
|
||||
function getFinalConvertedAmount(toExchangeRate: LocalizedLatestExchangeRate): string {
|
||||
function getFinalConvertedAmount(toExchangeRate: LocalizedLatestExchangeRate, displayLocalizedDigits: boolean): string {
|
||||
const numeralSystem = getCurrentNumeralSystemType();
|
||||
const fromExchangeRate = exchangeRatesStore.latestExchangeRateMap[baseCurrency.value];
|
||||
const exchangeRateAmount = getConvertedAmount(baseAmount.value / 100, fromExchangeRate, toExchangeRate);
|
||||
|
||||
if (!exchangeRateAmount) {
|
||||
return '0';
|
||||
if (displayLocalizedDigits) {
|
||||
return numeralSystem.digitZero;
|
||||
} else {
|
||||
return NumeralSystem.WesternArabicNumerals.digitZero;
|
||||
}
|
||||
}
|
||||
|
||||
return formatExchangeRateAmount(exchangeRateAmount);
|
||||
let ret = formatExchangeRateAmountToWesternArabicNumerals(exchangeRateAmount);
|
||||
|
||||
if (displayLocalizedDigits) {
|
||||
ret = numeralSystem.replaceWesternArabicDigitsToLocalizedDigits(ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function onExchangeRateSwipeoutClosed(): void {
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
<template #title>
|
||||
<small>{{ currentLongYearMonth }}</small>
|
||||
<small class="transaction-amount-statistics">
|
||||
<span class="text-income">{{ `+${formatAmountWithCurrency('12345')}` }}</span>
|
||||
<span class="text-expense">{{ `-${formatAmountWithCurrency('67890')}` }}</span>
|
||||
<span class="text-income">{{ `+${formatAmountToLocalizedNumeralsWithCurrency(12345)}` }}</span>
|
||||
<span class="text-expense">{{ `-${formatAmountToLocalizedNumeralsWithCurrency(67890)}` }}</span>
|
||||
</small>
|
||||
<f7-icon class="combination-list-chevron-icon" f7="chevron_up"></f7-icon>
|
||||
</template>
|
||||
@@ -53,7 +53,7 @@
|
||||
</div>
|
||||
<div class="item-after">
|
||||
<div class="transaction-amount">
|
||||
<span>{{ formatAmountWithCurrency('12345') }}</span>
|
||||
<span>{{ formatAmountToLocalizedNumeralsWithCurrency(12345) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -128,7 +128,7 @@ const props = defineProps<{
|
||||
f7router: Router.Router;
|
||||
}>();
|
||||
|
||||
const { tt, getWeekdayShortName, formatUnixTimeToLongYearMonth, formatUnixTimeToShortTime, formatAmountWithCurrency } = useI18n();
|
||||
const { tt, getWeekdayShortName, formatUnixTimeToLongYearMonth, formatUnixTimeToShortTime, formatAmountToLocalizedNumeralsWithCurrency } = useI18n();
|
||||
|
||||
const settingsStore = useSettingsStore();
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
<template #title>
|
||||
<div class="statistics-list-item-text">
|
||||
<span>{{ item.name }}</span>
|
||||
<small class="statistics-percent" v-if="item.percent >= 0">{{ formatPercent(item.percent, 2, '<0.01') }}</small>
|
||||
<small class="statistics-percent" v-if="item.percent >= 0">{{ formatPercentToLocalizedNumerals(item.percent, 2, '<0.01') }}</small>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -367,7 +367,7 @@ const props = defineProps<{
|
||||
f7router: Router.Router;
|
||||
}>();
|
||||
|
||||
const { tt, getAllCategoricalChartTypes, formatPercent } = useI18n();
|
||||
const { tt, getAllCategoricalChartTypes, formatPercentToLocalizedNumerals } = useI18n();
|
||||
const { showPrompt, showToast, routeBackOnError } = useI18nUIComponents();
|
||||
|
||||
const {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
class="ebk-small-amount"
|
||||
link="#" no-chevron
|
||||
:header="amount1Header"
|
||||
:title="formatAmountWithCurrency(amount1)"
|
||||
:title="formatAmountToLocalizedNumeralsWithCurrency(amount1)"
|
||||
@click="showAmount1Sheet = true"
|
||||
>
|
||||
<number-pad-sheet :min-value="TRANSACTION_MIN_AMOUNT"
|
||||
@@ -27,7 +27,7 @@
|
||||
class="ebk-small-amount"
|
||||
link="#" no-chevron
|
||||
:header="amount2Header"
|
||||
:title="formatAmountWithCurrency(amount2)"
|
||||
:title="formatAmountToLocalizedNumeralsWithCurrency(amount2)"
|
||||
@click="showAmount2Sheet = true"
|
||||
v-if="amountCount === 2"
|
||||
>
|
||||
@@ -76,7 +76,7 @@ const amount2 = ref<number>(0);
|
||||
const showAmount1Sheet = ref<boolean>(false);
|
||||
const showAmount2Sheet = ref<boolean>(false);
|
||||
|
||||
const { tt, formatAmountWithCurrency } = useI18n();
|
||||
const { tt, formatAmountToLocalizedNumeralsWithCurrency } = useI18n();
|
||||
const { showToast } = useI18nUIComponents();
|
||||
|
||||
const transactionsStore = useTransactionsStore();
|
||||
|
||||
@@ -343,6 +343,26 @@
|
||||
</list-item-selection-popup>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item
|
||||
link="#"
|
||||
class="list-item-with-header-and-title list-item-no-item-after"
|
||||
:header="tt('Numeral System')"
|
||||
:title="findDisplayNameByType(allNumeralSystemTypes, newProfile.numeralSystem)"
|
||||
@click="showNumberSystemPopup = true"
|
||||
>
|
||||
<list-item-selection-popup value-type="item"
|
||||
key-field="type" value-field="type"
|
||||
title-field="displayName"
|
||||
:title="tt('Numeral System')"
|
||||
:enable-filter="true"
|
||||
:filter-placeholder="tt('Numeral System')"
|
||||
:filter-no-items-text="tt('No results')"
|
||||
:items="allNumeralSystemTypes"
|
||||
v-model:show="showNumberSystemPopup"
|
||||
v-model="newProfile.numeralSystem">
|
||||
</list-item-selection-popup>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item
|
||||
link="#"
|
||||
class="list-item-with-header-and-title list-item-no-item-after"
|
||||
@@ -536,10 +556,11 @@ const {
|
||||
allLongTimeFormats,
|
||||
allShortTimeFormats,
|
||||
allFiscalYearFormats,
|
||||
allCurrencyDisplayTypes,
|
||||
allNumeralSystemTypes,
|
||||
allDecimalSeparators,
|
||||
allDigitGroupingSymbols,
|
||||
allDigitGroupingTypes,
|
||||
allCurrencyDisplayTypes,
|
||||
allCoordinateDisplayTypes,
|
||||
allExpenseAmountColorTypes,
|
||||
allIncomeAmountColorTypes,
|
||||
@@ -577,6 +598,7 @@ const showLongTimeFormatPopup = ref<boolean>(false);
|
||||
const showShortTimeFormatPopup = ref<boolean>(false);
|
||||
const showFiscalYearFormatPopup = ref<boolean>(false);
|
||||
const showCurrencyDisplayTypePopup = ref<boolean>(false);
|
||||
const showNumberSystemPopup = ref<boolean>(false);
|
||||
const showDigitGroupingPopup = ref<boolean>(false);
|
||||
const showDigitGroupingSymbolPopup = ref<boolean>(false);
|
||||
const showDecimalSeparatorPopup = ref<boolean>(false);
|
||||
|
||||
Reference in New Issue
Block a user