mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Revamp multi-account report.
This commit is contained in:
parent
4743230136
commit
47de2fec28
@ -52,13 +52,14 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
public function generate(): string
|
||||
{
|
||||
$accountIds = implode(',', $this->accounts->pluck('id')->toArray());
|
||||
$expenseIds = implode(',', $this->expense->pluck('id')->toArray());
|
||||
$doubleIds = implode(',', $this->expense->pluck('id')->toArray());
|
||||
$reportType = 'account';
|
||||
$preferredPeriod = $this->preferredPeriod();
|
||||
try {
|
||||
$result = view(
|
||||
'reports.double.report', compact('accountIds', 'reportType', 'expenseIds', 'preferredPeriod')
|
||||
)->with('start', $this->start)->with('end', $this->end)->render();
|
||||
$result = view('reports.double.report', compact('accountIds', 'reportType', 'doubleIds', 'preferredPeriod'))
|
||||
->with('start', $this->start)->with('end', $this->end)
|
||||
->with('doubles', $this->expense)
|
||||
->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Cannot render reports.double.report: %s', $e->getMessage()));
|
||||
$result = sprintf('Could not render report view: %s', $e->getMessage());
|
||||
|
@ -403,6 +403,29 @@ class GroupCollector implements GroupCollectorInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Both source AND destination must be in this list of accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setBothAccounts(Collection $accounts): GroupCollectorInterface
|
||||
{
|
||||
if ($accounts->count() > 0) {
|
||||
$accountIds = $accounts->pluck('id')->toArray();
|
||||
$this->query->where(
|
||||
static function (EloquentBuilder $query) use ($accountIds) {
|
||||
$query->whereIn('source.account_id', $accountIds);
|
||||
$query->whereIn('destination.account_id', $accountIds);
|
||||
}
|
||||
);
|
||||
app('log')->debug(sprintf('GroupCollector: setBothAccounts: %s', implode(', ', $accountIds)));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit the search to a specific budget.
|
||||
*
|
||||
@ -499,7 +522,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
$accountIds = $accounts->pluck('id')->toArray();
|
||||
$this->query->whereIn('destination.account_id', $accountIds);
|
||||
|
||||
app('log')->debug(sprintf('GroupCollector: setSourceAccounts: %s', implode(', ', $accountIds)));
|
||||
app('log')->debug(sprintf('GroupCollector: setDestinationAccounts: %s', implode(', ', $accountIds)));
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -894,7 +917,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $existingJournal
|
||||
* @param array $existingJournal
|
||||
* @param TransactionJournal $newJournal
|
||||
*
|
||||
* @return array
|
||||
|
@ -39,103 +39,6 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface GroupCollectorInterface
|
||||
{
|
||||
/**
|
||||
* Return the transaction journals without group information. Is useful in some instances.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getExtractedJournals(): array;
|
||||
|
||||
/**
|
||||
* Set source accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setSourceAccounts(Collection $accounts): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* These accounts must not be source accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function excludeSourceAccounts(Collection $accounts): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Exclude destination accounts.
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function excludeDestinationAccounts(Collection $accounts): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Set destination accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setDestinationAccounts(Collection $accounts): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Return the sum of all journals.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSum(): string;
|
||||
|
||||
/**
|
||||
* Add tag info.
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withTagInformation(): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Return the groups.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getGroups(): Collection;
|
||||
|
||||
/**
|
||||
* Same as getGroups but everything is in a paginator.
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getPaginatedGroups(): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Define which accounts can be part of the source and destination transactions.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setAccounts(Collection $accounts): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit the search to a specific bill.
|
||||
*
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setBill(Bill $bill): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit the search to a specific set of bills.
|
||||
*
|
||||
* @param Collection $bills
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setBills(Collection $bills): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Get transactions with a specific amount.
|
||||
*
|
||||
@ -163,6 +66,106 @@ interface GroupCollectorInterface
|
||||
*/
|
||||
public function amountMore(string $amount): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Exclude destination accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function excludeDestinationAccounts(Collection $accounts): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* These accounts must not be source accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function excludeSourceAccounts(Collection $accounts): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Return the transaction journals without group information. Is useful in some instances.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getExtractedJournals(): array;
|
||||
|
||||
/**
|
||||
* Return the groups.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getGroups(): Collection;
|
||||
|
||||
/**
|
||||
* Same as getGroups but everything is in a paginator.
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getPaginatedGroups(): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Return the sum of all journals.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSum(): string;
|
||||
|
||||
/**
|
||||
* Define which accounts can be part of the source and destination transactions.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setAccounts(Collection $accounts): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Collect transactions after a specific date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setAfter(Carbon $date): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Collect transactions before a specific date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setBefore(Carbon $date): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit the search to a specific bill.
|
||||
*
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setBill(Bill $bill): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit the search to a specific set of bills.
|
||||
*
|
||||
* @param Collection $bills
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setBills(Collection $bills): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Both source AND destination must be in this list of accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setBothAccounts(Collection $accounts): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit the search to a specific budget.
|
||||
*
|
||||
@ -181,6 +184,15 @@ interface GroupCollectorInterface
|
||||
*/
|
||||
public function setBudgets(Collection $budgets): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit the search to a specific bunch of categories.
|
||||
*
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setCategories(Collection $categories): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit the search to a specific category.
|
||||
*
|
||||
@ -201,13 +213,13 @@ interface GroupCollectorInterface
|
||||
public function setCurrency(TransactionCurrency $currency): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit the result to a set of specific transaction journals.
|
||||
* Set destination accounts.
|
||||
*
|
||||
* @param array $journalIds
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setJournalIds(array $journalIds): GroupCollectorInterface;
|
||||
public function setDestinationAccounts(Collection $accounts): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit the result to a specific transaction group.
|
||||
@ -219,13 +231,13 @@ interface GroupCollectorInterface
|
||||
public function setGroup(TransactionGroup $transactionGroup): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Search for words in descriptions.
|
||||
* Limit the result to a set of specific transaction journals.
|
||||
*
|
||||
* @param array $array
|
||||
* @param array $journalIds
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setSearchWords(array $array): GroupCollectorInterface;
|
||||
public function setJournalIds(array $journalIds): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit the number of returned entries.
|
||||
@ -255,6 +267,24 @@ interface GroupCollectorInterface
|
||||
*/
|
||||
public function setRange(Carbon $start, Carbon $end): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Search for words in descriptions.
|
||||
*
|
||||
* @param array $array
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setSearchWords(array $array): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Set source accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setSourceAccounts(Collection $accounts): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit results to a specific tag.
|
||||
*
|
||||
@ -273,20 +303,6 @@ interface GroupCollectorInterface
|
||||
*/
|
||||
public function setTags(Collection $tags): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit results to a transactions without a budget.
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withoutBudget(): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit results to a transactions without a category.
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withoutCategory(): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit the search to one specific transaction group.
|
||||
*
|
||||
@ -328,33 +344,6 @@ interface GroupCollectorInterface
|
||||
*/
|
||||
public function withAccountInformation(): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit the search to a specific bunch of categories.
|
||||
*
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setCategories(Collection $categories): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Collect transactions before a specific date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setBefore(Carbon $date): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Collect transactions after a specific date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setAfter(Carbon $date): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Include bill name + ID.
|
||||
*
|
||||
@ -376,4 +365,25 @@ interface GroupCollectorInterface
|
||||
*/
|
||||
public function withCategoryInformation(): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Add tag info.
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withTagInformation(): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit results to a transactions without a budget.
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withoutBudget(): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit results to a transactions without a category.
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withoutCategory(): GroupCollectorInterface;
|
||||
|
||||
}
|
||||
|
415
app/Http/Controllers/Chart/DoubleReportController.php
Normal file
415
app/Http/Controllers/Chart/DoubleReportController.php
Normal file
@ -0,0 +1,415 @@
|
||||
<?php
|
||||
/**
|
||||
* DoubleReportController.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Chart;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Account\OperationsRepositoryInterface;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class DoubleReportController
|
||||
*/
|
||||
class DoubleReportController extends Controller
|
||||
{
|
||||
|
||||
/** @var GeneratorInterface Chart generation methods. */
|
||||
private $generator;
|
||||
/** @var OperationsRepositoryInterface */
|
||||
private $opsRepository;
|
||||
|
||||
/** @var AccountRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* CategoryReportController constructor.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
$this->generator = app(GeneratorInterface::class);
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
$this->repository = app(AccountRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function budgetExpense(Collection $accounts, Collection $others, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
$result = [];
|
||||
$joined = $this->repository->expandWithDoubles($others);
|
||||
$accounts = $accounts->merge($joined);
|
||||
$expenses = $this->opsRepository->listExpenses($start, $end, $accounts);
|
||||
|
||||
// loop expenses.
|
||||
foreach ($expenses as $currency) {
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$categoryName = $journal['budget_name'] ?? trans('firefly.no_budget');
|
||||
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->generator->multiCurrencyPieChart($result);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function categoryExpense(Collection $accounts, Collection $others, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
$result = [];
|
||||
$joined = $this->repository->expandWithDoubles($others);
|
||||
$accounts = $accounts->merge($joined);
|
||||
$spent = $this->opsRepository->listExpenses($start, $end, $accounts);
|
||||
|
||||
// loop expenses.
|
||||
foreach ($spent as $currency) {
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$categoryName = $journal['category_name'] ?? trans('firefly.no_category');
|
||||
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->generator->multiCurrencyPieChart($result);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function categoryIncome(Collection $accounts, Collection $others, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
$result = [];
|
||||
$joined = $this->repository->expandWithDoubles($others);
|
||||
$accounts = $accounts->merge($joined);
|
||||
$earned = $this->opsRepository->listIncome($start, $end, $accounts);
|
||||
|
||||
// loop income.
|
||||
foreach ($earned as $currency) {
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$categoryName = $journal['category_name'] ?? trans('firefly.no_category');
|
||||
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->generator->multiCurrencyPieChart($result);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
*/
|
||||
public function mainChart(Collection $accounts, Account $account, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
$chartData = [];
|
||||
|
||||
$opposing = $this->repository->expandWithDoubles(new Collection([$account]));
|
||||
$accounts = $accounts->merge($opposing);
|
||||
$spent = $this->opsRepository->listExpenses($start, $end, $accounts);
|
||||
$earned = $this->opsRepository->listIncome($start, $end, $accounts);
|
||||
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||
|
||||
// loop expenses.
|
||||
foreach ($spent as $currency) {
|
||||
// add things to chart Data for each currency:
|
||||
$spentKey = sprintf('%d-spent', $currency['currency_id']);
|
||||
$name = $this->getCounterpartName($accounts, $account->id, $account->name, $account->iban);
|
||||
|
||||
$chartData[$spentKey] = $chartData[$spentKey] ?? [
|
||||
'label' => sprintf(
|
||||
'%s (%s)', (string)trans('firefly.spent_in_specific_double', ['account' => $name]), $currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$key = $journal['date']->formatLocalized($format);
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0';
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
|
||||
}
|
||||
|
||||
}
|
||||
// loop income.
|
||||
foreach ($earned as $currency) {
|
||||
// add things to chart Data for each currency:
|
||||
$earnedKey = sprintf('%d-earned', $currency['currency_id']);
|
||||
$name = $this->getCounterpartName($accounts, $account->id, $account->name, $account->iban);
|
||||
|
||||
$chartData[$earnedKey] = $chartData[$earnedKey] ?? [
|
||||
'label' => sprintf(
|
||||
'%s (%s)', (string)trans('firefly.earned_in_specific_double', ['account' => $name]), $currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$key = $journal['date']->formatLocalized($format);
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$chartData[$earnedKey]['entries'][$key] = $chartData[$earnedKey]['entries'][$key] ?? '0';
|
||||
$chartData[$earnedKey]['entries'][$key] = bcadd($chartData[$earnedKey]['entries'][$key], $amount);
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function tagExpense(Collection $accounts, Collection $others, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
$result = [];
|
||||
$joined = $this->repository->expandWithDoubles($others);
|
||||
$accounts = $accounts->merge($joined);
|
||||
$expenses = $this->opsRepository->listExpenses($start, $end, $accounts);
|
||||
$includedJournals = [];
|
||||
// loop expenses.
|
||||
foreach ($expenses as $currency) {
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$journalId = $journal['transaction_journal_id'];
|
||||
|
||||
// no tags? also deserves a sport
|
||||
if (0 === count($journal['tags'])) {
|
||||
$includedJournals[] = $journalId;
|
||||
// do something
|
||||
$tagName = trans('firefly.no_tags');
|
||||
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
|
||||
}
|
||||
// loop each tag:
|
||||
/** @var array $tag */
|
||||
foreach ($journal['tags'] as $tag) {
|
||||
if (in_array($journalId, $includedJournals, true)) {
|
||||
continue;
|
||||
}
|
||||
$includedJournals[] = $journalId;
|
||||
// do something
|
||||
$tagName = $tag['name'];
|
||||
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->generator->multiCurrencyPieChart($result);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function tagIncome(Collection $accounts, Collection $others, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
$result = [];
|
||||
$joined = $this->repository->expandWithDoubles($others);
|
||||
$accounts = $accounts->merge($joined);
|
||||
$income = $this->opsRepository->listIncome($start, $end, $accounts);
|
||||
$includedJournals = [];
|
||||
// loop income.
|
||||
foreach ($income as $currency) {
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$journalId = $journal['transaction_journal_id'];
|
||||
|
||||
// no tags? also deserves a sport
|
||||
if (0 === count($journal['tags'])) {
|
||||
$includedJournals[] = $journalId;
|
||||
// do something
|
||||
$tagName = trans('firefly.no_tags');
|
||||
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
|
||||
}
|
||||
// loop each tag:
|
||||
/** @var array $tag */
|
||||
foreach ($journal['tags'] as $tag) {
|
||||
if (in_array($journalId, $includedJournals, true)) {
|
||||
continue;
|
||||
}
|
||||
$includedJournals[] = $journalId;
|
||||
// do something
|
||||
$tagName = $tag['name'];
|
||||
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->generator->multiCurrencyPieChart($result);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO this method is double.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param string $iban
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getCounterpartName(Collection $accounts, int $id, string $name, string $iban): string
|
||||
{
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
if ($account->name === $name && $account->id !== $id) {
|
||||
return $account->name;
|
||||
}
|
||||
if ($account->iban === $iban && $account->id !== $id) {
|
||||
return $account->iban;
|
||||
}
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO duplicate function
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function makeEntries(Carbon $start, Carbon $end): array
|
||||
{
|
||||
$return = [];
|
||||
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||
$preferredRange = app('navigation')->preferredRangeFormat($start, $end);
|
||||
$currentStart = clone $start;
|
||||
while ($currentStart <= $end) {
|
||||
$currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
|
||||
$key = $currentStart->formatLocalized($format);
|
||||
$return[$key] = '0';
|
||||
$currentStart = clone $currentEnd;
|
||||
$currentStart->addDay()->startOfDay();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
}
|
795
app/Http/Controllers/Report/DoubleController.php
Normal file
795
app/Http/Controllers/Report/DoubleController.php
Normal file
@ -0,0 +1,795 @@
|
||||
<?php
|
||||
/**
|
||||
* DoubleController.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Report;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Account\OperationsRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Controllers\AugumentData;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class DoubleController
|
||||
*
|
||||
*/
|
||||
class DoubleController extends Controller
|
||||
{
|
||||
use AugumentData;
|
||||
|
||||
/** @var AccountRepositoryInterface The account repository */
|
||||
protected $accountRepository;
|
||||
|
||||
/** @var OperationsRepositoryInterface */
|
||||
private $opsRepository;
|
||||
|
||||
/**
|
||||
* Constructor for ExpenseController
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// translations:
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
$this->accountRepository = app(AccountRepositoryInterface::class);
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $doubles
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
public function avgExpenses(Collection $accounts, Collection $doubles, Carbon $start, Carbon $end)
|
||||
{
|
||||
$expanded = $this->accountRepository->expandWithDoubles($doubles);
|
||||
$accounts = $accounts->merge($expanded);
|
||||
$spent = $this->opsRepository->listExpenses($start, $end, $accounts);
|
||||
$result = [];
|
||||
foreach ($spent as $currency) {
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$sourceId = $journal['source_account_id'];
|
||||
$key = sprintf('%d-%d', $sourceId, $currency['currency_id']);
|
||||
$result[$key] = $result[$key] ?? [
|
||||
'transactions' => 0,
|
||||
'sum' => '0',
|
||||
'avg' => '0',
|
||||
'avg_float' => 0,
|
||||
'source_account_name' => $journal['source_account_name'],
|
||||
'source_account_id' => $journal['source_account_id'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
$result[$key]['transactions']++;
|
||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||
}
|
||||
}
|
||||
// sort by amount_float
|
||||
// sort temp array by amount.
|
||||
$amounts = array_column($result, 'avg_float');
|
||||
array_multisort($amounts, SORT_ASC, $result);
|
||||
|
||||
try {
|
||||
$result = view('reports.double.partials.avg-expenses', compact('result'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
||||
$result = sprintf('Could not render view: %s', $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $doubles
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
public function avgIncome(Collection $accounts, Collection $doubles, Carbon $start, Carbon $end)
|
||||
{
|
||||
$expanded = $this->accountRepository->expandWithDoubles($doubles);
|
||||
$accounts = $accounts->merge($expanded);
|
||||
$spent = $this->opsRepository->listIncome($start, $end, $accounts);
|
||||
$result = [];
|
||||
foreach ($spent as $currency) {
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$destinationId = $journal['destination_account_id'];
|
||||
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
|
||||
$result[$key] = $result[$key] ?? [
|
||||
'transactions' => 0,
|
||||
'sum' => '0',
|
||||
'avg' => '0',
|
||||
'avg_float' => 0,
|
||||
'destination_account_name' => $journal['destination_account_name'],
|
||||
'destination_account_id' => $journal['destination_account_id'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
$result[$key]['transactions']++;
|
||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||
}
|
||||
}
|
||||
// sort by amount_float
|
||||
// sort temp array by amount.
|
||||
$amounts = array_column($result, 'avg_float');
|
||||
array_multisort($amounts, SORT_DESC, $result);
|
||||
|
||||
try {
|
||||
$result = view('reports.double.partials.avg-income', compact('result'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
||||
$result = sprintf('Could not render view: %s', $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $double
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function operations(Collection $accounts, Collection $double, Carbon $start, Carbon $end)
|
||||
{
|
||||
$withCounterpart = $this->accountRepository->expandWithDoubles($double);
|
||||
$together = $accounts->merge($withCounterpart);
|
||||
$report = [];
|
||||
$sums = [];
|
||||
// see what happens when we collect transactions.
|
||||
$spent = $this->opsRepository->listExpenses($start, $end, $together);
|
||||
$earned = $this->opsRepository->listIncome($start, $end, $together);
|
||||
// group and list per account name (as long as its not in accounts, only in double)
|
||||
|
||||
/** @var array $currency */
|
||||
foreach ($spent as $currency) {
|
||||
$currencyId = $currency['currency_id'];
|
||||
|
||||
$sums[$currencyId] = $sums[$currencyId] ?? [
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$destId = $journal['destination_account_id'];
|
||||
$destName = $journal['destination_account_name'];
|
||||
$destIban = $journal['destination_account_iban'];
|
||||
$genericName = $this->getCounterpartName($withCounterpart, $destId, $destName, $destIban);
|
||||
$objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']);
|
||||
$report[$objectName] = $report[$objectName] ?? [
|
||||
'dest_name' => '',
|
||||
'dest_iban' => '',
|
||||
'source_name' => '',
|
||||
'source_iban' => '',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
];
|
||||
// set name
|
||||
$report[$objectName]['dest_name'] = $destName;
|
||||
$report[$objectName]['dest_iban'] = $destIban;
|
||||
|
||||
// add amounts:
|
||||
$report[$objectName]['spent'] = bcadd($report[$objectName]['spent'], $journal['amount']);
|
||||
$report[$objectName]['sum'] = bcadd($report[$objectName]['sum'], $journal['amount']);
|
||||
$sums[$currencyId]['spent'] = bcadd($sums[$currencyId]['spent'], $journal['amount']);
|
||||
$sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], $journal['amount']);
|
||||
}
|
||||
}
|
||||
|
||||
/** @var array $currency */
|
||||
foreach ($earned as $currency) {
|
||||
$currencyId = $currency['currency_id'];
|
||||
|
||||
$sums[$currencyId] = $sums[$currencyId] ?? [
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$sourceId = $journal['source_account_id'];
|
||||
$sourceName = $journal['source_account_name'];
|
||||
$sourceIban = $journal['source_account_iban'];
|
||||
$genericName = $this->getCounterpartName($withCounterpart, $sourceId, $sourceName, $sourceIban);
|
||||
$objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']);
|
||||
$report[$objectName] = $report[$objectName] ?? [
|
||||
'dest_name' => '',
|
||||
'dest_iban' => '',
|
||||
'source_name' => '',
|
||||
'source_iban' => '',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
];
|
||||
|
||||
// set name
|
||||
$report[$objectName]['source_name'] = $sourceName;
|
||||
$report[$objectName]['source_iban'] = $sourceIban;
|
||||
|
||||
// add amounts:
|
||||
$report[$objectName]['earned'] = bcadd($report[$objectName]['earned'], $journal['amount']);
|
||||
$report[$objectName]['sum'] = bcadd($report[$objectName]['sum'], $journal['amount']);
|
||||
$sums[$currencyId]['earned'] = bcadd($sums[$currencyId]['earned'], $journal['amount']);
|
||||
$sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], $journal['amount']);
|
||||
}
|
||||
}
|
||||
|
||||
return view('reports.double.partials.accounts', compact('sums', 'report'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $double
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function operationsPerAsset(Collection $accounts, Collection $double, Carbon $start, Carbon $end)
|
||||
{
|
||||
$withCounterpart = $this->accountRepository->expandWithDoubles($double);
|
||||
$together = $accounts->merge($withCounterpart);
|
||||
$report = [];
|
||||
$sums = [];
|
||||
// see what happens when we collect transactions.
|
||||
$spent = $this->opsRepository->listExpenses($start, $end, $together);
|
||||
$earned = $this->opsRepository->listIncome($start, $end, $together);
|
||||
// group and list per account name (as long as its not in accounts, only in double)
|
||||
|
||||
/** @var array $currency */
|
||||
foreach ($spent as $currency) {
|
||||
$currencyId = $currency['currency_id'];
|
||||
|
||||
$sums[$currencyId] = $sums[$currencyId] ?? [
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$objectName = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']);
|
||||
$report[$objectName] = $report[$objectName] ?? [
|
||||
'account_id' => $journal['source_account_id'],
|
||||
'account_name' => $objectName,
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
];
|
||||
// set name
|
||||
// add amounts:
|
||||
$report[$objectName]['spent'] = bcadd($report[$objectName]['spent'], $journal['amount']);
|
||||
$report[$objectName]['sum'] = bcadd($report[$objectName]['sum'], $journal['amount']);
|
||||
$sums[$currencyId]['spent'] = bcadd($sums[$currencyId]['spent'], $journal['amount']);
|
||||
$sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], $journal['amount']);
|
||||
}
|
||||
}
|
||||
|
||||
/** @var array $currency */
|
||||
foreach ($earned as $currency) {
|
||||
$currencyId = $currency['currency_id'];
|
||||
|
||||
$sums[$currencyId] = $sums[$currencyId] ?? [
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$objectName = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']);
|
||||
$report[$objectName] = $report[$objectName] ?? [
|
||||
'account_id' => $journal['destination_account_id'],
|
||||
'account_name' => $objectName,
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
];
|
||||
|
||||
// add amounts:
|
||||
$report[$objectName]['earned'] = bcadd($report[$objectName]['earned'], $journal['amount']);
|
||||
$report[$objectName]['sum'] = bcadd($report[$objectName]['sum'], $journal['amount']);
|
||||
$sums[$currencyId]['earned'] = bcadd($sums[$currencyId]['earned'], $journal['amount']);
|
||||
$sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], $journal['amount']);
|
||||
}
|
||||
}
|
||||
|
||||
return view('reports.double.partials.accounts-per-asset', compact('sums', 'report'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $doubles
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
public function topExpenses(Collection $accounts, Collection $doubles, Carbon $start, Carbon $end)
|
||||
{
|
||||
$expanded = $this->accountRepository->expandWithDoubles($doubles);
|
||||
$accounts = $accounts->merge($expanded);
|
||||
$spent = $this->opsRepository->listExpenses($start, $end, $accounts);
|
||||
$result = [];
|
||||
foreach ($spent as $currency) {
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$result[] = [
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
'amount_float' => (float)$journal['amount'],
|
||||
'amount' => $journal['amount'],
|
||||
'date' => $journal['date']->formatLocalized($this->monthAndDayFormat),
|
||||
'destination_account_name' => $journal['destination_account_name'],
|
||||
'destination_account_id' => $journal['destination_account_id'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'source_account_name' => $journal['source_account_name'],
|
||||
'source_account_id' => $journal['source_account_id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
// sort by amount_float
|
||||
// sort temp array by amount.
|
||||
$amounts = array_column($result, 'amount_float');
|
||||
array_multisort($amounts, SORT_ASC, $result);
|
||||
|
||||
try {
|
||||
$result = view('reports.double.partials.top-expenses', compact('result'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
||||
$result = sprintf('Could not render view: %s', $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $doubles
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
public function topIncome(Collection $accounts, Collection $doubles, Carbon $start, Carbon $end)
|
||||
{
|
||||
$expanded = $this->accountRepository->expandWithDoubles($doubles);
|
||||
$accounts = $accounts->merge($expanded);
|
||||
$spent = $this->opsRepository->listIncome($start, $end, $accounts);
|
||||
$result = [];
|
||||
foreach ($spent as $currency) {
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$result[] = [
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
'amount_float' => (float)$journal['amount'],
|
||||
'amount' => $journal['amount'],
|
||||
'date' => $journal['date']->formatLocalized($this->monthAndDayFormat),
|
||||
'destination_account_name' => $journal['destination_account_name'],
|
||||
'destination_account_id' => $journal['destination_account_id'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'source_account_name' => $journal['source_account_name'],
|
||||
'source_account_id' => $journal['source_account_id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
// sort by amount_float
|
||||
// sort temp array by amount.
|
||||
$amounts = array_column($result, 'amount_float');
|
||||
array_multisort($amounts, SORT_DESC, $result);
|
||||
|
||||
try {
|
||||
$result = view('reports.double.partials.top-income', compact('result'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
||||
$result = sprintf('Could not render view: %s', $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Generates the overview per budget.
|
||||
// *
|
||||
// * @param Collection $accounts
|
||||
// * @param Collection $expense
|
||||
// * @param Carbon $start
|
||||
// * @param Carbon $end
|
||||
// *
|
||||
// * @return string
|
||||
// */
|
||||
// public function budget(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): string
|
||||
// {
|
||||
// // Properties for cache:
|
||||
// $cache = new CacheProperties;
|
||||
// $cache->addProperty($start);
|
||||
// $cache->addProperty($end);
|
||||
// $cache->addProperty('expense-budget');
|
||||
// $cache->addProperty($accounts->pluck('id')->toArray());
|
||||
// $cache->addProperty($expense->pluck('id')->toArray());
|
||||
// if ($cache->has()) {
|
||||
// return $cache->get(); // @codeCoverageIgnore
|
||||
// }
|
||||
// $combined = $this->combineAccounts($expense);
|
||||
// $all = new Collection;
|
||||
// foreach ($combined as $combi) {
|
||||
// $all = $all->merge($combi);
|
||||
// }
|
||||
// // now find spent / earned:
|
||||
// $spent = $this->spentByBudget($accounts, $all, $start, $end);
|
||||
// // join arrays somehow:
|
||||
// $together = [];
|
||||
// foreach ($spent as $categoryId => $spentInfo) {
|
||||
// if (!isset($together[$categoryId])) {
|
||||
// $together[$categoryId]['spent'] = $spentInfo;
|
||||
// $together[$categoryId]['budget'] = $spentInfo['name'];
|
||||
// $together[$categoryId]['grand_total'] = '0';
|
||||
// }
|
||||
// $together[$categoryId]['grand_total'] = bcadd($spentInfo['grand_total'], $together[$categoryId]['grand_total']);
|
||||
// }
|
||||
// try {
|
||||
// $result = view('reports.partials.exp-budgets', compact('together'))->render();
|
||||
// // @codeCoverageIgnoreStart
|
||||
// } catch (Throwable $e) {
|
||||
// Log::error(sprintf('Could not render category::budget: %s', $e->getMessage()));
|
||||
// $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
|
||||
// }
|
||||
// // @codeCoverageIgnoreEnd
|
||||
// $cache->store($result);
|
||||
//
|
||||
// return $result;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Generates the overview per category (spent and earned).
|
||||
// *
|
||||
// * @param Collection $accounts
|
||||
// * @param Collection $expense
|
||||
// * @param Carbon $start
|
||||
// * @param Carbon $end
|
||||
// *
|
||||
// * @return string
|
||||
// */
|
||||
// public function category(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): string
|
||||
// {
|
||||
// // Properties for cache:
|
||||
// $cache = new CacheProperties;
|
||||
// $cache->addProperty($start);
|
||||
// $cache->addProperty($end);
|
||||
// $cache->addProperty('expense-category');
|
||||
// $cache->addProperty($accounts->pluck('id')->toArray());
|
||||
// $cache->addProperty($expense->pluck('id')->toArray());
|
||||
// if ($cache->has()) {
|
||||
// return $cache->get(); // @codeCoverageIgnore
|
||||
// }
|
||||
// $combined = $this->combineAccounts($expense);
|
||||
// $all = new Collection;
|
||||
// foreach ($combined as $combi) {
|
||||
// $all = $all->merge($combi);
|
||||
// }
|
||||
// // now find spent / earned:
|
||||
// $spent = $this->spentByCategory($accounts, $all, $start, $end);
|
||||
// $earned = $this->earnedByCategory($accounts, $all, $start, $end);
|
||||
// // join arrays somehow:
|
||||
// $together = [];
|
||||
// foreach ($spent as $categoryId => $spentInfo) {
|
||||
// if (!isset($together[$categoryId])) {
|
||||
// $together[$categoryId]['spent'] = $spentInfo;
|
||||
// $together[$categoryId]['category'] = $spentInfo['name'];
|
||||
// $together[$categoryId]['grand_total'] = '0';
|
||||
// }
|
||||
// $together[$categoryId]['grand_total'] = bcadd($spentInfo['grand_total'], $together[$categoryId]['grand_total']);
|
||||
// }
|
||||
// foreach ($earned as $categoryId => $earnedInfo) {
|
||||
// if (!isset($together[$categoryId])) {
|
||||
// $together[$categoryId]['earned'] = $earnedInfo;
|
||||
// $together[$categoryId]['category'] = $earnedInfo['name'];
|
||||
// $together[$categoryId]['grand_total'] = '0';
|
||||
// }
|
||||
// $together[$categoryId]['grand_total'] = bcadd($earnedInfo['grand_total'], $together[$categoryId]['grand_total']);
|
||||
// }
|
||||
// try {
|
||||
// $result = view('reports.partials.exp-categories', compact('together'))->render();
|
||||
// // @codeCoverageIgnoreStart
|
||||
// } catch (Throwable $e) {
|
||||
// Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
|
||||
// $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
|
||||
// }
|
||||
// // @codeCoverageIgnoreEnd
|
||||
// $cache->store($result);
|
||||
//
|
||||
// return $result;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Overview of spending.
|
||||
// *
|
||||
// * @param Collection $accounts
|
||||
// * @param Collection $expense
|
||||
// * @param Carbon $start
|
||||
// * @param Carbon $end
|
||||
// *
|
||||
// * @return array|mixed|string
|
||||
// */
|
||||
// public function spent(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
|
||||
// {
|
||||
// // chart properties for cache:
|
||||
// $cache = new CacheProperties;
|
||||
// $cache->addProperty($start);
|
||||
// $cache->addProperty($end);
|
||||
// $cache->addProperty('expense-spent');
|
||||
// $cache->addProperty($accounts->pluck('id')->toArray());
|
||||
// $cache->addProperty($expense->pluck('id')->toArray());
|
||||
// if ($cache->has()) {
|
||||
// return $cache->get(); // @codeCoverageIgnore
|
||||
// }
|
||||
//
|
||||
// $combined = $this->combineAccounts($expense);
|
||||
// $result = [];
|
||||
//
|
||||
// foreach ($combined as $name => $combi) {
|
||||
// /**
|
||||
// * @var string
|
||||
// * @var Collection $combi
|
||||
// */
|
||||
// $spent = $this->spentInPeriod($accounts, $combi, $start, $end);
|
||||
// $earned = $this->earnedInPeriod($accounts, $combi, $start, $end);
|
||||
// $result[$name] = [
|
||||
// 'spent' => $spent,
|
||||
// 'earned' => $earned,
|
||||
// ];
|
||||
// }
|
||||
// try {
|
||||
// $result = view('reports.partials.exp-not-grouped', compact('result'))->render();
|
||||
// // @codeCoverageIgnoreStart
|
||||
// } catch (Throwable $e) {
|
||||
// Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
|
||||
// $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
|
||||
// }
|
||||
// // @codeCoverageIgnoreEnd
|
||||
// $cache->store($result);
|
||||
//
|
||||
// return $result;
|
||||
// // for period, get spent and earned for each account (by name)
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * List of top expenses.
|
||||
// *
|
||||
// * @param Collection $accounts
|
||||
// * @param Collection $expense
|
||||
// * @param Carbon $start
|
||||
// * @param Carbon $end
|
||||
// *
|
||||
// * @return string
|
||||
// */
|
||||
// public function topExpense(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): string
|
||||
// {
|
||||
// // Properties for cache:
|
||||
// $cache = new CacheProperties;
|
||||
// $cache->addProperty($start);
|
||||
// $cache->addProperty($end);
|
||||
// $cache->addProperty('top-expense');
|
||||
// $cache->addProperty($accounts->pluck('id')->toArray());
|
||||
// $cache->addProperty($expense->pluck('id')->toArray());
|
||||
// if ($cache->has()) {
|
||||
// return $cache->get(); // @codeCoverageIgnore
|
||||
// }
|
||||
// $combined = $this->combineAccounts($expense);
|
||||
// $all = new Collection;
|
||||
// foreach ($combined as $combi) {
|
||||
// $all = $all->merge($combi);
|
||||
// }
|
||||
// // get all expenses in period:
|
||||
// /** @var GroupCollectorInterface $collector */
|
||||
// $collector = app(GroupCollectorInterface::class);
|
||||
//
|
||||
// $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setAccounts($accounts);
|
||||
// $collector->setAccounts($all)->withAccountInformation();
|
||||
// $sorted = $collector->getExtractedJournals();
|
||||
//
|
||||
// usort($sorted, function ($a, $b) {
|
||||
// return $a['amount'] <=> $b['amount']; // @codeCoverageIgnore
|
||||
// });
|
||||
//
|
||||
// try {
|
||||
// $result = view('reports.partials.top-transactions', compact('sorted'))->render();
|
||||
// // @codeCoverageIgnoreStart
|
||||
// } catch (Throwable $e) {
|
||||
// Log::error(sprintf('Could not render category::topExpense: %s', $e->getMessage()));
|
||||
// $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
|
||||
// }
|
||||
// // @codeCoverageIgnoreEnd
|
||||
// $cache->store($result);
|
||||
//
|
||||
// return $result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * List of top income.
|
||||
// *
|
||||
// * @param Collection $accounts
|
||||
// * @param Collection $expense
|
||||
// * @param Carbon $start
|
||||
// * @param Carbon $end
|
||||
// *
|
||||
// * @return mixed|string
|
||||
// */
|
||||
// public function topIncome(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
|
||||
// {
|
||||
// // Properties for cache:
|
||||
// $cache = new CacheProperties;
|
||||
// $cache->addProperty($start);
|
||||
// $cache->addProperty($end);
|
||||
// $cache->addProperty('top-income');
|
||||
// $cache->addProperty($accounts->pluck('id')->toArray());
|
||||
// $cache->addProperty($expense->pluck('id')->toArray());
|
||||
// if ($cache->has()) {
|
||||
// return $cache->get(); // @codeCoverageIgnore
|
||||
// }
|
||||
// $combined = $this->combineAccounts($expense);
|
||||
// $all = new Collection;
|
||||
// foreach ($combined as $combi) {
|
||||
// $all = $all->merge($combi);
|
||||
// }
|
||||
// // get all expenses in period:
|
||||
//
|
||||
// /** @var GroupCollectorInterface $collector */
|
||||
// $collector = app(GroupCollectorInterface::class);
|
||||
//
|
||||
// $total = $accounts->merge($all);
|
||||
// $collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAccounts($total)->withAccountInformation();
|
||||
// $sorted = $collector->getExtractedJournals();
|
||||
//
|
||||
// foreach (array_keys($sorted) as $key) {
|
||||
// $sorted[$key]['amount'] = bcmul($sorted[$key]['amount'], '-1');
|
||||
// }
|
||||
//
|
||||
// usort($sorted, function ($a, $b) {
|
||||
// return $a['amount'] <=> $b['amount']; // @codeCoverageIgnore
|
||||
// });
|
||||
//
|
||||
// try {
|
||||
// $result = view('reports.partials.top-transactions', compact('sorted'))->render();
|
||||
// // @codeCoverageIgnoreStart
|
||||
// } catch (Throwable $e) {
|
||||
// Log::error(sprintf('Could not render category::topIncome: %s', $e->getMessage()));
|
||||
// $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
|
||||
// }
|
||||
// // @codeCoverageIgnoreEnd
|
||||
// $cache->store($result);
|
||||
//
|
||||
// return $result;
|
||||
// }
|
||||
|
||||
/**
|
||||
* TODO this method is double.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param string $iban
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getCounterpartName(Collection $accounts, int $id, string $name, string $iban): string
|
||||
{
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
if ($account->name === $name && $account->id !== $id) {
|
||||
return $account->name;
|
||||
}
|
||||
if ($account->iban === $iban && $account->id !== $id) {
|
||||
return $account->iban;
|
||||
}
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
@ -1,346 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* ExpenseController.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Report;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Http\Controllers\AugumentData;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class ExpenseController
|
||||
*
|
||||
*/
|
||||
class ExpenseController extends Controller
|
||||
{
|
||||
use AugumentData;
|
||||
|
||||
/** @var AccountRepositoryInterface The account repository */
|
||||
protected $accountRepository;
|
||||
|
||||
/**
|
||||
* Constructor for ExpenseController
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// translations:
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
$this->accountRepository = app(AccountRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generates the overview per budget.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $expense
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function budget(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): string
|
||||
{
|
||||
// Properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('expense-budget');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
$cache->addProperty($expense->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$combined = $this->combineAccounts($expense);
|
||||
$all = new Collection;
|
||||
foreach ($combined as $combi) {
|
||||
$all = $all->merge($combi);
|
||||
}
|
||||
// now find spent / earned:
|
||||
$spent = $this->spentByBudget($accounts, $all, $start, $end);
|
||||
// join arrays somehow:
|
||||
$together = [];
|
||||
foreach ($spent as $categoryId => $spentInfo) {
|
||||
if (!isset($together[$categoryId])) {
|
||||
$together[$categoryId]['spent'] = $spentInfo;
|
||||
$together[$categoryId]['budget'] = $spentInfo['name'];
|
||||
$together[$categoryId]['grand_total'] = '0';
|
||||
}
|
||||
$together[$categoryId]['grand_total'] = bcadd($spentInfo['grand_total'], $together[$categoryId]['grand_total']);
|
||||
}
|
||||
try {
|
||||
$result = view('reports.partials.exp-budgets', compact('together'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::budget: %s', $e->getMessage()));
|
||||
$result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generates the overview per category (spent and earned).
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $expense
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function category(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): string
|
||||
{
|
||||
// Properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('expense-category');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
$cache->addProperty($expense->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$combined = $this->combineAccounts($expense);
|
||||
$all = new Collection;
|
||||
foreach ($combined as $combi) {
|
||||
$all = $all->merge($combi);
|
||||
}
|
||||
// now find spent / earned:
|
||||
$spent = $this->spentByCategory($accounts, $all, $start, $end);
|
||||
$earned = $this->earnedByCategory($accounts, $all, $start, $end);
|
||||
// join arrays somehow:
|
||||
$together = [];
|
||||
foreach ($spent as $categoryId => $spentInfo) {
|
||||
if (!isset($together[$categoryId])) {
|
||||
$together[$categoryId]['spent'] = $spentInfo;
|
||||
$together[$categoryId]['category'] = $spentInfo['name'];
|
||||
$together[$categoryId]['grand_total'] = '0';
|
||||
}
|
||||
$together[$categoryId]['grand_total'] = bcadd($spentInfo['grand_total'], $together[$categoryId]['grand_total']);
|
||||
}
|
||||
foreach ($earned as $categoryId => $earnedInfo) {
|
||||
if (!isset($together[$categoryId])) {
|
||||
$together[$categoryId]['earned'] = $earnedInfo;
|
||||
$together[$categoryId]['category'] = $earnedInfo['name'];
|
||||
$together[$categoryId]['grand_total'] = '0';
|
||||
}
|
||||
$together[$categoryId]['grand_total'] = bcadd($earnedInfo['grand_total'], $together[$categoryId]['grand_total']);
|
||||
}
|
||||
try {
|
||||
$result = view('reports.partials.exp-categories', compact('together'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
|
||||
$result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overview of spending.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $expense
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array|mixed|string
|
||||
*/
|
||||
public function spent(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
|
||||
{
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('expense-spent');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
$cache->addProperty($expense->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$combined = $this->combineAccounts($expense);
|
||||
$result = [];
|
||||
|
||||
foreach ($combined as $name => $combi) {
|
||||
/**
|
||||
* @var string
|
||||
* @var Collection $combi
|
||||
*/
|
||||
$spent = $this->spentInPeriod($accounts, $combi, $start, $end);
|
||||
$earned = $this->earnedInPeriod($accounts, $combi, $start, $end);
|
||||
$result[$name] = [
|
||||
'spent' => $spent,
|
||||
'earned' => $earned,
|
||||
];
|
||||
}
|
||||
try {
|
||||
$result = view('reports.partials.exp-not-grouped', compact('result'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
|
||||
$result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
// for period, get spent and earned for each account (by name)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List of top expenses.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $expense
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function topExpense(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): string
|
||||
{
|
||||
// Properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('top-expense');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
$cache->addProperty($expense->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$combined = $this->combineAccounts($expense);
|
||||
$all = new Collection;
|
||||
foreach ($combined as $combi) {
|
||||
$all = $all->merge($combi);
|
||||
}
|
||||
// get all expenses in period:
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setAccounts($accounts);
|
||||
$collector->setAccounts($all)->withAccountInformation();
|
||||
$sorted = $collector->getExtractedJournals();
|
||||
|
||||
usort($sorted, function ($a, $b) {
|
||||
return $a['amount'] <=> $b['amount']; // @codeCoverageIgnore
|
||||
});
|
||||
|
||||
try {
|
||||
$result = view('reports.partials.top-transactions', compact('sorted'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::topExpense: %s', $e->getMessage()));
|
||||
$result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of top income.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $expense
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function topIncome(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
|
||||
{
|
||||
// Properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('top-income');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
$cache->addProperty($expense->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$combined = $this->combineAccounts($expense);
|
||||
$all = new Collection;
|
||||
foreach ($combined as $combi) {
|
||||
$all = $all->merge($combi);
|
||||
}
|
||||
// get all expenses in period:
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$total = $accounts->merge($all);
|
||||
$collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAccounts($total)->withAccountInformation();
|
||||
$sorted = $collector->getExtractedJournals();
|
||||
|
||||
foreach (array_keys($sorted) as $key) {
|
||||
$sorted[$key]['amount'] = bcmul($sorted[$key]['amount'], '-1');
|
||||
}
|
||||
|
||||
usort($sorted, function ($a, $b) {
|
||||
return $a['amount'] <=> $b['amount']; // @codeCoverageIgnore
|
||||
});
|
||||
|
||||
try {
|
||||
$result = view('reports.partials.top-transactions', compact('sorted'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::topIncome: %s', $e->getMessage()));
|
||||
$result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -80,18 +80,18 @@ class ReportController extends Controller
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function accountReport(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
|
||||
public function doubleReport(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
|
||||
{
|
||||
if ($end < $start) {
|
||||
return view('error')->with('message', (string)trans('firefly.end_after_start_date')); // @codeCoverageIgnore
|
||||
[$start, $end] = [$end, $start];
|
||||
}
|
||||
|
||||
$this->repository->cleanupBudgets();
|
||||
|
||||
app('view')->share(
|
||||
'subTitle', trans(
|
||||
'firefly.report_account',
|
||||
['start' => $start->formatLocalized($this->monthFormat), 'end' => $end->formatLocalized($this->monthFormat)]
|
||||
'firefly.report_double',
|
||||
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||
)
|
||||
);
|
||||
|
||||
@ -292,8 +292,8 @@ class ReportController extends Controller
|
||||
case 'tag':
|
||||
$result = $this->tagReportOptions();
|
||||
break;
|
||||
case 'account':
|
||||
$result = $this->accountReportOptions();
|
||||
case 'double':
|
||||
$result = $this->doubleReportOptions();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ class ReportController extends Controller
|
||||
return redirect(route('reports.index'));
|
||||
}
|
||||
|
||||
if ('account' === $reportType && 0 === $request->getDoubleList()->count()) {
|
||||
if ('double' === $reportType && 0 === $request->getDoubleList()->count()) {
|
||||
session()->flash('error', (string)trans('firefly.select_at_least_one_expense'));
|
||||
|
||||
return redirect(route('reports.index'));
|
||||
@ -374,8 +374,8 @@ class ReportController extends Controller
|
||||
case 'tag':
|
||||
$uri = route('reports.report.tag', [$accounts, $tags, $start, $end]);
|
||||
break;
|
||||
case 'account':
|
||||
$uri = route('reports.report.account', [$accounts, $double, $start, $end]);
|
||||
case 'double':
|
||||
$uri = route('reports.report.double', [$accounts, $double, $start, $end]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ class ReportFormRequest extends Request
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'report_type' => 'in:audit,default,category,budget,tag,account',
|
||||
'report_type' => 'in:audit,default,category,budget,tag,double',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ use FireflyIII\Repositories\Account\AccountRepository;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Account\AccountTasker;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
use FireflyIII\Repositories\Account\OperationsRepository;
|
||||
use FireflyIII\Repositories\Account\OperationsRepositoryInterface;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
@ -69,6 +71,20 @@ class AccountServiceProvider extends ServiceProvider
|
||||
return $repository;
|
||||
}
|
||||
);
|
||||
|
||||
$this->app->bind(
|
||||
OperationsRepositoryInterface::class,
|
||||
static function (Application $app) {
|
||||
/** @var OperationsRepository $repository */
|
||||
$repository = app(OperationsRepository::class);
|
||||
|
||||
if ($app->auth->check()) {
|
||||
$repository->setUser(auth()->user());
|
||||
}
|
||||
|
||||
return $repository;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,6 +88,41 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find account with same name OR same IBAN or both, but not the same type or ID.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function expandWithDoubles(Collection $accounts): Collection
|
||||
{
|
||||
$result = new Collection;
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$byName = $this->user->accounts()->where('name', $account->name)
|
||||
->where('id', '!=', $account->id)->first();
|
||||
if (null !== $byName) {
|
||||
$result->push($account);
|
||||
$result->push($byName);
|
||||
continue;
|
||||
}
|
||||
if (null !== $account->iban) {
|
||||
$byIban = $this->user->accounts()->where('iban', $account->iban)
|
||||
->where('id', '!=', $account->id)->first();
|
||||
if (null !== $byIban) {
|
||||
$result->push($account);
|
||||
$result->push($byIban);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$result->push($account);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $number
|
||||
* @param array $types
|
||||
|
@ -37,21 +37,6 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface AccountRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return TransactionJournal|null
|
||||
*
|
||||
*/
|
||||
public function getOpeningBalance(Account $account): ?TransactionJournal;
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @return TransactionGroup|null
|
||||
*/
|
||||
public function getOpeningBalanceGroup(Account $account): ?TransactionGroup;
|
||||
|
||||
/**
|
||||
* Moved here from account CRUD.
|
||||
*
|
||||
@ -64,18 +49,27 @@ interface AccountRepositoryInterface
|
||||
/**
|
||||
* Moved here from account CRUD.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Account $account
|
||||
* @param Account|null $moveTo
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Account $account, ?Account $moveTo): bool;
|
||||
|
||||
/**
|
||||
* Find account with same name OR same IBAN or both, but not the same type or ID.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function expandWithDoubles(Collection $accounts): Collection;
|
||||
|
||||
/**
|
||||
* Find by account number. Is used.
|
||||
*
|
||||
* @param string $number
|
||||
* @param array $types
|
||||
* @param array $types
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
@ -83,7 +77,7 @@ interface AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param string $iban
|
||||
* @param array $types
|
||||
* @param array $types
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
@ -91,7 +85,7 @@ interface AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $types
|
||||
* @param array $types
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
@ -157,7 +151,7 @@ interface AccountRepositoryInterface
|
||||
* Return meta value for account. Null if not found.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param string $field
|
||||
* @param string $field
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
@ -172,6 +166,14 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function getNoteText(Account $account): ?string;
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return TransactionJournal|null
|
||||
*
|
||||
*/
|
||||
public function getOpeningBalance(Account $account): ?TransactionJournal;
|
||||
|
||||
/**
|
||||
* Returns the amount of the opening balance for this account.
|
||||
*
|
||||
@ -190,6 +192,13 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function getOpeningBalanceDate(Account $account): ?string;
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return TransactionGroup|null
|
||||
*/
|
||||
public function getOpeningBalanceGroup(Account $account): ?TransactionGroup;
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
@ -235,7 +244,7 @@ interface AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $types
|
||||
* @param array $types
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
@ -255,7 +264,7 @@ interface AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
|
189
app/Repositories/Account/OperationsRepository.php
Normal file
189
app/Repositories/Account/OperationsRepository.php
Normal file
@ -0,0 +1,189 @@
|
||||
<?php
|
||||
/**
|
||||
* OperationsRepository.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Account;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class OperationsRepository
|
||||
*/
|
||||
class OperationsRepository implements OperationsRepositoryInterface
|
||||
{
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* This method returns a list of all the withdrawal transaction journals (as arrays) set in that period
|
||||
* which have the specified accounts. It's grouped per currency, with as few details in the array
|
||||
* as possible. Amounts are always negative.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listExpenses(Carbon $start, Carbon $end, Collection $accounts): array
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL]);
|
||||
$collector->setBothAccounts($accounts);
|
||||
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation()->withTagInformation();
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$array = [];
|
||||
|
||||
|
||||
foreach ($journals as $journal) {
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$array[$currencyId] = $array[$currencyId] ?? [
|
||||
|
||||
'currency_id' => $currencyId,
|
||||
'currency_name' => $journal['currency_name'],
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_decimal_places' => $journal['currency_decimal_places'],
|
||||
'transaction_journals' => [],
|
||||
];
|
||||
|
||||
$journalId = (int)$journal['transaction_journal_id'];
|
||||
$array[$currencyId]['transaction_journals'][$journalId] = [
|
||||
'amount' => app('steam')->negative($journal['amount']),
|
||||
'date' => $journal['date'],
|
||||
'transaction_journal_id' => $journalId,
|
||||
'budget_name' => $journal['budget_name'],
|
||||
'category_name' => $journal['category_name'],
|
||||
'source_account_id' => $journal['source_account_id'],
|
||||
'source_account_name' => $journal['source_account_name'],
|
||||
'source_account_iban' => $journal['source_account_iban'],
|
||||
'destination_account_id' => $journal['destination_account_id'],
|
||||
'destination_account_name' => $journal['destination_account_name'],
|
||||
'destination_account_iban' => $journal['destination_account_iban'],
|
||||
'tags' => $journal['tags'],
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
];
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a list of all the deposit transaction journals (as arrays) set in that period
|
||||
* which have the specified accounts. It's grouped per currency, with as few details in the array
|
||||
* as possible. Amounts are always positive.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection|null $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listIncome(Carbon $start, Carbon $end, ?Collection $accounts = null): array
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT]);
|
||||
$collector->setBothAccounts($accounts);
|
||||
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation()->withTagInformation();
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$array = [];
|
||||
|
||||
|
||||
foreach ($journals as $journal) {
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$array[$currencyId] = $array[$currencyId] ?? [
|
||||
|
||||
'currency_id' => $currencyId,
|
||||
'currency_name' => $journal['currency_name'],
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_decimal_places' => $journal['currency_decimal_places'],
|
||||
'transaction_journals' => [],
|
||||
];
|
||||
|
||||
$journalId = (int)$journal['transaction_journal_id'];
|
||||
$array[$currencyId]['transaction_journals'][$journalId] = [
|
||||
'amount' => app('steam')->positive($journal['amount']),
|
||||
'date' => $journal['date'],
|
||||
'transaction_journal_id' => $journalId,
|
||||
'budget_name' => $journal['budget_name'],
|
||||
'tags' => $journal['tags'],
|
||||
'category_name' => $journal['category_name'],
|
||||
'source_account_id' => $journal['source_account_id'],
|
||||
'source_account_name' => $journal['source_account_name'],
|
||||
'source_account_iban' => $journal['source_account_iban'],
|
||||
'destination_account_id' => $journal['destination_account_id'],
|
||||
'destination_account_name' => $journal['destination_account_name'],
|
||||
'destination_account_iban' => $journal['destination_account_iban'],
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
];
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sum of withdrawal journals in period for a set of accounts, grouped per currency. Amounts are always negative.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection|null $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sumExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null): array
|
||||
{
|
||||
throw new FireflyException(sprintf('%s is not yet implemented', __METHOD__));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sum of income journals in period for a set of accounts, grouped per currency. Amounts are always positive.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection|null $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sumIncome(Carbon $start, Carbon $end, ?Collection $accounts = null): array
|
||||
{
|
||||
throw new FireflyException(sprintf('%s is not yet implemented', __METHOD__));
|
||||
}
|
||||
}
|
87
app/Repositories/Account/OperationsRepositoryInterface.php
Normal file
87
app/Repositories/Account/OperationsRepositoryInterface.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* OperationsRepositoryInterface.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Account;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface OperationsRepositoryInterface
|
||||
*/
|
||||
interface OperationsRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* This method returns a list of all the withdrawal transaction journals (as arrays) set in that period
|
||||
* which have the specified accounts. It's grouped per currency, with as few details in the array
|
||||
* as possible. Amounts are always negative.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listExpenses(Carbon $start, Carbon $end, Collection $accounts): array;
|
||||
|
||||
/**
|
||||
* This method returns a list of all the deposit transaction journals (as arrays) set in that period
|
||||
* which have the specified accounts. It's grouped per currency, with as few details in the array
|
||||
* as possible. Amounts are always positive.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection|null $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listIncome(Carbon $start, Carbon $end, ?Collection $accounts = null): array;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user): void;
|
||||
|
||||
/**
|
||||
* Sum of withdrawal journals in period for a set of accounts, grouped per currency. Amounts are always negative.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection|null $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sumExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null): array;
|
||||
|
||||
/**
|
||||
* Sum of income journals in period for a set of accounts, grouped per currency. Amounts are always positive.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection|null $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sumIncome(Carbon $start, Carbon $end, ?Collection $accounts = null): array;
|
||||
}
|
@ -45,11 +45,11 @@ trait RenderPartialViews
|
||||
{
|
||||
|
||||
/**
|
||||
* Get options for account report.
|
||||
* Get options for double report.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function accountReportOptions(): string // render a view
|
||||
protected function doubleReportOptions(): string // render a view
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
@ -77,7 +77,7 @@ trait RenderPartialViews
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
try {
|
||||
$result = view('reports.options.account', compact('set'))->render();
|
||||
$result = view('reports.options.double', compact('set'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
|
32
public/v1/js/ff/reports/account/month.js
vendored
32
public/v1/js/ff/reports/account/month.js
vendored
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* month.js
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/** global: spentUri, categoryUri, budgetUri, expenseUri, incomeUri, mainUri */
|
||||
$(function () {
|
||||
"use strict";
|
||||
doubleYChart(mainUri, 'in-out-chart');
|
||||
|
||||
loadAjaxPartial('inOutAccounts', spentUri);
|
||||
loadAjaxPartial('inOutCategory', categoryUri);
|
||||
loadAjaxPartial('inOutBudget', budgetUri);
|
||||
loadAjaxPartial('topXexpense', expenseUri);
|
||||
loadAjaxPartial('topXincome', incomeUri);
|
||||
|
||||
});
|
||||
|
43
public/v1/js/ff/reports/double/month.js
vendored
Normal file
43
public/v1/js/ff/reports/double/month.js
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* month.js
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
$(function () {
|
||||
"use strict";
|
||||
|
||||
loadAjaxPartial('opsAccounts', opsAccountsUri);
|
||||
loadAjaxPartial('opsAccountsAsset', opsAccountsAssetUri);
|
||||
|
||||
multiCurrencyPieChart(categoryOutUri, 'category-out-pie-chart');
|
||||
multiCurrencyPieChart(categoryInUri, 'category-in-pie-chart');
|
||||
multiCurrencyPieChart(budgetsOutUri, 'budgets-out-pie-chart');
|
||||
multiCurrencyPieChart(tagOutUri, 'tag-out-pie-chart');
|
||||
multiCurrencyPieChart(tagInUri, 'tag-in-pie-chart');
|
||||
|
||||
$.each($('.main_double_canvas'), function (i, v) {
|
||||
var canvas = $(v);
|
||||
columnChart(canvas.data('url'), canvas.attr('id'));
|
||||
});
|
||||
|
||||
loadAjaxPartial('topExpensesHolder', topExpensesUri);
|
||||
loadAjaxPartial('avgExpensesHolder', avgExpensesUri);
|
||||
loadAjaxPartial('topIncomeHolder', topIncomeUri);
|
||||
loadAjaxPartial('avgIncomeHolder', avgIncomeUri);
|
||||
|
||||
});
|
||||
|
12
public/v1/js/ff/reports/index.js
vendored
12
public/v1/js/ff/reports/index.js
vendored
@ -132,13 +132,13 @@ function setOptionalFromCookies() {
|
||||
$('#inputTags').multiselect(defaultMultiSelect);
|
||||
|
||||
// and expense/revenue thing
|
||||
if ((readCookie('report-exp-rev') !== null)) {
|
||||
arr = readCookie('report-exp-rev').split(',');
|
||||
if ((readCookie('report-double') !== null)) {
|
||||
arr = readCookie('report-double').split(',');
|
||||
arr.forEach(function (val) {
|
||||
$('#inputExpRevAccounts').find('option[value="' + encodeURI(val) + '"]').prop('selected', true);
|
||||
$('#inputDoubleAccounts').find('option[value="' + encodeURI(val) + '"]').prop('selected', true);
|
||||
});
|
||||
}
|
||||
$('#inputExpRevAccounts').multiselect(defaultMultiSelect);
|
||||
$('#inputDoubleAccounts').multiselect(defaultMultiSelect);
|
||||
|
||||
|
||||
}
|
||||
@ -153,7 +153,7 @@ function catchSubmit() {
|
||||
var categories = $('#inputCategories').val();
|
||||
var budgets = $('#inputBudgets').val();
|
||||
var tags = $('#inputTags').val();
|
||||
var expRev = $('#inputExpRevAccounts').val();
|
||||
var double = $('#inputDoubleAccounts').val();
|
||||
|
||||
// remember all
|
||||
// set cookie to remember choices.
|
||||
@ -162,7 +162,7 @@ function catchSubmit() {
|
||||
createCookie('report-categories', categories, 365);
|
||||
createCookie('report-budgets', budgets, 365);
|
||||
createCookie('report-tags', tags, 365);
|
||||
createCookie('report-exp-rev', expRev, 365);
|
||||
createCookie('report-double', double, 365);
|
||||
createCookie('report-start', moment(picker.startDate).format("YYYYMMDD"), 365);
|
||||
createCookie('report-end', moment(picker.endDate).format("YYYYMMDD"), 365);
|
||||
|
||||
|
@ -123,6 +123,10 @@ return [
|
||||
'sum_of_income' => 'Sum of income',
|
||||
'liabilities' => 'Liabilities',
|
||||
'spent_in_specific_budget' => 'Spent in budget ":budget"',
|
||||
'spent_in_specific_double' => 'Spent in account(s) ":account"',
|
||||
'earned_in_specific_double' => 'Earned in account(s) ":account"',
|
||||
'source_account' => 'Source account',
|
||||
'destination_account' => 'Destination account',
|
||||
'sum_of_expenses_in_budget' => 'Spent total in budget ":budget"',
|
||||
'left_in_budget_limit' => 'Left to spend according to budgeting',
|
||||
'current_period' => 'Current period',
|
||||
@ -902,9 +906,12 @@ return [
|
||||
'earned_in_specific_tag' => 'Earned in tag ":tag"',
|
||||
'income_per_source_account' => 'Income per source account',
|
||||
'average_spending_per_destination' => 'Average expense per destination account',
|
||||
'average_spending_per_source' => 'Average expense per source account',
|
||||
'average_earning_per_source' => 'Average earning per source account',
|
||||
'average_earning_per_destination' => 'Average earning per destination account',
|
||||
'account_per_tag' => 'Account per tag',
|
||||
'tag_report_expenses_listed_once' => 'Expenses and income are never listed twice. If a transaction has multiple tags, it may only show up under one of its tags. This list may appear to be missing data, but the amounts will be correct.',
|
||||
'double_report_expenses_charted_once' => 'Expenses and income are never displayed twice. If a transaction has multiple tags, it may only show up under one of its tags. This chart may appear to be missing data, but the amounts will be correct.',
|
||||
'tag_report_chart_single_tag' => 'This chart applies to a single tag. If a transaction has multiple tags, what you see here may be reflected in the charts of other tags as well.',
|
||||
'tag' => 'Tag',
|
||||
'no_budget_squared' => '(no budget)',
|
||||
@ -1028,7 +1035,7 @@ return [
|
||||
'report_default' => 'Default financial report between :start and :end',
|
||||
'report_audit' => 'Transaction history overview between :start and :end',
|
||||
'report_category' => 'Category report between :start and :end',
|
||||
'report_account' => 'Expense/revenue account report between :start and :end',
|
||||
'report_double' => 'Expense/revenue account report between :start and :end',
|
||||
'report_budget' => 'Budget report between :start and :end',
|
||||
'report_tag' => 'Tag report between :start and :end',
|
||||
'quick_link_reports' => 'Quick links',
|
||||
@ -1065,7 +1072,7 @@ return [
|
||||
'report_type_category' => 'Category report',
|
||||
'report_type_budget' => 'Budget report',
|
||||
'report_type_tag' => 'Tag report',
|
||||
'report_type_account' => 'Expense/revenue account report',
|
||||
'report_type_double' => 'Expense/revenue account report',
|
||||
'more_info_help' => 'More information about these types of reports can be found in the help pages. Press the (?) icon in the top right corner.',
|
||||
'report_included_accounts' => 'Included accounts',
|
||||
'report_date_range' => 'Date range',
|
||||
@ -1119,6 +1126,7 @@ return [
|
||||
'budget_chart_click' => 'Please click on a budget name in the table above to see a chart.',
|
||||
'category_chart_click' => 'Please click on a category name in the table above to see a chart.',
|
||||
'in_out_accounts' => 'Earned and spent per combination',
|
||||
'in_out_accounts_per_asset' => 'Earned and spent (per asset account)',
|
||||
'in_out_per_category' => 'Earned and spent per category',
|
||||
'out_per_budget' => 'Spent per budget',
|
||||
'select_expense_revenue' => 'Select expense/revenue account',
|
||||
@ -1152,6 +1160,7 @@ return [
|
||||
'average' => 'Average',
|
||||
'balanceFor' => 'Balance for :name',
|
||||
'no_tags_for_cloud' => 'No tags to generate cloud',
|
||||
'no_tags' => '(no tags)',
|
||||
'tag_cloud' => 'Tag cloud',
|
||||
|
||||
// piggy banks:
|
||||
|
@ -0,0 +1,44 @@
|
||||
<table class="table table-hover sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-defaultsign="az">{{ 'name'|_ }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ 'spent'|_ }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ 'earned'|_ }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ 'sum'|_ }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for account in report %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ route('accounts.show', [account.account_id]) }}" title="{{ account.account_name }}">{{ account.account_name }}</a>
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(account.spent, account.currency_symbol, account.currency_decimal_places) }}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(account.earned, account.currency_symbol, account.currency_decimal_places) }}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(account.sum, account.currency_symbol, account.currency_decimal_places) }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{% for sum in sums %}
|
||||
<tr>
|
||||
<td>{{ 'sum'|_ }} ({{ sum.currency_name }})</td>
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(sum.spent, sum.currency_symbol, sum.currency_decimal_places) }}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(sum.earned, sum.currency_symbol, sum.currency_decimal_places) }}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(sum.sum, sum.currency_symbol, sum.currency_decimal_places) }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tfoot>
|
||||
</table>
|
55
resources/views/v1/reports/double/partials/accounts.twig
Normal file
55
resources/views/v1/reports/double/partials/accounts.twig
Normal file
@ -0,0 +1,55 @@
|
||||
<table class="table table-hover sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-defaultsign="az">{{ 'name'|_ }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ 'spent'|_ }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ 'earned'|_ }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ 'sum'|_ }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for account in report %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if account.source_name == account.dest_name %}
|
||||
{{ account.source_name }}
|
||||
{% else %}
|
||||
{{ account.source_name }} / {{ account.dest_name }}
|
||||
{% endif %}
|
||||
{% if account.source_iban != '' and account.dest_iban != '' %}
|
||||
{% if account.source_iban == account.dest_iban %}
|
||||
({{ account.source_iban }})
|
||||
{% else %}
|
||||
({{ account.source_iban }} / ({{ account.dest_iban }}))
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(account.spent, account.currency_symbol, account.currency_decimal_places) }}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(account.earned, account.currency_symbol, account.currency_decimal_places) }}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(account.sum, account.currency_symbol, account.currency_decimal_places) }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{% for sum in sums %}
|
||||
<tr>
|
||||
<td>{{ 'sum'|_ }} ({{ sum.currency_name }})</td>
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(sum.spent, sum.currency_symbol, sum.currency_decimal_places) }}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(sum.earned, sum.currency_symbol, sum.currency_decimal_places) }}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(sum.sum, sum.currency_symbol, sum.currency_decimal_places) }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tfoot>
|
||||
</table>
|
46
resources/views/v1/reports/double/partials/avg-expenses.twig
Normal file
46
resources/views/v1/reports/double/partials/avg-expenses.twig
Normal file
@ -0,0 +1,46 @@
|
||||
<table class="table table-hover sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-defaultsign="az">{{ 'account'|_ }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ 'spent_average'|_ }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ 'total'|_ }}</th>
|
||||
<th data-defaultsign="_19">{{ 'transaction_count'|_ }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in result %}
|
||||
{% if loop.index > listLength %}
|
||||
<tr class="overListLength">
|
||||
{% else %}
|
||||
<tr>
|
||||
{% endif %}
|
||||
<td data-sortable="false">
|
||||
<a href="{{ route('accounts.show', row.source_account_id) }}">
|
||||
{{ row.source_account_name }}
|
||||
</a>
|
||||
</td>
|
||||
<td data-value="{{ row.avg }}" style="text-align: right;">
|
||||
{{ formatAmountBySymbol(row.avg, row.currency_symbol, row.currency_decimal_places) }}
|
||||
</td>
|
||||
|
||||
<td data-value="{{ row.sum }}" style="text-align: right;">
|
||||
{{ formatAmountBySymbol(row.sum, row.currency_symbol, row.currency_decimal_places) }}
|
||||
</td>
|
||||
|
||||
<td data-value="{{ row.transactions }}">
|
||||
{{ row.transactions }}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{% if result|length > listLength %}
|
||||
<tr>
|
||||
<td colspan="5" class="active">
|
||||
<a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tfoot>
|
||||
</table>
|
46
resources/views/v1/reports/double/partials/avg-income.twig
Normal file
46
resources/views/v1/reports/double/partials/avg-income.twig
Normal file
@ -0,0 +1,46 @@
|
||||
<table class="table table-hover sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-defaultsign="az">{{ 'account'|_ }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ 'spent_average'|_ }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ 'total'|_ }}</th>
|
||||
<th data-defaultsign="_19">{{ 'transaction_count'|_ }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in result %}
|
||||
{% if loop.index > listLength %}
|
||||
<tr class="overListLength">
|
||||
{% else %}
|
||||
<tr>
|
||||
{% endif %}
|
||||
<td data-sortable="false">
|
||||
<a href="{{ route('accounts.show', row.destination_account_id) }}">
|
||||
{{ row.destination_account_name }}
|
||||
</a>
|
||||
</td>
|
||||
<td data-value="{{ row.avg }}" style="text-align: right;">
|
||||
{{ formatAmountBySymbol(row.avg, row.currency_symbol, row.currency_decimal_places) }}
|
||||
</td>
|
||||
|
||||
<td data-value="{{ row.sum }}" style="text-align: right;">
|
||||
{{ formatAmountBySymbol(row.sum, row.currency_symbol, row.currency_decimal_places) }}
|
||||
</td>
|
||||
|
||||
<td data-value="{{ row.transactions }}">
|
||||
{{ row.transactions }}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{% if result|length > listLength %}
|
||||
<tr>
|
||||
<td colspan="5" class="active">
|
||||
<a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tfoot>
|
||||
</table>
|
55
resources/views/v1/reports/double/partials/top-expenses.twig
Normal file
55
resources/views/v1/reports/double/partials/top-expenses.twig
Normal file
@ -0,0 +1,55 @@
|
||||
<table class="table table-hover sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-defaultsort="disabled">{{ 'description'|_ }}</th>
|
||||
<th data-defaultsign="month">{{ 'date'|_ }}</th>
|
||||
<th data-defaultsign="az">{{ 'source_account'|_ }}</th>
|
||||
<th data-defaultsign="az">{{ 'destination_account'|_ }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ 'amount'|_ }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in result %}
|
||||
{% if loop.index > listLength %}
|
||||
<tr class="overListLength">
|
||||
{% else %}
|
||||
<tr>
|
||||
{% endif %}
|
||||
<td data-sortable="false">
|
||||
<a href="{{ route('transactions.show', row.transaction_group_id) }}">
|
||||
{{ row.description }}
|
||||
</a>
|
||||
</td>
|
||||
<td data-sortable="false">
|
||||
{{ row.date }}
|
||||
</td>
|
||||
|
||||
<td data-sortable="false">
|
||||
<a href="{{ route('accounts.show', row.source_account_id) }}">
|
||||
{{ row.source_account_name }}
|
||||
</a>
|
||||
</td>
|
||||
<td data-sortable="false">
|
||||
<a href="{{ route('accounts.show', row.destination_account_id) }}">
|
||||
{{ row.destination_account_name }}
|
||||
</a>
|
||||
</td>
|
||||
|
||||
|
||||
<td data-value="{{ row.amount }}" style="text-align: right;">
|
||||
{{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_decimal_places) }}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{% if result|length > listLength %}
|
||||
<tr>
|
||||
<td colspan="5" class="active">
|
||||
<a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tfoot>
|
||||
</table>
|
55
resources/views/v1/reports/double/partials/top-income.twig
Normal file
55
resources/views/v1/reports/double/partials/top-income.twig
Normal file
@ -0,0 +1,55 @@
|
||||
<table class="table table-hover sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-defaultsort="disabled">{{ 'description'|_ }}</th>
|
||||
<th data-defaultsign="month">{{ 'date'|_ }}</th>
|
||||
<th data-defaultsign="az">{{ 'source_account'|_ }}</th>
|
||||
<th data-defaultsign="az">{{ 'destination_account'|_ }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ 'amount'|_ }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in result %}
|
||||
{% if loop.index > listLength %}
|
||||
<tr class="overListLength">
|
||||
{% else %}
|
||||
<tr>
|
||||
{% endif %}
|
||||
<td data-sortable="false">
|
||||
<a href="{{ route('transactions.show', row.transaction_group_id) }}">
|
||||
{{ row.description }}
|
||||
</a>
|
||||
</td>
|
||||
<td data-sortable="false">
|
||||
{{ row.date }}
|
||||
</td>
|
||||
|
||||
<td data-sortable="false">
|
||||
<a href="{{ route('accounts.show', row.source_account_id) }}">
|
||||
{{ row.source_account_name }}
|
||||
</a>
|
||||
</td>
|
||||
<td data-sortable="false">
|
||||
<a href="{{ route('accounts.show', row.destination_account_id) }}">
|
||||
{{ row.destination_account_name }}
|
||||
</a>
|
||||
</td>
|
||||
|
||||
|
||||
<td data-value="{{ row.amount }}" style="text-align: right;">
|
||||
{{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_decimal_places) }}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{% if result|length > listLength %}
|
||||
<tr>
|
||||
<td colspan="5" class="active">
|
||||
<a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tfoot>
|
||||
</table>
|
@ -6,14 +6,27 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
{# in/out + In/out per per periode #}
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
||||
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'in_out_accounts'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body table-responsive no-padding" id="inOutAccounts">
|
||||
<div class="box-body table-responsive no-padding" id="opsAccounts">
|
||||
{# loading indicator #}
|
||||
<div class="overlay">
|
||||
<i class="fa fa-refresh fa-spin"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'in_out_accounts_per_asset'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body table-responsive no-padding" id="opsAccountsAsset">
|
||||
{# loading indicator #}
|
||||
<div class="overlay">
|
||||
<i class="fa fa-refresh fa-spin"></i>
|
||||
@ -23,59 +36,107 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# chart #}
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="box" id="incomeAndExpensesChart">
|
||||
<div class="col-lg-4 col-md-6">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'income_and_expenses'|_ }}</h3>
|
||||
<h3 class="box-title">{{ 'expense_per_category'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<canvas id="in-out-chart" style="width:100%;height:400px;" height="400" width="100%"></canvas>
|
||||
<div style="width:100%;margin:0 auto;">
|
||||
<canvas id="category-out-pie-chart" style="width:100%;height:250px;" height="250"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-6">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'income_per_category'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div style="width:100%;margin:0 auto;">
|
||||
<canvas id="category-in-pie-chart" style="width:100%;height:250px;" height="250"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-6">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'expense_per_budget'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div style="width:100%;margin:0 auto;">
|
||||
<canvas id="budgets-out-pie-chart" style="width:100%;height:250px;" height="250"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# in/out category + out per budget #}
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
||||
<div class="col-lg-6 col-md-6">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'in_out_per_category'|_ }}</h3>
|
||||
<h3 class="box-title">{{ 'expense_per_tag'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body table-responsive no-padding" id="inOutCategory">
|
||||
{# loading indicator #}
|
||||
<div class="overlay">
|
||||
<i class="fa fa-refresh fa-spin"></i>
|
||||
<div class="box-body">
|
||||
<div style="width:100%;margin:0 auto;">
|
||||
<canvas id="tag-out-pie-chart" style="width:100%;height:250px;" height="250"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<p class="text-info">
|
||||
<em>{{ 'double_report_expenses_charted_once'|_ }}</em>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
||||
<div class="col-lg-6 col-md-6">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'out_per_budget'|_ }}</h3>
|
||||
<h3 class="box-title">{{ 'income_per_tag'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body table-responsive no-padding" id="inOutBudget">
|
||||
{# loading indicator #}
|
||||
<div class="overlay">
|
||||
<i class="fa fa-refresh fa-spin"></i>
|
||||
<div class="box-body">
|
||||
<div style="width:100%;margin:0 auto;">
|
||||
<canvas id="tag-in-pie-chart" style="width:100%;height:250px;" height="250"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<p class="text-info">
|
||||
<em>{{ 'double_report_expenses_charted_once'|_ }}</em>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# expenses top 10 + income top 10 #}
|
||||
|
||||
{% for account in doubles %}
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="box" id="incomeAndExpensesChart">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'income_and_expenses'|_ }} ({{ account.name }}) {% if account.iban %}({{ account.iban }}){% endif %}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<canvas class="main_double_canvas"
|
||||
data-url="{{ route('chart.double.main', [accountIds, account.id, start.format('Ymd'), end.format('Ymd')]) }}"
|
||||
id="in-out-chart-{{ account.id }}" style="width:100%;height:400px;" height="400" width="100%"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'expenses'|_ }} ({{ trans('firefly.topX', {number: listLength}) }})</h3>
|
||||
</div>
|
||||
<div class="box-body table-responsive no-padding" id="topXexpense">
|
||||
<div class="box-body table-responsive no-padding" id="topExpensesHolder">
|
||||
{# loading indicator #}
|
||||
<div class="overlay">
|
||||
<i class="fa fa-refresh fa-spin"></i>
|
||||
@ -89,7 +150,7 @@
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'income'|_ }} ({{ trans('firefly.topX', {number: listLength}) }})</h3>
|
||||
</div>
|
||||
<div class="box-body table-responsive no-padding" id="topXincome">
|
||||
<div class="box-body table-responsive no-padding" id="topIncomeHolder">
|
||||
{# loading indicator #}
|
||||
<div class="overlay">
|
||||
<i class="fa fa-refresh fa-spin"></i>
|
||||
@ -99,6 +160,35 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'average_spending_per_source'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body table-responsive no-padding" id="avgExpensesHolder">
|
||||
</div>
|
||||
{# loading indicator #}
|
||||
<div class="overlay">
|
||||
<i class="fa fa-refresh fa-spin"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'average_earning_per_destination'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body table-responsive no-padding" id="avgIncomeHolder">
|
||||
</div>
|
||||
{# loading indicator #}
|
||||
<div class="overlay">
|
||||
<i class="fa fa-refresh fa-spin"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
@ -112,23 +202,30 @@
|
||||
var startDate = '{{ start.format('Ymd') }}';
|
||||
var endDate = '{{ end.format('Ymd') }}';
|
||||
var accountIds = '{{ accountIds }}';
|
||||
var expenseIds = '{{ expenseIds }}';
|
||||
var doubleIds = '{{ doubleIds }}';
|
||||
|
||||
// chart uri's
|
||||
var mainUri = '{{ route('chart.expense.main', [accountIds, expenseIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
{#var mainUri = '{{ route('chart.expense.main', [accountIds, expenseIds, start.format('Ymd'), end.format('Ymd')]) }}';#}
|
||||
|
||||
// boxes with stuff:
|
||||
var spentUri = '{{ route('report-data.expense.spent', [accountIds, expenseIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
var categoryUri = '{{ route('report-data.expense.category', [accountIds, expenseIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
var budgetUri = '{{ route('report-data.expense.budget', [accountIds, expenseIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
var expenseUri = '{{ route('report-data.expense.expenses', [accountIds, expenseIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
var incomeUri = '{{ route('report-data.expense.income', [accountIds, expenseIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
// html blocks.
|
||||
var opsAccountsUri = '{{ route('report-data.double.operations', [accountIds, doubleIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
var opsAccountsAssetUri = '{{ route('report-data.double.ops-asset', [accountIds, doubleIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
|
||||
// pie charts:
|
||||
var categoryOutUri = '{{ route('chart.double.category-expense', [accountIds, doubleIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
var categoryInUri = '{{ route('chart.double.category-income', [accountIds, doubleIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
var budgetsOutUri = '{{ route('chart.double.budget-expense', [accountIds, doubleIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
var tagOutUri = '{{ route('chart.double.tag-expense', [accountIds, doubleIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
var tagInUri = '{{ route('chart.double.tag-income', [accountIds, doubleIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
|
||||
var avgExpensesUri = '{{ route('report-data.double.avg-expenses', [accountIds, doubleIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
var topExpensesUri = '{{ route('report-data.double.top-expenses', [accountIds, doubleIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
var avgIncomeUri = '{{ route('report-data.double.avg-income', [accountIds, doubleIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
var topIncomeUri = '{{ route('report-data.double.top-income', [accountIds, doubleIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="v1/js/ff/reports/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="v1/js/ff/reports/account/month.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="v1/js/ff/reports/double/month.js?v={{ FF_VERSION }}"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
<option label="{{ 'report_type_budget'|_ }}" value="budget">{{ 'report_type_budget'|_ }}</option>
|
||||
<option label="{{ 'report_type_category'|_ }}" value="category">{{ 'report_type_category'|_ }}</option>
|
||||
<option label="{{ 'report_type_tag'|_ }}" value="tag">{{ 'report_type_tag'|_ }}</option>
|
||||
<option label="{{ 'report_type_account'|_ }}" value="account">{{ 'report_type_account'|_ }}</option>
|
||||
<option label="{{ 'report_type_double'|_ }}" value="double">{{ 'report_type_double'|_ }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="form-group">
|
||||
<label for="inputExpRevAccounts" class="col-sm-3 control-label">{{ 'select_expense_revenue'|_ }}</label>
|
||||
<label for="inputDoubleAccounts" class="col-sm-3 control-label">{{ 'select_expense_revenue'|_ }}</label>
|
||||
<div class="col-sm-9">
|
||||
<select id="inputExpRevAccounts" name="exp_rev[]" multiple="multiple" class="form-control">
|
||||
<select id="inputDoubleAccounts" name="double[]" multiple="multiple" class="form-control">
|
||||
{% for account in set %}
|
||||
<option value="{{ account.id }}" label="{{ account.name }}{% if account.iban !='' %} ({{ account.iban }}){% endif %}">{{ account.name }}{% if account.iban !='' %} ({{ account.iban }}){% endif %}</option>
|
||||
{% endfor %}
|
@ -439,13 +439,20 @@ Route::group(
|
||||
);
|
||||
|
||||
/**
|
||||
* Chart\Expense Controller (for expense/revenue report).
|
||||
* Chart\Double Controller (for expense/revenue report).
|
||||
*/
|
||||
Route::group(
|
||||
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/expense', 'as' => 'chart.expense.'],
|
||||
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/double', 'as' => 'chart.double.'],
|
||||
static function () {
|
||||
// TODO replace me.
|
||||
//Route::get('operations/{accountList}/{expenseList}/{start_date}/{end_date}', ['uses' => 'ExpenseReportController@mainChart', 'as' => 'main']);
|
||||
|
||||
Route::get('main/{accountList}/{account}/{start_date}/{end_date}', ['uses' => 'DoubleReportController@mainChart', 'as' => 'main']);
|
||||
|
||||
Route::get('category/expense/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'DoubleReportController@categoryExpense', 'as' => 'category-expense']);
|
||||
Route::get('category/income/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'DoubleReportController@categoryIncome', 'as' => 'category-income']);
|
||||
Route::get('budget/expense/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'DoubleReportController@budgetExpense', 'as' => 'budget-expense']);
|
||||
|
||||
Route::get('tag/expense/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'DoubleReportController@tagExpense', 'as' => 'tag-expense']);
|
||||
Route::get('tag/income/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'DoubleReportController@tagIncome', 'as' => 'tag-income']);
|
||||
}
|
||||
);
|
||||
|
||||
@ -455,7 +462,7 @@ Route::group(
|
||||
*/
|
||||
Route::group(
|
||||
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/piggy-bank', 'as' => 'chart.piggy-bank.'],
|
||||
function () {
|
||||
static function () {
|
||||
Route::get('{piggyBank}', ['uses' => 'PiggyBankController@history', 'as' => 'history']);
|
||||
}
|
||||
);
|
||||
@ -687,7 +694,7 @@ Route::group(
|
||||
Route::get('category/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'ReportController@categoryReport', 'as' => 'report.category']);
|
||||
Route::get('budget/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'ReportController@budgetReport', 'as' => 'report.budget']);
|
||||
Route::get('tag/{accountList}/{tagList}/{start_date}/{end_date}', ['uses' => 'ReportController@tagReport', 'as' => 'report.tag']);
|
||||
Route::get('account/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'ReportController@accountReport', 'as' => 'report.account']);
|
||||
Route::get('double/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'ReportController@doubleReport', 'as' => 'report.double']);
|
||||
|
||||
Route::post('', ['uses' => 'ReportController@postIndex', 'as' => 'index.post']);
|
||||
}
|
||||
@ -698,7 +705,7 @@ Route::group(
|
||||
*/
|
||||
Route::group(
|
||||
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Report', 'prefix' => 'report-data/account', 'as' => 'report-data.account.'],
|
||||
function () {
|
||||
static function () {
|
||||
Route::get('general/{accountList}/{start_date}/{end_date}', ['uses' => 'AccountController@general', 'as' => 'general']);
|
||||
}
|
||||
);
|
||||
@ -714,22 +721,21 @@ Route::group(
|
||||
);
|
||||
|
||||
/**
|
||||
* Report Data Expense / Revenue Account Controller
|
||||
* Report Double Data Expense / Revenue Account Controller
|
||||
*/
|
||||
Route::group(
|
||||
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Report', 'prefix' => 'report-data/expense', 'as' => 'report-data.expense.'],
|
||||
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Report', 'prefix' => 'report-data/double', 'as' => 'report-data.double.'],
|
||||
static function () {
|
||||
|
||||
// TODO replace me.
|
||||
// spent per period
|
||||
//Route::get('spent/{accountList}/{expenseList}/{start_date}/{end_date}', ['uses' => 'ExpenseController@spent', 'as' => 'spent']);
|
||||
// per category && per budget
|
||||
//Route::get('category/{accountList}/{expenseList}/{start_date}/{end_date}', ['uses' => 'ExpenseController@category', 'as' => 'category']);
|
||||
//Route::get('budget/{accountList}/{expenseList}/{start_date}/{end_date}', ['uses' => 'ExpenseController@budget', 'as' => 'budget']);
|
||||
//expense earned top X
|
||||
//Route::get('expenses/{accountList}/{expenseList}/{start_date}/{end_date}', ['uses' => 'ExpenseController@topExpense', 'as' => 'expenses']);
|
||||
//Route::get('income/{accountList}/{expenseList}/{start_date}/{end_date}', ['uses' => 'ExpenseController@topIncome', 'as' => 'income']);
|
||||
// spent + earned per combination.
|
||||
Route::get('operations/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'DoubleController@operations', 'as' => 'operations']);
|
||||
Route::get('ops-asset/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'DoubleController@operationsPerAsset', 'as' => 'ops-asset']);
|
||||
|
||||
Route::get('top-expenses/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'DoubleController@topExpenses', 'as' => 'top-expenses']);
|
||||
Route::get('avg-expenses/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'DoubleController@avgExpenses', 'as' => 'avg-expenses']);
|
||||
|
||||
Route::get('top-income/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'DoubleController@topIncome', 'as' => 'top-income']);
|
||||
Route::get('avg-income/{accountList}/{doubleList}/{start_date}/{end_date}', ['uses' => 'DoubleController@avgIncome', 'as' => 'avg-income']);
|
||||
}
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user