Rebuild front

This commit is contained in:
James Cole 2020-11-29 07:06:55 +01:00
parent a5b6bf5797
commit b38e7cbb1a
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
22 changed files with 301 additions and 54 deletions

View File

@ -0,0 +1,130 @@
<?php
/*
* DateController.php
* Copyright (c) 2020 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/>.
*/
namespace FireflyIII\Api\V1\Controllers\Insight\Income;
use Carbon\Carbon;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\DateRequest;
use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\Http\Api\ApiSupport;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
/**
* Class DateController
*
* Shows income information grouped or limited by date.
* Ie. all income grouped by revenue + currency.
*/
class DateController extends Controller
{
use ApiSupport;
private CurrencyRepositoryInterface $currencyRepository;
private AccountRepositoryInterface $repository;
/**
* AccountController constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser($user);
$this->currencyRepository = app(CurrencyRepositoryInterface::class);
$this->currencyRepository->setUser($user);
return $next($request);
}
);
}
/**
*
*/
public function basic(DateRequest $request): JsonResponse
{
// parameters for chart:
$dates = $request->getAll();
/** @var Carbon $start */
$start = $dates['start'];
/** @var Carbon $end */
$end = $dates['end'];
$start->subDay();
// prep some vars:
$currencies = [];
$chartData = [];
$tempData = [];
// grab all accounts and names
$accounts = $this->repository->getAccountsByType([AccountType::REVENUE]);
$accountNames = $this->extractNames($accounts);
$startBalances = app('steam')->balancesPerCurrencyByAccounts($accounts, $start);
$endBalances = app('steam')->balancesPerCurrencyByAccounts($accounts, $end);
// loop the end balances. This is an array for each account ($expenses)
foreach ($endBalances as $accountId => $expenses) {
$accountId = (int)$accountId;
// loop each expense entry (each entry can be a different currency).
foreach ($expenses as $currencyId => $endAmount) {
$currencyId = (int)$currencyId;
// see if there is an accompanying start amount.
// grab the difference and find the currency.
$startAmount = $startBalances[$accountId][$currencyId] ?? '0';
$diff = bcsub($endAmount, $startAmount);
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->findNull($currencyId);
if (0 !== bccomp($diff, '0')) {
// store the values in a temporary array.
$tempData[] = [
'id' => $accountId,
'name' => $accountNames[$accountId],
'difference' => $diff,
'difference_float' => (float)$diff,
'currency_id' => $currencyId,
'currency_code' => $currencies[$currencyId]->code,
];
}
}
}
// sort temp array by amount.
$amounts = array_column($tempData, 'difference_float');
array_multisort($amounts, SORT_ASC, $tempData);
return response()->json($tempData);
}
}

View File

@ -1,22 +1,12 @@
{
"/public/js/manifest.js": "/public/js/manifest.js",
"/public/js/manifest.js.map": "/public/js/manifest.js.map",
"/public/js/vendor.js": "/public/js/vendor.js",
"/public/js/vendor.js.map": "/public/js/vendor.js.map",
"/public/js/accounts/index.js": "/public/js/accounts/index.js",
"/public/js/accounts/index.js.map": "/public/js/accounts/index.js.map",
"/public/js/accounts/show.js": "/public/js/accounts/show.js",
"/public/js/accounts/show.js.map": "/public/js/accounts/show.js.map",
"/public/js/dashboard.js": "/public/js/dashboard.js",
"/public/css/app.css": "/public/css/app.css",
"/public/js/dashboard.js.map": "/public/js/dashboard.js.map",
"/public/css/app.css.map": "/public/css/app.css.map",
"/public/js/empty.js": "/public/js/empty.js",
"/public/js/empty.js.map": "/public/js/empty.js.map",
"/public/js/manifest.js": "/public/js/manifest.js",
"/public/js/new-user/index.js": "/public/js/new-user/index.js",
"/public/js/new-user/index.js.map": "/public/js/new-user/index.js.map",
"/public/js/register.js": "/public/js/register.js",
"/public/js/register.js.map": "/public/js/register.js.map",
"/public/js/transactions/create.js": "/public/js/transactions/create.js",
"/public/js/transactions/create.js.map": "/public/js/transactions/create.js.map"
"/public/js/vendor.js": "/public/js/vendor.js"
}

View File

@ -48,7 +48,7 @@
<main-debit-list />
</div>
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
<main-credit/>
<main-credit-list />
</div>
</div>

