/** * @param $description * @param Carbon $date * @param $amount * * @return TransactionJournal */ protected function createWater($description, Carbon $date, $amount) { $date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); $toAccount = TestData::findAccount($this->user, 'Vitens'); $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $this->user->id]); $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $this->user->id]); $journal = TransactionJournal::create(['user_id' => $this->user->id, 'transaction_type_id' => 1, 'transaction_currency_id' => 1, 'description' => $description, 'completed' => 1, 'date' => $date]); Transaction::create(['account_id' => $fromAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $amount * -1]); Transaction::create(['account_id' => $toAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $amount]); $journal->categories()->save($category); $journal->budgets()->save($budget); return $journal; }
/** * @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]); }