Small update to frontend and associated code.

This commit is contained in:
James Cole
2022-06-05 20:02:43 +02:00
parent 6b2619c5cc
commit 9c08b9f1d3
102 changed files with 974 additions and 519 deletions

38
frontend/src/api/v2/bills/sum.js vendored Normal file
View File

@@ -0,0 +1,38 @@
/*
* list.js
* Copyright (c) 2022 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {api} from "boot/axios";
import {format} from "date-fns";
export default class Sum {
unpaid(start, end) {
let url = 'api/v2/bills/sum/unpaid';
let startStr = format(start, 'y-MM-dd');
let endStr = format(end, 'y-MM-dd');
return api.get(url, {params: {start: startStr, end: endStr}});
}
paid(start, end) {
let url = 'api/v2/bills/sum/paid';
let startStr = format(start, 'y-MM-dd');
let endStr = format(end, 'y-MM-dd');
return api.get(url, {params: {start: startStr, end: endStr}});
}
}

View File

@@ -0,0 +1,178 @@
<!--
- BillInsightBox.vue
- Copyright (c) 2022 james@firefly-iii.org
-
- This file is part of Firefly III (https://github.com/firefly-iii).
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<template>
<!-- TODO most left? q-mr-sm -->
<!-- TODO middle? dan q-mx-sm -->
<!-- TODO right? dan q-ml-sm -->
<div class="q-mr-sm">
<q-card bordered>
<q-item>
<q-item-section>
<q-item-label>{{ $t('firefly.bills_to_pay') }}</q-item-label>
</q-item-section>
</q-item>
<q-separator/>
<q-card-section horizontal>
<q-card-section>
<q-circular-progress
:value="percentage"
size="50px"
:thickness="0.22"
color="green"
track-color="grey-3"
/>
</q-card-section>
<q-separator vertical/>
<q-card-section>
{{ $t('firefly.bills_to_pay') }}:
<span v-for="(bill, index) in unpaid">
{{ formatAmount(bill.code, bill.sum) }}
<span v-if="index+1 !== unpaid.length">, </span>
</span>
<br/>
{{ $t('firefly.bills_paid') }}:
<span v-for="(bill, index) in paid">
{{ formatAmount(bill.code, bill.sum) }}
<span v-if="index+1 !== paid.length">, </span>
</span>
</q-card-section>
</q-card-section>
<!--
<q-card-section class="q-pt-xs">
<div class="text-overline">
<span class="float-right">
<span class="text-grey-4 fas fa-redo-alt" style="cursor: pointer;" @click="triggerForcedUpgrade"></span>
</span>
</div>
</q-card-section>
<q-card-section class="q-pt-xs">
<span v-for="(bill, index) in unpaid">
{{ formatAmount(bill.code, bill.sum) }}
<span v-if="index+1 !== unpaid.length">, </span>
</span>
</q-card-section>
-->
</q-card>
</div>
</template>
<script>
import {useFireflyIIIStore} from "../../stores/fireflyiii";
import Sum from "../../api/v2/bills/sum";
export default {
data() {
return {
store: null,
unpaid: [],
paid: [],
//percentage: 0,
unpaidAmount: 0.0,
paidAmount: 0.0,
range: {
start: null,
end: null,
},
}
},
name: "BillInsightBox",
computed: {
percentage: function () {
if (0 === this.unpaidAmount) {
return 100;
}
const sum = this.unpaidAmount + this.paidAmount;
if (0.0 === this.paidAmount) {
return 0;
}
return (this.paidAmount / sum) * 100;
}
},
mounted() {
this.store = useFireflyIIIStore();
// TODO this code snippet is recycled a lot.
if (null === this.range.start || null === this.range.end) {
// subscribe, then update:
this.store.$onAction(
({name, $store, args, after, onError,}) => {
after((result) => {
if (name === 'setRange') {
this.range = result;
this.triggerUpdate();
}
})
}
)
}
this.triggerUpdate();
},
methods: {
triggerUpdate: function () {
if (null !== this.store.getRange.start && null !== this.store.getRange.end) {
this.unpaid = [];
const start = new Date(this.store.getRange.start);
const end = new Date(this.store.getRange.end);
const sum = new Sum;
sum.unpaid(start, end).then((response) => this.parseUnpaidResponse(response.data));
sum.paid(start, end).then((response) => this.parsePaidResponse(response.data));
}
},
formatAmount: function (currencyCode, amount) {
// TODO not yet internationalized
return Intl.NumberFormat('en-US', {style: 'currency', currency: currencyCode}).format(amount);
},
parseUnpaidResponse: function (data) {
for (let i in data) {
if (data.hasOwnProperty(i)) {
const current = data[i];
this.unpaid.push(
{
sum: current.sum,
code: current.code,
}
);
this.unpaidAmount = this.unpaidAmount + parseFloat(current.sum);
}
}
},
parsePaidResponse: function (data) {
for (let i in data) {
if (data.hasOwnProperty(i)) {
const current = data[i];
this.paid.push(
{
sum: current.sum,
code: current.code,
}
);
this.paidAmount = this.paidAmount + (parseFloat(current.sum) * -1);
}
}
}
}
}
</script>
<style scoped>
</style>

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "\u041d\u043e\u0432\u043e \u043f\u0440\u0435\u0445\u0432\u044a\u0440\u043b\u044f\u043d\u0435",
"newDeposit": "\u041d\u043e\u0432 \u0434\u0435\u043f\u043e\u0437\u0438\u0442",
"newWithdrawal": "\u041d\u043e\u0432 \u0440\u0430\u0437\u0445\u043e\u0434",
"bills_paid": "\u041f\u043b\u0430\u0442\u0435\u043d\u0438 \u0441\u043c\u0435\u0442\u043a\u0438",
"rule_trigger_source_account_starts_choice": "\u0418\u043c\u0435\u0442\u043e \u043d\u0430 \u0440\u0430\u0437\u0445\u043e\u0434\u043d\u0430\u0442\u0430 \u0441\u043c\u0435\u0442\u043a\u0430 \u0437\u0430\u043f\u043e\u0447\u0432\u0430 \u0441..",
"rule_trigger_source_account_ends_choice": "\u0418\u043c\u0435\u0442\u043e \u043d\u0430 \u0440\u0430\u0437\u0445\u043e\u0434\u043d\u0430\u0442\u0430 \u0441\u043c\u0435\u0442\u043a\u0430 \u0437\u0430\u0432\u044a\u0440\u0448\u0432\u0430 \u0441..",
"rule_trigger_source_account_is_choice": "\u0418\u043c\u0435\u0442\u043e \u043d\u0430 \u0440\u0430\u0437\u0445\u043e\u0434\u043d\u0430\u0442\u0430 \u0441\u043c\u0435\u0442\u043a\u0430 \u0435..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Nov\u00fd p\u0159evod",
"newDeposit": "Nov\u00fd vklad",
"newWithdrawal": "Nov\u00fd v\u00fddaj",
"bills_paid": "Zaplacen\u00e9 \u00fa\u010dty",
"rule_trigger_source_account_starts_choice": "Source account name starts with..",
"rule_trigger_source_account_ends_choice": "Source account name ends with..",
"rule_trigger_source_account_is_choice": "Source account name is..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Neue Umbuchung",
"newDeposit": "Neue Einnahme",
"newWithdrawal": "Neue Ausgabe",
"bills_paid": "Rechnungen bezahlt",
"rule_trigger_source_account_starts_choice": "Name des Quellkontos beginnt mit..",
"rule_trigger_source_account_ends_choice": "Quellkonto-Name endet mit..",
"rule_trigger_source_account_is_choice": "Quellkonto-Name lautet..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "\u039d\u03ad\u03b1 \u03bc\u03b5\u03c4\u03b1\u03c6\u03bf\u03c1\u03ac",
"newDeposit": "\u039d\u03ad\u03b1 \u03ba\u03b1\u03c4\u03ac\u03b8\u03b5\u03c3\u03b7",
"newWithdrawal": "\u039d\u03ad\u03b1 \u03b4\u03b1\u03c0\u03ac\u03bd\u03b7",
"bills_paid": "\u03a0\u03bb\u03b7\u03c1\u03c9\u03bc\u03ad\u03bd\u03b1 \u03c0\u03ac\u03b3\u03b9\u03b1 \u03ad\u03be\u03bf\u03b4\u03b1",
"rule_trigger_source_account_starts_choice": "\u03a4\u03bf \u03cc\u03bd\u03bf\u03bc\u03b1 \u03c4\u03bf\u03c5 \u03bb\u03bf\u03b3\u03b1\u03c1\u03b9\u03b1\u03c3\u03bc\u03bf\u03cd \u03c0\u03c1\u03bf\u03ad\u03bb\u03b5\u03c5\u03c3\u03b7\u03c2 \u03b1\u03c1\u03c7\u03af\u03b6\u03b5\u03b9 \u03bc\u03b5..",
"rule_trigger_source_account_ends_choice": "\u03a4\u03bf \u03cc\u03bd\u03bf\u03bc\u03b1 \u03c4\u03bf\u03c5 \u03bb\u03bf\u03b3\u03b1\u03c1\u03b9\u03b1\u03c3\u03bc\u03bf\u03cd \u03c0\u03c1\u03bf\u03ad\u03bb\u03b5\u03c5\u03c3\u03b7\u03c2 \u03c4\u03b5\u03bb\u03b5\u03b9\u03ce\u03bd\u03b5\u03b9 \u03bc\u03b5..",
"rule_trigger_source_account_is_choice": "\u03a4\u03bf \u03cc\u03bd\u03bf\u03bc\u03b1 \u03c4\u03bf\u03c5 \u03bb\u03bf\u03b3\u03b1\u03c1\u03b9\u03b1\u03c3\u03bc\u03bf\u03cd \u03c0\u03c1\u03bf\u03ad\u03bb\u03b5\u03c5\u03c3\u03b7\u03c2 \u03b5\u03af\u03bd\u03b1\u03b9..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "New transfer",
"newDeposit": "New deposit",
"newWithdrawal": "New expense",
"bills_paid": "Bills paid",
"rule_trigger_source_account_starts_choice": "Source account name starts with..",
"rule_trigger_source_account_ends_choice": "Source account name ends with..",
"rule_trigger_source_account_is_choice": "Source account name is..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "New transfer",
"newDeposit": "New deposit",
"newWithdrawal": "New expense",
"bills_paid": "Bills paid",
"rule_trigger_source_account_starts_choice": "Source account name starts with..",
"rule_trigger_source_account_ends_choice": "Source account name ends with..",
"rule_trigger_source_account_is_choice": "Source account name is..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Nueva transferencia",
"newDeposit": "Nuevo deposito",
"newWithdrawal": "Nuevo gasto",
"bills_paid": "Facturas pagadas",
"rule_trigger_source_account_starts_choice": "El nombre de la cuenta de origen comienza con..",
"rule_trigger_source_account_ends_choice": "El nombre de la cuenta de origen termina con..",
"rule_trigger_source_account_is_choice": "El nombre de la cuenta origen es..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Uusi siirto",
"newDeposit": "Uusi talletus",
"newWithdrawal": "Uusi kustannus",
"bills_paid": "Maksetut laskut",
"rule_trigger_source_account_starts_choice": "L\u00e4hdetilin nimi alkaa ...",
"rule_trigger_source_account_ends_choice": "L\u00e4hdetilin nimi p\u00e4\u00e4ttyy..",
"rule_trigger_source_account_is_choice": "L\u00e4hdetilin nimi on..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Nouveau transfert",
"newDeposit": "Nouveau d\u00e9p\u00f4t",
"newWithdrawal": "Nouvelle d\u00e9pense",
"bills_paid": "Factures pay\u00e9es",
"rule_trigger_source_account_starts_choice": "Le nom du compte source commence par..",
"rule_trigger_source_account_ends_choice": "Le nom du compte source se termine par..",
"rule_trigger_source_account_is_choice": "Le nom du compte source est..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "\u00daj \u00e1tvezet\u00e9s",
"newDeposit": "\u00daj bev\u00e9tel",
"newWithdrawal": "\u00daj k\u00f6lts\u00e9g",
"bills_paid": "Befizetett sz\u00e1ml\u00e1k",
"rule_trigger_source_account_starts_choice": "Forr\u00e1ssz\u00e1mla nev\u00e9nek eleje..",
"rule_trigger_source_account_ends_choice": "Forr\u00e1ssz\u00e1mla nev\u00e9nek v\u00e9ge..",
"rule_trigger_source_account_is_choice": "A forr\u00e1ssz\u00e1mla neve..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Nuovo trasferimento",
"newDeposit": "Nuova entrata",
"newWithdrawal": "Nuova uscita",
"bills_paid": "Bollette pagate",
"rule_trigger_source_account_starts_choice": "Il nome del conto di origine inizia con..",
"rule_trigger_source_account_ends_choice": "Il nome del conto di origine termina con..",
"rule_trigger_source_account_is_choice": "Il nome del conto di origine \u00e8..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "\u65b0\u3057\u3044\u9001\u91d1",
"newDeposit": "\u65b0\u3057\u3044\u5165\u91d1",
"newWithdrawal": "\u65b0\u3057\u3044\u652f\u51fa",
"bills_paid": "\u652f\u6255\u3044\u6e08\u307f\u8acb\u6c42",
"rule_trigger_source_account_starts_choice": "\u51fa\u91d1\u5143\u53e3\u5ea7\u540d\u304c...\u3067\u59cb\u307e\u308b",
"rule_trigger_source_account_ends_choice": "\u51fa\u91d1\u5143\u53e3\u5ea7\u540d\u304c\u2026\u3067\u7d42\u308f\u308b",
"rule_trigger_source_account_is_choice": "\u51fa\u91d1\u5143\u53e3\u5ea7\u540d\u304c...",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Ny overf\u00f8ring",
"newDeposit": "Nytt innskudd",
"newWithdrawal": "Ny utgift",
"bills_paid": "Regninger betalt",
"rule_trigger_source_account_starts_choice": "Source account name starts with..",
"rule_trigger_source_account_ends_choice": "Source account name ends with..",
"rule_trigger_source_account_is_choice": "Source account name is..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Nieuwe overschrijving",
"newDeposit": "Nieuwe inkomsten",
"newWithdrawal": "Nieuwe uitgave",
"bills_paid": "Betaalde contracten",
"rule_trigger_source_account_starts_choice": "Bronrekeningnaam begint met..",
"rule_trigger_source_account_ends_choice": "Bronrekeningnaam eindigt op..",
"rule_trigger_source_account_is_choice": "Bronrekeningnaam is..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Nowy transfer",
"newDeposit": "Nowa wp\u0142ata",
"newWithdrawal": "Nowy wydatek",
"bills_paid": "Zap\u0142acone rachunki",
"rule_trigger_source_account_starts_choice": "Konto \u017ar\u00f3d\u0142owe si\u0119 zaczyna od..",
"rule_trigger_source_account_ends_choice": "Konto \u017ar\u00f3d\u0142owe ko\u0144czy si\u0119 na..",
"rule_trigger_source_account_is_choice": "Kontem \u017ar\u00f3d\u0142owym jest..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Nova transfer\u00eancia",
"newDeposit": "Novo dep\u00f3sito",
"newWithdrawal": "Nova despesa",
"bills_paid": "Contas pagas",
"rule_trigger_source_account_starts_choice": "Nome da conta de origem come\u00e7a com..",
"rule_trigger_source_account_ends_choice": "O nome da conta de origem termina com..",
"rule_trigger_source_account_is_choice": "Nome da conta de origem \u00e9..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Nova transfer\u00eancia",
"newDeposit": "Novo dep\u00f3sito",
"newWithdrawal": "Nova despesa",
"bills_paid": "Fatura pagas",
"rule_trigger_source_account_starts_choice": "O nome da conta de origem come\u00e7a com..",
"rule_trigger_source_account_ends_choice": "O nome da conta de origem acaba com..",
"rule_trigger_source_account_is_choice": "O nome da conta de origem \u00e9..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Transfer nou",
"newDeposit": "Depozit nou",
"newWithdrawal": "Cheltuieli noi",
"bills_paid": "Facturile pl\u0103tite",
"rule_trigger_source_account_starts_choice": "Numele contului surs\u0103 \u00eencepe cu..",
"rule_trigger_source_account_ends_choice": "Numele contului surs\u0103 se termin\u0103 cu..",
"rule_trigger_source_account_is_choice": "Numele contului surs\u0103 este..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "\u041d\u043e\u0432\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434",
"newDeposit": "\u041d\u043e\u0432\u044b\u0439 \u0434\u043e\u0445\u043e\u0434",
"newWithdrawal": "\u041d\u043e\u0432\u044b\u0439 \u0440\u0430\u0441\u0445\u043e\u0434",
"bills_paid": "\u041e\u043f\u043b\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0441\u0447\u0435\u0442\u0430",
"rule_trigger_source_account_starts_choice": "\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0447\u0451\u0442\u0430-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441..",
"rule_trigger_source_account_ends_choice": "\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0447\u0451\u0442\u0430-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430..",
"rule_trigger_source_account_is_choice": "\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0447\u0451\u0442\u0430-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Nov\u00fd p\u0159evod",
"newDeposit": "Nov\u00fd vklad",
"newWithdrawal": "Nov\u00fd v\u00fddavok",
"bills_paid": "Zaplaten\u00e9 \u00fa\u010dty",
"rule_trigger_source_account_starts_choice": "N\u00e1zov zdrojov\u00e9ho \u00fa\u010dtu za\u010d\u00edna..",
"rule_trigger_source_account_ends_choice": "N\u00e1zov zdrojov\u00e9ho \u00fa\u010dtu kon\u010d\u00ed..",
"rule_trigger_source_account_is_choice": "N\u00e1zov zdrojov\u00e9ho \u00fa\u010dtu je..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Ny \u00f6verf\u00f6ring",
"newDeposit": "Ny ins\u00e4ttning",
"newWithdrawal": "Ny utgift",
"bills_paid": "Notor betalda",
"rule_trigger_source_account_starts_choice": "K\u00e4llkontonamn b\u00f6rjar med..",
"rule_trigger_source_account_ends_choice": "K\u00e4llkontonamn slutar med..",
"rule_trigger_source_account_is_choice": "K\u00e4llkontonamn \u00e4r..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "Chuy\u1ec3n kho\u1ea3n m\u1edbi",
"newDeposit": "Ti\u1ec1n g\u1eedi m\u1edbi",
"newWithdrawal": "Chi ph\u00ed m\u1edbi",
"bills_paid": "H\u00f3a \u0111\u01a1n thanh to\u00e1n",
"rule_trigger_source_account_starts_choice": "Source account name starts with..",
"rule_trigger_source_account_ends_choice": "Source account name ends with..",
"rule_trigger_source_account_is_choice": "Source account name is..",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "\u65b0\u8f6c\u8d26",
"newDeposit": "\u65b0\u6536\u5165",
"newWithdrawal": "\u65b0\u652f\u51fa",
"bills_paid": "\u5df2\u4ed8\u8d26\u5355",
"rule_trigger_source_account_starts_choice": "\u6765\u6e90\u8d26\u6237\u540d\u79f0\u5f00\u5934\u4e3a...",
"rule_trigger_source_account_ends_choice": "\u6765\u6e90\u8d26\u6237\u7ed3\u5c3e\u4e3a\u2026",
"rule_trigger_source_account_is_choice": "\u6765\u6e90\u8d26\u6237\u540d\u79f0\u4e3a...",

View File

@@ -51,6 +51,7 @@ export default {
"newTransfer": "\u65b0\u8f49\u5e33",
"newDeposit": "\u65b0\u5b58\u6b3e",
"newWithdrawal": "\u65b0\u652f\u51fa",
"bills_paid": "\u5df2\u7e73\u5e33\u55ae",
"rule_trigger_source_account_starts_choice": "Source account name starts with..",
"rule_trigger_source_account_ends_choice": "Source account name ends with..",
"rule_trigger_source_account_is_choice": "Source account name is..",