mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup and documentation improvements.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CreateExport.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -20,6 +19,8 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @noinspection MultipleReturnStatementsInspection */
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CreateImport.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -20,6 +19,8 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @noinspection MultipleReturnStatementsInspection */
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* DecryptAttachment.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -20,6 +19,8 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @noinspection MultipleReturnStatementsInspection */
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* EncryptFile.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php /** @noinspection PhpDynamicAsStaticMethodCallInspection */
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Import.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -20,6 +19,9 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @noinspection MultipleReturnStatementsInspection */
|
||||
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@@ -52,6 +54,8 @@ class Import extends Command
|
||||
|
||||
/**
|
||||
* Run the import routine.
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
@@ -102,10 +106,11 @@ class Import extends Command
|
||||
}
|
||||
|
||||
$this->infoLine(sprintf('The import has finished. %d transactions have been imported.', $count));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an error.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array|null $data
|
||||
*/
|
||||
@@ -117,6 +122,8 @@ class Import extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an informational message.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $data
|
||||
*/
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php /** @noinspection PhpDynamicAsStaticMethodCallInspection */
|
||||
|
||||
<?php
|
||||
/**
|
||||
* ScanAttachments.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -20,6 +19,8 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@@ -63,13 +64,13 @@ class ScanAttachments extends Command
|
||||
try {
|
||||
$content = $disk->get($fileName);
|
||||
} catch (FileNotFoundException $e) {
|
||||
$this->error(sprintf('Could not find data for attachment #%d', $attachment->id));
|
||||
$this->error(sprintf('Could not find data for attachment #%d: %s', $attachment->id, $e->getMessage()));
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$decrypted = Crypt::decrypt($content);
|
||||
} catch (DecryptException $e) {
|
||||
$this->error(sprintf('Could not decrypt data of attachment #%d', $attachment->id));
|
||||
$this->error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
|
||||
continue;
|
||||
}
|
||||
$tmpfname = tempnam(sys_get_temp_dir(), 'FireflyIII');
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php /** @noinspection PhpStaticAsDynamicMethodCallInspection */
|
||||
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
|
||||
<?php
|
||||
|
||||
/**
|
||||
* UpgradeDatabase.php
|
||||
@@ -21,6 +20,10 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @noinspection MultipleReturnStatementsInspection */
|
||||
/** @noinspection PhpStaticAsDynamicMethodCallInspection */
|
||||
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@@ -59,6 +62,8 @@ use UnexpectedValueException;
|
||||
* Class UpgradeDatabase.
|
||||
*
|
||||
* Upgrade user database.
|
||||
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class UpgradeDatabase extends Command
|
||||
{
|
||||
@@ -94,6 +99,13 @@ class UpgradeDatabase extends Command
|
||||
$this->info('Firefly III database is up to date.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Since it is one routine these warnings make sense and should be supressed.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||
*/
|
||||
public function migrateBillsToRules(): void
|
||||
{
|
||||
foreach (User::get() as $user) {
|
||||
@@ -104,11 +116,14 @@ class UpgradeDatabase extends Command
|
||||
$currencyPreference = Preferences::getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
|
||||
if (null === $currencyPreference) {
|
||||
$this->error('User has no currency preference. Impossible.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$currency = TransactionCurrency::where('code', $currencyPreference->data)->first();
|
||||
if (null === $currency) {
|
||||
$this->line('Fall back to default currency in migrateBillsToRules().');
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
}
|
||||
|
||||
@@ -265,6 +280,9 @@ class UpgradeDatabase extends Command
|
||||
|
||||
/**
|
||||
* Each (asset) account must have a reference to a preferred currency. If the account does not have one, it's forced upon the account.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
public function updateAccountCurrencies(): void
|
||||
{
|
||||
@@ -325,6 +343,9 @@ class UpgradeDatabase extends Command
|
||||
*
|
||||
* Both source and destination must match the respective currency preference of the related asset account.
|
||||
* So FF3 must verify all transactions.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
public function updateOtherCurrencies(): void
|
||||
{
|
||||
@@ -570,7 +591,11 @@ class UpgradeDatabase extends Command
|
||||
*
|
||||
* The transaction that is sent to this function MUST be the source transaction (amount negative).
|
||||
*
|
||||
* Method is long and complex bit I'm taking it for granted.
|
||||
* Method is long and complex but I'll allow it. https://imgur.com/gallery/dVDJiez
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||
*
|
||||
* @param Transaction $transaction
|
||||
*/
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* UpgradeFireflyInstructions.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* UseEncryption.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* VerifiesAccessToken.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php /** @noinspection PhpDynamicAsStaticMethodCallInspection */
|
||||
|
||||
<?php
|
||||
/**
|
||||
* VerifyDatabase.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -20,6 +19,8 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@@ -40,12 +41,16 @@ use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Schema;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class VerifyDatabase.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class VerifyDatabase extends Command
|
||||
{
|
||||
@@ -144,9 +149,10 @@ class VerifyDatabase extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix the situation where the matching transactions
|
||||
* of a journal somehow have non-matching categories
|
||||
* or budgets
|
||||
* Fix the situation where the matching transactions of a journal somehow have non-matching categories or budgets.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
private function fixBadMeta(): void
|
||||
{
|
||||
@@ -207,6 +213,12 @@ class VerifyDatabase extends Command
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure amounts are stored correctly.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
private function fixDoubleAmounts(): void
|
||||
{
|
||||
$count = 0;
|
||||
@@ -256,7 +268,7 @@ class VerifyDatabase extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Removes bills from journals that should not have bills.
|
||||
*/
|
||||
private function removeBills(): void
|
||||
{
|
||||
@@ -396,6 +408,7 @@ class VerifyDatabase extends Command
|
||||
$objName = Crypt::decrypt($objName);
|
||||
} catch (DecryptException $e) {
|
||||
// it probably was not encrypted.
|
||||
Log::debug(sprintf('Not a problem: %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
// also count the transactions:
|
||||
@@ -433,6 +446,7 @@ class VerifyDatabase extends Command
|
||||
$objName = Crypt::decrypt($objName);
|
||||
} catch (DecryptException $e) {
|
||||
// it probably was not encrypted.
|
||||
Log::debug(sprintf('Not a problem: %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
// also count the transactions:
|
||||
@@ -571,6 +585,7 @@ class VerifyDatabase extends Command
|
||||
$objName = Crypt::decrypt($objName);
|
||||
} catch (DecryptException $e) {
|
||||
// it probably was not encrypted.
|
||||
Log::debug(sprintf('Not a problem: %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
$line = sprintf(
|
||||
@@ -598,7 +613,8 @@ class VerifyDatabase extends Command
|
||||
$sum = (string)$user->transactions()->sum('amount');
|
||||
if (0 !== bccomp($sum, '0')) {
|
||||
$this->error('Error: Transactions for user #' . $user->id . ' (' . $user->email . ') are off by ' . $sum . '!');
|
||||
} else {
|
||||
}
|
||||
if (0 === bccomp($sum, '0')) {
|
||||
$this->info(sprintf('Amount integrity OK for user #%d', $user->id));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user