Lots of cleanup and formatting.

This commit is contained in:
James Cole
2014-12-06 17:34:39 +01:00
parent bb3ba42ce2
commit cc111d14b0
6 changed files with 61 additions and 53 deletions

View File

@@ -65,12 +65,6 @@ class AccountController extends BaseController
/** @var \FireflyIII\Database\Account $acct */ /** @var \FireflyIII\Database\Account $acct */
$acct = App::make('FireflyIII\Database\Account'); $acct = App::make('FireflyIII\Database\Account');
// find the initial balance account (the only other account that should be deleted)
// find all journals for both accounts (or just the one) and delete them.
// the rest will take care of itself.
// in the least amount of queries possible.
// and it can be done in ONE query! or maybe two.
$acct->destroy($account); $acct->destroy($account);
$return = 'asset'; $return = 'asset';

View File

@@ -21,7 +21,7 @@ class HomeController extends BaseController
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
foreach ($journals as $journal) { foreach ($journals as $journal) {
if ($journal->TransactionType->type == 'Withdrawal') { if ($journal->transactionType->type == 'Withdrawal') {
echo '#' . $journal->id . ': ' . e($journal->description); echo '#' . $journal->id . ': ' . e($journal->description);
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) { foreach ($journal->transactions as $transaction) {

View File

@@ -14,6 +14,49 @@ class ReminderController extends BaseController
View::share('mainTitleIcon', 'fa-lightbulb-o'); View::share('mainTitleIcon', 'fa-lightbulb-o');
} }
public function act(Reminder $reminder)
{
switch (get_class($reminder->remindersable)) {
default:
throw new FireflyException('Cannot act on reminder for ' . get_class($reminder->remindersable));
break;
break;
case 'Piggybank':
$amount = Reminders::amountForReminder($reminder);
$prefilled = [
'amount' => round($amount, 2),
'description' => 'Money for ' . $reminder->remindersable->name,
'piggybank_id' => $reminder->remindersable_id,
'account_to_id' => $reminder->remindersable->account_id
];
Session::flash('prefilled', $prefilled);
return Redirect::route('transactions.create', 'transfer');
break;
}
}
public function dismiss(Reminder $reminder)
{
$reminder->active = 0;
$reminder->save();
Session::flash('success', 'Reminder dismissed');
return Redirect::route('index');
}
public function notnow(Reminder $reminder)
{
$reminder->active = 0;
$reminder->notnow = 1;
$reminder->save();
Session::flash('success', 'Reminder dismissed');
return Redirect::route('index');
}
/** /**
* @param Reminder $reminder * @param Reminder $reminder
*/ */
@@ -29,40 +72,4 @@ class ReminderController extends BaseController
return View::make('reminders.show', compact('reminder', 'amount')); return View::make('reminders.show', compact('reminder', 'amount'));
} }
public function act(Reminder $reminder) {
switch(get_class($reminder->remindersable)) {
default:
throw new FireflyException('Cannot act on reminder for ' . get_class($reminder->remindersable));
break;
break;
case 'Piggybank':
$amount = Reminders::amountForReminder($reminder);
$prefilled = [
'amount' => round($amount,2),
'description' => 'Money for ' . $reminder->remindersable->name,
'piggybank_id' => $reminder->remindersable_id,
'account_to_id' => $reminder->remindersable->account_id
];
Session::flash('prefilled',$prefilled);
return Redirect::route('transactions.create','transfer');
break;
}
}
public function dismiss(Reminder $reminder) {
$reminder->active = 0;
$reminder->save();
Session::flash('success','Reminder dismissed');
return Redirect::route('index');
}
public function notnow(Reminder $reminder) {
$reminder->active = 0;
$reminder->notnow = 1;
$reminder->save();
Session::flash('success','Reminder dismissed');
return Redirect::route('index');
}
} }

View File

@@ -60,7 +60,7 @@ class RepeatedExpenseController extends BaseController
} }
); );
return View::make('repeatedexpense.show', compact('repetitions','piggyBank', 'today', 'subTitle')); return View::make('repeatedexpense.show', compact('repetitions', 'piggyBank', 'today', 'subTitle'));
} }
/** /**

View File

@@ -180,7 +180,10 @@ class ReportController extends BaseController
return $journal; return $journal;
} }
} }
return null;
} }
); );
/* /*
* Filter deposits. * Filter deposits.
@@ -193,6 +196,8 @@ class ReportController extends BaseController
return $journal; return $journal;
} }
} }
return null;
} }
); );
@@ -221,7 +226,7 @@ class ReportController extends BaseController
*/ */
public function year($year) public function year($year)
{ {
Config::set('app.debug',false); Config::set('app.debug', false);
try { try {
$date = new Carbon('01-01-' . $year); $date = new Carbon('01-01-' . $year);
} catch (Exception $e) { } catch (Exception $e) {
@@ -276,9 +281,9 @@ class ReportController extends BaseController
} }
$summary[] = [ $summary[] = [
'month' => $month, 'month' => $month,
'income' => $income, 'income' => $income,
'expense' => $expense, 'expense' => $expense,
'incomeShared' => $incomeShared, 'incomeShared' => $incomeShared,
'expenseShared' => $expenseShared, 'expenseShared' => $expenseShared,
]; ];

View File

@@ -140,18 +140,19 @@ class TransactionController extends BaseController
$repository = App::make('FireflyIII\Database\TransactionJournal'); $repository = App::make('FireflyIII\Database\TransactionJournal');
$repository->destroy($transactionJournal); $repository->destroy($transactionJournal);
$return = 'withdrawal';
switch ($type) { switch ($type) {
case 'Withdrawal':
return Redirect::route('transactions.index', 'withdrawal');
break;
case 'Deposit': case 'Deposit':
return Redirect::route('transactions.index', 'deposit'); $return = 'deposit';
break; break;
case 'Transfer': case 'Transfer':
return Redirect::route('transactions.index', 'transfers'); $return = 'transfers';
break; break;
} }
return Redirect::route('transactions.index', $return);
} }
// TODO this needs cleaning up and thinking over. // TODO this needs cleaning up and thinking over.
@@ -506,6 +507,7 @@ class TransactionController extends BaseController
$group->delete(); $group->delete();
} }
} }
return Response::json(true); return Response::json(true);
} }