View File

@ -0,0 +1,97 @@
<!--
- MainCreditList.vue
- Copyright (c) 2020 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>
<div class="card">
<div class="card-header">
<h3 class="card-title">{{ $t('firefly.revenue_accounts') }}</h3>
</div>
<div class="card-body table-responsive p-0">
<table class="table table-sm">
<tbody>
<tr v-for="entry in income">
<td style="width:20%;"><a :href="'./accounts/show/' + entry.id">{{ entry.name }}</a></td>
<td class="align-middle">
<div class="progress" v-if="entry.pct > 0">
<div class="progress-bar progress-bar-striped bg-success" role="progressbar" :aria-valuenow="entry.pct"
:style="{ width: entry.pct + '%'}" aria-valuemin="0"
aria-valuemax="100">
<span v-if="entry.pct > 20">
{{ Intl.NumberFormat(locale, {style: 'currency', currency: entry.currency_code}).format(entry.difference_float) }}
</span>
</div>
<span v-if="entry.pct <= 20">&nbsp;
{{ Intl.NumberFormat(locale, {style: 'currency', currency: entry.currency_code}).format(entry.difference_float) }}
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="card-footer">
<a href="./transactions/deposit" class="btn btn-default button-sm"><i class="far fa-money-bill-alt"></i> {{ $t('firefly.go_to_deposits') }}</a>
</div>
</div>
</template>
<script>
export default {
name: "MainCreditList",
data() {
return {
locale: 'en-US',
income: [],
max: 0
}
},
created() {
this.locale = localStorage.locale ?? 'en-US';
this.getExpenses();
},
methods: {
getExpenses() {
axios.get('./api/v1/insight/income/date/basic?start=' + window.sessionStart + '&end=' + window.sessionEnd)
.then(response => {
// do something with response.
this.parseExpenses(response.data);
});
},
parseExpenses(data) {
for (let mainKey in data) {
if (data.hasOwnProperty(mainKey) && /^0$|^[1-9]\d*$/.test(mainKey) && mainKey <= 4294967294) {
// contains currency info and entries.
let current = data[mainKey];
if (0 === parseInt(mainKey)) {
this.max = data[mainKey].difference_float;
current.pct = 100;
}
if(0 !== parseInt(mainKey)) {
// calc percentage:
current.pct = (data[mainKey].difference_float / this.max) * 100;
}
this.income.push(current);
}
}
}
}
}
</script>

View File

@ -47,7 +47,7 @@
</table>
</div>
<div class="card-footer">
<a href="./transactions/withdrawals" class="btn btn-default button-sm"><i class="far fa-money-bill-alt"></i> {{ $t('firefly.go_to_expenses') }}</a>
<a href="./transactions/withdrawal" class="btn btn-default button-sm"><i class="far fa-money-bill-alt"></i> {{ $t('firefly.go_to_withdrawals') }}</a>
</div>
</div>
</template>
@ -91,13 +91,7 @@ export default {
}
}
console.log(this.expenses);
// sort:
}
}
}
</script>
<style scoped>
</style>

View File

