From b38e7cbb1ae26ae6da8d14827e1717ea028bf7bc Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 29 Nov 2020 07:06:55 +0100 Subject: [PATCH] Rebuild front --- .../Insight/Income/DateController.php | 130 ++++++++++++++++++ frontend/mix-manifest.json | 14 +- .../src/components/dashboard/Dashboard.vue | 2 +- .../components/dashboard/MainCreditList.vue | 97 +++++++++++++ .../components/dashboard/MainDebitList.vue | 8 +- frontend/src/locales/bg.json | 16 ++- frontend/src/locales/cs.json | 4 +- frontend/src/locales/de.json | 4 +- frontend/src/locales/el.json | 4 +- frontend/src/locales/en-gb.json | 4 +- frontend/src/locales/en.json | 4 +- frontend/src/locales/es.json | 16 ++- frontend/src/locales/fr.json | 4 +- frontend/src/locales/hu.json | 4 +- frontend/src/locales/it.json | 4 +- frontend/src/locales/nb.json | 4 +- frontend/src/locales/nl.json | 4 +- frontend/src/locales/pl.json | 16 ++- frontend/src/locales/pt-br.json | 4 +- frontend/src/locales/ro.json | 4 +- frontend/src/locales/ru.json | 4 +- routes/api.php | 4 + 22 files changed, 301 insertions(+), 54 deletions(-) create mode 100644 app/Api/V1/Controllers/Insight/Income/DateController.php create mode 100644 frontend/src/components/dashboard/MainCreditList.vue diff --git a/app/Api/V1/Controllers/Insight/Income/DateController.php b/app/Api/V1/Controllers/Insight/Income/DateController.php new file mode 100644 index 0000000000..5ae5b1eb8a --- /dev/null +++ b/app/Api/V1/Controllers/Insight/Income/DateController.php @@ -0,0 +1,130 @@ +. + */ + +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); + } + +} \ No newline at end of file diff --git a/frontend/mix-manifest.json b/frontend/mix-manifest.json index 4cefb1e099..54e5e196b9 100644 --- a/frontend/mix-manifest.json +++ b/frontend/mix-manifest.json @@ -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" } diff --git a/frontend/src/components/dashboard/Dashboard.vue b/frontend/src/components/dashboard/Dashboard.vue index 0556d9cca7..8b7aa5d583 100644 --- a/frontend/src/components/dashboard/Dashboard.vue +++ b/frontend/src/components/dashboard/Dashboard.vue @@ -48,7 +48,7 @@
- +
diff --git a/frontend/src/components/dashboard/MainCreditList.vue b/frontend/src/components/dashboard/MainCreditList.vue new file mode 100644 index 0000000000..6d559f3062 --- /dev/null +++ b/frontend/src/components/dashboard/MainCreditList.vue @@ -0,0 +1,97 @@ + + + + + diff --git a/frontend/src/components/dashboard/MainDebitList.vue b/frontend/src/components/dashboard/MainDebitList.vue index 58469fc73d..1c1ee0ef4d 100644 --- a/frontend/src/components/dashboard/MainDebitList.vue +++ b/frontend/src/components/dashboard/MainDebitList.vue @@ -47,7 +47,7 @@ @@ -91,13 +91,7 @@ export default { } } - console.log(this.expenses); - // sort: } } } - - \ No newline at end of file diff --git a/frontend/src/locales/bg.json b/frontend/src/locales/bg.json index c0f1fdd2ea..9410352245 100644 --- a/frontend/src/locales/bg.json +++ b/frontend/src/locales/bg.json @@ -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", diff --git a/frontend/src/locales/cs.json b/frontend/src/locales/cs.json index a054fb8dc2..1f0649eeb0 100644 --- a/frontend/src/locales/cs.json +++ b/frontend/src/locales/cs.json @@ -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", diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 36140431a4..363993e8ef 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -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", diff --git a/frontend/src/locales/el.json b/frontend/src/locales/el.json index cfbdd24812..bfe55ffaf3 100644 --- a/frontend/src/locales/el.json +++ b/frontend/src/locales/el.json @@ -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", diff --git a/frontend/src/locales/en-gb.json b/frontend/src/locales/en-gb.json index 933a0b2487..b704ffb015 100644 --- a/frontend/src/locales/en-gb.json +++ b/frontend/src/locales/en-gb.json @@ -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", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index ef17f89825..78f6476d09 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -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", diff --git a/frontend/src/locales/es.json b/frontend/src/locales/es.json index 154bc9ac14..25e1ba5722 100644 --- a/frontend/src/locales/es.json +++ b/frontend/src/locales/es.json @@ -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", diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/fr.json index c2267a5e38..e736111ce0 100644 --- a/frontend/src/locales/fr.json +++ b/frontend/src/locales/fr.json @@ -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", diff --git a/frontend/src/locales/hu.json b/frontend/src/locales/hu.json index b3ffedd85c..df47754ce1 100644 --- a/frontend/src/locales/hu.json +++ b/frontend/src/locales/hu.json @@ -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", diff --git a/frontend/src/locales/it.json b/frontend/src/locales/it.json index c33a957736..c6c5c4a3f6 100644 --- a/frontend/src/locales/it.json +++ b/frontend/src/locales/it.json @@ -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", diff --git a/frontend/src/locales/nb.json b/frontend/src/locales/nb.json index 19cafcfb76..aa06438961 100644 --- a/frontend/src/locales/nb.json +++ b/frontend/src/locales/nb.json @@ -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", diff --git a/frontend/src/locales/nl.json b/frontend/src/locales/nl.json index cf9360fe84..8924bc29b9 100644 --- a/frontend/src/locales/nl.json +++ b/frontend/src/locales/nl.json @@ -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", diff --git a/frontend/src/locales/pl.json b/frontend/src/locales/pl.json index eb6333df5f..6d1d1bf84b 100644 --- a/frontend/src/locales/pl.json +++ b/frontend/src/locales/pl.json @@ -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", diff --git a/frontend/src/locales/pt-br.json b/frontend/src/locales/pt-br.json index 23d5bee06f..8d6d125e59 100644 --- a/frontend/src/locales/pt-br.json +++ b/frontend/src/locales/pt-br.json @@ -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", diff --git a/frontend/src/locales/ro.json b/frontend/src/locales/ro.json index 4e1318963e..9091eb7405 100644 --- a/frontend/src/locales/ro.json +++ b/frontend/src/locales/ro.json @@ -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", diff --git a/frontend/src/locales/ru.json b/frontend/src/locales/ru.json index dd18047e85..2e57cbb499 100644 --- a/frontend/src/locales/ru.json +++ b/frontend/src/locales/ru.json @@ -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", diff --git a/routes/api.php b/routes/api.php index 04d286774c..d0389c3e21 100644 --- a/routes/api.php +++ b/routes/api.php @@ -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']); } );