New stuff pertaining to the import procedure and user registration.

This commit is contained in:
James Cole
2014-07-05 16:19:15 +02:00
parent c3254c2351
commit a0c0dc288d
23 changed files with 305 additions and 63 deletions

View File

@@ -3,6 +3,8 @@
namespace Firefly\Storage\Account;
use Firefly\Helper\MigrationException;
class EloquentAccountRepository implements AccountRepositoryInterface
{
public $validator;
@@ -28,11 +30,17 @@ class EloquentAccountRepository implements AccountRepositoryInterface
$initial->user()->associate(\Auth::user());
$initial->name = $data['name'] . ' initial balance';
$initial->active = 0;
$initial->save();
try {
$initial->save();
} catch (\Illuminate\Database\QueryException $e) {
\Log::error('DB ERROR: ' . $e->getMessage());
throw new FireflyException('Could not save counterbalance account for ' . $data['name']);
}
// create new transaction journal (and transactions):
/** @var \Firefly\Storage\TransactionJournal\TransactionJournalInterface $transactionJournal */
$transactionJournal = \App::make('Firefly\Storage\TransactionJournal\TransactionJournalInterface');
/** @var \Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface $transactionJournal */
$transactionJournal = \App::make('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
$transactionJournal->createSimpleJournal(
$initial, $account, 'Initial Balance for ' . $data['name'], $amount, $date
);
@@ -54,7 +62,13 @@ class EloquentAccountRepository implements AccountRepositoryInterface
$account->user()->associate(\Auth::user());
$account->name = $data['name'];
$account->active = isset($data['active']) ? $data['active'] : 1;
$account->save();
try {
$account->save();
} catch (\Illuminate\Database\QueryException $e) {
\Log::error('DB ERROR: ' . $e->getMessage());
throw new \Firefly\Exception\FireflyException('Could not save account ' . $data['name']);
}
return $account;
}