James Cole
2023-12-03 07:44:53 +01:00
parent 3136bccb24
commit 40083bf2b4
3 changed files with 22 additions and 6 deletions

View File

@@ -116,6 +116,17 @@ class AccountController extends Controller
$accounts = $this->repository->getAccountsById($frontPage->data);
}
// both options are overruled by "preselected"
if('all' === $params['preselected']) {
$accounts = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
}
if('assets' === $params['preselected']) {
$accounts = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
}
if('liabilities' === $params['preselected']) {
$accounts = $this->repository->getAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
}
/** @var Account $account */
foreach ($accounts as $account) {
$currency = $this->repository->getAccountCurrency($account);

View File

@@ -30,7 +30,7 @@ use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
/**
* Class DashboardChartRequest
* Class DashboardChartRequest
*/
class DashboardChartRequest extends FormRequest
{
@@ -47,6 +47,7 @@ class DashboardChartRequest extends FormRequest
{
return [
'accounts' => $this->getAccountList(),
'preselected' => $this->convertString('preselected'),
];
}
@@ -60,6 +61,7 @@ class DashboardChartRequest extends FormRequest
return [
'start' => 'required|date|after:1900-01-01|before:2099-12-31',
'end' => 'required|date|after_or_equal:start|before:2099-12-31|after:1900-01-01',
'preselected' => sprintf('in:%s', join(',', config('firefly.preselected_accounts'))),
'accounts.*' => 'exists:accounts,id',
];
}

View File

@@ -912,4 +912,7 @@ return [
// only used in v1
'allowed_sort_parameters' => ['order', 'name', 'iban'],
// preselected account lists possibilities:
'preselected_accounts' => ['all','assets','liabilities'],
];