mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-20 11:48:27 -06:00
Do some code cleanup.
This commit is contained in:
parent
f63e51fea2
commit
6967bb003e
@ -227,10 +227,8 @@ class AccountController extends Controller
|
||||
if (null !== $limit && $limit > 0) {
|
||||
$pageSize = $limit;
|
||||
}
|
||||
|
||||
$types = $this->mapTransactionTypes($this->parameters->get('type'));
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var User $admin */
|
||||
$admin = auth()->user();
|
||||
|
||||
@ -240,7 +238,6 @@ class AccountController extends Controller
|
||||
$collector->setUser($admin)->setAccounts(new Collection([$account]))
|
||||
->withAPIInformation()->setLimit($pageSize)->setPage($this->parameters->get('page'))->setTypes($types);
|
||||
|
||||
// set range if necessary:
|
||||
if (null !== $this->parameters->get('start') && null !== $this->parameters->get('end')) {
|
||||
$collector->setRange($this->parameters->get('start'), $this->parameters->get('end'));
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ class ConfigurationController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
/** @noinspection UnusedConstructorDependenciesInspection */
|
||||
$this->repository = app(UserRepositoryInterface::class);
|
||||
/** @var User $admin */
|
||||
$admin = auth()->user();
|
||||
@ -109,13 +108,12 @@ class ConfigurationController extends Controller
|
||||
$lastCheck = app('fireflyconfig')->get('last_update_check');
|
||||
/** @var Configuration $singleUser */
|
||||
$singleUser = app('fireflyconfig')->get('single_user_mode');
|
||||
$data = [
|
||||
|
||||
return [
|
||||
'is_demo_site' => null === $isDemoSite ? null : $isDemoSite->data,
|
||||
'permission_update_check' => null === $updateCheck ? null : (int)$updateCheck->data,
|
||||
'last_update_check' => null === $lastCheck ? null : (int)$lastCheck->data,
|
||||
'single_user_mode' => null === $singleUser ? null : $singleUser->data,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Search;
|
||||
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||
use FireflyIII\Support\Search\AccountSearch;
|
||||
@ -98,5 +97,4 @@ class AccountController extends Controller
|
||||
|
||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Search;
|
||||
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
/**
|
||||
* Class TransactionController
|
||||
@ -60,9 +57,8 @@ class TransactionController extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function search(Request $request)
|
||||
public function search(Request $request): void
|
||||
{
|
||||
die('the route is present but nobody\'s home.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,16 +22,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Search;
|
||||
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Search\TransferRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Support\Search\TransferSearch;
|
||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use League\Fractal\Resource\Collection as FractalCollection;
|
||||
@ -113,4 +110,4 @@ class TransferController extends Controller
|
||||
|
||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Api\V1\Requests\DateRequest;
|
||||
@ -124,7 +123,6 @@ class SummaryController extends Controller
|
||||
}
|
||||
|
||||
return response()->json($return);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,25 +149,6 @@ class SummaryController extends Controller
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will scroll through the results of the spentInPeriodMc() array and return the correct info.
|
||||
*
|
||||
* @param array $spentInfo
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function findInSpentArray(array $spentInfo, TransactionCurrency $currency): string
|
||||
{
|
||||
foreach ($spentInfo as $array) {
|
||||
if ($array['currency_id'] === $currency->id) {
|
||||
return (string)$array['amount'];
|
||||
}
|
||||
}
|
||||
|
||||
return '0'; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
@ -197,7 +176,6 @@ class SummaryController extends Controller
|
||||
$set = $collector->getExtractedJournals();
|
||||
/** @var array $transactionJournal */
|
||||
foreach ($set as $transactionJournal) {
|
||||
|
||||
$currencyId = (int)$transactionJournal['currency_id'];
|
||||
$incomes[$currencyId] = $incomes[$currencyId] ?? '0';
|
||||
$incomes[$currencyId] = bcadd($incomes[$currencyId], bcmul($transactionJournal['amount'], '-1'));
|
||||
@ -373,12 +351,15 @@ class SummaryController extends Controller
|
||||
'value_parsed' => app('amount')->formatFlat($row['currency_symbol'], $row['currency_decimal_places'], $leftToSpend, false),
|
||||
'local_icon' => 'money',
|
||||
'sub_title' => (string)trans(
|
||||
'firefly.box_spend_per_day', ['amount' => app('amount')->formatFlat(
|
||||
$row['currency_symbol'], $row['currency_decimal_places'], $perDay, false
|
||||
)]
|
||||
'firefly.box_spend_per_day',
|
||||
['amount' => app('amount')->formatFlat(
|
||||
$row['currency_symbol'],
|
||||
$row['currency_decimal_places'],
|
||||
$perDay,
|
||||
false
|
||||
)]
|
||||
),
|
||||
];
|
||||
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
@ -442,5 +423,4 @@ class SummaryController extends Controller
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -110,7 +110,6 @@ class TransactionController extends Controller
|
||||
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
||||
|
||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -215,7 +214,6 @@ class TransactionController extends Controller
|
||||
$resource = new FractalCollection($events, $transformer, 'piggy_bank_events');
|
||||
|
||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -296,7 +294,7 @@ class TransactionController extends Controller
|
||||
];
|
||||
|
||||
return response()->json($response, 422);
|
||||
} catch(FireflyException $e) {
|
||||
} catch (FireflyException $e) {
|
||||
Log::warning('Caught an exception. Return error message.');
|
||||
Log::error($e->getMessage());
|
||||
// return bad validation message.
|
||||
@ -304,7 +302,7 @@ class TransactionController extends Controller
|
||||
$response = [
|
||||
'message' => 'The given data was invalid.',
|
||||
'errors' => [
|
||||
'transactions.0.description' => [sprintf('Internal exception: %s',$e->getMessage())],
|
||||
'transactions.0.description' => [sprintf('Internal exception: %s', $e->getMessage())]
|
||||
],
|
||||
];
|
||||
|
||||
@ -379,6 +377,5 @@ class TransactionController extends Controller
|
||||
$resource = new Item($selectedGroup, $transformer, 'transactions');
|
||||
|
||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -64,15 +64,13 @@ class AvailableBudgetRequest extends Request
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
return [
|
||||
'currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||
'currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
|
||||
'amount' => 'required|numeric|more:0',
|
||||
'start' => 'required|date|before:end',
|
||||
'end' => 'required|date|after:start',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ class BillRequest extends Request
|
||||
$active = $this->boolean('active');
|
||||
}
|
||||
|
||||
$data = [
|
||||
return [
|
||||
'name' => $this->string('name'),
|
||||
'amount_min' => $this->string('amount_min'),
|
||||
'amount_max' => $this->string('amount_max'),
|
||||
@ -72,8 +72,6 @@ class BillRequest extends Request
|
||||
'active' => $active,
|
||||
'notes' => $this->nlString('notes'),
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,8 @@ class RecurrenceStoreRequest extends Request
|
||||
if (null !== $this->get('apply_rules')) {
|
||||
$applyRules = $this->boolean('apply_rules');
|
||||
}
|
||||
$return = [
|
||||
|
||||
return [
|
||||
'recurrence' => [
|
||||
'type' => $this->string('type'),
|
||||
'title' => $this->string('title'),
|
||||
@ -77,8 +78,6 @@ class RecurrenceStoreRequest extends Request
|
||||
'transactions' => $this->getTransactionData(),
|
||||
'repetitions' => $this->getRepetitionData(),
|
||||
];
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,8 @@ class RecurrenceUpdateRequest extends Request
|
||||
if (null !== $this->get('apply_rules')) {
|
||||
$applyRules = $this->boolean('apply_rules');
|
||||
}
|
||||
$return = [
|
||||
|
||||
return [
|
||||
'recurrence' => [
|
||||
'type' => $this->nullableString('type'),
|
||||
'title' => $this->nullableString('title'),
|
||||
@ -78,8 +79,6 @@ class RecurrenceUpdateRequest extends Request
|
||||
'transactions' => $this->getTransactionData(),
|
||||
'repetitions' => $this->getRepetitionData(),
|
||||
];
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,7 +54,7 @@ class RuleGroupTestRequest extends Request
|
||||
*/
|
||||
public function getTestParameters(): array
|
||||
{
|
||||
$return = [
|
||||
return [
|
||||
'page' => $this->getPage(),
|
||||
'start_date' => $this->getDate('start_date'),
|
||||
'end_date' => $this->getDate('end_date'),
|
||||
@ -62,9 +62,6 @@ class RuleGroupTestRequest extends Request
|
||||
'trigger_limit' => $this->getTriggerLimit(),
|
||||
'accounts' => $this->getAccounts(),
|
||||
];
|
||||
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,14 +54,11 @@ class RuleGroupTriggerRequest extends Request
|
||||
*/
|
||||
public function getTriggerParameters(): array
|
||||
{
|
||||
$return = [
|
||||
return [
|
||||
'start_date' => $this->getDate('start_date'),
|
||||
'end_date' => $this->getDate('end_date'),
|
||||
'accounts' => $this->getAccounts(),
|
||||
];
|
||||
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,7 @@ class RuleStoreRequest extends Request
|
||||
$stopProcessing = $this->boolean('stop_processing');
|
||||
}
|
||||
|
||||
$data = [
|
||||
return [
|
||||
'title' => $this->string('title'),
|
||||
'description' => $this->string('description'),
|
||||
'rule_group_id' => $this->integer('rule_group_id'),
|
||||
@ -77,8 +77,6 @@ class RuleStoreRequest extends Request
|
||||
'triggers' => $this->getRuleTriggers(),
|
||||
'actions' => $this->getRuleActions(),
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +92,8 @@ class RuleStoreRequest extends Request
|
||||
// some triggers and actions require text:
|
||||
$contextTriggers = implode(',', config('firefly.context-rule-triggers'));
|
||||
$contextActions = implode(',', config('firefly.context-rule-actions'));
|
||||
$rules = [
|
||||
|
||||
return [
|
||||
'title' => 'required|between:1,100|uniqueObjectForUser:rules,title',
|
||||
'description' => 'between:1,5000|nullable',
|
||||
'rule_group_id' => 'required|belongsToUser:rule_groups|required_without:rule_group_title',
|
||||
@ -112,8 +111,6 @@ class RuleStoreRequest extends Request
|
||||
'stop_processing' => [new IsBoolean],
|
||||
'active' => [new IsBoolean],
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,7 +54,7 @@ class RuleTestRequest extends Request
|
||||
*/
|
||||
public function getTestParameters(): array
|
||||
{
|
||||
$return = [
|
||||
return [
|
||||
'page' => $this->getPage(),
|
||||
'start_date' => $this->getDate('start_date'),
|
||||
'end_date' => $this->getDate('end_date'),
|
||||
@ -62,9 +62,6 @@ class RuleTestRequest extends Request
|
||||
'trigger_limit' => $this->getTriggerLimit(),
|
||||
'accounts' => $this->getAccounts(),
|
||||
];
|
||||
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,14 +53,11 @@ class RuleTriggerRequest extends Request
|
||||
*/
|
||||
public function getTriggerParameters(): array
|
||||
{
|
||||
$return = [
|
||||
return [
|
||||
'start_date' => $this->getDate('start_date'),
|
||||
'end_date' => $this->getDate('end_date'),
|
||||
'accounts' => $this->getAccounts(),
|
||||
];
|
||||
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,7 @@ class RuleUpdateRequest extends Request
|
||||
$stopProcessing = $this->boolean('stop_processing');
|
||||
}
|
||||
|
||||
$data = [
|
||||
return [
|
||||
'title' => $this->nullableString('title'),
|
||||
'description' => $this->nullableString('description'),
|
||||
'rule_group_id' => $this->nullableInteger('rule_group_id'),
|
||||
@ -77,8 +77,6 @@ class RuleUpdateRequest extends Request
|
||||
'triggers' => $this->getRuleTriggers(),
|
||||
'actions' => $this->getRuleActions(),
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +93,8 @@ class RuleUpdateRequest extends Request
|
||||
// some triggers and actions require text:
|
||||
$contextTriggers = implode(',', config('firefly.context-rule-triggers'));
|
||||
$contextActions = implode(',', config('firefly.context-rule-actions'));
|
||||
$rules = [
|
||||
|
||||
return [
|
||||
'title' => sprintf('between:1,100|uniqueObjectForUser:rules,title,%d', $rule->id),
|
||||
'description' => 'between:1,5000|nullable',
|
||||
'rule_group_id' => 'belongsToUser:rule_groups',
|
||||
@ -113,8 +112,6 @@ class RuleUpdateRequest extends Request
|
||||
'stop_processing' => [new IsBoolean],
|
||||
'active' => [new IsBoolean],
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests\Search;
|
||||
|
||||
|
||||
use FireflyIII\Api\V1\Requests\Request;
|
||||
use FireflyIII\Rules\IsTransferAccount;
|
||||
|
||||
@ -55,5 +54,4 @@ class TransferRequest extends Request
|
||||
'date' => 'required|date',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -60,14 +60,13 @@ class TransactionStoreRequest extends Request
|
||||
public function getAll(): array
|
||||
{
|
||||
Log::debug('get all data in TransactionStoreRequest');
|
||||
$data = [
|
||||
|
||||
return [
|
||||
'group_title' => $this->string('group_title'),
|
||||
'error_if_duplicate_hash' => $this->boolean('error_if_duplicate_hash'),
|
||||
'apply_rules' => $this->boolean('apply_rules', true),
|
||||
'transactions' => $this->getTransactionData(),
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,7 +77,8 @@ class TransactionStoreRequest extends Request
|
||||
public function rules(): array
|
||||
{
|
||||
Log::debug('Collect rules of TransactionStoreRequest');
|
||||
$rules = [
|
||||
|
||||
return [
|
||||
// basic fields for group:
|
||||
'group_title' => 'between:1,1000|nullable',
|
||||
'error_if_duplicate_hash' => [new IsBoolean],
|
||||
@ -156,8 +156,6 @@ class TransactionStoreRequest extends Request
|
||||
'transactions.*.invoice_date' => 'date|nullable',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ class TransactionUpdateRequest extends Request
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
return [
|
||||
// basic fields for group:
|
||||
'group_title' => 'between:1,1000',
|
||||
'apply_rules' => [new IsBoolean],
|
||||
@ -222,8 +222,6 @@ class TransactionUpdateRequest extends Request
|
||||
'transactions.*.payment_date' => 'date|nullable',
|
||||
'transactions.*.invoice_date' => 'date|nullable',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,14 +69,13 @@ class UserStoreRequest extends Request
|
||||
if (null !== $this->get('blocked')) {
|
||||
$blocked = $this->boolean('blocked');
|
||||
}
|
||||
$data = [
|
||||
|
||||
return [
|
||||
'email' => $this->string('email'),
|
||||
'blocked' => $blocked,
|
||||
'blocked_code' => $this->string('blocked_code'),
|
||||
'role' => $this->string('role'),
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,14 +69,13 @@ class UserUpdateRequest extends Request
|
||||
if (null !== $this->get('blocked')) {
|
||||
$blocked = $this->boolean('blocked');
|
||||
}
|
||||
$data = [
|
||||
|
||||
return [
|
||||
'email' => $this->string('email'),
|
||||
'blocked' => $blocked,
|
||||
'blocked_code' => $this->string('blocked_code'),
|
||||
'role' => $this->string('role'),
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,14 +86,13 @@ class UserUpdateRequest extends Request
|
||||
public function rules(): array
|
||||
{
|
||||
$user = $this->route()->parameter('user');
|
||||
$rules = [
|
||||
|
||||
return [
|
||||
'email' => sprintf('email|unique:users,email,%d', $user->id),
|
||||
'blocked' => [new IsBoolean],
|
||||
'blocked_code' => 'in:email_changed',
|
||||
'role' => 'in:owner,demo,',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -111,15 +111,12 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
*/
|
||||
private function getAccount(TransactionJournal $journal): ?Account
|
||||
{
|
||||
$excluded = [];
|
||||
$transactions = $journal->transactions()->with(['account', 'account.accountType'])->get();
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$account = $transaction->account;
|
||||
if (null !== $account) {
|
||||
if (AccountType::INITIAL_BALANCE !== $account->accountType->type) {
|
||||
return $account;
|
||||
}
|
||||
if ((null !== $account) && AccountType::INITIAL_BALANCE !== $account->accountType->type) {
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@ namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
@ -59,7 +58,7 @@ class DeleteEmptyGroups extends Command
|
||||
$start = microtime(true);
|
||||
$groupIds =
|
||||
TransactionGroup
|
||||
::leftJoin('transaction_journals','transaction_groups.id','=','transaction_journals.transaction_group_id')
|
||||
::leftJoin('transaction_journals', 'transaction_groups.id', '=', 'transaction_journals.transaction_group_id')
|
||||
->whereNull('transaction_journals.id')->get(['transaction_groups.id'])->pluck('id')->toArray();
|
||||
|
||||
$total = count($groupIds);
|
||||
|
@ -91,8 +91,11 @@ class DeleteOrphanedTransactions extends Command
|
||||
}
|
||||
Transaction::where('transaction_journal_id', (int)$transaction->transaction_journal_id)->delete();
|
||||
$this->line(
|
||||
sprintf('Deleted transaction journal #%d because account #%d was already deleted.',
|
||||
$transaction->transaction_journal_id, $transaction->account_id)
|
||||
sprintf(
|
||||
'Deleted transaction journal #%d because account #%d was already deleted.',
|
||||
$transaction->transaction_journal_id,
|
||||
$transaction->account_id
|
||||
)
|
||||
);
|
||||
$count++;
|
||||
}
|
||||
@ -134,6 +137,5 @@ class DeleteOrphanedTransactions extends Command
|
||||
if (0 === $count) {
|
||||
$this->info('No orphaned transactions.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -167,9 +167,12 @@ class FixAccountTypes extends Command
|
||||
$dest->save();
|
||||
$this->info(
|
||||
sprintf(
|
||||
'Transaction journal #%d, destination account changed from #%d ("%s") to #%d ("%s").', $journal->id,
|
||||
$oldDest->id, $oldDest->name,
|
||||
$result->id, $result->name
|
||||
'Transaction journal #%d, destination account changed from #%d ("%s") to #%d ("%s").',
|
||||
$journal->id,
|
||||
$oldDest->id,
|
||||
$oldDest->name,
|
||||
$result->id,
|
||||
$result->name
|
||||
)
|
||||
);
|
||||
$this->inspectJournal($journal);
|
||||
@ -184,9 +187,12 @@ class FixAccountTypes extends Command
|
||||
$source->save();
|
||||
$this->info(
|
||||
sprintf(
|
||||
'Transaction journal #%d, source account changed from #%d ("%s") to #%d ("%s").', $journal->id,
|
||||
$oldSource->id, $oldSource->name,
|
||||
$result->id, $result->name
|
||||
'Transaction journal #%d, source account changed from #%d ("%s") to #%d ("%s").',
|
||||
$journal->id,
|
||||
$oldSource->id,
|
||||
$oldSource->name,
|
||||
$result->id,
|
||||
$result->name
|
||||
)
|
||||
);
|
||||
$this->inspectJournal($journal);
|
||||
@ -198,7 +204,6 @@ class FixAccountTypes extends Command
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -273,5 +278,4 @@ class FixAccountTypes extends Command
|
||||
$this->fixJournal($journal, $type, $sourceTransaction, $destTransaction);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -51,16 +51,6 @@ class FixRecurringTransactions extends Command
|
||||
/** @var UserRepositoryInterface */
|
||||
private $userRepos;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
@ -94,7 +94,8 @@ class FixUnevenAmount extends Command
|
||||
if (null === $source) {
|
||||
$this->error(
|
||||
sprintf(
|
||||
'Journal #%d ("%s") has no source transaction. It will be deleted to maintain database consistency.', $journal->id ?? 0,
|
||||
'Journal #%d ("%s") has no source transaction. It will be deleted to maintain database consistency.',
|
||||
$journal->id ?? 0,
|
||||
$journal->description ?? ''
|
||||
)
|
||||
);
|
||||
@ -113,7 +114,8 @@ class FixUnevenAmount extends Command
|
||||
if (null === $destination) {
|
||||
$this->error(
|
||||
sprintf(
|
||||
'Journal #%d ("%s") has no destination transaction. It will be deleted to maintain database consistency.', $journal->id ?? 0,
|
||||
'Journal #%d ("%s") has no destination transaction. It will be deleted to maintain database consistency.',
|
||||
$journal->id ?? 0,
|
||||
$journal->description ?? ''
|
||||
)
|
||||
);
|
||||
|
@ -92,7 +92,7 @@ class DecryptDatabase extends Command
|
||||
// A separate routine for preferences:
|
||||
if ('preferences' === $table) {
|
||||
// try to json_decrypt the value.
|
||||
$value = json_decode($value, true) ?? $value;
|
||||
$value = json_decode($value, true, 512, JSON_THROW_ON_ERROR) ?? $value;
|
||||
Log::debug(sprintf('Decrypted field "%s" "%s" to "%s" in table "%s" (row #%d)', $field, $original, print_r($value, true), $table, $id));
|
||||
|
||||
/** @var Preference $object */
|
||||
|
@ -76,21 +76,12 @@ class ExportData extends Command
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
* @throws FireflyException
|
||||
* @throws \League\Csv\CannotInsertRecord
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
@ -206,6 +197,7 @@ class ExportData extends Command
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws FireflyException
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function getDateParameter(string $field): Carbon
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ class CreateCSVImport extends Command
|
||||
|
||||
$this->importRepository->setUser($user);
|
||||
|
||||
$configurationData = json_decode(file_get_contents($configuration), true);
|
||||
$configurationData = json_decode(file_get_contents($configuration), true, 512, JSON_THROW_ON_ERROR);
|
||||
$this->importJob = $this->importRepository->create('file');
|
||||
|
||||
|
||||
@ -214,7 +214,7 @@ class CreateCSVImport extends Command
|
||||
return false;
|
||||
}
|
||||
|
||||
$configurationData = json_decode(file_get_contents($configuration), true);
|
||||
$configurationData = json_decode(file_get_contents($configuration), true, 512, JSON_THROW_ON_ERROR);
|
||||
if (null === $configurationData) {
|
||||
$this->errorLine(sprintf('Firefly III cannot read the contents of configuration file "%s" (working directory: "%s").', $configuration, $cwd));
|
||||
|
||||
|
@ -21,8 +21,6 @@
|
||||
|
||||
namespace FireflyIII\Console\Commands\Integrity;
|
||||
|
||||
use Artisan;
|
||||
use Crypt;
|
||||
use FireflyIII\Support\System\OAuthKeys;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@ -122,4 +120,4 @@ class RestoreOAuthKeys extends Command
|
||||
{
|
||||
OAuthKeys::storeKeysInDB();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,6 @@ class ScanAttachments extends Command
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($attachments as $attachment) {
|
||||
$fileName = $attachment->fileName();
|
||||
$decryptedContent = '';
|
||||
try {
|
||||
$encryptedContent = $disk->get($fileName);
|
||||
} catch (FileNotFoundException $e) {
|
||||
|
@ -43,16 +43,6 @@ class SetLatestVersion extends Command
|
||||
*/
|
||||
protected $signature = 'firefly-iii:set-latest-version {--james-is-cool}';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
@ -100,9 +100,11 @@ class Cron extends Command
|
||||
/**
|
||||
* @param bool $force
|
||||
* @param Carbon|null $date
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @throws Exception
|
||||
*/
|
||||
private function autoBudgetCronJob(bool $force, ?Carbon $date)
|
||||
private function autoBudgetCronJob(bool $force, ?Carbon $date): void
|
||||
{
|
||||
$autoBudget = new AutoBudgetCronjob;
|
||||
$autoBudget->setForce($force);
|
||||
|
@ -178,7 +178,8 @@ class AccountCurrencies extends Command
|
||||
static function (Transaction $transaction) use ($accountCurrency) {
|
||||
$transaction->transaction_currency_id = $accountCurrency;
|
||||
$transaction->save();
|
||||
});
|
||||
}
|
||||
);
|
||||
$this->line(sprintf('Account #%d ("%s") now has a correct currency for opening balance.', $account->id, $account->name));
|
||||
$this->count++;
|
||||
|
||||
|
@ -115,7 +115,7 @@ class MigrateRecurrenceMeta extends Command
|
||||
|
||||
if ('tags' === $meta->name) {
|
||||
$array = explode(',', $meta->value);
|
||||
$value = json_encode($array);
|
||||
$value = json_encode($array, JSON_THROW_ON_ERROR, 512);
|
||||
}
|
||||
|
||||
RecurrenceTransactionMeta::create(
|
||||
|
@ -302,7 +302,8 @@ class MigrateToGroups extends Command
|
||||
$this->error(
|
||||
sprintf(
|
||||
'Journal #%d has no opposing transaction for transaction #%d. Cannot upgrade this entry.',
|
||||
$journal->id, $transaction->id
|
||||
$journal->id,
|
||||
$transaction->id
|
||||
)
|
||||
);
|
||||
continue;
|
||||
@ -365,12 +366,20 @@ class MigrateToGroups extends Command
|
||||
|
||||
// report on result:
|
||||
Log::debug(
|
||||
sprintf('Migrated journal #%d into group #%d with these journals: #%s',
|
||||
$journal->id, $group->id, implode(', #', $group->transactionJournals->pluck('id')->toArray()))
|
||||
sprintf(
|
||||
'Migrated journal #%d into group #%d with these journals: #%s',
|
||||
$journal->id,
|
||||
$group->id,
|
||||
implode(', #', $group->transactionJournals->pluck('id')->toArray())
|
||||
)
|
||||
);
|
||||
$this->line(
|
||||
sprintf('Migrated journal #%d into group #%d with these journals: #%s',
|
||||
$journal->id, $group->id, implode(', #', $group->transactionJournals->pluck('id')->toArray()))
|
||||
sprintf(
|
||||
'Migrated journal #%d into group #%d with these journals: #%s',
|
||||
$journal->id,
|
||||
$group->id,
|
||||
implode(', #', $group->transactionJournals->pluck('id')->toArray())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -447,5 +456,4 @@ class MigrateToGroups extends Command
|
||||
{
|
||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -177,9 +177,9 @@ class MigrateToRules extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
* @param Bill $bill
|
||||
* @throws FireflyException
|
||||
* @param RuleGroup $ruleGroup
|
||||
* @param Bill $bill
|
||||
* @param Preference $language
|
||||
*/
|
||||
private function migrateBill(RuleGroup $ruleGroup, Bill $bill, Preference $language): void
|
||||
{
|
||||
|
@ -40,7 +40,6 @@ use Illuminate\Console\Command;
|
||||
*/
|
||||
class OtherCurrenciesCorrections extends Command
|
||||
{
|
||||
|
||||
public const CONFIG_NAME = '480_other_currencies';
|
||||
/**
|
||||
* The console command description.
|
||||
@ -136,8 +135,6 @@ class OtherCurrenciesCorrections extends Command
|
||||
$this->accountCurrencies[$accountId] = $currency;
|
||||
|
||||
return $currency;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,8 +183,12 @@ class OtherCurrenciesCorrections extends Command
|
||||
$currency = $this->getCurrency($account);
|
||||
if (null === $currency) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$this->error(sprintf('Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected',
|
||||
$account->id, $account->name, $journal->id));
|
||||
$this->error(sprintf(
|
||||
'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected',
|
||||
$account->id,
|
||||
$account->name,
|
||||
$journal->id
|
||||
));
|
||||
$this->count++;
|
||||
|
||||
return;
|
||||
|
@ -76,7 +76,7 @@ class RenameAccountMeta extends Command
|
||||
$count += AccountMeta::where('name', $old)->update(['name' => $new]);
|
||||
|
||||
// delete empty entries while we're at it.
|
||||
AccountMeta::where('name', $new)->where('data','""')->delete();
|
||||
AccountMeta::where('name', $new)->where('data', '""')->delete();
|
||||
}
|
||||
|
||||
$this->markAsExecuted();
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Upgrade;
|
||||
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
@ -41,7 +40,6 @@ use Log;
|
||||
*/
|
||||
class TransferCurrenciesCorrections extends Command
|
||||
{
|
||||
|
||||
public const CONFIG_NAME = '480_transfer_currencies';
|
||||
/**
|
||||
* The console command description.
|
||||
@ -162,8 +160,6 @@ class TransferCurrenciesCorrections extends Command
|
||||
$this->accountCurrencies[$accountId] = $result;
|
||||
|
||||
return $result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -297,7 +293,6 @@ class TransferCurrenciesCorrections extends Command
|
||||
*/
|
||||
private function updateTransferCurrency(TransactionJournal $transfer): void
|
||||
{
|
||||
|
||||
$this->resetInformation();
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
@ -325,7 +320,8 @@ class TransferCurrenciesCorrections extends Command
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($this->isNoCurrencyPresent()) {
|
||||
$this->error(
|
||||
sprintf('Source or destination accounts for transaction journal #%d have no currency information. Cannot fix this one.', $transfer->id));
|
||||
sprintf('Source or destination accounts for transaction journal #%d have no currency information. Cannot fix this one.', $transfer->id)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -355,7 +351,6 @@ class TransferCurrenciesCorrections extends Command
|
||||
|
||||
// fix journal itself:
|
||||
$this->fixTransactionJournalCurrency($transfer);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -367,8 +362,11 @@ class TransferCurrenciesCorrections extends Command
|
||||
if (null === $this->sourceTransaction->transaction_currency_id && null !== $this->sourceCurrency) {
|
||||
$this->sourceTransaction
|
||||
->transaction_currency_id = (int)$this->sourceCurrency->id;
|
||||
$message = sprintf('Transaction #%d has no currency setting, now set to %s.',
|
||||
$this->sourceTransaction->id, $this->sourceCurrency->code);
|
||||
$message = sprintf(
|
||||
'Transaction #%d has no currency setting, now set to %s.',
|
||||
$this->sourceTransaction->id,
|
||||
$this->sourceCurrency->code
|
||||
);
|
||||
Log::debug($message);
|
||||
$this->line($message);
|
||||
$this->count++;
|
||||
@ -385,8 +383,11 @@ class TransferCurrenciesCorrections extends Command
|
||||
if (null === $this->destinationTransaction->transaction_currency_id && null !== $this->destinationCurrency) {
|
||||
$this->destinationTransaction
|
||||
->transaction_currency_id = (int)$this->destinationCurrency->id;
|
||||
$message = sprintf('Transaction #%d has no currency setting, now set to %s.',
|
||||
$this->destinationTransaction->id, $this->destinationCurrency->code);
|
||||
$message = sprintf(
|
||||
'Transaction #%d has no currency setting, now set to %s.',
|
||||
$this->destinationTransaction->id,
|
||||
$this->destinationCurrency->code
|
||||
);
|
||||
Log::debug($message);
|
||||
$this->line($message);
|
||||
$this->count++;
|
||||
@ -490,9 +491,13 @@ class TransferCurrenciesCorrections extends Command
|
||||
sprintf(
|
||||
'Currency for account "%s" is %s, and currency for account "%s" is also
|
||||
%s, so transactions #%d and #%d has been verified to be to %s exclusively.',
|
||||
$this->destinationAccount->name, $this->destinationCurrency->code,
|
||||
$this->sourceAccount->name, $this->sourceCurrency->code,
|
||||
$this->sourceTransaction->id, $this->destinationTransaction->id, $this->sourceCurrency->code
|
||||
$this->destinationAccount->name,
|
||||
$this->destinationCurrency->code,
|
||||
$this->sourceAccount->name,
|
||||
$this->sourceCurrency->code,
|
||||
$this->sourceTransaction->id,
|
||||
$this->destinationTransaction->id,
|
||||
$this->sourceCurrency->code
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -528,8 +533,11 @@ class TransferCurrenciesCorrections extends Command
|
||||
$this->sourceTransaction->foreign_amount = bcmul((string)$this->destinationTransaction->foreign_amount, '-1');
|
||||
$this->sourceTransaction->save();
|
||||
$this->count++;
|
||||
Log::debug(sprintf('Restored foreign amount of source transaction #%d to %s',
|
||||
$this->sourceTransaction->id, $this->sourceTransaction->foreign_amount));
|
||||
Log::debug(sprintf(
|
||||
'Restored foreign amount of source transaction #%d to %s',
|
||||
$this->sourceTransaction->id,
|
||||
$this->sourceTransaction->foreign_amount
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -543,8 +551,11 @@ class TransferCurrenciesCorrections extends Command
|
||||
$this->destinationTransaction->foreign_amount = bcmul((string)$this->sourceTransaction->foreign_amount, '-1');
|
||||
$this->destinationTransaction->save();
|
||||
$this->count++;
|
||||
Log::debug(sprintf('Restored foreign amount of destination transaction #%d to %s',
|
||||
$this->destinationTransaction->id, $this->destinationTransaction->foreign_amount));
|
||||
Log::debug(sprintf(
|
||||
'Restored foreign amount of destination transaction #%d to %s',
|
||||
$this->destinationTransaction->id,
|
||||
$this->destinationTransaction->foreign_amount
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -565,8 +576,11 @@ class TransferCurrenciesCorrections extends Command
|
||||
|
||||
// destination account must have a currency preference.
|
||||
if (null === $this->destinationCurrency) {
|
||||
$message = sprintf('Account #%d ("%s") must have currency preference but has none.',
|
||||
$this->destinationAccount->id, $this->destinationAccount->name);
|
||||
$message = sprintf(
|
||||
'Account #%d ("%s") must have currency preference but has none.',
|
||||
$this->destinationAccount->id,
|
||||
$this->destinationAccount->name
|
||||
);
|
||||
Log::error($message);
|
||||
$this->error($message);
|
||||
|
||||
@ -575,5 +589,4 @@ class TransferCurrenciesCorrections extends Command
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Repositories\TransactionGroup;
|
||||
|
||||
use FireflyIII\Exceptions\DuplicateTransactionException;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Support\NullArrayObject;
|
||||
use FireflyIII\User;
|
||||
@ -135,6 +136,7 @@ interface TransactionGroupRepositoryInterface
|
||||
*
|
||||
* @return TransactionGroup
|
||||
* @throws DuplicateTransactionException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function store(array $data): TransactionGroup;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user