support changing numeral system
This commit is contained in:
@@ -6,14 +6,15 @@ import { useSettingsStore } from '@/stores/setting.ts';
|
||||
import { useUserStore } from '@/stores/user.ts';
|
||||
import { useAccountsStore } from '@/stores/account.ts';
|
||||
|
||||
import type { HiddenAmount, NumberWithSuffix } from '@/core/numeral.ts';
|
||||
import type { WeekDayValue } from '@/core/datetime.ts';
|
||||
import { type AccountCategory, AccountType } from '@/core/account.ts';
|
||||
import type { Account, CategorizedAccount } from '@/models/account.ts';
|
||||
|
||||
import { isObject, isString } from '@/lib/common.ts';
|
||||
import { isObject, isNumber, isString } from '@/lib/common.ts';
|
||||
|
||||
export function useAccountListPageBaseBase() {
|
||||
const { formatAmountWithCurrency } = useI18n();
|
||||
const { formatAmountToLocalizedNumeralsWithCurrency } = useI18n();
|
||||
|
||||
const settingsStore = useSettingsStore();
|
||||
const userStore = useUserStore();
|
||||
@@ -37,18 +38,18 @@ export function useAccountListPageBaseBase() {
|
||||
const allAccountCount = computed<number>(() => accountsStore.allAvailableAccountsCount);
|
||||
|
||||
const netAssets = computed<string>(() => {
|
||||
const netAssets = accountsStore.getNetAssets(showAccountBalance.value);
|
||||
return formatAmountWithCurrency(netAssets, defaultCurrency.value);
|
||||
const netAssets: number | HiddenAmount | NumberWithSuffix = accountsStore.getNetAssets(showAccountBalance.value);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(netAssets, defaultCurrency.value);
|
||||
});
|
||||
|
||||
const totalAssets = computed<string>(() => {
|
||||
const totalAssets = accountsStore.getTotalAssets(showAccountBalance.value);
|
||||
return formatAmountWithCurrency(totalAssets, defaultCurrency.value);
|
||||
const totalAssets: number | HiddenAmount | NumberWithSuffix = accountsStore.getTotalAssets(showAccountBalance.value);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(totalAssets, defaultCurrency.value);
|
||||
});
|
||||
|
||||
const totalLiabilities = computed<string>(() => {
|
||||
const totalLiabilities = accountsStore.getTotalLiabilities(showAccountBalance.value);
|
||||
return formatAmountWithCurrency(totalLiabilities, defaultCurrency.value);
|
||||
const totalLiabilities: number | HiddenAmount | NumberWithSuffix = accountsStore.getTotalLiabilities(showAccountBalance.value);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(totalLiabilities, defaultCurrency.value);
|
||||
});
|
||||
|
||||
function accountCategoryTotalBalance(accountCategory?: AccountCategory): string {
|
||||
@@ -56,19 +57,19 @@ export function useAccountListPageBaseBase() {
|
||||
return '';
|
||||
}
|
||||
|
||||
const totalBalance = accountsStore.getAccountCategoryTotalBalance(showAccountBalance.value, accountCategory);
|
||||
return formatAmountWithCurrency(totalBalance, defaultCurrency.value);
|
||||
const totalBalance: number | HiddenAmount | NumberWithSuffix = accountsStore.getAccountCategoryTotalBalance(showAccountBalance.value, accountCategory);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(totalBalance, defaultCurrency.value);
|
||||
}
|
||||
|
||||
function accountBalance(account: Account, currentSubAccountId?: string): string | null {
|
||||
if (account.type === AccountType.SingleAccount.type) {
|
||||
const balance = accountsStore.getAccountBalance(showAccountBalance.value, account);
|
||||
const balance: number| HiddenAmount | null = accountsStore.getAccountBalance(showAccountBalance.value, account);
|
||||
|
||||
if (!isString(balance)) {
|
||||
if (!isNumber(balance) && !isString(balance)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return formatAmountWithCurrency(balance, account.currency);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(balance, account.currency);
|
||||
} else if (account.type === AccountType.MultiSubAccounts.type) {
|
||||
const balanceResult = accountsStore.getAccountSubAccountBalance(showAccountBalance.value, showHidden.value, account, currentSubAccountId);
|
||||
|
||||
@@ -76,7 +77,7 @@ export function useAccountListPageBaseBase() {
|
||||
return '';
|
||||
}
|
||||
|
||||
return formatAmountWithCurrency(balanceResult.balance, balanceResult.currency);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(balanceResult.balance, balanceResult.currency);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ import type {
|
||||
TransactionReconciliationStatementResponseItem
|
||||
} from '@/models/transaction.ts';
|
||||
|
||||
import {
|
||||
replaceAll,
|
||||
removeAll
|
||||
} from '@/lib/common.ts';
|
||||
import { replaceAll } from '@/lib/common.ts';
|
||||
|
||||
import {
|
||||
getUtcOffsetByUtcOffsetMinutes,
|
||||
@@ -36,12 +33,11 @@ export function useReconciliationStatementPageBase() {
|
||||
tt,
|
||||
getAllAccountBalanceTrendChartTypes,
|
||||
getAllStatisticsDateAggregationTypesWithShortName,
|
||||
getCurrentDigitGroupingSymbol,
|
||||
formatUnixTimeToLongDateTime,
|
||||
formatUnixTimeToLongDate,
|
||||
formatUnixTimeToShortTime,
|
||||
formatAmount,
|
||||
formatAmountWithCurrency
|
||||
formatAmountToWesternArabicNumeralsWithoutDigitGrouping,
|
||||
formatAmountToLocalizedNumeralsWithCurrency
|
||||
} = useI18n();
|
||||
|
||||
const settingsStore = useSettingsStore();
|
||||
@@ -90,30 +86,30 @@ export function useReconciliationStatementPageBase() {
|
||||
});
|
||||
|
||||
const displayTotalInflows = computed<string>(() => {
|
||||
return formatAmountWithCurrency(reconciliationStatements.value?.totalInflows ?? 0, currentAccountCurrency.value);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(reconciliationStatements.value?.totalInflows ?? 0, currentAccountCurrency.value);
|
||||
});
|
||||
|
||||
const displayTotalOutflows = computed<string>(() => {
|
||||
return formatAmountWithCurrency(reconciliationStatements.value?.totalOutflows ?? 0, currentAccountCurrency.value);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(reconciliationStatements.value?.totalOutflows ?? 0, currentAccountCurrency.value);
|
||||
});
|
||||
|
||||
const displayTotalBalance = computed<string>(() => {
|
||||
return formatAmountWithCurrency((reconciliationStatements?.value?.totalInflows ?? 0) - (reconciliationStatements.value?.totalOutflows ?? 0), currentAccountCurrency.value);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency((reconciliationStatements?.value?.totalInflows ?? 0) - (reconciliationStatements.value?.totalOutflows ?? 0), currentAccountCurrency.value);
|
||||
});
|
||||
|
||||
const displayOpeningBalance = computed<string>(() => {
|
||||
if (isCurrentLiabilityAccount.value) {
|
||||
return formatAmountWithCurrency(-(reconciliationStatements?.value?.openingBalance ?? 0), currentAccountCurrency.value);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(-(reconciliationStatements?.value?.openingBalance ?? 0), currentAccountCurrency.value);
|
||||
} else {
|
||||
return formatAmountWithCurrency(reconciliationStatements?.value?.openingBalance ?? 0, currentAccountCurrency.value);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(reconciliationStatements?.value?.openingBalance ?? 0, currentAccountCurrency.value);
|
||||
}
|
||||
});
|
||||
|
||||
const displayClosingBalance = computed<string>(() => {
|
||||
if (isCurrentLiabilityAccount.value) {
|
||||
return formatAmountWithCurrency(-(reconciliationStatements?.value?.closingBalance ?? 0), currentAccountCurrency.value);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(-(reconciliationStatements?.value?.closingBalance ?? 0), currentAccountCurrency.value);
|
||||
} else {
|
||||
return formatAmountWithCurrency(reconciliationStatements?.value?.closingBalance ?? 0, currentAccountCurrency.value);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(reconciliationStatements?.value?.closingBalance ?? 0, currentAccountCurrency.value);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -159,7 +155,7 @@ export function useReconciliationStatementPageBase() {
|
||||
currency = allAccountsMap.value[transaction.sourceAccountId].currency;
|
||||
}
|
||||
|
||||
return formatAmountWithCurrency(transaction.sourceAmount, currency);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(transaction.sourceAmount, currency);
|
||||
}
|
||||
|
||||
function getDisplayDestinationAmount(transaction: TransactionReconciliationStatementResponseItem): string {
|
||||
@@ -169,7 +165,7 @@ export function useReconciliationStatementPageBase() {
|
||||
currency = allAccountsMap.value[transaction.destinationAccountId].currency;
|
||||
}
|
||||
|
||||
return formatAmountWithCurrency(transaction.destinationAmount, currency);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(transaction.destinationAmount, currency);
|
||||
}
|
||||
|
||||
function getDisplayAccountBalance(transaction: TransactionReconciliationStatementResponseItem): string {
|
||||
@@ -187,9 +183,9 @@ export function useReconciliationStatementPageBase() {
|
||||
}
|
||||
|
||||
if (isLiabilityAccount) {
|
||||
return formatAmountWithCurrency(-transaction.accountClosingBalance, currency);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(-transaction.accountClosingBalance, currency);
|
||||
} else {
|
||||
return formatAmountWithCurrency(transaction.accountClosingBalance, currency);
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(transaction.accountClosingBalance, currency);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +196,6 @@ export function useReconciliationStatementPageBase() {
|
||||
separator = '\t';
|
||||
}
|
||||
|
||||
const digitGroupingSymbol = getCurrentDigitGroupingSymbol();
|
||||
const accountBalanceName = isCurrentLiabilityAccount.value ? 'Account Outstanding Balance' : 'Account Balance';
|
||||
|
||||
const header = [
|
||||
@@ -218,13 +213,13 @@ export function useReconciliationStatementPageBase() {
|
||||
const transactionTime = getUnixTime(parseDateFromUnixTime(transaction.time, transaction.utcOffset, currentTimezoneOffsetMinutes.value));
|
||||
const type = getDisplayTransactionType(transaction);
|
||||
let categoryName = allCategoriesMap.value[transaction.categoryId]?.name || '';
|
||||
let displayAmount = removeAll(formatAmount(transaction.sourceAmount), digitGroupingSymbol);
|
||||
let displayAmount = formatAmountToWesternArabicNumeralsWithoutDigitGrouping(transaction.sourceAmount);
|
||||
let displayAccountName = allAccountsMap.value[transaction.sourceAccountId]?.name || '';
|
||||
|
||||
if (transaction.type === TransactionType.ModifyBalance) {
|
||||
categoryName = tt('Modify Balance');
|
||||
} else if (transaction.type === TransactionType.Transfer && transaction.destinationAccountId === accountId.value) {
|
||||
displayAmount = removeAll(formatAmount(transaction.destinationAmount), digitGroupingSymbol);
|
||||
displayAmount = formatAmountToWesternArabicNumeralsWithoutDigitGrouping(transaction.destinationAmount);
|
||||
}
|
||||
|
||||
if (transaction.type === TransactionType.Transfer && allAccountsMap.value[transaction.destinationAccountId]) {
|
||||
@@ -234,9 +229,9 @@ export function useReconciliationStatementPageBase() {
|
||||
let displayAccountBalance = '';
|
||||
|
||||
if (isCurrentLiabilityAccount.value) {
|
||||
displayAccountBalance = removeAll(formatAmount(-transaction.accountClosingBalance), digitGroupingSymbol);
|
||||
displayAccountBalance = formatAmountToWesternArabicNumeralsWithoutDigitGrouping(-transaction.accountClosingBalance);
|
||||
} else {
|
||||
displayAccountBalance = removeAll(formatAmount(transaction.accountClosingBalance), digitGroupingSymbol);
|
||||
displayAccountBalance = formatAmountToWesternArabicNumeralsWithoutDigitGrouping(transaction.accountClosingBalance);
|
||||
}
|
||||
|
||||
let description = transaction.comment || '';
|
||||
|
||||
Reference in New Issue
Block a user