diff --git a/app/controllers/GoogleChartController.php b/app/controllers/GoogleChartController.php index fa9c58bb46..5e82d64c87 100644 --- a/app/controllers/GoogleChartController.php +++ b/app/controllers/GoogleChartController.php @@ -329,6 +329,8 @@ class GoogleChartController extends BaseController * * @param Budget $budget * + * @param int $year + * * @return \Illuminate\Http\JsonResponse */ public function budgetsAndSpending(Budget $budget, $year = 0) diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index 702ffe991b..e4d5186c5b 100644 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -79,9 +79,11 @@ class UserController extends BaseController if ($user) { $result = $email->sendVerificationMail($user); if ($result === false && Config::get('mail.pretend') === false) { + // @CodeCoverageIgnoreStart $user->delete(); return View::make('error')->with('message', 'The email message could not be send. See the log files.'); + // @CodeCoverageIgnoreEnd } return View::make('user.verification-pending'); diff --git a/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php b/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php index 25ee14cc3d..c5b7c0e0ca 100644 --- a/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php +++ b/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php @@ -432,6 +432,7 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C * Returns all objects. * * @return Collection + * @throws NotImplementedException * @codeCoverageIgnore */ public function get() diff --git a/app/lib/FireflyIII/FF3ServiceProvider.php b/app/lib/FireflyIII/FF3ServiceProvider.php index 5940441dda..dbcf7b69f7 100644 --- a/app/lib/FireflyIII/FF3ServiceProvider.php +++ b/app/lib/FireflyIII/FF3ServiceProvider.php @@ -37,7 +37,9 @@ class FF3ServiceProvider extends ServiceProvider */ public function provides() { + // @CodeCoverageIgnoreStart return ['reminders', 'filters', 'datekit', 'navigation']; + // @CodeCoverageIgnoreEnd } /** diff --git a/app/lib/FireflyIII/Helper/Related/Related.php b/app/lib/FireflyIII/Helper/Related/Related.php index f705145e87..06e1047858 100644 --- a/app/lib/FireflyIII/Helper/Related/Related.php +++ b/app/lib/FireflyIII/Helper/Related/Related.php @@ -50,7 +50,7 @@ class Related implements RelatedInterface // get already related transactions: $exclude = [$journal->id]; foreach ($journal->transactiongroups()->get() as $group) { - foreach ($group->transactionjournals() as $current) { + foreach ($group->transactionjournals()->get() as $current) { $exclude[] = $current->id; } } diff --git a/app/lib/FireflyIII/Report/Report.php b/app/lib/FireflyIII/Report/Report.php index 80922ea2da..a48ae74916 100644 --- a/app/lib/FireflyIII/Report/Report.php +++ b/app/lib/FireflyIII/Report/Report.php @@ -243,49 +243,9 @@ class Report implements ReportInterface $start->startOfMonth(); $end = clone $date; $end->endOfMonth(); - $userId = $this->_accounts->getUser()->id; return $this->_queries->incomeByPeriod($start, $end); - // $list = \TransactionJournal::leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') - // ->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id') - // ->leftJoin( - // 'account_meta', function (JoinClause $join) { - // $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole'); - // } - // ) - // ->transactionTypes(['Deposit']) - // ->where('transaction_journals.user_id', $userId) - // ->where('transactions.amount', '>', 0) - // ->where('transaction_journals.user_id', \Auth::user()->id) - // ->where('account_meta.data', '!=', '"sharedExpense"') - // ->orderBy('date', 'ASC') - // ->before($end)->after($start)->get(['transaction_journals.*']); - // - // // incoming from a shared account: it's profit (income): - // $transfers = \TransactionJournal::withRelevantData() - // ->leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') - // ->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id') - // ->leftJoin( - // 'account_meta', function (JoinClause $join) { - // $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole'); - // } - // ) - // ->transactionTypes(['Transfer']) - // ->where('transaction_journals.user_id', $userId) - // ->where('transactions.amount', '<', 0) - // ->where('account_meta.data', '=', '"sharedExpense"') - // ->orderBy('date', 'ASC') - // ->before($end)->after($start)->get(['transaction_journals.*']); - // - // $list = $list->merge($transfers); - // $list->sort( - // function (\TransactionJournal $journal) { - // return $journal->date->format('U'); - // } - // ); - // - // return $list; } diff --git a/app/models/Account.php b/app/models/Account.php index e8150ce3d1..9bf3bbe4a9 100644 --- a/app/models/Account.php +++ b/app/models/Account.php @@ -86,6 +86,7 @@ class Account extends Eloquent /** * * @param EloquentBuilder $query + * @param string $field */ public function scopeWithMeta(EloquentBuilder $query, $field = 'accountRole') { diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.php index f29033e547..d6f13cf646 100644 --- a/app/models/TransactionJournal.php +++ b/app/models/TransactionJournal.php @@ -82,13 +82,19 @@ class TransactionJournal extends Eloquent return ['created_at', 'updated_at', 'date']; } + /** + * @param $value + * + * @return string + */ public function getDescriptionAttribute($value) { if ($this->encrypted) { return Crypt::decrypt($value); } - + // @CodeCoverageIgnoreStart return $value; + // @CodeCoverageIgnoreEnd } /** @@ -207,6 +213,9 @@ class TransactionJournal extends Eloquent ); } + /** + * @param $value + */ public function setDescriptionAttribute($value) { $this->attributes['description'] = Crypt::encrypt($value); diff --git a/tests/functional/TransactionControllerCest.php b/tests/functional/TransactionControllerCest.php index f9e40d8062..f722e2ee31 100644 --- a/tests/functional/TransactionControllerCest.php +++ b/tests/functional/TransactionControllerCest.php @@ -69,6 +69,21 @@ class TransactionControllerCest } + public function destroyTransferWithEvent(FunctionalTester $I) + { + // get withdrawal transaction type id: + $row = DB::table('piggy_bank_events')->whereNotNull('transaction_journal_id')->first(); + $journalId = $row->transaction_journal_id; + $journal = TransactionJournal::find($journalId); + + $I->wantTo('destroy a transfer connected to a piggy bank'); + + $I->amOnPage('/transaction/delete/' . $journal->id); + $I->submitForm('#destroy', []); + $I->see('Transaction "' . $journal->description . '" destroyed.'); + + } + public function destroyWithdrawal(FunctionalTester $I) { // get withdrawal transaction type id: