Updated code.

This commit is contained in:
James Cole
2022-06-07 19:46:09 +02:00
parent c3bd46d7c0
commit 86d4549874
6 changed files with 53 additions and 28 deletions

View File

@@ -260,7 +260,7 @@ trait ConvertsExchangeRates
*/
private function getPreference(): void
{
$this->enabled = false;
$this->enabled = true;
}
}

View File

@@ -19,7 +19,6 @@
-->
<template>
<!-- -->
<div class="q-mt-sm q-mr-sm">
<q-card bordered>
<q-item>
@@ -31,9 +30,7 @@
<ApexChart ref="chart" height="350" type="line" :options="options" :series="series"></ApexChart>
</q-card>
</div>
<div>
</div>
</template>
@@ -110,8 +107,15 @@ export default {
},
methods: {
numberFormatter: function (value, index) {
let currencyCode = this.currencies[index] ?? 'EUR';
return Intl.NumberFormat(this.locale, {style: 'currency', currency: currencyCode}).format(value);
if(index instanceof Object) {
let currencyCode = this.currencies[index.seriesIndex] ?? 'EUR';
return Intl.NumberFormat(this.locale, {style: 'currency', currency: currencyCode}).format(value);
}
if(Number.isInteger(index)) {
let currencyCode = this.currencies[index] ?? 'EUR';
return Intl.NumberFormat(this.locale, {style: 'currency', currency: currencyCode}).format(value);
}
return 'x';
},
buildChart: function () {
console.log('buildChart');
@@ -130,6 +134,7 @@ export default {
}
},
generateSeries: function (data) {
console.log('generateSeries');
this.series = [];
let series;
for (let i in data) {
@@ -137,7 +142,12 @@ export default {
series = {};
series.name = data[i].label;
series.data = [];
this.currencies.push(data[i].currency_code);
if(!data[i].converted) {
this.currencies.push(data[i].currency_code);
}
if(data[i].converted) {
this.currencies.push(data[i].native_code);
}
for (let ii in data[i].entries) {
series.data.push(data[i].entries[ii]);
}

View File

@@ -130,19 +130,22 @@ export default {
for (let i in data) {
if (data.hasOwnProperty(i)) {
const current = data[i];
const hasNative = current.native_id !== current.id && current.native_sum !== '0';
const hasNative = current.converted && current.native_id !== current.id && parseFloat(current.native_sum) !== 0.0;
this.unpaid.push(
{
sum: current.sum,
code: current.code,
native_sum: current.native_sum,
native_code: current.native_code,
native_sum: current.converted ? current.native_sum : current.sum,
native_code: current.converted ? current.native_code : current.code,
native: hasNative,
}
);
if (hasNative || current.native_id === current.id) {
if (current.converted && (hasNative || current.native_id === current.id)) {
this.unpaidAmount = this.unpaidAmount + parseFloat(current.native_sum);
}
if (!current.converted) {
this.unpaidAmount = this.unpaidAmount + parseFloat(current.sum);
}
}
}
},
@@ -150,19 +153,22 @@ export default {
for (let i in data) {
if (data.hasOwnProperty(i)) {
const current = data[i];
const hasNative = current.native_id !== current.id && parseFloat(current.native_sum) !== 0.0;
const hasNative = current.converted && current.native_id !== current.id && parseFloat(current.native_sum) !== 0.0;
this.paid.push(
{
sum: current.sum,
code: current.code,
native_sum: current.native_sum,
native_code: current.native_code,
native_sum: current.converted ? current.native_sum : current.sum,
native_code: current.converted ? current.native_code : current.code,
native: hasNative,
}
);
if (hasNative || current.native_id === current.id) {
if (current.converted && (hasNative || current.native_id === current.id)) {
this.paidAmount = this.paidAmount + (parseFloat(current.native_sum) * -1);
}
if (!current.converted) {
this.paidAmount = this.paidAmount + (parseFloat(current.sum) * -1);
}
}
}
}

View File

@@ -101,17 +101,20 @@ export default {
continue;
}
const hasNative = current.native_id !== current.id && current.native_sum !== '0';
if (hasNative || current.native_id === current.id) {
const hasNative = current.converted && current.native_id !== current.id && parseFloat(current.native_sum) !== 0.0;
if (current.converted && (hasNative || current.native_id === current.id)) {
this.primary = this.primary + parseFloat(current.native_sum);
}
if (!current.converted) {
this.primary = this.primary + parseFloat(current.sum);
}
this.netWorth.push(
{
sum: current.sum,
code: current.code,
native_sum: current.native_sum,
native_code: current.native_code,
native_sum: current.converted ? current.native_sum : current.sum,
native_code: current.converted ? current.native_code : current.code,
native: hasNative,
}
);

View File

@@ -131,19 +131,22 @@ export default {
for (let i in data) {
if (data.hasOwnProperty(i)) {
const current = data[i];
const hasNative = current.native_id !== current.id && parseFloat(current.native_sum) !== 0.0;
const hasNative = current.converted && current.native_id !== current.id && parseFloat(current.native_sum) !== 0.0;
this.budgeted.push(
{
sum: current.sum,
code: current.code,
native_sum: current.native_sum,
native_code: current.native_code,
native_sum: current.converted ? current.native_sum : current.sum,
native_code: current.converted ? current.native_code : current.code,
native: hasNative
}
);
if (hasNative || current.native_id === current.id) {
if (current.converted && (hasNative || current.native_id === current.id)) {
this.budgetedAmount = this.budgetedAmount + parseFloat(current.native_sum);
}
if (!current.converted) {
this.budgetedAmount = this.budgetedAmount + parseFloat(current.sum);
}
}
}
},
@@ -151,19 +154,22 @@ export default {
for (let i in data) {
if (data.hasOwnProperty(i)) {
const current = data[i];
const hasNative = current.native_id !== current.id && parseFloat(current.native_sum) !== 0.0;
const hasNative = current.converted && current.native_id !== current.id && parseFloat(current.native_sum) !== 0.0;
this.spent.push(
{
sum: current.sum,
code: current.code,
native_sum: current.native_sum,
native_code: current.native_code,
native_sum: current.converted ? current.native_sum : current.sum,
native_code: current.converted ? current.native_code : current.code,
native: hasNative
}
);
if (hasNative || current.native_id === current.id) {
if (current.converted && (hasNative || current.native_id === current.id)) {
this.spentAmount = this.spentAmount + (parseFloat(current.native_sum) * -1);
}
if (!current.converted) {
this.spentAmount = this.spentAmount + (parseFloat(current.sum) * -1);
}
}
}
},

View File

@@ -94,7 +94,7 @@ export default {
name: "Dashboard",
components: {
AccountChart: defineAsyncComponent(() => import('../../components/dashboard/AccountChart.vue')),
NetWorthInsightBox: defineAsyncComponent(() => import('../../components/dashboard/BillInsightBox.vue')),
NetWorthInsightBox: defineAsyncComponent(() => import('../../components/dashboard/NetWorthInsightBox.vue')),
BillInsightBox: defineAsyncComponent(() => import('../../components/dashboard/BillInsightBox.vue')),
SpendInsightBox: defineAsyncComponent(() => import('../../components/dashboard/SpendInsightBox.vue')),
}