Various code cleanup.

This commit is contained in:
James Cole
2020-10-31 08:00:44 +01:00
parent 55c8b9012c
commit c8a87833c6
15 changed files with 28 additions and 110 deletions

View File

@@ -35,14 +35,10 @@ use Throwable;
*/ */
class MonthReportGenerator implements ReportGeneratorInterface class MonthReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection The accounts involved in the report. */ private Collection $accounts;
private $accounts; private Carbon $end;
/** @var Carbon The end date */ private Collection $expense;
private $end; private Carbon $start;
/** @var Collection The expense accounts. */
private $expense;
/** @var Carbon The start date. */
private $start;
/** /**
* Generate the report. * Generate the report.

View File

@@ -41,16 +41,11 @@ use Throwable;
*/ */
class MonthReportGenerator implements ReportGeneratorInterface class MonthReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection The accounts in the report. */ private Collection $accounts;
private $accounts; private Collection $budgets;
/** @var Collection The budgets in the report. */ private Carbon $end;
private $budgets; private array $expenses;
/** @var Carbon The end date. */ private Carbon $start;
private $end;
/** @var array The expenses in the report. */
private $expenses;
/** @var Carbon The start date. */
private $start;
/** /**
* MonthReportGenerator constructor. * MonthReportGenerator constructor.

View File

@@ -244,20 +244,6 @@ class GroupCollector implements GroupCollectorInterface
return $this; return $this;
} }
/**
* Limit the result to a specific transaction group.
*
* @param TransactionGroup $transactionGroup
*
* @return GroupCollectorInterface
*/
public function setGroup(TransactionGroup $transactionGroup): GroupCollectorInterface
{
$this->query->where('transaction_groups.id', $transactionGroup->id);
return $this;
}
/** /**
* Limit the result to a set of specific journals. * Limit the result to a set of specific journals.
* *

View File

@@ -238,15 +238,6 @@ interface GroupCollectorInterface
*/ */
public function setDestinationAccounts(Collection $accounts): GroupCollectorInterface; public function setDestinationAccounts(Collection $accounts): GroupCollectorInterface;
/**
* Limit the result to a specific transaction group.
*
* @param TransactionGroup $transactionGroup
*
* @return GroupCollectorInterface
*/
public function setGroup(TransactionGroup $transactionGroup): GroupCollectorInterface;
/** /**
* Limit the result to a set of specific transaction journals. * Limit the result to a set of specific transaction journals.
* *

View File

@@ -111,7 +111,7 @@ class AvailableBudgetController extends Controller
*/ */
public function createAlternative(Request $request, Carbon $start, Carbon $end) public function createAlternative(Request $request, Carbon $start, Carbon $end)
{ {
$currencies = $this->currencyRepos->getEnabled(); $currencies = $this->currencyRepos->get();
$availableBudgets = $this->abRepository->get($start, $end); $availableBudgets = $this->abRepository->get($start, $end);
// remove already budgeted currencies: // remove already budgeted currencies:

View File

@@ -86,7 +86,7 @@ class BudgetLimitController extends Controller
*/ */
public function create(Budget $budget, Carbon $start, Carbon $end) public function create(Budget $budget, Carbon $start, Carbon $end)
{ {
$collection = $this->currencyRepos->getEnabled(); $collection = $this->currencyRepos->get();
$budgetLimits = $this->blRepository->getBudgetLimits($budget, $start, $end); $budgetLimits = $this->blRepository->getBudgetLimits($budget, $start, $end);
// remove already budgeted currencies: // remove already budgeted currencies:

View File

@@ -99,7 +99,7 @@ class IndexController extends Controller
$start = $start ?? session('start', Carbon::now()->startOfMonth()); $start = $start ?? session('start', Carbon::now()->startOfMonth());
$end = $end ?? app('navigation')->endOfPeriod($start, $range); $end = $end ?? app('navigation')->endOfPeriod($start, $range);
$defaultCurrency = app('amount')->getDefaultCurrency(); $defaultCurrency = app('amount')->getDefaultCurrency();
$currencies = $this->currencyRepository->getEnabled(); $currencies = $this->currencyRepository->get();
$budgeted = '0'; $budgeted = '0';
$spent = '0'; $spent = '0';

View File

@@ -55,7 +55,6 @@ class StartFireflySession extends StartSession
&& 'GET' === $request->method() && 'GET' === $request->method()
&& !$request->ajax()) { && !$request->ajax()) {
$session->setPreviousUrl($uri); $session->setPreviousUrl($uri);
return;
} }
} }
} }

