mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some tests and a rename.
This commit is contained in:
@@ -44,7 +44,7 @@ class ReportController extends BaseController
|
||||
try {
|
||||
new Carbon($year . '-' . $month . '-01');
|
||||
} catch (Exception $e) {
|
||||
View::make('error')->with('message', 'Invalid date');
|
||||
return View::make('error')->with('message', 'Invalid date');
|
||||
}
|
||||
$date = new Carbon($year . '-' . $month . '-01');
|
||||
$dayEarly = clone $date;
|
||||
@@ -81,7 +81,7 @@ class ReportController extends BaseController
|
||||
try {
|
||||
new Carbon($year . '-' . $month . '-01');
|
||||
} catch (Exception $e) {
|
||||
View::make('error')->with('message', 'Invalid date');
|
||||
return View::make('error')->with('message', 'Invalid date.');
|
||||
}
|
||||
$date = new Carbon($year . '-' . $month . '-01');
|
||||
$subTitle = 'Report for ' . $date->format('F Y');
|
||||
@@ -110,7 +110,7 @@ class ReportController extends BaseController
|
||||
try {
|
||||
new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
return View::make('error')->with('message', 'Invalid date.');
|
||||
}
|
||||
$date = new Carbon('01-01-' . $year);
|
||||
$end = clone $date;
|
||||
|
||||
@@ -174,46 +174,6 @@ class PiggyBankShared
|
||||
}
|
||||
|
||||
|
||||
return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
|
||||
|
||||
exit;
|
||||
|
||||
if (!in_array(ucfirst($model['reminder']), \Config::get('firefly.piggy_bank_periods'))) {
|
||||
$errors->add('reminder', 'Invalid reminder period (' . $model['reminder'] . ')');
|
||||
}
|
||||
// check period.
|
||||
if (!$errors->has('reminder') && !$errors->has('targetdate') && isset($model['remind_me']) && intval($model['remind_me']) == 1) {
|
||||
$today = new Carbon;
|
||||
$target = new Carbon($model['targetdate']);
|
||||
switch ($model['reminder']) {
|
||||
case 'week':
|
||||
$today->addWeek();
|
||||
break;
|
||||
case 'month':
|
||||
$today->addMonth();
|
||||
break;
|
||||
case 'year':
|
||||
$today->addYear();
|
||||
break;
|
||||
}
|
||||
if ($today > $target) {
|
||||
$errors->add('reminder', 'Target date is too close to today to set reminders.');
|
||||
}
|
||||
}
|
||||
|
||||
$validator = \Validator::make($model, \PiggyBank::$rules);
|
||||
if ($validator->invalid()) {
|
||||
$errors->merge($errors);
|
||||
}
|
||||
|
||||
// add ok messages.
|
||||
$list = ['name', 'account_id', 'targetamount', 'targetdate', 'remind_me', 'reminder'];
|
||||
foreach ($list as $entry) {
|
||||
if (!$errors->has($entry) && !$warnings->has($entry)) {
|
||||
$successes->add($entry, 'OK');
|
||||
}
|
||||
}
|
||||
|
||||
return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
|
||||
}
|
||||
|
||||
|
||||
@@ -388,7 +388,7 @@ class Report implements ReportInterface
|
||||
->where('acm_to.data', '!=', '"sharedExpense"')
|
||||
->before($end)->after($start)
|
||||
->where('transaction_journals.user_id', \Auth::user()->id)
|
||||
->groupBy('account_id')->orderBy('sum')->limit(15)
|
||||
->groupBy('t_from.account_id')->orderBy('sum')->limit(15)
|
||||
->get(['t_from.account_id as account_id', 'ac_from.name as name', \DB::Raw('SUM(t_from.amount) as `sum`')]);
|
||||
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
->where('account_meta.data', '!=', '"sharedExpense"')
|
||||
->where('transaction_types.type', 'Withdrawal')
|
||||
->groupBy('budgets.id')
|
||||
->orderBy('name', 'ASC')
|
||||
->orderBy('budgets.name', 'ASC')
|
||||
->get(['budgets.id', 'budgets.name', \DB::Raw('SUM(`transactions`.`amount`) AS `spent`')]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user