Remove methods no longer used.

This commit is contained in:
James Cole 2016-10-09 10:59:28 +02:00
parent b082858866
commit f5adb4047f
2 changed files with 0 additions and 115 deletions

View File

@ -111,101 +111,6 @@ class AccountRepository implements AccountRepositoryInterface
return $transaction;
}
/**
* Get the accounts of a user that have piggy banks connected to them.
*
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getPiggyBankAccounts(Carbon $start, Carbon $end): Collection
{
$collection = new Collection(DB::table('piggy_banks')->distinct()->get(['piggy_banks.account_id']));
$accountIds = $collection->pluck('account_id')->toArray();
$accounts = new Collection;
$accountIds = array_unique($accountIds);
if (count($accountIds) > 0) {
$accounts = $this->user->accounts()->whereIn('id', $accountIds)->where('accounts.active', 1)->get();
}
$accounts->each(
function (Account $account) use ($start, $end) {
$account->startBalance = Steam::balanceIgnoreVirtual($account, $start);
$account->endBalance = Steam::balanceIgnoreVirtual($account, $end);
$account->piggyBalance = '0';
/** @var PiggyBank $piggyBank */
foreach ($account->piggyBanks as $piggyBank) {
$account->piggyBalance = bcadd($account->piggyBalance, $piggyBank->currentRelevantRep()->currentamount);
}
// sum of piggy bank amounts on this account:
// diff between endBalance and piggyBalance.
// then, percentage.
$difference = bcsub($account->endBalance, $account->piggyBalance);
$account->difference = $difference;
$account->percentage = $difference != 0 && $account->endBalance != 0 ? round((($difference / $account->endBalance) * 100)) : 100;
}
);
return $accounts;
}
/**
* Get savings accounts.
*
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getSavingsAccounts(Carbon $start, Carbon $end): Collection
{
$accounts = $this->user->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')
->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
->where('account_meta.name', 'accountRole')
->where('accounts.active', 1)
->where('account_meta.data', '"savingAsset"')
->get(['accounts.*']);
$accounts->each(
function (Account $account) use ($start, $end) {
$account->startBalance = Steam::balance($account, $start);
$account->endBalance = Steam::balance($account, $end);
// diff (negative when lost, positive when gained)
$diff = bcsub($account->endBalance, $account->startBalance);
if ($diff < 0 && $account->startBalance > 0) {
// percentage lost compared to start.
$pct = (($diff * -1) / $account->startBalance) * 100;
$pct = $pct > 100 ? 100 : $pct;
$account->difference = $diff;
$account->percentage = round($pct);
return;
}
if ($diff >= 0 && $account->startBalance > 0) {
$pct = ($diff / $account->startBalance) * 100;
$pct = $pct > 100 ? 100 : $pct;
$account->difference = $diff;
$account->percentage = round($pct);
return;
}
$account->difference = $diff;
$account->percentage = 100;
}
);
return $accounts;
}
/**
* @param Collection $accounts
* @param array $types

View File

@ -60,26 +60,6 @@ interface AccountRepositoryInterface
*/
public function getFirstTransaction(TransactionJournal $journal, Account $account): Transaction;
/**
* Get the accounts of a user that have piggy banks connected to them.
*
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getPiggyBankAccounts(Carbon $start, Carbon $end): Collection;
/**
* Get savings accounts.
*
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getSavingsAccounts(Carbon $start, Carbon $end): Collection;
/**
* @param Collection $accounts
* @param array $types