mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Some cleaning up
This commit is contained in:
@@ -33,50 +33,6 @@ class BillController extends Controller
|
||||
View::share('mainTitleIcon', 'fa-calendar-o');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function add(AccountRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
$matches = explode(',', $bill->match);
|
||||
$description = [];
|
||||
$expense = null;
|
||||
|
||||
// get users expense accounts:
|
||||
$accounts = $repository->getAccounts(Config::get('firefly.accountTypesByIdentifier.expense'));
|
||||
|
||||
foreach ($matches as $match) {
|
||||
$match = strtolower($match);
|
||||
// find expense account for each word if not found already:
|
||||
if (is_null($expense)) {
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$name = strtolower($account->name);
|
||||
if (!(strpos($name, $match) === false)) {
|
||||
$expense = $account;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (is_null($expense)) {
|
||||
$description[] = $match;
|
||||
}
|
||||
}
|
||||
$parameters = [
|
||||
'description' => ucfirst(join(' ', $description)),
|
||||
'expense_account' => is_null($expense) ? '' : $expense->name,
|
||||
'amount' => round(($bill->amount_min + $bill->amount_max), 2),
|
||||
];
|
||||
Session::put('preFilled', $parameters);
|
||||
|
||||
return Redirect::to(route('transactions.create', 'withdrawal'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
|
@@ -63,13 +63,11 @@ class HomeController extends Controller
|
||||
$savings = $repository->getSavingsAccounts();
|
||||
$piggyBankAccounts = $repository->getPiggyBankAccounts();
|
||||
|
||||
|
||||
$savingsTotal = 0;
|
||||
foreach ($savings as $savingAccount) {
|
||||
$savingsTotal += Steam::balance($savingAccount, $end);
|
||||
}
|
||||
|
||||
// check if all books are correct.
|
||||
$sum = $repository->sumOfEverything();
|
||||
if ($sum != 0) {
|
||||
Session::flash(
|
||||
|
@@ -38,7 +38,7 @@ class JsonController extends Controller
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$amount = 0;
|
||||
|
||||
// these two functions are the same as the chart TODO
|
||||
// these two functions are the same as the chart
|
||||
$bills = $repository->getActiveBills();
|
||||
|
||||
/** @var Bill $bill */
|
||||
@@ -141,7 +141,7 @@ class JsonController extends Controller
|
||||
{
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$amount = $reportQuery->journalsByExpenseAccount($start, $end, true)->sum('queryAmount');
|
||||
$amount = $reportQuery->expenseInPeriod($start, $end, true)->sum('queryAmount') * -1;
|
||||
|
||||
return Response::json(['box' => 'out', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]);
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||
use FireflyIII\Helpers\Report\ReportQueryInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
@@ -37,9 +36,10 @@ class ReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return View
|
||||
* @internal param ReportHelperInterface $helper
|
||||
*
|
||||
*/
|
||||
public function index(AccountRepositoryInterface $repository)
|
||||
{
|
||||
@@ -65,6 +65,8 @@ class ReportController extends Controller
|
||||
* @param string $year
|
||||
* @param string $month
|
||||
*
|
||||
* @param bool $shared
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function month($year = '2014', $month = '1', $shared = false)
|
||||
@@ -98,7 +100,7 @@ class ReportController extends Controller
|
||||
'accounts',
|
||||
'incomes', 'incomeTopLength',
|
||||
'expenses', 'expenseTopLength',
|
||||
'budgets','balance',
|
||||
'budgets', 'balance',
|
||||
'categories'
|
||||
)
|
||||
);
|
||||
@@ -106,7 +108,9 @@ class ReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $year
|
||||
* @param $year
|
||||
*
|
||||
* @param bool $shared
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
|
@@ -223,7 +223,6 @@ Route::group(
|
||||
Route::get('/bills/rescan/{bill}', ['uses' => 'BillController@rescan', 'as' => 'bills.rescan']); # rescan for matching.
|
||||
Route::get('/bills/create', ['uses' => 'BillController@create', 'as' => 'bills.create']);
|
||||
Route::get('/bills/edit/{bill}', ['uses' => 'BillController@edit', 'as' => 'bills.edit']);
|
||||
Route::get('/bills/add/{bill}', ['uses' => 'BillController@add', 'as' => 'bills.add']);
|
||||
Route::get('/bills/delete/{bill}', ['uses' => 'BillController@delete', 'as' => 'bills.delete']);
|
||||
Route::get('/bills/show/{bill}', ['uses' => 'BillController@show', 'as' => 'bills.show']);
|
||||
Route::post('/bills/store', ['uses' => 'BillController@store', 'as' => 'bills.store']);
|
||||
|
Reference in New Issue
Block a user