Code cleanup.

This commit is contained in:
James Cole
2021-03-28 11:46:23 +02:00
parent 2c575f3ca5
commit b5eeacc128
124 changed files with 1568 additions and 1384 deletions

View File

@@ -50,6 +50,7 @@ use Log;
class ReconcileController extends Controller
{
use UserNavigation;
/** @var AccountRepositoryInterface The account repository */
private $accountRepos;
/** @var CurrencyRepositoryInterface The currency repository */
@@ -70,7 +71,7 @@ class ReconcileController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-credit-card');
app('view')->share('title', (string) trans('firefly.accounts'));
app('view')->share('title', (string)trans('firefly.accounts'));
$this->repository = app(JournalRepositoryInterface::class);
$this->accountRepos = app(AccountRepositoryInterface::class);
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
@@ -87,8 +88,8 @@ class ReconcileController extends Controller
* @param Carbon|null $start
* @param Carbon|null $end
*
* @throws Exception
* @return Factory|RedirectResponse|Redirector|View
* @throws Exception
*/
public function reconcile(Account $account, Carbon $start = null, Carbon $end = null)
{
@@ -97,7 +98,7 @@ class ReconcileController extends Controller
}
if (AccountType::ASSET !== $account->accountType->type) {
// @codeCoverageIgnoreStart
session()->flash('error', (string) trans('firefly.must_be_asset_account'));
session()->flash('error', (string)trans('firefly.must_be_asset_account'));
return redirect(route('accounts.index', [config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type))]));
// @codeCoverageIgnoreEnd
@@ -127,10 +128,10 @@ class ReconcileController extends Controller
$startDate = clone $start;
$startDate->subDay();
$startBalance = number_format((float) app('steam')->balance($account, $startDate), $currency->decimal_places, '.', '');
$endBalance = number_format((float) app('steam')->balance($account, $end), $currency->decimal_places, '.', '');
$startBalance = number_format((float)app('steam')->balance($account, $startDate), $currency->decimal_places, '.', '');
$endBalance = number_format((float)app('steam')->balance($account, $end), $currency->decimal_places, '.', '');
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));
$subTitle = (string) trans('firefly.reconcile_account', ['account' => $account->name]);
$subTitle = (string)trans('firefly.reconcile_account', ['account' => $account->name]);
// various links
$transactionsUri = route('accounts.reconcile.transactions', [$account->id, '%start%', '%end%']);
@@ -178,7 +179,7 @@ class ReconcileController extends Controller
/** @var string $journalId */
foreach ($data['journals'] as $journalId) {
$this->repository->reconcileById((int) $journalId);
$this->repository->reconcileById((int)$journalId);
}
Log::debug('Reconciled all transactions.');
@@ -195,10 +196,10 @@ class ReconcileController extends Controller
Log::debug('End of routine.');
app('preferences')->mark();
if ('' === $result) {
session()->flash('success', (string) trans('firefly.reconciliation_stored'));
session()->flash('success', (string)trans('firefly.reconciliation_stored'));
}
if ('' !== $result) {
session()->flash('error', (string) trans('firefly.reconciliation_error', ['error' => $result]));
session()->flash('error', (string)trans('firefly.reconciliation_error', ['error' => $result]));
}
return redirect(route('accounts.show', [$account->id]));
@@ -212,9 +213,9 @@ class ReconcileController extends Controller
* @param Carbon $end
* @param string $difference
*
* @return RedirectResponse|Redirector|string
* @throws DuplicateTransactionException
*
* @return RedirectResponse|Redirector|string
*/
private function createReconciliation(Account $account, Carbon $start, Carbon $end, string $difference)
{