mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-29 02:11:12 -06:00
Removed references to components.
This commit is contained in:
parent
3c5179f145
commit
d49dc599a2
@ -251,6 +251,54 @@ class GoogleChartController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $component
|
||||
* @param $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function budgetsAndSpending(Budget $component, $year)
|
||||
{
|
||||
try {
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
|
||||
/** @var \FireflyIII\Database\Budget\Budget $repos */
|
||||
$repos = App::make('FireflyIII\Database\Budget\Budget');
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Month', 'date');
|
||||
$chart->addColumn('Budgeted', 'number');
|
||||
$chart->addColumn('Spent', 'number');
|
||||
|
||||
$end = clone $start;
|
||||
$end->endOfYear();
|
||||
while ($start <= $end) {
|
||||
|
||||
$spent = $repos->spentInMonth($component, $start);
|
||||
$repetition = $repos->repetitionOnStartingOnDate($component, $start);
|
||||
if ($repetition) {
|
||||
$budgeted = floatval($repetition->amount);
|
||||
} else {
|
||||
$budgeted = null;
|
||||
}
|
||||
|
||||
$chart->addRow(clone $start, $budgeted, $spent);
|
||||
|
||||
$start->addMonth();
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $year
|
||||
*
|
||||
@ -310,12 +358,12 @@ class GoogleChartController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Component $component
|
||||
* @param Category $component
|
||||
* @param $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function componentsAndSpending(Component $component, $year)
|
||||
public function categoriesAndSpending(Category $component, $year)
|
||||
{
|
||||
try {
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
@ -323,13 +371,8 @@ class GoogleChartController extends BaseController
|
||||
App::abort(500);
|
||||
}
|
||||
|
||||
if ($component->class == 'Budget') {
|
||||
/** @var \FireflyIII\Database\Budget\Budget $repos */
|
||||
$repos = App::make('FireflyIII\Database\Budget\Budget');
|
||||
} else {
|
||||
/** @var \FireflyIII\Database\Category\Category $repos */
|
||||
$repos = App::make('FireflyIII\Database\Category\Category');
|
||||
}
|
||||
/** @var \FireflyIII\Database\Category\Category $repos */
|
||||
$repos = App::make('FireflyIII\Database\Category\Category');
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
@ -341,13 +384,8 @@ class GoogleChartController extends BaseController
|
||||
$end->endOfYear();
|
||||
while ($start <= $end) {
|
||||
|
||||
$spent = $repos->spentInMonth($component, $start);
|
||||
$repetition = $repos->repetitionOnStartingOnDate($component, $start);
|
||||
if ($repetition) {
|
||||
$budgeted = floatval($repetition->amount);
|
||||
} else {
|
||||
$budgeted = null;
|
||||
}
|
||||
$spent = $repos->spentInMonth($component, $start);
|
||||
$budgeted = null;
|
||||
|
||||
$chart->addRow(clone $start, $budgeted, $spent);
|
||||
|
||||
|
@ -236,9 +236,9 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
{
|
||||
return \LimitRepetition::
|
||||
leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')->leftJoin(
|
||||
'components', 'budget_limits.component_id', '=', 'components.id'
|
||||
'budgets', 'budget_limits.budget_id', '=', 'budgets.id'
|
||||
)->where('limit_repetitions.startdate', $date->format('Y-m-d'))->where(
|
||||
'components.id', $budget->id
|
||||
'budgets.id', $budget->id
|
||||
)->first(['limit_repetitions.*']);
|
||||
}
|
||||
|
||||
@ -254,10 +254,10 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
return $this->getUser()->transactionjournals()->whereNotIn(
|
||||
'transaction_journals.id', function ($query) use ($start, $end) {
|
||||
$query->select('transaction_journals.id')->from('transaction_journals')->leftJoin(
|
||||
'component_transaction_journal', 'component_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
|
||||
)->leftJoin('components', 'components.id', '=', 'component_transaction_journal.component_id')->where(
|
||||
'budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
|
||||
)->leftJoin('budgets', 'budgets.id', '=', 'budget_transaction_journal.budget_id')->where(
|
||||
'transaction_journals.date', '>=', $start->format('Y-m-d')
|
||||
)->where('transaction_journals.date', '<=', $end->format('Y-m-d'))->where('components.class', 'Budget');
|
||||
)->where('transaction_journals.date', '<=', $end->format('Y-m-d'));
|
||||
}
|
||||
)->before($end)->after($start)->lessThan(0)->transactionTypes(['Withdrawal'])->get();
|
||||
}
|
||||
|
@ -117,6 +117,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
\Log::error($model->getErrors()->all());
|
||||
throw new FireflyException('store() transaction journal failed, but it should not!');
|
||||
}
|
||||
throw new NotImplementedException('Still have to fix the budget/category change to components.');
|
||||
$model->save();
|
||||
|
||||
/*
|
||||
@ -147,6 +148,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
/*
|
||||
* Update the budget and the category.
|
||||
*/
|
||||
|
||||
$components = [];
|
||||
if (isset($data['budget_id']) && intval($data['budget_id']) > 0) {
|
||||
/** @var \FireflyIII\Database\Budget\Budget $budgetRepository */
|
||||
|
@ -63,7 +63,7 @@ class Steam
|
||||
{
|
||||
$user = \Auth::user();
|
||||
if ($user) {
|
||||
\BudgetLimit::leftJoin('components', 'components.id', '=', 'budget_limits.component_id')->where('components.user_id', $user->id)
|
||||
\BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')->where('budgets.user_id', $user->id)
|
||||
->where('budget_limits.amount', 0)->delete();
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class BudgetLimit extends Eloquent
|
||||
use ValidatingTrait;
|
||||
public static $rules
|
||||
= [
|
||||
'component_id' => 'required|exists:components,id',
|
||||
'budget_id' => 'required|exists:budgets,id',
|
||||
'startdate' => 'required|date',
|
||||
'amount' => 'numeric|required|min:0.01',
|
||||
'repeats' => 'required|boolean',
|
||||
@ -27,7 +27,7 @@ class BudgetLimit extends Eloquent
|
||||
*/
|
||||
public function budget()
|
||||
{
|
||||
return $this->belongsTo('Budget', 'component_id');
|
||||
return $this->belongsTo('Budget', 'budget_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,29 +27,6 @@ class Transaction extends Eloquent
|
||||
return $this->belongsTo('Account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function budgets()
|
||||
{
|
||||
return $this->belongsToMany('Budget', 'component_transaction', 'transaction_id', 'component_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function categories()
|
||||
{
|
||||
return $this->belongsToMany('Category', 'component_transaction', 'transaction_id', 'component_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function components()
|
||||
{
|
||||
return $this->belongsToMany('Component');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
@ -42,13 +42,6 @@ class TransactionJournal extends Eloquent
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function components()
|
||||
{
|
||||
return $this->belongsToMany('Component');
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||
@ -208,9 +201,7 @@ class TransactionJournal extends Eloquent
|
||||
$query->with(
|
||||
['transactions' => function ($q) {
|
||||
$q->orderBy('amount', 'ASC');
|
||||
}, 'transactiontype', 'components' => function ($q) {
|
||||
$q->orderBy('class');
|
||||
}, 'transactions.account.accounttype', 'recurringTransaction', 'budgets', 'categories']
|
||||
}, 'transactiontype', 'budgets','categories', 'transactions.account.accounttype', 'recurringTransaction', 'budgets', 'categories']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -51,14 +51,6 @@ class User extends Eloquent implements UserInterface, RemindableInterface
|
||||
return $this->hasMany('Category');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function components()
|
||||
{
|
||||
return $this->hasMany('Component');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
*/
|
||||
|
@ -185,7 +185,8 @@ Route::group(
|
||||
Route::get('/chart/piggyhistory/{piggybank}', ['uses' => 'GoogleChartController@piggyBankHistory']);
|
||||
|
||||
// google chart for components (categories + budgets combined)
|
||||
Route::get('/chart/component/{component}/spending/{year}', ['uses' => 'GoogleChartController@componentsAndSpending']);
|
||||
Route::get('/chart/budget/{budget}/spending/{year}', ['uses' => 'GoogleChartController@budgetsAndSpending']);
|
||||
Route::get('/chart/category/{category}/spending/{year}', ['uses' => 'GoogleChartController@categoriesAndSpending']);
|
||||
|
||||
// help controller
|
||||
Route::get('/help/{route}', ['uses' => 'HelpController@show', 'as' => 'help.show']);
|
||||
|
@ -8,7 +8,7 @@ $(function () {
|
||||
|
||||
|
||||
if (typeof componentID != 'undefined' && typeof repetitionID == 'undefined') {
|
||||
googleColumnChart('chart/component/' + componentID + '/spending/' + year, 'componentOverview');
|
||||
googleColumnChart('chart/budget/' + componentID + '/spending/' + year, 'componentOverview');
|
||||
}
|
||||
if (typeof componentID != 'undefined' && typeof repetitionID != 'undefined') {
|
||||
googleLineChart('chart/budget/' + componentID + '/' + repetitionID, 'componentOverview');
|
||||
|
@ -1,7 +1,7 @@
|
||||
$(function () {
|
||||
|
||||
if (typeof componentID != 'undefined' && typeof repetitionID == 'undefined') {
|
||||
googleColumnChart('chart/component/' + componentID + '/spending/' + year, 'componentOverview');
|
||||
googleColumnChart('chart/category/' + componentID + '/spending/' + year, 'componentOverview');
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user