/** * @param User $user */ public static function createAssetAccounts(User $user) { $assets = ['TestData Checking Account', 'TestData Savings', 'TestData Shared', 'TestData Creditcard', 'Emergencies', 'STE']; // first two ibans match test-upload.csv $ibans = ['NL11XOLA6707795988', 'NL96DZCO4665940223', 'NL81RCQZ7160379858', 'NL19NRAP2367994221', 'NL40UKBK3619908726', 'NL38SRMN4325934708']; $assetMeta = [['accountRole' => 'defaultAsset'], ['accountRole' => 'savingAsset'], ['accountRole' => 'sharedAsset'], ['accountRole' => 'ccAsset', 'ccMonthlyPaymentDate' => '2015-05-27', 'ccType' => 'monthlyFull'], ['accountRole' => 'savingAsset'], ['accountRole' => 'savingAsset']]; foreach ($assets as $index => $name) { // create account: $account = Account::create(['user_id' => $user->id, 'account_type_id' => 3, 'name' => $name, 'active' => 1, 'encrypted' => 1, 'iban' => $ibans[$index]]); foreach ($assetMeta[$index] as $name => $value) { AccountMeta::create(['account_id' => $account->id, 'name' => $name, 'data' => $value]); } } }
/** * @param array $fields * @SuppressWarnings(PHPMD.CyclomaticComplexity) * * @return Account|null */ public static function firstOrCreateEncrypted(array $fields) { // everything but the name: $query = Account::orderBy('id'); foreach ($fields as $name => $value) { if ($name != 'name') { $query->where($name, $value); } } $set = $query->get(['accounts.*']); /** @var Account $account */ foreach ($set as $account) { if ($account->name == $fields['name']) { return $account; } } // create it! $account = Account::create($fields); return $account; }
/** * @param array $fields * @SuppressWarnings(PHPMD.CyclomaticComplexity) * * @return Account|null */ public static function firstOrCreateEncrypted(array $fields) { // everything but the name: $query = Account::orderBy('id'); $search = $fields; unset($search['name'], $search['iban']); foreach ($search as $name => $value) { $query->where($name, $value); } $set = $query->get(['accounts.*']); /** @var Account $account */ foreach ($set as $account) { if ($account->name == $fields['name']) { return $account; } } // account must have a name. If not set, use IBAN. if (!isset($fields['name'])) { $fields['name'] = $fields['iban']; } // create it! $account = Account::create($fields); return $account; }
/** * */ protected function createRevenueAccounts() { $revenues = ['Job', 'Belastingdienst', 'Bank', 'KPN', 'Google']; foreach ($revenues as $name) { // create account: Account::create(['user_id' => $this->user->id, 'account_type_id' => 5, 'name' => $name, 'active' => 1, 'encrypted' => 1]); } }
/** * */ public function createRevenueAccounts() { $user = User::whereEmail('*****@*****.**')->first(); $revenueType = AccountType::whereType('Revenue account')->first(); Account::create(['user_id' => $user->id, 'account_type_id' => $revenueType->id, 'name' => 'Employer', 'active' => 1]); Account::create(['user_id' => $user->id, 'account_type_id' => $revenueType->id, 'name' => 'IRS', 'active' => 1]); Account::create(['user_id' => $user->id, 'account_type_id' => $revenueType->id, 'name' => 'Second job employer', 'active' => 1]); }
/** * @param User $user */ private function openingBalanceSavings(User $user) { // opposing account for opening balance: $opposing = Account::create(['user_id' => $user->id, 'account_type_id' => 6, 'name' => 'Opposing for savings', 'active' => 1, 'encrypted' => 1]); // savings $savings = TestData::findAccount($user, 'TestData Savings'); $journal = TransactionJournal::create(['user_id' => $user->id, 'transaction_type_id' => 4, 'transaction_currency_id' => 1, 'description' => 'Opening balance for savings account', 'completed' => 1, 'date' => $this->start->format('Y-m-d')]); // transactions Transaction::create(['account_id' => $opposing->id, 'transaction_journal_id' => $journal->id, 'amount' => -10000]); Transaction::create(['account_id' => $savings->id, 'transaction_journal_id' => $journal->id, 'amount' => 10000]); }