@ -35,13 +35,15 @@
"account_role_sharedAsset": "\u0421\u043c\u0435\u0442\u043a\u0430 \u0437\u0430 \u0441\u043f\u043e\u0434\u0435\u043b\u0435\u043d\u0438 \u0430\u043a\u0442\u0438\u0432\u0438",
"account_role_ccAsset": "\u041a\u0440\u0435\u0434\u0438\u0442\u043d\u0430 \u043a\u0430\u0440\u0442\u0430",
"account_role_cashWalletAsset": "\u041f\u0430\u0440\u0438\u0447\u0435\u043d \u043f\u043e\u0440\u0442\u0444\u0435\u0439\u043b",
"daily_budgets": "Daily budgets",
"weekly_budgets": "Weekly budgets",
"monthly_budgets": "Monthly budgets",
"quarterly_budgets": "Quarterly budgets",
"half_year_budgets": "Half-yearly budgets",
"yearly_budgets": "Yearly budgets",
"other_budgets": "Custom timed budgets"
"daily_budgets": "\u0414\u043d\u0435\u0432\u043d\u0438 \u0431\u044e\u0434\u0436\u0435\u0442\u0438",
"weekly_budgets": "\u0421\u0435\u0434\u043c\u0438\u0447\u043d\u0438 \u0431\u044e\u0434\u0436\u0435\u0442\u0438",
"monthly_budgets": "\u041c\u0435\u0441\u0435\u0447\u043d\u0438 \u0431\u044e\u0434\u0436\u0435\u0442\u0438",
"quarterly_budgets": "\u0422\u0440\u0438\u043c\u0435\u0441\u0435\u0447\u043d\u0438 \u0431\u044e\u0434\u0436\u0435\u0442\u0438",
"half_year_budgets": "\u0428\u0435\u0441\u0442\u043c\u0435\u0441\u0435\u0447\u043d\u0438 \u0431\u044e\u0434\u0436\u0435\u0442\u0438",
"yearly_budgets": "\u0413\u043e\u0434\u0438\u0448\u043d\u0438 \u0431\u044e\u0434\u0436\u0435\u0442\u0438",
"other_budgets": "\u0412\u0440\u0435\u043c\u0435\u0432\u043e \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0430\u043d\u0438 \u0431\u044e\u0434\u0436\u0435\u0442\u0438",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "\u0421\u043c\u0435\u0442\u043a\u0438 \u0437\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438"
},
"list": {
"piggy_bank": "\u041a\u0430\u0441\u0438\u0447\u043a\u0430",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Quarterly budgets",
"half_year_budgets": "Half-yearly budgets",
"yearly_budgets": "Yearly budgets",
"other_budgets": "Custom timed budgets"
"other_budgets": "Custom timed budgets",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "P\u0159\u00edjmov\u00e9 \u00fa\u010dty"
},
"list": {
"piggy_bank": "Pokladni\u010dka",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Quartalsbudgets",
"half_year_budgets": "Halbjahresbudgets",
"yearly_budgets": "Jahresbudgets",
"other_budgets": "Zeitlich befristete Budgets"
"other_budgets": "Zeitlich befristete Budgets",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "Einnahmekonten"
},
"list": {
"piggy_bank": "Sparschwein",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Quarterly budgets",
"half_year_budgets": "Half-yearly budgets",
"yearly_budgets": "Yearly budgets",
"other_budgets": "Custom timed budgets"
"other_budgets": "Custom timed budgets",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "\u0388\u03c3\u03bf\u03b4\u03b1"
},
"list": {
"piggy_bank": "\u039a\u03bf\u03c5\u03bc\u03c0\u03b1\u03c1\u03ac\u03c2",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Quarterly budgets",
"half_year_budgets": "Half-yearly budgets",
"yearly_budgets": "Yearly budgets",
"other_budgets": "Custom timed budgets"
"other_budgets": "Custom timed budgets",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "Revenue accounts"
},
"list": {
"piggy_bank": "Piggy bank",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Quarterly budgets",
"half_year_budgets": "Half-yearly budgets",
"yearly_budgets": "Yearly budgets",
"other_budgets": "Custom timed budgets"
"other_budgets": "Custom timed budgets",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "Revenue accounts"
},
"list": {
"piggy_bank": "Piggy bank",

View File

@ -35,13 +35,15 @@
"account_role_sharedAsset": "Cuenta de ingresos compartida",
"account_role_ccAsset": "Tarjeta de Cr\u00e9dito",
"account_role_cashWalletAsset": "Billetera de efectivo",
"daily_budgets": "Daily budgets",
"weekly_budgets": "Weekly budgets",
"monthly_budgets": "Monthly budgets",
"quarterly_budgets": "Quarterly budgets",
"half_year_budgets": "Half-yearly budgets",
"yearly_budgets": "Yearly budgets",
"other_budgets": "Custom timed budgets"
"daily_budgets": "Presupuestos diarios",
"weekly_budgets": "Presupuestos semanales",
"monthly_budgets": "Presupuestos mensuales",
"quarterly_budgets": "Presupuestos trimestrales",
"half_year_budgets": "Presupuestos semestrales",
"yearly_budgets": "Presupuestos anuales",
"other_budgets": "Presupuestos de tiempo personalizado",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "Cuentas de ingresos"
},
"list": {
"piggy_bank": "Alcancilla",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Budgets trimestriels",
"half_year_budgets": "Budgets semestriels",
"yearly_budgets": "Budgets annuels",
"other_budgets": "Budgets \u00e0 p\u00e9riode personnalis\u00e9e"
"other_budgets": "Budgets \u00e0 p\u00e9riode personnalis\u00e9e",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "Comptes de recettes"
},
"list": {
"piggy_bank": "Tirelire",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Quarterly budgets",
"half_year_budgets": "Half-yearly budgets",
"yearly_budgets": "Yearly budgets",
"other_budgets": "Custom timed budgets"
"other_budgets": "Custom timed budgets",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "J\u00f6vedelemsz\u00e1ml\u00e1k"
},
"list": {
"piggy_bank": "Malacpersely",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Bilanci trimestrali",
"half_year_budgets": "Bilanci semestrali",
"yearly_budgets": "Budget annuali",
"other_budgets": "Budget a periodi personalizzati"
"other_budgets": "Budget a periodi personalizzati",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "Conti entrate"
},
"list": {
"piggy_bank": "Salvadanaio",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Quarterly budgets",
"half_year_budgets": "Half-yearly budgets",
"yearly_budgets": "Yearly budgets",
"other_budgets": "Custom timed budgets"
"other_budgets": "Custom timed budgets",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "Inntektskontoer"
},
"list": {
"piggy_bank": "Sparegris",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Driemaandelijkse budgetten",
"half_year_budgets": "Halfjaarlijkse budgetten",
"yearly_budgets": "Jaarlijkse budgetten",
"other_budgets": "Aangepaste budgetten"
"other_budgets": "Aangepaste budgetten",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "Debiteuren"
},
"list": {
"piggy_bank": "Spaarpotje",

View File

@ -35,13 +35,15 @@
"account_role_sharedAsset": "Wsp\u00f3\u0142dzielone konto aktyw\u00f3w",
"account_role_ccAsset": "Karta kredytowa",
"account_role_cashWalletAsset": "Portfel got\u00f3wkowy",
"daily_budgets": "Daily budgets",
"weekly_budgets": "Weekly budgets",
"monthly_budgets": "Monthly budgets",
"quarterly_budgets": "Quarterly budgets",
"half_year_budgets": "Half-yearly budgets",
"yearly_budgets": "Yearly budgets",
"other_budgets": "Custom timed budgets"
"daily_budgets": "Bud\u017cety dzienne",
"weekly_budgets": "Bud\u017cety tygodniowe",
"monthly_budgets": "Bud\u017cety miesi\u0119czne",
"quarterly_budgets": "Bud\u017cety kwartalne",
"half_year_budgets": "Bud\u017cety p\u00f3\u0142roczne",
"yearly_budgets": "Bud\u017cety roczne",
"other_budgets": "Bud\u017cety niestandardowe",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "Konta przychod\u00f3w"
},
"list": {
"piggy_bank": "Skarbonka",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Or\u00e7amentos trimestrais",
"half_year_budgets": "Or\u00e7amentos semestrais",
"yearly_budgets": "Or\u00e7amentos anuais",
"other_budgets": "Custom timed budgets"
"other_budgets": "Custom timed budgets",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "Contas de receitas"
},
"list": {
"piggy_bank": "Cofrinho",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Quarterly budgets",
"half_year_budgets": "Half-yearly budgets",
"yearly_budgets": "Yearly budgets",
"other_budgets": "Custom timed budgets"
"other_budgets": "Custom timed budgets",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "Conturi de venituri"
},
"list": {
"piggy_bank": "Pu\u0219culi\u021b\u0103",

View File

@ -41,7 +41,9 @@
"quarterly_budgets": "Quarterly budgets",
"half_year_budgets": "Half-yearly budgets",
"yearly_budgets": "Yearly budgets",
"other_budgets": "Custom timed budgets"
"other_budgets": "Custom timed budgets",
"go_to_withdrawals": "Go to your withdrawals",
"revenue_accounts": "\u0421\u0447\u0435\u0442\u0430 \u0434\u043e\u0445\u043e\u0434\u043e\u0432"
},
"list": {
"piggy_bank": "\u041a\u043e\u043f\u0438\u043b\u043a\u0430",

View File

@ -415,6 +415,10 @@ Route::group(
// Insight in expenses.
// Insight in expenses by date.
Route::get('expense/date/basic', ['uses' => 'Expense\DateController@basic', 'as' => 'expense.date.basic']);
// Insight in income.
// Insight in income by date.
Route::get('income/date/basic', ['uses' => 'Income\DateController@basic', 'as' => 'income.date.basic']);
}
);