mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-03 20:55:05 +00:00
Basic testing, not full coverage.
This commit is contained in:
@@ -50,8 +50,8 @@ class BudgetController extends BaseController
|
||||
*/
|
||||
public function destroy(Budget $budget)
|
||||
{
|
||||
Event::fire('budgets.destroy',[$budget]); // just before deletion.
|
||||
$result = $this->_repository->destroy($budget);
|
||||
Event::fire('budgets.change');
|
||||
if ($result === true) {
|
||||
Session::flash('success', 'The budget was deleted.');
|
||||
if (Input::get('from') == 'date') {
|
||||
@@ -86,8 +86,6 @@ class BudgetController extends BaseController
|
||||
$budgets = $this->_repository->get();
|
||||
$today = new Carbon;
|
||||
|
||||
Event::fire('budgets.change');
|
||||
|
||||
return View::make('budgets.indexByBudget')->with('budgets', $budgets)->with('today', $today);
|
||||
|
||||
}
|
||||
@@ -102,7 +100,6 @@ class BudgetController extends BaseController
|
||||
$set = $this->_repository->get();
|
||||
$budgets = $this->_budgets->organizeByDate($set);
|
||||
|
||||
Event::fire('budgets.change');
|
||||
|
||||
return View::make('budgets.indexByDate')->with('budgets', $budgets);
|
||||
|
||||
@@ -146,7 +143,7 @@ class BudgetController extends BaseController
|
||||
|
||||
$budget = $this->_repository->store(Input::all());
|
||||
if ($budget->validate()) {
|
||||
Event::fire('budgets.change');
|
||||
Event::fire('budgets.store',[$budget]);
|
||||
Session::flash('success', 'Budget created!');
|
||||
|
||||
if (Input::get('create') == '1') {
|
||||
@@ -175,7 +172,7 @@ class BudgetController extends BaseController
|
||||
{
|
||||
$budget = $this->_repository->update($budget, Input::all());
|
||||
if ($budget->validate()) {
|
||||
Event::fire('budgets.change');
|
||||
Event::fire('budgets.update',[$budget]);
|
||||
Session::flash('success', 'Budget "' . $budget->name . '" updated.');
|
||||
|
||||
if (Input::get('from') == 'date') {
|
||||
|
||||
@@ -31,13 +31,12 @@ class LimitController extends BaseController
|
||||
{
|
||||
$periods = \Config::get('firefly.periods_to_text');
|
||||
$prefilled = [
|
||||
'startdate' => Input::get('startdate') ? : date('Y-m-d'),
|
||||
'repeat_freq' => Input::get('repeat_freq') ? : 'monthly',
|
||||
'startdate' => \Input::get('startdate') ? : date('Y-m-d'),
|
||||
'repeat_freq' => \Input::get('repeat_freq') ? : 'monthly',
|
||||
'budget_id' => $budget ? $budget->id : null
|
||||
];
|
||||
|
||||
$budgets = $this->_budgets->getAsSelectList();
|
||||
Event::fire('budgets.change');
|
||||
|
||||
return View::make('limits.create')->with('budgets', $budgets)->with(
|
||||
'periods', $periods
|
||||
@@ -61,6 +60,7 @@ class LimitController extends BaseController
|
||||
*/
|
||||
public function destroy(\Limit $limit)
|
||||
{
|
||||
Event::fire('limits.destroy',[$limit]); // before
|
||||
$success = $this->_limits->destroy($limit);
|
||||
|
||||
if ($success) {
|
||||
@@ -68,7 +68,6 @@ class LimitController extends BaseController
|
||||
} else {
|
||||
Session::flash('error', 'Could not delete the envelope. Check the logs to be sure.');
|
||||
}
|
||||
Event::fire('budgets.change');
|
||||
if (Input::get('from') == 'date') {
|
||||
return Redirect::route('budgets.index');
|
||||
} else {
|
||||
@@ -103,7 +102,7 @@ class LimitController extends BaseController
|
||||
$limit = $this->_limits->store(Input::all());
|
||||
if ($limit->validate()) {
|
||||
Session::flash('success', 'Envelope created!');
|
||||
Event::fire('budgets.change');
|
||||
Event::fire('limits.store',[$limit]);
|
||||
if (Input::get('from') == 'date') {
|
||||
return Redirect::route('budgets.index');
|
||||
} else {
|
||||
@@ -126,18 +125,13 @@ class LimitController extends BaseController
|
||||
*/
|
||||
public function update(\Limit $limit)
|
||||
{
|
||||
// TODO move logic to repository.
|
||||
/** @var \Limit $limit */
|
||||
$limit->startdate = new \Carbon\Carbon(Input::get('date'));
|
||||
$limit->repeat_freq = Input::get('period');
|
||||
$limit->repeats = !is_null(Input::get('repeats')) && Input::get('repeats') == '1' ? 1 : 0;
|
||||
$limit->amount = floatval(Input::get('amount'));
|
||||
Event::fire('budgets.change');
|
||||
if ($limit->save()) {
|
||||
|
||||
|
||||
$limit = $this->_limits->update($limit,Input::all());
|
||||
|
||||
if ($limit->validate()) {
|
||||
Event::fire('limits.update',[$limit]);
|
||||
Session::flash('success', 'Limit saved!');
|
||||
foreach ($limit->limitrepetitions()->get() as $rep) {
|
||||
$rep->delete();
|
||||
}
|
||||
if (Input::get('from') == 'date') {
|
||||
return Redirect::route('budgets.index');
|
||||
} else {
|
||||
|
||||
@@ -37,7 +37,7 @@ class TransactionController extends BaseController
|
||||
$budgets = $budgetRepository->getAsSelectList();
|
||||
$budgets[0] = '(no budget)';
|
||||
|
||||
// get the number of piggy banks.
|
||||
// get the piggy banks.
|
||||
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
|
||||
$piggyRepository = App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
||||
$piggies = $piggyRepository->get();
|
||||
@@ -96,11 +96,22 @@ class TransactionController extends BaseController
|
||||
$budgets = $budgetRepository->getAsSelectList();
|
||||
$budgets[0] = '(no budget)';
|
||||
|
||||
// get the piggy banks.
|
||||
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
|
||||
$piggyRepository = App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
||||
$piggies = $piggyRepository->get();
|
||||
// piggy bank id?
|
||||
$piggyBankId = null;
|
||||
foreach($journal->transactions as $t) {
|
||||
$piggyBankId = $t->piggybank_id;
|
||||
}
|
||||
|
||||
// data to properly display form:
|
||||
$data = [
|
||||
'date' => $journal->date->format('Y-m-d'),
|
||||
'category' => '',
|
||||
'budget_id' => 0
|
||||
'budget_id' => 0,
|
||||
'piggybank_id' => $piggyBankId
|
||||
];
|
||||
$category = $journal->categories()->first();
|
||||
if (!is_null($category)) {
|
||||
@@ -130,7 +141,7 @@ class TransactionController extends BaseController
|
||||
|
||||
return View::make('transactions.edit')->with('journal', $journal)->with('accounts', $accounts)->with(
|
||||
'what', $what
|
||||
)->with('budgets', $budgets)->with('data', $data);
|
||||
)->with('budgets', $budgets)->with('data', $data)->with('piggies',$piggies);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user