Skip to content

Firefly III: a personal finances manager

Cleanup.

James Cole3270d3bf967b
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php
index b2768bf998..08b54448c2 100644
--- a/app/Helpers/Report/ReportHelper.php
+++ b/app/Helpers/Report/ReportHelper.php
@@ -85,55 +85,4 @@ class ReportHelper implements ReportHelperInterface
return $months;
}
- /**
- * @param Carbon $date
- * @param bool $includeShared
- *
- * @return array
- */
- public function yearBalanceReport(Carbon $date, $includeShared = false)
- {
- $start = clone $date;
- $end = clone $date;
- $sharedAccounts = [];
- if ($includeShared === false) {
- $sharedCollection = Auth::user()->accounts()
- ->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
- ->where('account_meta.name', '=', 'accountRole')
- ->where('account_meta.data', '=', json_encode('sharedAsset'))
- ->get(['accounts.id']);
-
- foreach ($sharedCollection as $account) {
- $sharedAccounts[] = $account->id;
- }
- }
-
- $accounts = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->get(['accounts.*'])
- ->filter(
- function (Account $account) use ($sharedAccounts) {
- if (!in_array($account->id, $sharedAccounts)) {
- return $account;
- }
-
- return null;
- }
- );
- $report = [];
- $start->startOfYear()->subDay();
- $end->endOfYear();
-
- foreach ($accounts as $account) {
- $startBalance = Steam::balance($account, $start);
- $endBalance = Steam::balance($account, $end);
- $report[] = [
- 'start' => $startBalance,
- 'end' => $endBalance,
- 'hide' => ($startBalance == 0 && $endBalance == 0),
- 'account' => $account,
- 'shared' => $account->accountRole == 'sharedAsset'
- ];
- }
-
- return $report;
- }
}
diff --git a/app/Helpers/Report/ReportHelperInterface.php b/app/Helpers/Report/ReportHelperInterface.php
index dd2f179d0f..64fecb8902 100644
--- a/app/Helpers/Report/ReportHelperInterface.php
+++ b/app/Helpers/Report/ReportHelperInterface.php
@@ -30,11 +30,4 @@ interface ReportHelperInterface
*/
public function listOfMonths(Carbon $date);
- /**
- * @param Carbon $date
- * @param bool $includeShared
- *
- * @return array
- */
- public function yearBalanceReport(Carbon $date, $includeShared = false);
}
diff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.php
index b1c2d8c2a5..68f5fc8e80 100644
--- a/app/Helpers/Report/ReportQuery.php
+++ b/app/Helpers/Report/ReportQuery.php
@@ -437,58 +437,6 @@ class ReportQuery implements ReportQueryInterface
return $data;
}
- /**
- * This method returns all deposits into asset accounts, grouped by the revenue account,
- *
- * @param Carbon $start
- * @param Carbon $end
- * @param bool $includeShared
- *
- * @return Collection
- */
- public function journalsByRevenueAccount(Carbon $start, Carbon $end, $includeShared = false)
- {
- $query = $this->queryJournalsWithTransactions($start, $end);
- if ($includeShared === false) {
-
- // show queries where transfer type is deposit, and its not to a shared account
- // or where its a transfer and its from a shared account (both count as incomes)
- $query->where(
- function (Builder $query) {
- $query->where(
- function (Builder $q) {
- $q->where('transaction_types.type', 'Deposit');
- $q->where('acm_to.data', '!=', '"sharedAsset"');
- }
- );
- $query->orWhere(
- function (Builder $q) {
- $q->where('transaction_types.type', 'Transfer');
- $q->where('acm_from.data', '=', '"sharedAsset"');
- }
- );
- }
- );
- } else {
- // any deposit goes:
- $query->where('transaction_types.type', 'Deposit');
- }
-
- $query->groupBy('t_from.account_id')->orderBy('queryAmount');
-
- $data = $query->get(
- ['t_from.account_id as account_id', 'ac_from.name as name', 'ac_from.encrypted as encrypted', DB::Raw('SUM(t_from.amount) as `queryAmount`')]
- );
- // decrypt
- $data->each(
- function (Model $object) {
- $object->name = intval($object->encrypted) == 1 ? Crypt::decrypt($object->name) : $object->name;
- }
- );
-
- return $data;
- }
-
/**
* With an equally misleading name, this query returns are transfers to shared accounts. These are considered
* expenses.
diff --git a/app/Helpers/Report/ReportQueryInterface.php b/app/Helpers/Report/ReportQueryInterface.php
index c4931af7ed..7b700d8d9a 100644
--- a/app/Helpers/Report/ReportQueryInterface.php
+++ b/app/Helpers/Report/ReportQueryInterface.php
@@ -138,17 +138,6 @@ interface ReportQueryInterface
*/
public function journalsByExpenseAccount(Carbon $start, Carbon $end, $includeShared = false);
- /**
- * This method returns all deposits into asset accounts, grouped by the revenue account,
- *
- * @param Carbon $start
- * @param Carbon $end
- * @param bool $includeShared
- *
- * @return Collection
- */
- public function journalsByRevenueAccount(Carbon $start, Carbon $end, $includeShared = false);
-
/**
* With an equally misleading name, this query returns are transfers to shared accounts. These are considered
* expenses.
diff --git a/tests/helpers/ReportHelperTest.php b/tests/helpers/ReportHelperTest.php
index cbe0894c77..4a0a1d2796 100644
--- a/tests/helpers/ReportHelperTest.php
+++ b/tests/helpers/ReportHelperTest.php
@@ -118,108 +118,4 @@ class ReportHelperTest extends TestCase
}
-
- public function testYearBalanceReport()
- {
- $date = new Carbon('2015-01-01');
- $user = FactoryMuffin::create('FireflyIII\User');
- $setShared = [];
- $setNormal = [];
-
- FactoryMuffin::create('FireflyIII\Models\AccountType');
- FactoryMuffin::create('FireflyIII\Models\AccountType');
- $assetType = FactoryMuffin::create('FireflyIII\Models\AccountType');
-
- // need some shared accounts:
- for ($i = 0; $i < 3; $i++) {
- $shared = FactoryMuffin::create('FireflyIII\Models\Account');
- $shared->user_id = $user->id;
- $shared->account_type_id = $assetType->id;
- $shared->save();
- // meta for shared:
- AccountMeta::create(
- [
- 'account_id' => $shared->id,
- 'name' => 'accountRole',
- 'data' => 'sharedAsset',
- ]
- );
- $setShared[] = $shared;
- }
-
- // need some normal accounts:
- for ($i = 0; $i < 3; $i++) {
- $account = FactoryMuffin::create('FireflyIII\Models\Account');
- $account->user_id = $user->id;
- $account->account_type_id = $assetType->id;
- $account->save();
- $setNormal[] = $account;
- }
-
- // mock stuff:
- Steam::shouldReceive('balance')->withAnyArgs()->andReturn(0);
-
- $this->be($user);
-
- $result = $this->object->yearBalanceReport($date, false);
- foreach ($result as $entry) {
- // everything is hidden:
- $this->assertTrue($entry['hide']);
- // nothing is shared:
- $this->assertFalse($entry['shared']);
- }
-
- }
-
- public function testYearBalanceReportWithShared()
- {
- $date = new Carbon('2015-01-01');
- $user = FactoryMuffin::create('FireflyIII\User');
- $setShared = [];
- $setNormal = [];
-
- FactoryMuffin::create('FireflyIII\Models\AccountType');
- FactoryMuffin::create('FireflyIII\Models\AccountType');
- $assetType = FactoryMuffin::create('FireflyIII\Models\AccountType');
-
- // need some shared accounts:
- for ($i = 0; $i < 3; $i++) {
- $shared = FactoryMuffin::create('FireflyIII\Models\Account');
- $shared->user_id = $user->id;
- $shared->account_type_id = $assetType->id;
- $shared->save();
- // meta for shared:
- AccountMeta::create(
- [
- 'account_id' => $shared->id,
- 'name' => 'accountRole',
- 'data' => 'sharedAsset',
- ]
- );
- $setShared[] = $shared;
- }
-
- // need some normal accounts:
- for ($i = 0; $i < 3; $i++) {
- $account = FactoryMuffin::create('FireflyIII\Models\Account');
- $account->user_id = $user->id;
- $account->account_type_id = $assetType->id;
- $account->save();
- $setNormal[] = $account;
- }
-
- // mock stuff:
- Steam::shouldReceive('balance')->withAnyArgs()->andReturn(0);
-
- $this->be($user);
-
- $result = $this->object->yearBalanceReport($date, true);
- foreach ($result as $entry) {
- // everything is hidden:
- $this->assertTrue($entry['hide']);
- // nothing is shared:
- $this->assertFalse($entry['shared']);
- }
-
- }
}
\ No newline at end of file