Skip to content

Firefly III: a personal finances manager

Add usergroup, clean up some code.

James Coleb407d8d3150c
diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.php
index 992477bdee..3f86521a4f 100644
--- a/app/Api/V1/Controllers/Chart/AccountController.php
+++ b/app/Api/V1/Controllers/Chart/AccountController.php
@@ -30,7 +30,6 @@ use FireflyIII\Api\V1\Requests\Data\DateRequest;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
-use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Http\Api\ApiSupport;
@@ -73,19 +72,19 @@ class AccountController extends Controller
public function overview(DateRequest $request): JsonResponse
{
// parameters for chart:
- $dates = $request->getAll();
+ $dates = $request->getAll();
/** @var Carbon $start */
- $start = $dates['start'];
+ $start = $dates['start'];
/** @var Carbon $end */
- $end = $dates['end'];
+ $end = $dates['end'];
// user's preferences
$defaultSet = $this->repository->getAccountsByType([AccountTypeEnum::ASSET->value])->pluck('id')->toArray();
/** @var Preference $frontpage */
- $frontpage = app('preferences')->get('frontpageAccounts', $defaultSet);
+ $frontpage = app('preferences')->get('frontpageAccounts', $defaultSet);
if (!(is_array($frontpage->data) && count($frontpage->data) > 0)) {
$frontpage->data = $defaultSet;
@@ -93,14 +92,14 @@ class AccountController extends Controller
}
// get accounts:
- $accounts = $this->repository->getAccountsById($frontpage->data);
- $chartData = [];
+ $accounts = $this->repository->getAccountsById($frontpage->data);
+ $chartData = [];
/** @var Account $account */
foreach ($accounts as $account) {
- $currency = $this->repository->getAccountCurrency($account) ?? $this->defaultCurrency;
- $field = $this->convertToNative ? 'native_balance' : 'balance';
- $currentSet = [
+ $currency = $this->repository->getAccountCurrency($account) ?? $this->defaultCurrency;
+ $field = $this->convertToNative && $currency->id !== $this->defaultCurrency->id ? 'native_balance' : 'balance';
+ $currentSet = [
'label' => $account->name,
'currency_id' => (string) $currency->id,
'currency_code' => $currency->code,
@@ -117,14 +116,14 @@ class AccountController extends Controller
$range = app('steam')->finalAccountBalanceInRange($account, $start, clone $end, $this->convertToNative);
$previous = array_values($range)[0][$field];
while ($currentStart <= $end) {
- $format = $currentStart->format('Y-m-d');
- $label = $currentStart->toAtomString();
- $balance = array_key_exists($format, $range) ? $range[$format][$field] : $previous;
- $previous = $balance;
+ $format = $currentStart->format('Y-m-d');
+ $label = $currentStart->toAtomString();
+ $balance = array_key_exists($format, $range) ? $range[$format][$field] : $previous;
+ $previous = $balance;
$currentStart->addDay();
$currentSet['entries'][$label] = $balance;
}
- $chartData[] = $currentSet;
+ $chartData[] = $currentSet;
}
return response()->json($chartData);
diff --git a/resources/views/emails/token-created.blade.php b/resources/views/emails/token-created.blade.php
index 57561e0c10..7d113cddca 100644
--- a/resources/views/emails/token-created.blade.php
+++ b/resources/views/emails/token-created.blade.php
@@ -10,4 +10,5 @@
- {{ trans('email.date_time') }}: {{ $time }}
- {{ trans('email.user_agent') }}: {{ $userAgent }}
+
@endcomponent
diff --git a/tests/integration/TestCase.php b/tests/integration/TestCase.php
index 0f73fc5894..bb85425ea0 100644
--- a/tests/integration/TestCase.php
+++ b/tests/integration/TestCase.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\integration;
+use FireflyIII\Models\UserGroup;
use FireflyIII\User;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Tests\integration\Traits\CollectsValues;