Remove a lot of references to user id.

This commit is contained in:
James Cole
2016-10-23 12:19:32 +02:00
parent 9a30fbd05a
commit c39659b064
21 changed files with 33 additions and 60 deletions

View File

@@ -388,7 +388,7 @@ class AccountRepository implements AccountRepositoryInterface
// create it:
$newAccount = new Account(
[
'user_id' => $data['user'],
'user_id' => $this->user->id,
'account_type_id' => $accountType->id,
'name' => $data['name'],
'virtual_balance' => $data['virtualBalance'],
@@ -417,13 +417,12 @@ class AccountRepository implements AccountRepositoryInterface
protected function storeInitialBalance(Account $account, array $data): TransactionJournal
{
$amount = $data['openingBalance'];
$user = $data['user'];
$name = $data['name'];
$opposing = $this->storeOpposingAccount($amount, $user, $name);
$opposing = $this->storeOpposingAccount($amount, $name);
$transactionType = TransactionType::whereType(TransactionType::OPENING_BALANCE)->first();
$journal = TransactionJournal::create(
[
'user_id' => $data['user'],
'user_id' => $this->user->id,
'transaction_type_id' => $transactionType->id,
'transaction_currency_id' => $data['openingBalanceCurrency'],
'description' => 'Initial balance for "' . $account->name . '"',
@@ -458,16 +457,14 @@ class AccountRepository implements AccountRepositoryInterface
/**
* @param float $amount
* @param int $user
* @param string $name
*
* @return Account
*/
protected function storeOpposingAccount(float $amount, int $user, string $name):Account
protected function storeOpposingAccount(float $amount, string $name):Account
{
$type = $amount < 0 ? 'expense' : 'revenue';
$opposingData = [
'user' => $user,
'accountType' => $type,
'name' => $name . ' initial balance',
'active' => false,