diffInDays($end);
if ($diff > 50) {
Session::flash('warning', strval(trans('firefly.warning_much_data', ['days' => $diff])));
}
Session::put('is_custom_range', $isCustomRange);
Session::put('start', $start);
Session::put('end', $end);
}
/**
* @throws FireflyException
*/
public function displayError()
{
throw new FireflyException('A very simple test error.');
}
/**
* @param TagRepositoryInterface $repository
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function flush(TagRepositoryInterface $repository)
{
Preferences::mark();
// get all tags.
// update all counts:
$tags = $repository->get();
/** @var Tag $tag */
foreach ($tags as $tag) {
foreach ($tag->transactionjournals()->get() as $journal) {
$count = $journal->tags()->count();
$journal->tag_count = $count;
$journal->save();
}
}
Session::clear();
Artisan::call('cache:clear');
return redirect(route('index'));
}
/**
* @param ARI $repository
* @param AccountCrudInterface $crud
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function index(ARI $repository, AccountCrudInterface $crud)
{
$types = config('firefly.accountTypesByIdentifier.asset');
$count = $repository->countAccounts($types);
if ($count == 0) {
return redirect(route('new-user.index'));
}
$title = 'Firefly';
$subTitle = trans('firefly.welcomeBack');
$mainTitleIcon = 'fa-fire';
$transactions = [];
$frontPage = Preferences::get(
'frontPageAccounts', $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray()
);
/** @var Carbon $start */
$start = session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
$end = session('end', Carbon::now()->endOfMonth());
$showTour = Preferences::get('tour', true)->data;
$accounts = $crud->getAccountsById($frontPage->data);
$savings = $repository->getSavingsAccounts($start, $end);
$piggyBankAccounts = $repository->getPiggyBankAccounts($start, $end);
$savingsTotal = '0';
foreach ($savings as $savingAccount) {
$savingsTotal = bcadd($savingsTotal, Steam::balance($savingAccount, $end));
}
foreach ($accounts as $account) {
$set = $repository->journalsInPeriod(new Collection([$account]), [], $start, $end);
$set = $set->splice(0, 10);
if (count($set) > 0) {
$transactions[] = [$set, $account];
}
}
return view(
'index', compact('count', 'showTour', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal', 'piggyBankAccounts')
);
}
/**
* Display a list of named routes. Excludes some that cannot be "shown". This method
* is used to generate help files (down the road).
*/
public function routes()
{
// these routes are not relevant for the help pages:
$ignore = [
];
$routes = Route::getRoutes();
/** @var \Illuminate\Routing\Route $route */
foreach ($routes as $route) {
$name = $route->getName();
$methods = $route->getMethods();
$search = [
'{account}', '{what}', '{rule}', '{tj}', '{category}', '{budget}', '{code}', '{date}', '{attachment}', '{bill}', '{limitrepetition}',
'{currency}', '{jobKey}', '{piggyBank}', '{ruleGroup}', '{rule}', '{route}', '{unfinishedJournal}',
'{reportType}', '{start_date}', '{end_date}', '{accountList}','{tag}','{journalList}'
];
$replace = [1, 'asset', 1, 1, 1, 1, 'abc', '2016-01-01', 1, 1, 1, 1, 1, 1, 1, 1, 'index', 1,
'default', '20160101', '20160131', '1,2',1,'1,2'
];
if (count($search) != count($replace)) {
echo 'count';
exit;
}
$url = str_replace($search, $replace, $route->getUri());
if (!is_null($name) && in_array('GET', $methods) && !$this->startsWithAny($ignore, $name)) {
echo '' . $name . '
' . "\n";
}
}
return '