View File

@@ -401,14 +401,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface
return $preferred; return $preferred;
} }
/**
* @return Collection
*/
public function getEnabled(): Collection
{
return TransactionCurrency::where('enabled', true)->orderBy('code', 'ASC')->get();
}
/** /**
* Get currency exchange rate. * Get currency exchange rate.
* *

View File

@@ -203,11 +203,6 @@ interface CurrencyRepositoryInterface
*/ */
public function getCurrencyByPreference(Preference $preference): TransactionCurrency; public function getCurrencyByPreference(Preference $preference): TransactionCurrency;
/**
* @return Collection
*/
public function getEnabled(): Collection;
/** /**
* Get currency exchange rate. * Get currency exchange rate.
* *

View File

@@ -72,41 +72,6 @@ class AccountForm
return $grouped; return $grouped;
} }
/**
* Shows a <select> with all active asset accounts.
*
* @param string $name
* @param mixed $value
* @param array $options
*
* @return string
*/
public function activeAssetAccountList(string $name, $value = null, array $options = null): string
{
$types = [AccountType::ASSET, AccountType::DEFAULT];
$grouped = $this->getAccountsGrouped($types);
return $this->select($name, $grouped, $value, $options);
}
/**
* Return a list that includes liabilities.
*
* @param string $name
* @param mixed $value
* @param array $options
*
* @return string
*/
public function activeLongAccountList(string $name, $value = null, array $options = null): string
{
$types = [AccountType::ASSET, AccountType::DEFAULT, AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN,];
$grouped = $this->getAccountsGrouped($types);
return $this->select($name, $grouped, $value, $options);
}
/** /**
* Grouped dropdown list of all accounts that are valid as the destination of a withdrawal. * Grouped dropdown list of all accounts that are valid as the destination of a withdrawal.
* *

24
composer.lock generated
View File

@@ -1182,16 +1182,16 @@
}, },
{ {
"name": "gdbots/query-parser", "name": "gdbots/query-parser",
"version": "v2.0.1", "version": "v2.0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/gdbots/query-parser-php.git", "url": "https://github.com/gdbots/query-parser-php.git",
"reference": "21fffb3dae156792c0ffe5d4c2ba25e7607ac264" "reference": "d35cb9ae613ee8d6a94b5758fb0047668ab1d34c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/gdbots/query-parser-php/zipball/21fffb3dae156792c0ffe5d4c2ba25e7607ac264", "url": "https://api.github.com/repos/gdbots/query-parser-php/zipball/d35cb9ae613ee8d6a94b5758fb0047668ab1d34c",
"reference": "21fffb3dae156792c0ffe5d4c2ba25e7607ac264", "reference": "d35cb9ae613ee8d6a94b5758fb0047668ab1d34c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1215,9 +1215,9 @@
"homepage": "https://github.com/gdbots/query-parser-php", "homepage": "https://github.com/gdbots/query-parser-php",
"support": { "support": {
"issues": "https://github.com/gdbots/query-parser-php/issues", "issues": "https://github.com/gdbots/query-parser-php/issues",
"source": "https://github.com/gdbots/query-parser-php/tree/v2.0.1" "source": "https://github.com/gdbots/query-parser-php/tree/v2.0.2"
}, },
"time": "2020-10-18T02:58:06+00:00" "time": "2020-10-30T23:41:54+00:00"
}, },
{ {
"name": "graham-campbell/result-type", "name": "graham-campbell/result-type",
@@ -7012,16 +7012,16 @@
}, },
{ {
"name": "composer/composer", "name": "composer/composer",
"version": "2.0.3", "version": "2.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/composer/composer.git", "url": "https://github.com/composer/composer.git",
"reference": "f7eebdd092873f5d63929f21183e69ec9f5e83cd" "reference": "4053eab90a7cdf0b81dd93073dc6c18c15d487fd"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/composer/composer/zipball/f7eebdd092873f5d63929f21183e69ec9f5e83cd", "url": "https://api.github.com/repos/composer/composer/zipball/4053eab90a7cdf0b81dd93073dc6c18c15d487fd",
"reference": "f7eebdd092873f5d63929f21183e69ec9f5e83cd", "reference": "4053eab90a7cdf0b81dd93073dc6c18c15d487fd",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -7089,7 +7089,7 @@
"support": { "support": {
"irc": "irc://irc.freenode.org/composer", "irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/composer/issues", "issues": "https://github.com/composer/composer/issues",
"source": "https://github.com/composer/composer/tree/2.0.3" "source": "https://github.com/composer/composer/tree/2.0.4"
}, },
"funding": [ "funding": [
{ {
@@ -7105,7 +7105,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2020-10-28T14:50:56+00:00" "time": "2020-10-30T21:39:11+00:00"
}, },
{ {
"name": "composer/package-versions-deprecated", "name": "composer/package-versions-deprecated",

View File

@@ -194,8 +194,7 @@ return [
], ],
'AccountForm' => [ 'AccountForm' => [
'is_safe' => [ 'is_safe' => [
'activeAssetAccountList', 'activeLongAccountList', 'activeWithdrawalDestinations', 'activeDepositDestinations', 'activeWithdrawalDestinations', 'activeDepositDestinations', 'assetAccountCheckList', 'assetAccountList', 'longAccountList',
'assetAccountCheckList', 'assetAccountList', 'longAccountList',
], ],
], ],
'CurrencyForm' => [ 'CurrencyForm' => [

View File

@@ -18,7 +18,7 @@
<div class="box-body"> <div class="box-body">
{{ ExpandedForm.text('name') }} {{ ExpandedForm.text('name') }}
{{ AccountForm.activeAssetAccountList('account_id', null, {label: 'saveOnAccount'|_ }) }} {{ AccountForm.assetAccountList('account_id', null, {label: 'saveOnAccount'|_ }) }}
{{ ExpandedForm.amountNoCurrency('targetamount') }} {{ ExpandedForm.amountNoCurrency('targetamount') }}
</div> </div>

View File

@@ -90,13 +90,13 @@
{{ ExpandedForm.amountNoCurrency('amount') }} {{ ExpandedForm.amountNoCurrency('amount') }}
{# source account if withdrawal, or if transfer: #} {# source account if withdrawal, or if transfer: #}
{{ AccountForm.activeLongAccountList('source_id', null, {label: trans('form.asset_source_account')}) }} {{ AccountForm.longAccountList('source_id', null, {label: trans('form.asset_source_account')}) }}
{# for deposits, a drop down with revenue accounts, loan debt cash and mortgage #} {# for deposits, a drop down with revenue accounts, loan debt cash and mortgage #}
{{ AccountForm.activeDepositDestinations('deposit_source_id', null, {label: trans('form.deposit_source_id')}) }} {{ AccountForm.activeDepositDestinations('deposit_source_id', null, {label: trans('form.deposit_source_id')}) }}
{# destination if deposit or transfer: #} {# destination if deposit or transfer: #}
{{ AccountForm.activeLongAccountList('destination_id', null, {label: trans('form.asset_destination_account')} ) }} {{ AccountForm.longAccountList('destination_id', null, {label: trans('form.asset_destination_account')} ) }}
{# destination account name for withdrawals #} {# destination account name for withdrawals #}
{#{{ ExpandedForm.text('destination_name', null, {label: trans('form.expense_account')}) }} #} {#{{ ExpandedForm.text('destination_name', null, {label: trans('form.expense_account')}) }} #}