mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Lots of cleaning up.
This commit is contained in:
@@ -128,17 +128,17 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$query = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account']);
|
||||
|
||||
|
||||
if ($preference->data == []) {
|
||||
$accounts = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
||||
} else {
|
||||
$accounts = Auth::user()->accounts()->whereIn('id', $preference->data)->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
||||
if (count($preference->data) > 0) {
|
||||
$query->whereIn('id', $preference->data);
|
||||
}
|
||||
|
||||
$cache->store($accounts);
|
||||
$result = $query->get(['accounts.*']);
|
||||
|
||||
return $accounts;
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,27 +207,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLastActivities(array $accounts)
|
||||
{
|
||||
$list = [];
|
||||
|
||||
$set = Auth::user()->transactions()
|
||||
->whereIn('account_id', $accounts)
|
||||
->groupBy('account_id')
|
||||
->get(['transactions.account_id', DB::Raw('MAX(`transaction_journals`.`date`) as `max_date`')]);
|
||||
|
||||
foreach ($set as $entry) {
|
||||
$list[intval($entry->account_id)] = new Carbon($entry->max_date);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the accounts of a user that have piggy banks connected to them.
|
||||
*
|
||||
@@ -433,11 +412,11 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @return string
|
||||
*/
|
||||
public function sumOfEverything()
|
||||
{
|
||||
return floatval(Auth::user()->transactions()->sum('amount'));
|
||||
return Auth::user()->transactions()->sum('amount');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -24,13 +24,6 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function countAccounts(array $types);
|
||||
|
||||
/**
|
||||
* @param array $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLastActivities(array $accounts);
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param Account $moveTo
|
||||
@@ -103,7 +96,7 @@ interface AccountRepositoryInterface
|
||||
public function getJournals(Account $account, $page);
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @return string
|
||||
*/
|
||||
public function sumOfEverything();
|
||||
|
||||
|
@@ -52,9 +52,10 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*/
|
||||
public function expensesOnDayCorrected(Budget $budget, Carbon $date)
|
||||
{
|
||||
$sum = floatval($budget->transactionjournals()->transactionTypes(['Withdrawal'])->onDate($date)->get(['transaction_journals.*'])->sum('amount'));
|
||||
bcscale(2);
|
||||
$sum = $budget->transactionjournals()->transactionTypes(['Withdrawal'])->onDate($date)->get(['transaction_journals.*'])->sum('amount');
|
||||
|
||||
return $sum * -1;
|
||||
return bcmul($sum, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,7 +248,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
->first(['limit_repetitions.*']);
|
||||
|
||||
if ($repetition) {
|
||||
return floatval($repetition->amount);
|
||||
return $repetition->amount;
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -299,7 +300,9 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
->transactionTypes(['Withdrawal'])
|
||||
->get(['transaction_journals.*'])->sum('amount');
|
||||
|
||||
return floatval($noBudgetSet) * -1;
|
||||
bcscale(2);
|
||||
|
||||
return bcmul($noBudgetSet, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -89,7 +89,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
||||
$name = $isEncrypted ? Crypt::decrypt($name) : $name;
|
||||
$result[$categoryId] = [
|
||||
'name' => $name,
|
||||
'sum' => floatval($entry->amount),
|
||||
'sum' => $entry->amount,
|
||||
];
|
||||
|
||||
}
|
||||
@@ -194,11 +194,11 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
||||
* @param Category $category
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return float
|
||||
* @return string
|
||||
*/
|
||||
public function spentOnDaySumCorrected(Category $category, Carbon $date)
|
||||
{
|
||||
return floatval($category->transactionjournals()->onDate($date)->get(['transaction_journals.*'])->sum('amount'));
|
||||
return $category->transactionjournals()->onDate($date)->get(['transaction_journals.*'])->sum('amount');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user