mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 09:14:27 +08:00
show account outstanding balance for liability account in account balance trends chart
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
|||||||
} from '@/core/datetime.ts';
|
} from '@/core/datetime.ts';
|
||||||
import type { FiscalYearUnixTime } from '@/core/fiscalyear.ts';
|
import type { FiscalYearUnixTime } from '@/core/fiscalyear.ts';
|
||||||
import { ChartDateAggregationType } from '@/core/statistics.ts';
|
import { ChartDateAggregationType } from '@/core/statistics.ts';
|
||||||
|
import type { AccountInfoResponse } from '@/models/account.ts';
|
||||||
import type { TransactionReconciliationStatementResponseItem } from '@/models/transaction.ts';
|
import type { TransactionReconciliationStatementResponseItem } from '@/models/transaction.ts';
|
||||||
|
|
||||||
import { isDefined, isArray } from '@/lib/common.ts';
|
import { isDefined, isArray } from '@/lib/common.ts';
|
||||||
@@ -39,7 +40,7 @@ export interface CommonAccountBalanceTrendsChartProps {
|
|||||||
items: TransactionReconciliationStatementResponseItem[] | undefined;
|
items: TransactionReconciliationStatementResponseItem[] | undefined;
|
||||||
dateAggregationType?: number;
|
dateAggregationType?: number;
|
||||||
fiscalYearStart: number;
|
fiscalYearStart: number;
|
||||||
accountCurrency: string;
|
account: AccountInfoResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTrendsChartProps) {
|
export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTrendsChartProps) {
|
||||||
@@ -152,7 +153,14 @@ export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTren
|
|||||||
|
|
||||||
if (dataItem.time >= lastUnixTime) {
|
if (dataItem.time >= lastUnixTime) {
|
||||||
lastUnixTime = dataItem.time;
|
lastUnixTime = dataItem.time;
|
||||||
lastAmount = dataItem.accountBalance;
|
|
||||||
|
if (props.account.isAsset) {
|
||||||
|
lastAmount = dataItem.accountBalance;
|
||||||
|
} else if (props.account.isLiability) {
|
||||||
|
lastAmount = -dataItem.accountBalance;
|
||||||
|
} else {
|
||||||
|
lastAmount = dataItem.accountBalance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ const yAxisWidth = computed<number>(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxValueText = formatAmountWithCurrency(maxValue, props.accountCurrency);
|
const maxValueText = formatAmountWithCurrency(maxValue, props.account.currency);
|
||||||
const minValueText = formatAmountWithCurrency(minValue, props.accountCurrency);
|
const minValueText = formatAmountWithCurrency(minValue, props.account.currency);
|
||||||
const maxLengthText = maxValueText.length > minValueText.length ? maxValueText : minValueText;
|
const maxLengthText = maxValueText.length > minValueText.length ? maxValueText : minValueText;
|
||||||
|
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
@@ -135,7 +135,7 @@ const chartOptions = computed<object>(() => {
|
|||||||
},
|
},
|
||||||
formatter: (params: CallbackDataParams[]) => {
|
formatter: (params: CallbackDataParams[]) => {
|
||||||
const amount = params[0].data as number;
|
const amount = params[0].data as number;
|
||||||
const value = formatAmountWithCurrency(amount, props.accountCurrency);
|
const value = formatAmountWithCurrency(amount, props.account.currency);
|
||||||
|
|
||||||
return `${params[0].name}<br/>`
|
return `${params[0].name}<br/>`
|
||||||
+ '<div><span class="chart-pointer" style="background-color: #' + DEFAULT_CHART_COLORS[0] + '"></span>'
|
+ '<div><span class="chart-pointer" style="background-color: #' + DEFAULT_CHART_COLORS[0] + '"></span>'
|
||||||
@@ -158,13 +158,13 @@ const chartOptions = computed<object>(() => {
|
|||||||
type: 'value',
|
type: 'value',
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
formatter: (value: string) => {
|
formatter: (value: string) => {
|
||||||
return formatAmountWithCurrency(value, props.accountCurrency);
|
return formatAmountWithCurrency(value, props.account.currency);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
axisPointer: {
|
axisPointer: {
|
||||||
label: {
|
label: {
|
||||||
formatter: (params: CallbackDataParams) => {
|
formatter: (params: CallbackDataParams) => {
|
||||||
return formatAmountWithCurrency(Math.floor(params.value as number), props.accountCurrency);
|
return formatAmountWithCurrency(Math.floor(params.value as number), props.account.currency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
:style="`top: ${virtualDataItems.topPosition}px`"
|
:style="`top: ${virtualDataItems.topPosition}px`"
|
||||||
:virtual-list-index="item.index"
|
:virtual-list-index="item.index"
|
||||||
:title="item.displayDate"
|
:title="item.displayDate"
|
||||||
:after="formatAmountWithCurrency(item.amount, accountCurrency)"
|
:after="formatAmountWithCurrency(item.amount, account.currency)"
|
||||||
v-for="item in virtualDataItems.items"
|
v-for="item in virtualDataItems.items"
|
||||||
>
|
>
|
||||||
<template #media>
|
<template #media>
|
||||||
|
|||||||
@@ -230,7 +230,7 @@
|
|||||||
:fiscal-year-start="fiscalYearStart"
|
:fiscal-year-start="fiscalYearStart"
|
||||||
:items="[]"
|
:items="[]"
|
||||||
:legend-name="isCurrentLiabilityAccount ? tt('Account Outstanding Balance') : tt('Account Balance')"
|
:legend-name="isCurrentLiabilityAccount ? tt('Account Outstanding Balance') : tt('Account Balance')"
|
||||||
:account-currency="currentAccountCurrency"
|
:account="currentAccount"
|
||||||
:skeleton="true"
|
:skeleton="true"
|
||||||
v-if="showAccountBalanceTrendsCharts && loading"
|
v-if="showAccountBalanceTrendsCharts && loading"
|
||||||
/>
|
/>
|
||||||
@@ -241,7 +241,7 @@
|
|||||||
:fiscal-year-start="fiscalYearStart"
|
:fiscal-year-start="fiscalYearStart"
|
||||||
:items="reconciliationStatements?.transactions"
|
:items="reconciliationStatements?.transactions"
|
||||||
:legend-name="isCurrentLiabilityAccount ? tt('Account Outstanding Balance') : tt('Account Balance')"
|
:legend-name="isCurrentLiabilityAccount ? tt('Account Outstanding Balance') : tt('Account Balance')"
|
||||||
:account-currency="currentAccountCurrency"
|
:account="currentAccount"
|
||||||
v-if="showAccountBalanceTrendsCharts && !loading"
|
v-if="showAccountBalanceTrendsCharts && !loading"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -329,6 +329,7 @@ const {
|
|||||||
fiscalYearStart,
|
fiscalYearStart,
|
||||||
allChartTypes,
|
allChartTypes,
|
||||||
allDateAggregationTypes,
|
allDateAggregationTypes,
|
||||||
|
currentAccount,
|
||||||
currentAccountCurrency,
|
currentAccountCurrency,
|
||||||
isCurrentLiabilityAccount,
|
isCurrentLiabilityAccount,
|
||||||
allAccountsMap,
|
allAccountsMap,
|
||||||
|
|||||||
@@ -247,7 +247,7 @@
|
|||||||
:date-aggregation-type="chartDataDateAggregationType"
|
:date-aggregation-type="chartDataDateAggregationType"
|
||||||
:fiscal-year-start="fiscalYearStart"
|
:fiscal-year-start="fiscalYearStart"
|
||||||
:items="reconciliationStatements?.transactions"
|
:items="reconciliationStatements?.transactions"
|
||||||
:account-currency="currentAccountCurrency"
|
:account="currentAccount"
|
||||||
/>
|
/>
|
||||||
</f7-card-content>
|
</f7-card-content>
|
||||||
</f7-card>
|
</f7-card>
|
||||||
|
|||||||
Reference in New Issue
Block a user