mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code cleanup.
This commit is contained in:
parent
c1ecc62ac1
commit
7343304284
@ -10,6 +10,7 @@ interface SpecifixInterface
|
||||
{
|
||||
const PRE_PROCESSOR = 1;
|
||||
const POST_PROCESSOR = 2;
|
||||
|
||||
/**
|
||||
* Implement bank and locale related fixes.
|
||||
*/
|
||||
|
@ -78,7 +78,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
||||
$balance->addBalanceLine($this->createEmptyBalanceLine($accounts, $spentData));
|
||||
$balance->addBalanceLine($this->createTagsBalanceLine($accounts, $start, $end));
|
||||
$balance->addBalanceLine($this->createDifferenceBalanceLine($accounts, $spentData, $start, $end));
|
||||
|
||||
$balance->setBalanceHeader($header);
|
||||
|
||||
return $balance;
|
||||
|
@ -150,7 +150,6 @@ class AuthController extends Controller
|
||||
|
||||
return redirect($this->redirectPath());
|
||||
}
|
||||
// @codeCoverageIgnoreStart
|
||||
abort(500, 'Not a user!');
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ class PiggyBankController extends Controller
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ class ReportController extends Controller
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@ -127,6 +127,7 @@ class ReportController extends Controller
|
||||
*/
|
||||
protected function singleYearInOutSummarized(array $earned, array $spent, Carbon $start, Carbon $end)
|
||||
{
|
||||
bcscale(2);
|
||||
$income = '0';
|
||||
$expense = '0';
|
||||
$count = 0;
|
||||
@ -156,6 +157,7 @@ class ReportController extends Controller
|
||||
*/
|
||||
protected function multiYearInOutSummarized(array $earned, array $spent, Carbon $start, Carbon $end)
|
||||
{
|
||||
bcscale(2);
|
||||
$income = '0';
|
||||
$expense = '0';
|
||||
$count = 0;
|
||||
|
@ -16,7 +16,7 @@ class PreferencesController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -5,6 +5,7 @@ use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Session;
|
||||
use View;
|
||||
@ -25,7 +26,7 @@ class ReportController extends Controller
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
*
|
||||
* @param ReportHelperInterface $helper
|
||||
*/
|
||||
@ -43,6 +44,32 @@ class ReportController extends Controller
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ARI $repository
|
||||
*
|
||||
* @return View
|
||||
* @internal param ReportHelperInterface $helper
|
||||
*/
|
||||
public function index(ARI $repository)
|
||||
{
|
||||
$start = session('first');
|
||||
$months = $this->helper->listOfMonths($start);
|
||||
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
|
||||
|
||||
// does the user have shared accounts?
|
||||
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
|
||||
// get id's for quick links:
|
||||
$accountIds = [];
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$accountIds [] = $account->id;
|
||||
}
|
||||
$accountList = join(',', $accountIds);
|
||||
|
||||
|
||||
return view('reports.index', compact('months', 'accounts', 'start', 'accountList', 'customFiscalYear'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $reportType
|
||||
* @param Carbon $start
|
||||
@ -51,7 +78,59 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function defaultMonth($reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function report($reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
// throw an error if necessary.
|
||||
if ($end < $start) {
|
||||
|
||||
return view('error')->with('message', 'End date cannot be before start date, silly!');
|
||||
}
|
||||
|
||||
// lower threshold
|
||||
if ($start < session('first')) {
|
||||
Log::debug('Start is ' . $start . ' but sessionfirst is ' . session('first'));
|
||||
$start = session('first');
|
||||
}
|
||||
|
||||
switch ($reportType) {
|
||||
default:
|
||||
case 'default':
|
||||
|
||||
View::share(
|
||||
'subTitle', trans(
|
||||
'firefly.report_default',
|
||||
[
|
||||
'start' => $start->formatLocalized($this->monthFormat),
|
||||
'end' => $end->formatLocalized($this->monthFormat),
|
||||
]
|
||||
)
|
||||
);
|
||||
View::share('subTitleIcon', 'fa-calendar');
|
||||
|
||||
// more than one year date difference means year report.
|
||||
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);
|
||||
}
|
||||
|
||||
return $this->defaultMonth($reportType, $start, $end, $accounts);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $reportType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
private function defaultMonth($reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
$incomeTopLength = 8;
|
||||
$expenseTopLength = 8;
|
||||
@ -92,7 +171,7 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function defaultMultiYear($reportType, $start, $end, $accounts)
|
||||
private function defaultMultiYear($reportType, $start, $end, $accounts)
|
||||
{
|
||||
|
||||
$incomeTopLength = 8;
|
||||
@ -129,7 +208,7 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function defaultYear($reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
private function defaultYear($reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
$incomeTopLength = 8;
|
||||
$expenseTopLength = 8;
|
||||
@ -159,81 +238,5 @@ class ReportController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ARI $repository
|
||||
*
|
||||
* @return View
|
||||
* @internal param ReportHelperInterface $helper
|
||||
*/
|
||||
public function index(ARI $repository)
|
||||
{
|
||||
$start = Session::get('first');
|
||||
$months = $this->helper->listOfMonths($start);
|
||||
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
|
||||
|
||||
// does the user have shared accounts?
|
||||
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
|
||||
// get id's for quick links:
|
||||
$accountIds = [];
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$accountIds [] = $account->id;
|
||||
}
|
||||
$accountList = join(',', $accountIds);
|
||||
|
||||
|
||||
return view('reports.index', compact('months', 'accounts', 'start', 'accountList','customFiscalYear'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $reportType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function report($reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
// throw an error if necessary.
|
||||
if ($end < $start) {
|
||||
return view('error')->with('message', 'End date cannot be before start date, silly!');
|
||||
}
|
||||
|
||||
// lower threshold
|
||||
if ($start < Session::get('first')) {
|
||||
$start = Session::get('first');
|
||||
}
|
||||
|
||||
switch ($reportType) {
|
||||
default:
|
||||
case 'default':
|
||||
|
||||
View::share(
|
||||
'subTitle', trans(
|
||||
'firefly.report_default',
|
||||
[
|
||||
'start' => $start->formatLocalized($this->monthFormat),
|
||||
'end' => $end->formatLocalized($this->monthFormat),
|
||||
]
|
||||
)
|
||||
);
|
||||
View::share('subTitleIcon', 'fa-calendar');
|
||||
|
||||
// more than one year date difference means year report.
|
||||
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);
|
||||
}
|
||||
|
||||
return $this->defaultMonth($reportType, $start, $end, $accounts);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,8 +3,9 @@
|
||||
namespace FireflyIII\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
/**
|
||||
* Class Authenticate
|
||||
*
|
||||
|
@ -10,7 +10,7 @@ use Input;
|
||||
/**
|
||||
* Class AccountFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class AccountFormRequest extends Request
|
||||
|
@ -7,7 +7,7 @@ use Auth;
|
||||
/**
|
||||
* Class AttachmentFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class AttachmentFormRequest extends Request
|
||||
|
@ -9,7 +9,7 @@ use Input;
|
||||
/**
|
||||
* Class BillFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class BillFormRequest extends Request
|
||||
|
@ -9,7 +9,7 @@ use Input;
|
||||
/**
|
||||
* Class BudgetFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class BudgetFormRequest extends Request
|
||||
|
@ -9,7 +9,7 @@ use Input;
|
||||
/**
|
||||
* Class CategoryFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class CategoryFormRequest extends Request
|
||||
|
@ -8,7 +8,7 @@ use Input;
|
||||
/**
|
||||
* Class BillFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class CurrencyFormRequest extends Request
|
||||
|
@ -7,7 +7,7 @@ use Auth;
|
||||
/**
|
||||
* Class DeleteAccountFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class DeleteAccountFormRequest extends Request
|
||||
|
@ -11,7 +11,7 @@ use Input;
|
||||
/**
|
||||
* Class JournalFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class JournalFormRequest extends Request
|
||||
|
@ -7,7 +7,7 @@ use Auth;
|
||||
/**
|
||||
* Class NewUserFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class NewUserFormRequest extends Request
|
||||
|
@ -8,7 +8,7 @@ use Input;
|
||||
/**
|
||||
* Class PiggyBankFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class PiggyBankFormRequest extends Request
|
||||
|
@ -7,7 +7,7 @@ use Auth;
|
||||
/**
|
||||
* Class ProfileFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class ProfileFormRequest extends Request
|
||||
|
@ -17,7 +17,7 @@ use Input;
|
||||
/**
|
||||
* Class RuleFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class RuleFormRequest extends Request
|
||||
|
@ -16,7 +16,7 @@ use Input;
|
||||
/**
|
||||
* Class RuleGroupFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class RuleGroupFormRequest extends Request
|
||||
|
@ -8,7 +8,7 @@ use Input;
|
||||
/**
|
||||
* Class TagFormRequest
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class TagFormRequest extends Request
|
||||
|
@ -5,15 +5,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
/**
|
||||
* Class Component
|
||||
*
|
||||
* @property int $transaction_journal_id
|
||||
* @property int $transaction_journal_id
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
*/
|
||||
class Component extends Model
|
||||
{
|
||||
|
@ -54,8 +54,8 @@ use Watson\Validating\ValidatingTrait;
|
||||
* @method static \Illuminate\Database\Query\Builder|TransactionJournal transactionTypes($types)
|
||||
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withRelevantData()
|
||||
* @property string $type
|
||||
* @property \Carbon\Carbon $interest_date
|
||||
* @property \Carbon\Carbon $book_date
|
||||
* @property \Carbon\Carbon $interest_date
|
||||
* @property \Carbon\Carbon $book_date
|
||||
*/
|
||||
class TransactionJournal extends Model
|
||||
{
|
||||
|
@ -11,8 +11,8 @@ namespace FireflyIII\Support\Binder;
|
||||
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\FiscalHelper;
|
||||
use Exception;
|
||||
use FireflyIII\Helpers\FiscalHelper;
|
||||
use Log;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user