This commit is contained in:
James Cole
2014-12-06 17:53:25 +01:00
parent 792e8a9947
commit dbc95dd878
13 changed files with 157 additions and 64 deletions

View File

@@ -6,48 +6,6 @@
*/
class HomeController extends BaseController
{
public function cleanup()
{
Auth::loginUsingId(1);
/** @var \FireflyIII\Database\TransactionJournal $repository */
$repository = App::make('FireflyIII\Database\TransactionJournal');
/** @var \FireflyIII\Database\Account $acct */
$acct = App::make('FireflyIII\Database\Account');
$journals = $repository->get();
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
if ($journal->transactionType->type == 'Withdrawal') {
echo '#' . $journal->id . ': ' . e($journal->description);
/** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) {
if (floatval($transaction->amount) > 0) {
// this is the one with the beneficiary account!
if ($transaction->account->accountType->type == 'Beneficiary account') {
echo ', <span style="color:red;">should be an expense account</span>';
if (Input::get('update') == 'true') {
$newAccount = $acct->firstExpenseAccountOrCreate($transaction->account->name);
$transaction->account_id = $newAccount->id;
$transaction->save();
echo '<span style="color:darkgreen">, updated!</span>';
}
}
}
}
echo '<br />';
}
}
return '&nbsp;';
}
/**
* @return \Illuminate\Http\RedirectResponse
*/