mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-19 10:53:31 +00:00
Fixed some sorting.
This commit is contained in:
@@ -44,9 +44,7 @@ class Wizard implements WizardInterface
|
|||||||
/*
|
/*
|
||||||
* Make each one unique.
|
* Make each one unique.
|
||||||
*/
|
*/
|
||||||
foreach ($values as $column => $found) {
|
$values = $this->uniqueRecursive($values);
|
||||||
$values[$column] = array_unique($found);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
@@ -176,4 +174,18 @@ class Wizard implements WizardInterface
|
|||||||
{
|
{
|
||||||
return ($hasHeaders && $index > 1) || !$hasHeaders;
|
return ($hasHeaders && $index > 1) || !$hasHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $array
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function uniqueRecursive(array $array)
|
||||||
|
{
|
||||||
|
foreach ($array as $column => $found) {
|
||||||
|
$array[$column] = array_unique($found);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -36,6 +36,7 @@ class JsonController extends Controller
|
|||||||
{
|
{
|
||||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||||
|
$amount = 0;
|
||||||
bcscale(2);
|
bcscale(2);
|
||||||
|
|
||||||
// works for json too!
|
// works for json too!
|
||||||
@@ -46,12 +47,7 @@ class JsonController extends Controller
|
|||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return Response::json($cache->get()); // @codeCoverageIgnore
|
return Response::json($cache->get()); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
$bills = $repository->getActiveBills(); // these two functions are the same as the chart
|
||||||
$amount = 0;
|
|
||||||
|
|
||||||
|
|
||||||
// these two functions are the same as the chart
|
|
||||||
$bills = $repository->getActiveBills();
|
|
||||||
|
|
||||||
/** @var Bill $bill */
|
/** @var Bill $bill */
|
||||||
foreach ($bills as $bill) {
|
foreach ($bills as $bill) {
|
||||||
@@ -59,14 +55,10 @@ class JsonController extends Controller
|
|||||||
}
|
}
|
||||||
unset($bill, $bills);
|
unset($bill, $bills);
|
||||||
|
|
||||||
/**
|
$creditCards = $accountRepository->getCreditCards(); // Find credit card accounts and possibly unpaid credit card bills.
|
||||||
* Find credit card accounts and possibly unpaid credit card bills.
|
|
||||||
*/
|
|
||||||
$creditCards = $accountRepository->getCreditCards();
|
|
||||||
// if the balance is not zero, the monthly payment is still underway.
|
|
||||||
/** @var Account $creditCard */
|
/** @var Account $creditCard */
|
||||||
foreach ($creditCards as $creditCard) {
|
foreach ($creditCards as $creditCard) {
|
||||||
$balance = Steam::balance($creditCard, $end, true);
|
$balance = Steam::balance($creditCard, $end, true); // if the balance is not zero, the monthly payment is still underway.
|
||||||
if ($balance == 0) {
|
if ($balance == 0) {
|
||||||
// find a transfer TO the credit card which should account for
|
// find a transfer TO the credit card which should account for
|
||||||
// anything paid. If not, the CC is not yet used.
|
// anything paid. If not, the CC is not yet used.
|
||||||
@@ -76,7 +68,6 @@ class JsonController extends Controller
|
|||||||
$data = ['box' => 'bills-paid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
$data = ['box' => 'bills-paid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||||
$cache->store($data);
|
$cache->store($data);
|
||||||
|
|
||||||
|
|
||||||
return Response::json($data);
|
return Response::json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,12 +63,19 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getAccounts(array $types)
|
public function getAccounts(array $types)
|
||||||
{
|
{
|
||||||
|
/** @var Collection $result */
|
||||||
$result = Auth::user()->accounts()->with(
|
$result = Auth::user()->accounts()->with(
|
||||||
['accountmeta' => function (HasMany $query) {
|
['accountmeta' => function (HasMany $query) {
|
||||||
$query->where('name', 'accountRole');
|
$query->where('name', 'accountRole');
|
||||||
}]
|
}]
|
||||||
)->accountTypeIn($types)->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
)->accountTypeIn($types)->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
||||||
|
|
||||||
|
$result = $result->sortBy(
|
||||||
|
function (Account $account) {
|
||||||
|
return strtolower($account->name);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user