mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-21 02:04:26 +08:00
code refactor
This commit is contained in:
@@ -51,6 +51,10 @@ export function useReconciliationStatementPageBase() {
|
|||||||
const currentTimezoneOffsetMinutes = computed<number>(() => getTimezoneOffsetMinutes(settingsStore.appSettings.timeZone));
|
const currentTimezoneOffsetMinutes = computed<number>(() => getTimezoneOffsetMinutes(settingsStore.appSettings.timeZone));
|
||||||
const defaultCurrency = computed<string>(() => userStore.currentUserDefaultCurrency);
|
const defaultCurrency = computed<string>(() => userStore.currentUserDefaultCurrency);
|
||||||
|
|
||||||
|
const currentAccount = computed(() => allAccountsMap.value[accountId.value]);
|
||||||
|
const currentAccountCurrency = computed<string>(() => currentAccount.value?.currency ?? defaultCurrency.value);
|
||||||
|
const isCurrentLiabilityAccount = computed<boolean>(() => currentAccount.value?.isLiability ?? false);
|
||||||
|
|
||||||
const exportFileName = computed<string>(() => {
|
const exportFileName = computed<string>(() => {
|
||||||
const nickname = userStore.currentUserNickname;
|
const nickname = userStore.currentUserNickname;
|
||||||
|
|
||||||
@@ -66,16 +70,6 @@ export function useReconciliationStatementPageBase() {
|
|||||||
const allAccountsMap = computed<Record<string, Account>>(() => accountsStore.allAccountsMap);
|
const allAccountsMap = computed<Record<string, Account>>(() => accountsStore.allAccountsMap);
|
||||||
const allCategoriesMap = computed<Record<string, TransactionCategory>>(() => transactionCategoriesStore.allTransactionCategoriesMap);
|
const allCategoriesMap = computed<Record<string, TransactionCategory>>(() => transactionCategoriesStore.allTransactionCategoriesMap);
|
||||||
|
|
||||||
const accountCurrency = computed<string>(() => {
|
|
||||||
let currency = defaultCurrency.value;
|
|
||||||
|
|
||||||
if (allAccountsMap.value[accountId.value]) {
|
|
||||||
currency = allAccountsMap.value[accountId.value].currency;
|
|
||||||
}
|
|
||||||
|
|
||||||
return currency;
|
|
||||||
});
|
|
||||||
|
|
||||||
const totalOutflows = computed<number>(() => {
|
const totalOutflows = computed<number>(() => {
|
||||||
let totalOutflows = 0;
|
let totalOutflows = 0;
|
||||||
|
|
||||||
@@ -117,42 +111,30 @@ export function useReconciliationStatementPageBase() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const displayTotalOutflows = computed<string>(() => {
|
const displayTotalOutflows = computed<string>(() => {
|
||||||
return formatAmountWithCurrency(totalOutflows.value, accountCurrency.value);
|
return formatAmountWithCurrency(totalOutflows.value, currentAccountCurrency.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
const displayTotalInflows = computed<string>(() => {
|
const displayTotalInflows = computed<string>(() => {
|
||||||
return formatAmountWithCurrency(totalInflows.value, accountCurrency.value);
|
return formatAmountWithCurrency(totalInflows.value, currentAccountCurrency.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
const displayTotalBalance = computed<string>(() => {
|
const displayTotalBalance = computed<string>(() => {
|
||||||
return formatAmountWithCurrency(totalInflows.value - totalOutflows.value, accountCurrency.value);
|
return formatAmountWithCurrency(totalInflows.value - totalOutflows.value, currentAccountCurrency.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
const displayOpeningBalance = computed<string>(() => {
|
const displayOpeningBalance = computed<string>(() => {
|
||||||
let isLiabilityAccount = false;
|
if (isCurrentLiabilityAccount.value) {
|
||||||
|
return formatAmountWithCurrency(-openingBalance.value, currentAccountCurrency.value);
|
||||||
if (allAccountsMap.value[accountId.value]) {
|
|
||||||
isLiabilityAccount = allAccountsMap.value[accountId.value].isLiability;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLiabilityAccount) {
|
|
||||||
return formatAmountWithCurrency(-openingBalance.value, accountCurrency.value);
|
|
||||||
} else {
|
} else {
|
||||||
return formatAmountWithCurrency(openingBalance.value, accountCurrency.value);
|
return formatAmountWithCurrency(openingBalance.value, currentAccountCurrency.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const displayClosingBalance = computed<string>(() => {
|
const displayClosingBalance = computed<string>(() => {
|
||||||
let isLiabilityAccount = false;
|
if (isCurrentLiabilityAccount.value) {
|
||||||
|
return formatAmountWithCurrency(-closingBalance.value, currentAccountCurrency.value);
|
||||||
if (allAccountsMap.value[accountId.value]) {
|
|
||||||
isLiabilityAccount = allAccountsMap.value[accountId.value].isLiability;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLiabilityAccount) {
|
|
||||||
return formatAmountWithCurrency(-closingBalance.value, accountCurrency.value);
|
|
||||||
} else {
|
} else {
|
||||||
return formatAmountWithCurrency(closingBalance.value, accountCurrency.value);
|
return formatAmountWithCurrency(closingBalance.value, currentAccountCurrency.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -213,14 +195,8 @@ export function useReconciliationStatementPageBase() {
|
|||||||
separator = '\t';
|
separator = '\t';
|
||||||
}
|
}
|
||||||
|
|
||||||
let isLiabilityAccount = false;
|
|
||||||
|
|
||||||
if (allAccountsMap.value[accountId.value]) {
|
|
||||||
isLiabilityAccount = allAccountsMap.value[accountId.value].isLiability;
|
|
||||||
}
|
|
||||||
|
|
||||||
const digitGroupingSymbol = getCurrentDigitGroupingSymbol();
|
const digitGroupingSymbol = getCurrentDigitGroupingSymbol();
|
||||||
const accountBalanceName = isLiabilityAccount ? 'Account Outstanding Balance' : 'Account Balance';
|
const accountBalanceName = isCurrentLiabilityAccount.value ? 'Account Outstanding Balance' : 'Account Balance';
|
||||||
|
|
||||||
const header = [
|
const header = [
|
||||||
tt('Transaction Time'),
|
tt('Transaction Time'),
|
||||||
@@ -263,7 +239,7 @@ export function useReconciliationStatementPageBase() {
|
|||||||
|
|
||||||
let displayAccountBalance = '';
|
let displayAccountBalance = '';
|
||||||
|
|
||||||
if (isLiabilityAccount) {
|
if (isCurrentLiabilityAccount.value) {
|
||||||
displayAccountBalance = removeAll(formatAmount(-transaction.accountBalance), digitGroupingSymbol);
|
displayAccountBalance = removeAll(formatAmount(-transaction.accountBalance), digitGroupingSymbol);
|
||||||
} else {
|
} else {
|
||||||
displayAccountBalance = removeAll(formatAmount(transaction.accountBalance), digitGroupingSymbol);
|
displayAccountBalance = removeAll(formatAmount(transaction.accountBalance), digitGroupingSymbol);
|
||||||
@@ -302,6 +278,9 @@ export function useReconciliationStatementPageBase() {
|
|||||||
// computed states
|
// computed states
|
||||||
currentTimezoneOffsetMinutes,
|
currentTimezoneOffsetMinutes,
|
||||||
defaultCurrency,
|
defaultCurrency,
|
||||||
|
currentAccount,
|
||||||
|
currentAccountCurrency,
|
||||||
|
isCurrentLiabilityAccount,
|
||||||
exportFileName,
|
exportFileName,
|
||||||
allAccountsMap,
|
allAccountsMap,
|
||||||
allCategoriesMap,
|
allCategoriesMap,
|
||||||
|
|||||||
@@ -244,6 +244,7 @@ const {
|
|||||||
currentTimezoneOffsetMinutes,
|
currentTimezoneOffsetMinutes,
|
||||||
allAccountsMap,
|
allAccountsMap,
|
||||||
allCategoriesMap,
|
allCategoriesMap,
|
||||||
|
isCurrentLiabilityAccount,
|
||||||
exportFileName,
|
exportFileName,
|
||||||
displayStartDateTime,
|
displayStartDateTime,
|
||||||
displayEndDateTime,
|
displayEndDateTime,
|
||||||
@@ -274,7 +275,6 @@ const countPerPage = ref<number>(10);
|
|||||||
|
|
||||||
let rejectFunc: ((reason?: unknown) => void) | null = null;
|
let rejectFunc: ((reason?: unknown) => void) | null = null;
|
||||||
|
|
||||||
const account = computed(() => allAccountsMap.value[accountId.value]);
|
|
||||||
const reconciliationStatementsTablePageOptions = computed<ReconciliationStatementDialogTablePageOption[]>(() => getTablePageOptions(reconciliationStatements.value?.length));
|
const reconciliationStatementsTablePageOptions = computed<ReconciliationStatementDialogTablePageOption[]>(() => getTablePageOptions(reconciliationStatements.value?.length));
|
||||||
|
|
||||||
const totalPageCount = computed<number>(() => {
|
const totalPageCount = computed<number>(() => {
|
||||||
@@ -293,7 +293,7 @@ const totalPageCount = computed<number>(() => {
|
|||||||
|
|
||||||
const dataTableHeaders = computed<object[]>(() => {
|
const dataTableHeaders = computed<object[]>(() => {
|
||||||
const headers: object[] = [];
|
const headers: object[] = [];
|
||||||
const accountBalanceName = account.value?.isLiability ? 'Account Outstanding Balance' : 'Account Balance';
|
const accountBalanceName = isCurrentLiabilityAccount.value ? 'Account Outstanding Balance' : 'Account Balance';
|
||||||
|
|
||||||
headers.push({ key: 'time', value: 'time', title: tt('Transaction Time'), sortable: true, nowrap: true });
|
headers.push({ key: 'time', value: 'time', title: tt('Transaction Time'), sortable: true, nowrap: true });
|
||||||
headers.push({ key: 'type', value: 'type', title: tt('Type'), sortable: true, nowrap: true });
|
headers.push({ key: 'type', value: 'type', title: tt('Type'), sortable: true, nowrap: true });
|
||||||
|
|||||||
Reference in New Issue
Block a user