mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Extend report capability for issue #396 and related report issues.
This commit is contained in:
parent
fe57648349
commit
3600e1b5e7
137
app/Generator/Report/Audit/MonthReportGenerator.php
Normal file
137
app/Generator/Report/Audit/MonthReportGenerator.php
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* MonthReportGenerator.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms of the
|
||||||
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||||
|
*
|
||||||
|
* See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Generator\Report\Audit;
|
||||||
|
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||||
|
use FireflyIII\Helpers\Collector\JournalCollector;
|
||||||
|
use FireflyIII\Models\Account;
|
||||||
|
use FireflyIII\Models\Transaction;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Steam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MonthReportGenerator
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Generator\Report\Standard
|
||||||
|
*/
|
||||||
|
class MonthReportGenerator implements ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
/** @var Collection */
|
||||||
|
private $accounts;
|
||||||
|
/** @var Carbon */
|
||||||
|
private $end;
|
||||||
|
/** @var Carbon */
|
||||||
|
private $start;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function generate(): string
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$auditData = [];
|
||||||
|
$dayBefore = clone $this->start;
|
||||||
|
$dayBefore->subDay();
|
||||||
|
/** @var Account $account */
|
||||||
|
foreach ($this->accounts as $account) {
|
||||||
|
// balance the day before:
|
||||||
|
$id = $account->id;
|
||||||
|
$dayBeforeBalance = Steam::balance($account, $dayBefore);
|
||||||
|
$collector = new JournalCollector(auth()->user());
|
||||||
|
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end);
|
||||||
|
$journals = $collector->getJournals();
|
||||||
|
$journals = $journals->reverse();
|
||||||
|
$startBalance = $dayBeforeBalance;
|
||||||
|
|
||||||
|
|
||||||
|
/** @var Transaction $journal */
|
||||||
|
foreach ($journals as $transaction) {
|
||||||
|
$transaction->before = $startBalance;
|
||||||
|
$transactionAmount = $transaction->transaction_amount;
|
||||||
|
$newBalance = bcadd($startBalance, $transactionAmount);
|
||||||
|
$transaction->after = $newBalance;
|
||||||
|
$startBalance = $newBalance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reverse set again.
|
||||||
|
*/
|
||||||
|
$auditData[$id]['journals'] = $journals->reverse();
|
||||||
|
$auditData[$id]['exists'] = $journals->count() > 0;
|
||||||
|
$auditData[$id]['end'] = $this->end->formatLocalized(strval(trans('config.month_and_day')));
|
||||||
|
$auditData[$id]['endBalance'] = Steam::balance($account, $this->end);
|
||||||
|
$auditData[$id]['dayBefore'] = $dayBefore->formatLocalized(strval(trans('config.month_and_day')));
|
||||||
|
$auditData[$id]['dayBeforeBalance'] = $dayBeforeBalance;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reportType = 'audit';
|
||||||
|
$accountIds = join(',', $this->accounts->pluck('id')->toArray());
|
||||||
|
|
||||||
|
$hideable = ['buttons', 'icon', 'description', 'balance_before', 'amount', 'balance_after', 'date',
|
||||||
|
'interest_date', 'book_date', 'process_date',
|
||||||
|
// three new optional fields.
|
||||||
|
'due_date', 'payment_date', 'invoice_date',
|
||||||
|
'from', 'to', 'budget', 'category', 'bill',
|
||||||
|
// more new optional fields
|
||||||
|
'internal_reference', 'notes',
|
||||||
|
|
||||||
|
'create_date', 'update_date',
|
||||||
|
];
|
||||||
|
$defaultShow = ['icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', 'to'];
|
||||||
|
|
||||||
|
return view('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow'))
|
||||||
|
->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts)
|
||||||
|
->render();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setAccounts(Collection $accounts): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$this->accounts = $accounts;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setEndDate(Carbon $date): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$this->end = $date;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setStartDate(Carbon $date): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$this->start = $date;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
27
app/Generator/Report/Audit/MultiYearReportGenerator.php
Normal file
27
app/Generator/Report/Audit/MultiYearReportGenerator.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* MultiYearReportGenerator.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms of the
|
||||||
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||||
|
*
|
||||||
|
* See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Generator\Report\Audit;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MultiYearReportGenerator
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Generator\Report\Audit
|
||||||
|
*/
|
||||||
|
class MultiYearReportGenerator extends MonthReportGenerator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Doesn't do anything different.
|
||||||
|
*/
|
||||||
|
}
|
28
app/Generator/Report/Audit/YearReportGenerator.php
Normal file
28
app/Generator/Report/Audit/YearReportGenerator.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* YearReportGenerator.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms of the
|
||||||
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||||
|
*
|
||||||
|
* See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Generator\Report\Audit;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class YearReportGenerator
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Generator\Report\Audit
|
||||||
|
*/
|
||||||
|
class YearReportGenerator extends MonthReportGenerator
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Doesn't do anything different.
|
||||||
|
*/
|
||||||
|
}
|
58
app/Generator/Report/ReportGeneratorFactory.php
Normal file
58
app/Generator/Report/ReportGeneratorFactory.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ReportGeneratorFactory.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms of the
|
||||||
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||||
|
*
|
||||||
|
* See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Generator\Report;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ReportGeneratorFactory
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Generator\Report
|
||||||
|
*/
|
||||||
|
class ReportGeneratorFactory
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $type
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public static function reportGenerator(string $type, Carbon $start, Carbon $end): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$period = 'Month';
|
||||||
|
// more than one year date difference means multi year report.
|
||||||
|
if ($start->diffInMonths($end) > 12) {
|
||||||
|
$period = 'MultiYear';
|
||||||
|
}
|
||||||
|
// more than two months date difference means year report.
|
||||||
|
if ($start->diffInMonths($end) > 1) {
|
||||||
|
$period = 'Year';
|
||||||
|
}
|
||||||
|
|
||||||
|
$class = sprintf('FireflyIII\Generator\Report\%s\%sReportGenerator', $type, $period);
|
||||||
|
if (class_exists($class)) {
|
||||||
|
/** @var ReportGeneratorInterface $obj */
|
||||||
|
$obj = new $class;
|
||||||
|
$obj->setStartDate($start);
|
||||||
|
$obj->setEndDate($end);
|
||||||
|
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
throw new FireflyException(sprintf('Class "%s" does not exist.', $class));
|
||||||
|
}
|
||||||
|
}
|
53
app/Generator/Report/ReportGeneratorInterface.php
Normal file
53
app/Generator/Report/ReportGeneratorInterface.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ReportGeneratorInterface.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms of the
|
||||||
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||||
|
*
|
||||||
|
* See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Generator\Report;
|
||||||
|
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface ReportGeneratorInterface
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Generator\Report
|
||||||
|
*/
|
||||||
|
interface ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function generate(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setAccounts(Collection $accounts): ReportGeneratorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setEndDate(Carbon $date): ReportGeneratorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setStartDate(Carbon $date): ReportGeneratorInterface;
|
||||||
|
|
||||||
|
}
|
90
app/Generator/Report/Standard/MonthReportGenerator.php
Normal file
90
app/Generator/Report/Standard/MonthReportGenerator.php
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* MonthReportGenerator.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms of the
|
||||||
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||||
|
*
|
||||||
|
* See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Generator\Report\Standard;
|
||||||
|
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||||
|
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MonthReportGenerator
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Generator\Report\Standard
|
||||||
|
*/
|
||||||
|
class MonthReportGenerator implements ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
/** @var Collection */
|
||||||
|
private $accounts;
|
||||||
|
/** @var Carbon */
|
||||||
|
private $end;
|
||||||
|
/** @var Carbon */
|
||||||
|
private $start;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function generate(): string
|
||||||
|
{
|
||||||
|
$helper = app(ReportHelperInterface::class);
|
||||||
|
$bills = $helper->getBillReport($this->start, $this->end, $this->accounts);
|
||||||
|
|
||||||
|
// and some id's, joined:
|
||||||
|
$accountIds = join(',', $this->accounts->pluck('id')->toArray());
|
||||||
|
$reportType = 'default';
|
||||||
|
|
||||||
|
// continue!
|
||||||
|
return view(
|
||||||
|
'reports.default.month',
|
||||||
|
compact('bills', 'accountIds', 'reportType')
|
||||||
|
)->with('start', $this->start)->with('end', $this->end)->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setAccounts(Collection $accounts): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$this->accounts = $accounts;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setEndDate(Carbon $date): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$this->end = $date;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setStartDate(Carbon $date): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$this->start = $date;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
87
app/Generator/Report/Standard/MultiYearReportGenerator.php
Normal file
87
app/Generator/Report/Standard/MultiYearReportGenerator.php
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* MultiYearReportGenerator.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms of the
|
||||||
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||||
|
*
|
||||||
|
* See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Generator\Report\Standard;
|
||||||
|
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||||
|
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MonthReportGenerator
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Generator\Report\Standard
|
||||||
|
*/
|
||||||
|
class MultiYearReportGenerator implements ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
/** @var Collection */
|
||||||
|
private $accounts;
|
||||||
|
/** @var Carbon */
|
||||||
|
private $end;
|
||||||
|
/** @var Carbon */
|
||||||
|
private $start;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function generate(): string
|
||||||
|
{
|
||||||
|
// and some id's, joined:
|
||||||
|
$accountIds = join(',', $this->accounts->pluck('id')->toArray());
|
||||||
|
$reportType = 'default';
|
||||||
|
|
||||||
|
// continue!
|
||||||
|
return view(
|
||||||
|
'reports.default.multi-year',
|
||||||
|
compact('accountIds', 'reportType')
|
||||||
|
)->with('start', $this->start)->with('end', $this->end)->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setAccounts(Collection $accounts): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$this->accounts = $accounts;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setEndDate(Carbon $date): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$this->end = $date;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setStartDate(Carbon $date): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$this->start = $date;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
87
app/Generator/Report/Standard/YearReportGenerator.php
Normal file
87
app/Generator/Report/Standard/YearReportGenerator.php
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* YearReportGenerator.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms of the
|
||||||
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||||
|
*
|
||||||
|
* See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Generator\Report\Standard;
|
||||||
|
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||||
|
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MonthReportGenerator
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Generator\Report\Standard
|
||||||
|
*/
|
||||||
|
class YearReportGenerator implements ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
/** @var Collection */
|
||||||
|
private $accounts;
|
||||||
|
/** @var Carbon */
|
||||||
|
private $end;
|
||||||
|
/** @var Carbon */
|
||||||
|
private $start;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function generate(): string
|
||||||
|
{
|
||||||
|
// and some id's, joined:
|
||||||
|
$accountIds = join(',', $this->accounts->pluck('id')->toArray());
|
||||||
|
$reportType = 'default';
|
||||||
|
|
||||||
|
// continue!
|
||||||
|
return view(
|
||||||
|
'reports.default.year',
|
||||||
|
compact('accountIds', 'reportType')
|
||||||
|
)->with('start', $this->start)->with('end', $this->end)->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setAccounts(Collection $accounts): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$this->accounts = $accounts;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setEndDate(Carbon $date): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$this->end = $date;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return ReportGeneratorInterface
|
||||||
|
*/
|
||||||
|
public function setStartDate(Carbon $date): ReportGeneratorInterface
|
||||||
|
{
|
||||||
|
$this->start = $date;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@ -15,12 +15,18 @@ namespace FireflyIII\Http\Controllers;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Generator\Report\ReportGeneratorFactory;
|
||||||
|
use FireflyIII\Generator\Report\Standard\MonthReportGenerator;
|
||||||
|
use FireflyIII\Generator\Report\StandardReportGenerator;
|
||||||
use FireflyIII\Helpers\Collector\JournalCollector;
|
use FireflyIII\Helpers\Collector\JournalCollector;
|
||||||
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||||
|
use FireflyIII\Http\Requests\ReportFormRequest;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Response;
|
use Response;
|
||||||
@ -59,6 +65,84 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function auditReport(Carbon $start, Carbon $end, Collection $accounts)
|
||||||
|
{
|
||||||
|
// throw an error if necessary.
|
||||||
|
if ($end < $start) {
|
||||||
|
throw new FireflyException('End date cannot be before start date, silly!');
|
||||||
|
}
|
||||||
|
|
||||||
|
// lower threshold
|
||||||
|
if ($start < session('first')) {
|
||||||
|
$start = session('first');
|
||||||
|
}
|
||||||
|
|
||||||
|
View::share(
|
||||||
|
'subTitle', trans(
|
||||||
|
'firefly.report_audit',
|
||||||
|
[
|
||||||
|
'start' => $start->formatLocalized($this->monthFormat),
|
||||||
|
'end' => $end->formatLocalized($this->monthFormat),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
View::share('subTitleIcon', 'fa-calendar');
|
||||||
|
|
||||||
|
$generator = ReportGeneratorFactory::reportGenerator('Audit', $start, $end);
|
||||||
|
$generator->setAccounts($accounts);
|
||||||
|
$result = $generator->generate();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function defaultReport(Carbon $start, Carbon $end, Collection $accounts)
|
||||||
|
{
|
||||||
|
// throw an error if necessary.
|
||||||
|
if ($end < $start) {
|
||||||
|
throw new FireflyException('End date cannot be before start date, silly!');
|
||||||
|
}
|
||||||
|
|
||||||
|
// lower threshold
|
||||||
|
if ($start < session('first')) {
|
||||||
|
$start = session('first');
|
||||||
|
}
|
||||||
|
|
||||||
|
View::share(
|
||||||
|
'subTitle', trans(
|
||||||
|
'firefly.report_default',
|
||||||
|
[
|
||||||
|
'start' => $start->formatLocalized($this->monthFormat),
|
||||||
|
'end' => $end->formatLocalized($this->monthFormat),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
View::share('subTitleIcon', 'fa-calendar');
|
||||||
|
|
||||||
|
$generator = ReportGeneratorFactory::reportGenerator('Standard', $start, $end);
|
||||||
|
$generator->setAccounts($accounts);
|
||||||
|
$result = $generator->generate();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountRepositoryInterface $repository
|
* @param AccountRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
@ -93,28 +177,34 @@ class ReportController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function options(string $reportType)
|
public function options(string $reportType)
|
||||||
{
|
{
|
||||||
$result = false;
|
$result = '';
|
||||||
switch ($reportType) {
|
switch ($reportType) {
|
||||||
default:
|
default:
|
||||||
$result = $this->noReportOptions();
|
$result = $this->noReportOptions();
|
||||||
break;
|
break;
|
||||||
|
case 'category':
|
||||||
|
$result = $this->categoryReportOptions();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::json($result);
|
return Response::json(['html' => $result]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $reportType
|
* @param ReportFormRequest $request
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
*
|
||||||
* @return View
|
* @return RedirectResponse
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
public function postIndex(ReportFormRequest $request): RedirectResponse
|
||||||
{
|
{
|
||||||
// throw an error if necessary.
|
// report type:
|
||||||
|
$reportType = $request->get('report_type');
|
||||||
|
$start = $request->getStartDate()->format('Ymd');
|
||||||
|
$end = $request->getEndDate()->format('Ymd');
|
||||||
|
$accounts = join(',', $request->getAccountList()->pluck('id')->toArray());
|
||||||
|
$categories = join(',', $request->getCategoryList()->pluck('id')->toArray());
|
||||||
|
|
||||||
if ($end < $start) {
|
if ($end < $start) {
|
||||||
throw new FireflyException('End date cannot be before start date, silly!');
|
throw new FireflyException('End date cannot be before start date, silly!');
|
||||||
}
|
}
|
||||||
@ -124,198 +214,42 @@ class ReportController extends Controller
|
|||||||
$start = session('first');
|
$start = session('first');
|
||||||
}
|
}
|
||||||
|
|
||||||
View::share(
|
|
||||||
'subTitle', trans(
|
|
||||||
'firefly.report_' . $reportType,
|
|
||||||
[
|
|
||||||
'start' => $start->formatLocalized($this->monthFormat),
|
|
||||||
'end' => $end->formatLocalized($this->monthFormat),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
View::share('subTitleIcon', 'fa-calendar');
|
|
||||||
|
|
||||||
switch ($reportType) {
|
switch ($reportType) {
|
||||||
default:
|
default:
|
||||||
throw new FireflyException('Unfortunately, reports of the type "' . e($reportType) . '" are not available at this time.');
|
throw new FireflyException(sprintf('Firefly does not support the "%s"-report yet.', $reportType));
|
||||||
|
case 'category':
|
||||||
|
$uri = route('reports.report.category', [$start, $end, $accounts, $categories]);
|
||||||
|
break;
|
||||||
case 'default':
|
case 'default':
|
||||||
|
$uri = route('reports.report.default', [$start, $end, $accounts]);
|
||||||
// more than one year date difference means year report.
|
break;
|
||||||
if ($start->diffInMonths($end) > 12) {
|
|
||||||
return $this->defaultMultiYear($reportType, $start, $end, $accounts);
|
|
||||||
}
|
|
||||||
// more than two months date difference means year report.
|
|
||||||
if ($start->diffInMonths($end) > 1) {
|
|
||||||
return $this->defaultYear($reportType, $start, $end, $accounts);
|
|
||||||
}
|
|
||||||
|
|
||||||
// otherwise default
|
|
||||||
return $this->defaultMonth($reportType, $start, $end, $accounts);
|
|
||||||
case 'audit':
|
case 'audit':
|
||||||
// always default
|
$uri = route('reports.report.audit', [$start, $end, $accounts]);
|
||||||
return $this->auditReport($start, $end, $accounts);
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return redirect($uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function categoryReportOptions(): string
|
||||||
|
{
|
||||||
|
/** @var CategoryRepositoryInterface $repository */
|
||||||
|
$repository = app(CategoryRepositoryInterface::class);
|
||||||
|
$categories = $repository->getCategories();
|
||||||
|
$result = view('reports.options.category', compact('categories'))->render();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $start
|
* @return string
|
||||||
* @param Carbon $end
|
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
|
||||||
* @return View
|
|
||||||
*/
|
*/
|
||||||
private function auditReport(Carbon $start, Carbon $end, Collection $accounts)
|
private function noReportOptions(): string
|
||||||
{
|
{
|
||||||
$auditData = [];
|
return view('reports.options.no-options')->render();
|
||||||
$dayBefore = clone $start;
|
|
||||||
$dayBefore->subDay();
|
|
||||||
/** @var Account $account */
|
|
||||||
foreach ($accounts as $account) {
|
|
||||||
// balance the day before:
|
|
||||||
$id = $account->id;
|
|
||||||
$dayBeforeBalance = Steam::balance($account, $dayBefore);
|
|
||||||
$collector = new JournalCollector(auth()->user());
|
|
||||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end);
|
|
||||||
$journals = $collector->getJournals();
|
|
||||||
$journals = $journals->reverse();
|
|
||||||
$startBalance = $dayBeforeBalance;
|
|
||||||
|
|
||||||
|
|
||||||
/** @var Transaction $journal */
|
|
||||||
foreach ($journals as $transaction) {
|
|
||||||
$transaction->before = $startBalance;
|
|
||||||
$transactionAmount = $transaction->transaction_amount;
|
|
||||||
$newBalance = bcadd($startBalance, $transactionAmount);
|
|
||||||
$transaction->after = $newBalance;
|
|
||||||
$startBalance = $newBalance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reverse set again.
|
|
||||||
*/
|
|
||||||
$auditData[$id]['journals'] = $journals->reverse();
|
|
||||||
$auditData[$id]['exists'] = $journals->count() > 0;
|
|
||||||
$auditData[$id]['end'] = $end->formatLocalized(strval(trans('config.month_and_day')));
|
|
||||||
$auditData[$id]['endBalance'] = Steam::balance($account, $end);
|
|
||||||
$auditData[$id]['dayBefore'] = $dayBefore->formatLocalized(strval(trans('config.month_and_day')));
|
|
||||||
$auditData[$id]['dayBeforeBalance'] = $dayBeforeBalance;
|
|
||||||
}
|
|
||||||
|
|
||||||
$reportType = 'audit';
|
|
||||||
$accountIds = join(',', $accounts->pluck('id')->toArray());
|
|
||||||
|
|
||||||
$hideable = ['buttons', 'icon', 'description', 'balance_before', 'amount', 'balance_after', 'date',
|
|
||||||
'interest_date', 'book_date', 'process_date',
|
|
||||||
// three new optional fields.
|
|
||||||
'due_date', 'payment_date', 'invoice_date',
|
|
||||||
'from', 'to', 'budget', 'category', 'bill',
|
|
||||||
// more new optional fields
|
|
||||||
'internal_reference', 'notes',
|
|
||||||
|
|
||||||
'create_date', 'update_date',
|
|
||||||
];
|
|
||||||
$defaultShow = ['icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', 'to'];
|
|
||||||
|
|
||||||
return view('reports.audit.report', compact('start', 'end', 'reportType', 'accountIds', 'accounts', 'auditData', 'hideable', 'defaultShow'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $reportType
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
|
||||||
* @return View
|
|
||||||
*/
|
|
||||||
private function defaultMonth(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
|
||||||
{
|
|
||||||
$bills = $this->helper->getBillReport($start, $end, $accounts);
|
|
||||||
$tags = $this->helper->tagReport($start, $end, $accounts);
|
|
||||||
|
|
||||||
// and some id's, joined:
|
|
||||||
$accountIds = join(',', $accounts->pluck('id')->toArray());
|
|
||||||
|
|
||||||
// continue!
|
|
||||||
return view(
|
|
||||||
'reports.default.month',
|
|
||||||
compact(
|
|
||||||
'start', 'end',
|
|
||||||
'tags',
|
|
||||||
'bills',
|
|
||||||
'accountIds',
|
|
||||||
'reportType'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $reportType
|
|
||||||
* @param $start
|
|
||||||
* @param $end
|
|
||||||
* @param $accounts
|
|
||||||
*
|
|
||||||
* @return View
|
|
||||||
*/
|
|
||||||
private function defaultMultiYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
|
||||||
{
|
|
||||||
// need all budgets
|
|
||||||
// need all years.
|
|
||||||
|
|
||||||
|
|
||||||
// and some id's, joined:
|
|
||||||
$accountIds = [];
|
|
||||||
/** @var Account $account */
|
|
||||||
foreach ($accounts as $account) {
|
|
||||||
$accountIds[] = $account->id;
|
|
||||||
}
|
|
||||||
$accountIds = join(',', $accountIds);
|
|
||||||
|
|
||||||
return view(
|
|
||||||
'reports.default.multi-year',
|
|
||||||
compact(
|
|
||||||
'accounts', 'start', 'end', 'accountIds', 'reportType'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $reportType
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
|
||||||
* @return View
|
|
||||||
*/
|
|
||||||
private function defaultYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
|
||||||
{
|
|
||||||
Session::flash('gaEventCategory', 'report');
|
|
||||||
Session::flash('gaEventAction', 'year');
|
|
||||||
Session::flash('gaEventLabel', $start->format('Y'));
|
|
||||||
|
|
||||||
// and some id's, joined:
|
|
||||||
$accountIds = [];
|
|
||||||
/** @var Account $account */
|
|
||||||
foreach ($accounts as $account) {
|
|
||||||
$accountIds[] = $account->id;
|
|
||||||
}
|
|
||||||
$accountIds = join(',', $accountIds);
|
|
||||||
|
|
||||||
return view(
|
|
||||||
'reports.default.year',
|
|
||||||
compact(
|
|
||||||
'start', 'reportType',
|
|
||||||
'accountIds', 'end'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function noReportOptions(): array
|
|
||||||
{
|
|
||||||
return ['html' => view('reports.options.no-options')->render()];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
128
app/Http/Requests/ReportFormRequest.php
Normal file
128
app/Http/Requests/ReportFormRequest.php
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ReportFormRequest.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms of the
|
||||||
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||||
|
*
|
||||||
|
* See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Exception;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CategoryFormRequest
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Http\Requests
|
||||||
|
*/
|
||||||
|
class ReportFormRequest extends Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
// Only allow logged in users
|
||||||
|
return auth()->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getAccountList():Collection
|
||||||
|
{
|
||||||
|
/** @var AccountRepositoryInterface $repository */
|
||||||
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
|
$set = $this->get('accounts');
|
||||||
|
$collection = new Collection;
|
||||||
|
if (is_array($set)) {
|
||||||
|
foreach ($set as $accountId) {
|
||||||
|
$account = $repository->find(intval($accountId));
|
||||||
|
if (!is_null($account->id)) {
|
||||||
|
$collection->push($account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getCategoryList(): Collection
|
||||||
|
{
|
||||||
|
/** @var CategoryRepositoryInterface $repository */
|
||||||
|
$repository = app(CategoryRepositoryInterface::class);
|
||||||
|
$set = $this->get('category');
|
||||||
|
$collection = new Collection;
|
||||||
|
if (is_array($set)) {
|
||||||
|
foreach ($set as $categoryId) {
|
||||||
|
$category = $repository->find(intval($categoryId));
|
||||||
|
if (!is_null($category->id)) {
|
||||||
|
$collection->push($category);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEndDate(): Carbon
|
||||||
|
{
|
||||||
|
$date = new Carbon;
|
||||||
|
$range = $this->get('daterange');
|
||||||
|
$parts = explode(' - ', strval($range));
|
||||||
|
if (count($parts) === 2) {
|
||||||
|
try {
|
||||||
|
$date = new Carbon($parts[1]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw new FireflyException(sprintf('"%s" is not a valid date range.', $range));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Carbon
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function getStartDate(): Carbon
|
||||||
|
{
|
||||||
|
$date = new Carbon;
|
||||||
|
$range = $this->get('daterange');
|
||||||
|
$parts = explode(' - ', strval($range));
|
||||||
|
if (count($parts) === 2) {
|
||||||
|
try {
|
||||||
|
$date = new Carbon($parts[0]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw new FireflyException(sprintf('"%s" is not a valid date range.', $range));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'report_type' => 'in:audit,default,category',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -55,23 +55,17 @@ function getReportOptions() {
|
|||||||
$('#extra-options').empty();
|
$('#extra-options').empty();
|
||||||
$('#extra-options').addClass('loading');
|
$('#extra-options').addClass('loading');
|
||||||
console.log('Changed report type to ' + reportType);
|
console.log('Changed report type to ' + reportType);
|
||||||
$.getJSON('reports/options/' + reportType, function(data) {
|
$.getJSON('reports/options/' + reportType, function (data) {
|
||||||
$('#extra-options').removeClass('loading').html(data.html);
|
$('#extra-options').removeClass('loading').html(data.html);
|
||||||
}).fail(function(){
|
}).fail(function () {
|
||||||
$('#extra-options').removeClass('loading').addClass('error');
|
$('#extra-options').removeClass('loading').addClass('error');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function catchSubmit() {
|
function catchSubmit() {
|
||||||
"use strict";
|
"use strict";
|
||||||
// default;20141201;20141231;4;5
|
|
||||||
// report name:
|
|
||||||
var url = '' + $('select[name="report_type"]').val() + '/';
|
|
||||||
|
|
||||||
// date, processed:
|
// date, processed:
|
||||||
var picker = $('#inputDateRange').data('daterangepicker');
|
var picker = $('#inputDateRange').data('daterangepicker');
|
||||||
url += moment(picker.startDate).format("YYYYMMDD") + '/';
|
|
||||||
url += moment(picker.endDate).format("YYYYMMDD") + '/';
|
|
||||||
|
|
||||||
// all account ids:
|
// all account ids:
|
||||||
var count = 0;
|
var count = 0;
|
||||||
@ -79,23 +73,24 @@ function catchSubmit() {
|
|||||||
$.each($('.account-checkbox'), function (i, v) {
|
$.each($('.account-checkbox'), function (i, v) {
|
||||||
var c = $(v);
|
var c = $(v);
|
||||||
if (c.prop('checked')) {
|
if (c.prop('checked')) {
|
||||||
url += c.val() + ',';
|
|
||||||
accounts.push(c.val());
|
accounts.push(c.val());
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// all category ids to come
|
||||||
|
|
||||||
|
|
||||||
|
// remember all
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
// set cookie to remember choices.
|
// set cookie to remember choices.
|
||||||
createCookie('report-type', $('select[name="report_type"]').val(), 365);
|
createCookie('report-type', $('select[name="report_type"]').val(), 365);
|
||||||
createCookie('report-accounts', accounts, 365);
|
createCookie('report-accounts', accounts, 365);
|
||||||
createCookie('report-start', moment(picker.startDate).format("YYYYMMDD"), 365);
|
createCookie('report-start', moment(picker.startDate).format("YYYYMMDD"), 365);
|
||||||
createCookie('report-end', moment(picker.endDate).format("YYYYMMDD"), 365);
|
createCookie('report-end', moment(picker.endDate).format("YYYYMMDD"), 365);
|
||||||
|
|
||||||
window.location.href = reportURL + "/" + url;
|
|
||||||
}
|
}
|
||||||
//console.log(url);
|
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function preSelectDate(e) {
|
function preSelectDate(e) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<form class="form-horizontal" id="report-form" action="{{ route('reports.index') }}" method="post">
|
<form class="form-horizontal" id="report-form" action="{{ route('reports.index.post') }}" method="post">
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
@ -116,16 +116,16 @@
|
|||||||
<h4>{{ 'quick_link_default_report'|_ }}</h4>
|
<h4>{{ 'quick_link_default_report'|_ }}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ route('reports.report',
|
<a href="{{ route('reports.report.default',
|
||||||
['default',
|
[
|
||||||
'currentMonthStart',
|
'currentMonthStart',
|
||||||
'currentMonthEnd',
|
'currentMonthEnd',
|
||||||
accountList
|
accountList
|
||||||
]) }}">{{ 'report_this_month_quick'|_ }}</a>
|
]) }}">{{ 'report_this_month_quick'|_ }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ route('reports.report',
|
<a href="{{ route('reports.report.default',
|
||||||
['default',
|
[
|
||||||
'currentYearStart',
|
'currentYearStart',
|
||||||
'currentYearEnd',
|
'currentYearEnd',
|
||||||
accountList
|
accountList
|
||||||
@ -133,7 +133,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{% if customFiscalYear == 1 %}
|
{% if customFiscalYear == 1 %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ route('reports.report',
|
<a href="{{ route('reports.report.default',
|
||||||
['default',
|
['default',
|
||||||
'currentFiscalYearStart',
|
'currentFiscalYearStart',
|
||||||
'currentFiscalYearEnd',
|
'currentFiscalYearEnd',
|
||||||
@ -142,8 +142,8 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ route('reports.report',
|
<a href="{{ route('reports.report.default',
|
||||||
['default',
|
[
|
||||||
start.format('Ymd'),
|
start.format('Ymd'),
|
||||||
'currentMonthEnd',
|
'currentMonthEnd',
|
||||||
accountList
|
accountList
|
||||||
@ -154,16 +154,16 @@
|
|||||||
<h4>{{ 'quick_link_audit_report'|_ }}</h4>
|
<h4>{{ 'quick_link_audit_report'|_ }}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ route('reports.report',
|
<a href="{{ route('reports.report.audit',
|
||||||
['audit',
|
[
|
||||||
'currentMonthStart',
|
'currentMonthStart',
|
||||||
'currentMonthEnd',
|
'currentMonthEnd',
|
||||||
accountList
|
accountList
|
||||||
]) }}">{{ 'report_this_month_quick'|_ }}</a>
|
]) }}">{{ 'report_this_month_quick'|_ }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ route('reports.report',
|
<a href="{{ route('reports.report.audit',
|
||||||
['audit',
|
[
|
||||||
'currentYearStart',
|
'currentYearStart',
|
||||||
'currentYearEnd',
|
'currentYearEnd',
|
||||||
accountList
|
accountList
|
||||||
@ -171,8 +171,8 @@
|
|||||||
</li>
|
</li>
|
||||||
{% if customFiscalYear == 1 %}
|
{% if customFiscalYear == 1 %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ route('reports.report',
|
<a href="{{ route('reports.report.audit',
|
||||||
['audit',
|
[
|
||||||
'currentFiscalYearStart',
|
'currentFiscalYearStart',
|
||||||
'currentFiscalYearEnd',
|
'currentFiscalYearEnd',
|
||||||
accountList
|
accountList
|
||||||
@ -180,15 +180,14 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ route('reports.report',
|
<a href="{{ route('reports.report.audit',
|
||||||
['audit',
|
[
|
||||||
start.format('Ymd'),
|
start.format('Ymd'),
|
||||||
'currentMonthEnd',
|
'currentMonthEnd',
|
||||||
accountList
|
accountList
|
||||||
]) }}">{{ 'report_all_time_quick'|_ }}</a>
|
]) }}">{{ 'report_all_time_quick'|_ }}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<em>{{ 'reports_can_bookmark'|_ }}</em>
|
<em>{{ 'reports_can_bookmark'|_ }}</em>
|
||||||
</p>
|
</p>
|
||||||
@ -202,8 +201,6 @@
|
|||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var reportURL = "{{ route('reports.report', ['','','','']) }}";
|
|
||||||
var minDate = "{{ start.format('m/d/Y') }}";
|
var minDate = "{{ start.format('m/d/Y') }}";
|
||||||
var picker;
|
var picker;
|
||||||
</script>
|
</script>
|
||||||
|
8
resources/views/reports/options/category.twig
Normal file
8
resources/views/reports/options/category.twig
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<p>
|
||||||
|
{{ 'select_category'|_ }}
|
||||||
|
</p>
|
||||||
|
{% for category in categories %}
|
||||||
|
<label class="checkbox-inline">
|
||||||
|
<input type="checkbox" name="category[]" value="{{ category.id }}"> {{ category.name }}
|
||||||
|
</label>
|
||||||
|
{% endfor %}
|
@ -307,7 +307,21 @@ Route::group(
|
|||||||
* Report Controller
|
* Report Controller
|
||||||
*/
|
*/
|
||||||
Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
|
Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
|
||||||
Route::get('/reports/report/{reportType}/{start_date}/{end_date}/{accountList}', ['uses' => 'ReportController@report', 'as' => 'reports.report']);
|
Route::post('/reports', ['uses' => 'ReportController@postIndex', 'as' => 'reports.index.post']);
|
||||||
|
|
||||||
|
// default report:
|
||||||
|
Route::get('/reports/default/{start_date}/{end_date}/{accountList}', ['uses' => 'ReportController@defaultReport', 'as' => 'reports.report.default']);
|
||||||
|
|
||||||
|
// audit report:
|
||||||
|
Route::get('/reports/audit/{start_date}/{end_date}/{accountList}', ['uses' => 'ReportController@auditReport', 'as' => 'reports.report.audit']);
|
||||||
|
|
||||||
|
// category report:
|
||||||
|
Route::get(
|
||||||
|
'/reports/category/{start_date}/{end_date}/{accountList}/{categoryList}',
|
||||||
|
['uses' => 'ReportController@categoryReport', 'as' => 'reports.report.category']
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
Route::get('/reports/options/{reportType}', ['uses' => 'ReportController@options', 'as' => 'reports.options']);
|
Route::get('/reports/options/{reportType}', ['uses' => 'ReportController@options', 'as' => 'reports.options']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user