mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-04 03:43:07 +00:00
Clean up some code.
This commit is contained in:
@@ -71,6 +71,7 @@ class DeleteEmptyJournals extends Command
|
||||
->groupBy('transactions.transaction_journal_id')
|
||||
->get([DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']);
|
||||
$total = 0;
|
||||
/** @var Transaction $row */
|
||||
foreach ($set as $row) {
|
||||
$count = (int)$row->the_count;
|
||||
if (1 === $count % 2) {
|
||||
|
@@ -60,6 +60,7 @@ class FixGroupAccounts extends Command
|
||||
$res = TransactionJournal
|
||||
::groupBy('transaction_group_id')
|
||||
->get(['transaction_group_id', DB::raw('COUNT(transaction_group_id) as the_count')]);
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($res as $journal) {
|
||||
if ((int)$journal->the_count > 1) {
|
||||
$groups[] = (int)$journal->transaction_group_id;
|
||||
|
@@ -177,7 +177,7 @@ class DecryptDatabase extends Command
|
||||
/**
|
||||
* Tries to decrypt data. Will only throw an exception when the MAC is invalid.
|
||||
*
|
||||
* @param $value
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
|
@@ -28,6 +28,7 @@ use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Console\Commands\VerifiesAccessToken;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
@@ -241,7 +242,7 @@ class ExportData extends Command
|
||||
$accounts = $this->accountRepository->getAccountsByType($types);
|
||||
}
|
||||
// filter accounts,
|
||||
/** @var AccountType $account */
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
if (in_array($account->accountType->type, $types, true)) {
|
||||
$final->push($account);
|
||||
|
@@ -144,8 +144,7 @@ class BackToJournals extends Command
|
||||
$chunks = array_chunk($transactions, 500);
|
||||
|
||||
foreach ($chunks as $chunk) {
|
||||
$set = DB::table('transactions')->whereIn('transactions.id', $chunk)
|
||||
->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
|
||||
$set = DB::table('transactions')->whereIn('transactions.id', $chunk)->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
|
||||
$array = array_merge($array, $set);
|
||||
}
|
||||
|
||||
|
@@ -414,7 +414,7 @@ class MigrateToGroups extends Command
|
||||
if ($total > 0) {
|
||||
Log::debug(sprintf('Going to convert %d transaction journals. Please hold..', $total));
|
||||
$this->line(sprintf('Going to convert %d transaction journals. Please hold..', $total));
|
||||
/** @var array $journal */
|
||||
/** @var array $array */
|
||||
foreach ($orphanedJournals as $array) {
|
||||
$this->giveGroup($array);
|
||||
}
|
||||
|
@@ -48,38 +48,38 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Exception $exception
|
||||
* @param Throwable $e
|
||||
*
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function render($request, Throwable $exception)
|
||||
public function render($request, Throwable $e)
|
||||
{
|
||||
$route = $request->route();
|
||||
if (null === $route) {
|
||||
return parent::render($request, $exception);
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
$name = $route->getName();
|
||||
if (!auth()->check()) {
|
||||
return parent::render($request, $exception);
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
|
||||
switch ($name) {
|
||||
default:
|
||||
Log::warning(sprintf('GracefulNotFoundHandler cannot handle route with name "%s"', $name));
|
||||
|
||||
return parent::render($request, $exception);
|
||||
return parent::render($request, $e);
|
||||
case 'accounts.show':
|
||||
case 'accounts.show.all':
|
||||
return $this->handleAccount($request, $exception);
|
||||
return $this->handleAccount($request, $e);
|
||||
case 'transactions.show':
|
||||
return $this->handleGroup($request, $exception);
|
||||
return $this->handleGroup($request, $e);
|
||||
case 'attachments.show':
|
||||
case 'attachments.edit':
|
||||
case 'attachments.download':
|
||||
case 'attachments.view':
|
||||
// redirect to original attachment holder.
|
||||
return $this->handleAttachment($request, $exception);
|
||||
return $this->handleAttachment($request, $e);
|
||||
break;
|
||||
case 'bills.show':
|
||||
$request->session()->reflash();
|
||||
@@ -131,7 +131,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
return redirect(route('index'));
|
||||
}
|
||||
|
||||
return parent::render($request, $exception);
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -141,7 +141,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
* @param Throwable $exception
|
||||
*
|
||||
* @return Redirector|Response
|
||||
* @throws Exception
|
||||
* @throws Throwable
|
||||
*/
|
||||
private function handleAccount(Request $request, Throwable $exception)
|
||||
{
|
||||
@@ -165,11 +165,11 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Throwable $request
|
||||
* @param Exception $exception
|
||||
* @param Request $request
|
||||
* @param Throwable $exception
|
||||
*
|
||||
* @return RedirectResponse|\Illuminate\Http\Response|Redirector|Response
|
||||
* @throws Exception
|
||||
* @throws Throwable
|
||||
*/
|
||||
private function handleGroup(Request $request, Throwable $exception)
|
||||
{
|
||||
@@ -209,7 +209,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
* @param Throwable $exception
|
||||
*
|
||||
* @return RedirectResponse|Redirector|Response
|
||||
* @throws Exception
|
||||
* @throws Throwable
|
||||
*/
|
||||
private function handleAttachment(Request $request, Throwable $exception)
|
||||
{
|
||||
|
@@ -46,7 +46,7 @@ class TransactionCurrencyFactory
|
||||
public function create(array $data): TransactionCurrency
|
||||
{
|
||||
try {
|
||||
/** @var TransactionCurrency $currency */
|
||||
/** @var TransactionCurrency $result */
|
||||
$result = TransactionCurrency::create(
|
||||
[
|
||||
'name' => $data['name'],
|
||||
|
@@ -549,8 +549,6 @@ interface GroupCollectorInterface
|
||||
public function withoutCategory(): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withoutNotes(): GroupCollectorInterface;
|
||||
|
@@ -91,7 +91,7 @@ class ReportHelper implements ReportHelperInterface
|
||||
'paid_moments' => [],
|
||||
];
|
||||
|
||||
/** @var Carbon $start */
|
||||
/** @var Carbon $expectedStart */
|
||||
foreach ($expectedDates as $expectedStart) {
|
||||
$expectedEnd = app('navigation')->endOfX($expectedStart, $bill->repeat_freq, null);
|
||||
|
||||
|
@@ -82,7 +82,7 @@ class PiggyBankController extends Controller
|
||||
// get first event or start date of piggy bank or today
|
||||
$startDate = $piggyBank->startdate ?? today(config('app.timezone'));
|
||||
|
||||
/** @var PiggyBankEvent $first */
|
||||
/** @var PiggyBankEvent $firstEvent */
|
||||
$firstEvent = $set->first();
|
||||
$firstDate = null === $firstEvent ? new Carbon : $firstEvent->date;
|
||||
|
||||
|
@@ -74,6 +74,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|Budget withTrashed()
|
||||
* @method static Builder|Budget withoutTrashed()
|
||||
* @mixin Eloquent
|
||||
* @property string $email
|
||||
*/
|
||||
class Budget extends Model
|
||||
{
|
||||
|
@@ -83,6 +83,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction withoutTrashed()
|
||||
* @mixin Eloquent
|
||||
* @property int $the_count
|
||||
*/
|
||||
class Transaction extends Model
|
||||
{
|
||||
|
@@ -114,6 +114,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @mixin Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Location[] $locations
|
||||
* @property-read int|null $locations_count
|
||||
* @property int $the_count
|
||||
*/
|
||||
class TransactionJournal extends Model
|
||||
{
|
||||
|
Reference in New Issue
Block a user