Verified Commit 72eaf828 authored by jxtxzzw's avatar jxtxzzw
Browse files

新增:允许在可用资产中选择是否包括未决款项



Signed-off-by: jxtxzzw's avatarjxtxzzw <jxtxzzw@126.com>
parent f6641ef8
Pipeline #734 passed with stages
in 13 minutes and 42 seconds
......@@ -4,34 +4,47 @@
"date": "2019-04-03",
"amount": "600.00",
"currency": "CNY",
"currency_weight": "1.0"
"currency_weight": "1.0",
"pending": false
},
{
"id": "2",
"date": "2019-10-03",
"amount": "4300.00",
"currency": "CNY",
"currency_weight": "1.0"
"currency_weight": "1.0",
"pending": false
},
{
"id": "3",
"date": "2019-10-03",
"amount": "1100.00",
"currency": "USD",
"currency_weight": "10.0"
"currency_weight": "10.0",
"pending": false
},
{
"id": "3",
"date": "2020-10-03",
"amount": "1100.00",
"currency": "CNY",
"currency_weight": "1.0"
"currency_weight": "1.0",
"pending": false
},
{
"id": "4",
"date": "2022-10-03",
"amount": "333.00",
"currency": "USD",
"currency_weight": "3.0"
"currency_weight": "3.0",
"pending": false
},
{
"id": "5",
"date": "2022-10-03",
"amount": "250.00",
"currency": "USD",
"currency_weight": "3.0",
"pending": true
}
]
......@@ -891,10 +891,13 @@ export function renderChartForAdvancedPlatform(that, rawData) {
return chart
}
function getBalanceData(rawData) {
function getBalanceData(rawData, includePendingBalance) {
const currencies = []
const dict = []
for (const x of rawData) {
if (x.pending && !includePendingBalance) {
continue
}
if (!dict[x.date]) {
dict[x.date] = {}
}
......@@ -911,8 +914,8 @@ function getBalanceData(rawData) {
weightedAmount: 0.0,
}
}
dict[x.date][x.currency].amount = amount
dict[x.date][x.currency].weightedAmount = amount * currencyWeight
dict[x.date][x.currency].amount += amount
dict[x.date][x.currency].weightedAmount += amount * currencyWeight
}
const data = []
......@@ -937,12 +940,16 @@ function onlyUnique(value, index, self) {
return self.indexOf(value) === index
}
export function renderChartForBalance(that, rawData) {
export function renderChartForBalance(
that,
rawData,
includePendingBalance = false
) {
const $container = document.getElementById('balance')
$container.innerHTML = `
<div id="app-container-balance">
<div id="g2-customize-tooltip-balance"></div>
<div id="g2-container-balance"></div>
<div id='app-container-balance'>
<div id='g2-customize-tooltip-balance'></div>
<div id='g2-container-balance'></div>
</div>
`
......@@ -953,7 +960,7 @@ export function renderChartForBalance(that, rawData) {
height: chartHeight(),
})
const data = getBalanceData(rawData)
const data = getBalanceData(rawData, includePendingBalance)
chart.data(data)
// 这里的 value 值都是 weightedAmount
......@@ -1003,8 +1010,8 @@ export function renderChartForBalance(that, rawData) {
function getTooltipHTML(data) {
const { title, items } = data
return `
<div class="tooltip-title">${title}</div>
<div class="tooltip-items">
<div class='tooltip-title'>${title}</div>
<div class='tooltip-items'>
${items
.map((datum) => {
const color = datum.color
......@@ -1013,9 +1020,9 @@ export function renderChartForBalance(that, rawData) {
const originalAmount = datum.data.originalAmount // 取出没有乘上汇率的值
return `
<div class="tooltip-item" style="border-left: 2px solid ${color}">
<div class="tooltip-item-name">${name} (Weighted ${name})</div>
<div class="tooltip-item-value">${originalAmount} (${value})</div>
<div class='tooltip-item' style='border-left: 2px solid ${color}'>
<div class='tooltip-item-name'>${name} (Weighted ${name})</div>
<div class='tooltip-item-value'>${originalAmount} (${value})</div>
</div>
`
})
......
......@@ -255,7 +255,8 @@
"advanced-year": "Advanced Income for Each Year",
"advanced-platform": "Advanced Income for Platforms",
"balance": "Balance",
"no-negative": "Negative amounts (e.g., tax, re-bill) are not included."
"no-negative": "Negative amounts (e.g., tax, re-bill) are not included.",
"show-pending": "Also include pending balances"
},
"credit": {
"source": "Source",
......
......@@ -255,7 +255,8 @@
"advanced-year": "每年被动收入",
"advanced-platform": "被动收入平台",
"balance": "可用资产",
"no-negative": "负数金额(例如税收、再分配)没有被统计。"
"no-negative": "负数金额(例如税收、再分配)没有被统计。",
"show-pending": "包括未决款项"
},
"credit": {
"source": "数据源",
......
......@@ -14,6 +14,17 @@
<span slot="close">{{ $t('income.close') }}</span>
</i-switch>
</Alert>
<Alert>
<CheckboxGroup
v-model="showPendingCheckGroup"
@on-change="renderAllCharts(['balance'])"
>
<Checkbox
:key="$t('income.show-pending')"
:label="$t('income.show-pending')"
></Checkbox>
</CheckboxGroup>
</Alert>
<div id="balance"></div>
<Divider>{{ $t('income.all-accumulated') }}</Divider>
......@@ -123,6 +134,7 @@ export default {
advancedIncomeChartForAdvancedPlatform: undefined,
balance: undefined,
},
showPendingCheckGroup: [],
}
},
watch: {
......@@ -203,7 +215,11 @@ export default {
)
}
if (charts.includes('balance')) {
this.oldChart.balance = incomeUtil.renderChartForBalance(this, balance)
this.oldChart.balance = incomeUtil.renderChartForBalance(
this,
balance,
this.showPendingCheckGroup.length > 0
)
}
// Chart 都是 autoFit 的,所以强制触发一次 resize 就可以了
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment