mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Reverse logic operators.
This commit is contained in:
parent
179a710c5b
commit
b3f1737495
@ -43,11 +43,13 @@ class OtherCurrenciesCorrections extends Command
|
|||||||
public const CONFIG_NAME = '480_other_currencies';
|
public const CONFIG_NAME = '480_other_currencies';
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $description = 'Update all journal currency information.';
|
protected $description = 'Update all journal currency information.';
|
||||||
/**
|
/**
|
||||||
* The name and signature of the console command.
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
|
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
|
||||||
@ -67,6 +69,7 @@ class OtherCurrenciesCorrections extends Command
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
@ -93,6 +96,7 @@ class OtherCurrenciesCorrections extends Command
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
|
*
|
||||||
* @return TransactionCurrency|null
|
* @return TransactionCurrency|null
|
||||||
*/
|
*/
|
||||||
private function getCurrency(Account $account): ?TransactionCurrency
|
private function getCurrency(Account $account): ?TransactionCurrency
|
||||||
@ -120,7 +124,9 @@ class OtherCurrenciesCorrections extends Command
|
|||||||
/**
|
/**
|
||||||
* Gets the transaction that determines the transaction that "leads" and will determine
|
* Gets the transaction that determines the transaction that "leads" and will determine
|
||||||
* the currency to be used by all transactions, and the journal itself.
|
* the currency to be used by all transactions, and the journal itself.
|
||||||
|
*
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
* @return Transaction|null
|
* @return Transaction|null
|
||||||
*/
|
*/
|
||||||
private function getLeadTransaction(TransactionJournal $journal): ?Transaction
|
private function getLeadTransaction(TransactionJournal $journal): ?Transaction
|
||||||
@ -138,11 +144,15 @@ class OtherCurrenciesCorrections extends Command
|
|||||||
break;
|
break;
|
||||||
case TransactionType::OPENING_BALANCE:
|
case TransactionType::OPENING_BALANCE:
|
||||||
// whichever isn't an initial balance account:
|
// whichever isn't an initial balance account:
|
||||||
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id')->where('account_types.type', '!=', AccountType::INITIAL_BALANCE)->first(['transactions.*']);
|
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin(
|
||||||
|
'account_types', 'accounts.account_type_id', '=', 'account_types.id'
|
||||||
|
)->where('account_types.type', '!=', AccountType::INITIAL_BALANCE)->first(['transactions.*']);
|
||||||
break;
|
break;
|
||||||
case TransactionType::RECONCILIATION:
|
case TransactionType::RECONCILIATION:
|
||||||
// whichever isn't the reconciliation account:
|
// whichever isn't the reconciliation account:
|
||||||
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id')->where('account_types.type', '!=', AccountType::RECONCILIATION)->first(['transactions.*']);
|
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin(
|
||||||
|
'account_types', 'accounts.account_type_id', '=', 'account_types.id'
|
||||||
|
)->where('account_types.type', '!=', AccountType::RECONCILIATION)->first(['transactions.*']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,6 +184,7 @@ class OtherCurrenciesCorrections extends Command
|
|||||||
* Laravel will execute ALL __construct() methods for ALL commands whenever a SINGLE command is
|
* Laravel will execute ALL __construct() methods for ALL commands whenever a SINGLE command is
|
||||||
* executed. This leads to noticeable slow-downs and class calls. To prevent this, this method should
|
* executed. This leads to noticeable slow-downs and class calls. To prevent this, this method should
|
||||||
* be called from the handle method instead of using the constructor to initialize the command.
|
* be called from the handle method instead of using the constructor to initialize the command.
|
||||||
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
private function stupidLaravel(): void
|
private function stupidLaravel(): void
|
||||||
@ -211,27 +222,33 @@ class OtherCurrenciesCorrections extends Command
|
|||||||
$currency = $this->getCurrency($account);
|
$currency = $this->getCurrency($account);
|
||||||
if (null === $currency) {
|
if (null === $currency) {
|
||||||
// @codeCoverageIgnoreStart
|
// @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++;
|
$this->count++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
}
|
}
|
||||||
// fix each transaction:
|
// fix each transaction:
|
||||||
$journal->transactions->each(static function (Transaction $transaction) use ($currency) {
|
$journal->transactions->each(
|
||||||
if (null === $transaction->transaction_currency_id) {
|
static function (Transaction $transaction) use ($currency) {
|
||||||
$transaction->transaction_currency_id = $currency->id;
|
if (null === $transaction->transaction_currency_id) {
|
||||||
$transaction->save();
|
$transaction->transaction_currency_id = $currency->id;
|
||||||
}
|
$transaction->save();
|
||||||
|
}
|
||||||
|
|
||||||
// when mismatch in transaction:
|
// when mismatch in transaction:
|
||||||
if (!((int)$transaction->transaction_currency_id === (int)$currency->id)) {
|
if ((int)$transaction->transaction_currency_id !== (int)$currency->id) {
|
||||||
$transaction->foreign_currency_id = (int)$transaction->transaction_currency_id;
|
$transaction->foreign_currency_id = (int)$transaction->transaction_currency_id;
|
||||||
$transaction->foreign_amount = $transaction->amount;
|
$transaction->foreign_amount = $transaction->amount;
|
||||||
$transaction->transaction_currency_id = $currency->id;
|
$transaction->transaction_currency_id = $currency->id;
|
||||||
$transaction->save();
|
$transaction->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
// also update the journal, of course:
|
// also update the journal, of course:
|
||||||
$journal->transaction_currency_id = $currency->id;
|
$journal->transaction_currency_id = $currency->id;
|
||||||
$this->count++;
|
$this->count++;
|
||||||
@ -246,7 +263,9 @@ class OtherCurrenciesCorrections extends Command
|
|||||||
*/
|
*/
|
||||||
private function updateOtherJournalsCurrencies(): void
|
private function updateOtherJournalsCurrencies(): void
|
||||||
{
|
{
|
||||||
$set = $this->cliRepos->getAllJournals([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION,]);
|
$set = $this->cliRepos->getAllJournals(
|
||||||
|
[TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION,]
|
||||||
|
);
|
||||||
|
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
foreach ($set as $journal) {
|
foreach ($set as $journal) {
|
||||||
|
@ -87,7 +87,7 @@ trait VerifiesAccessToken
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!($accessToken->data === $token)) {
|
if ($accessToken->data !== $token) {
|
||||||
Log::error(sprintf('Invalid access token for user #%d.', $userId));
|
Log::error(sprintf('Invalid access token for user #%d.', $userId));
|
||||||
Log::error(sprintf('Token given is "%s", expected something else.', $token));
|
Log::error(sprintf('Token given is "%s", expected something else.', $token));
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ class DebugController extends Controller
|
|||||||
if (in_array('GET', $route->methods(), true)) {
|
if (in_array('GET', $route->methods(), true)) {
|
||||||
$found = false;
|
$found = false;
|
||||||
foreach ($ignore as $string) {
|
foreach ($ignore as $string) {
|
||||||
if (!(false === stripos($name, $string))) {
|
if (false !== stripos($name, $string)) {
|
||||||
$found = true;
|
$found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ class Installer
|
|||||||
// don't run installer when already in installer.
|
// don't run installer when already in installer.
|
||||||
$url = $request->url();
|
$url = $request->url();
|
||||||
$strpos = stripos($url, '/install');
|
$strpos = stripos($url, '/install');
|
||||||
if (!(false === $strpos)) {
|
if (false !== $strpos) {
|
||||||
Log::debug(sprintf('URL is %s, will NOT run installer middleware', $url));
|
Log::debug(sprintf('URL is %s, will NOT run installer middleware', $url));
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
@ -90,7 +90,7 @@ class Installer
|
|||||||
*/
|
*/
|
||||||
protected function isAccessDenied(string $message): bool
|
protected function isAccessDenied(string $message): bool
|
||||||
{
|
{
|
||||||
return !(false === stripos($message, 'Access denied'));
|
return false !== stripos($message, 'Access denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,7 +102,7 @@ class Installer
|
|||||||
*/
|
*/
|
||||||
protected function noTablesExist(string $message): bool
|
protected function noTablesExist(string $message): bool
|
||||||
{
|
{
|
||||||
return !(false === stripos($message, 'Base table or view not found'));
|
return false !== stripos($message, 'Base table or view not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,4 +87,6 @@ class Note extends Model
|
|||||||
{
|
{
|
||||||
return $this->morphTo();
|
return $this->morphTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -71,6 +71,6 @@ class IsTransferAccount implements Rule
|
|||||||
$validAccount = $validator->validateSource((int)$value, null, null);
|
$validAccount = $validator->validateSource((int)$value, null, null);
|
||||||
Log::debug(sprintf('Search by id (%d), result is %s.', (int)$value, var_export($validAccount, true)));
|
Log::debug(sprintf('Search by id (%d), result is %s.', (int)$value, var_export($validAccount, true)));
|
||||||
|
|
||||||
return !(false === $validAccount);
|
return false !== $validAccount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,6 @@ class ZeroOrMore implements Rule
|
|||||||
}
|
}
|
||||||
$res = bccomp('0', $value);
|
$res = bccomp('0', $value);
|
||||||
|
|
||||||
return !($res > 0);
|
return $res <= 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ trait UserNavigation
|
|||||||
$uri = (string)session($identifier);
|
$uri = (string)session($identifier);
|
||||||
Log::debug(sprintf('The URI is %s', $uri));
|
Log::debug(sprintf('The URI is %s', $uri));
|
||||||
|
|
||||||
if (!(false === strpos($uri, 'jscript'))) {
|
if (false !== strpos($uri, 'jscript')) {
|
||||||
$uri = $this->redirectUri; // @codeCoverageIgnore
|
$uri = $this->redirectUri; // @codeCoverageIgnore
|
||||||
Log::debug(sprintf('URI is now %s (uri contains jscript)', $uri));
|
Log::debug(sprintf('URI is now %s (uri contains jscript)', $uri));
|
||||||
}
|
}
|
||||||
|
@ -531,21 +531,21 @@ class Steam
|
|||||||
{
|
{
|
||||||
$string = strtolower($string);
|
$string = strtolower($string);
|
||||||
|
|
||||||
if (!(false === stripos($string, 'k'))) {
|
if (false !== stripos($string, 'k')) {
|
||||||
// has a K in it, remove the K and multiply by 1024.
|
// has a K in it, remove the K and multiply by 1024.
|
||||||
$bytes = bcmul(rtrim($string, 'kK'), '1024');
|
$bytes = bcmul(rtrim($string, 'kK'), '1024');
|
||||||
|
|
||||||
return (int)$bytes;
|
return (int)$bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(false === stripos($string, 'm'))) {
|
if (false !== stripos($string, 'm')) {
|
||||||
// has a M in it, remove the M and multiply by 1048576.
|
// has a M in it, remove the M and multiply by 1048576.
|
||||||
$bytes = bcmul(rtrim($string, 'mM'), '1048576');
|
$bytes = bcmul(rtrim($string, 'mM'), '1048576');
|
||||||
|
|
||||||
return (int)$bytes;
|
return (int)$bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(false === stripos($string, 'g'))) {
|
if (false !== stripos($string, 'g')) {
|
||||||
// has a G in it, remove the G and multiply by (1024)^3.
|
// has a G in it, remove the G and multiply by (1024)^3.
|
||||||
$bytes = bcmul(rtrim($string, 'gG'), '1073741824');
|
$bytes = bcmul(rtrim($string, 'gG'), '1073741824');
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ class General extends AbstractExtension
|
|||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$route = $args[0]; // name of the route.
|
$route = $args[0]; // name of the route.
|
||||||
$name = Route::getCurrentRoute()->getName() ?? '';
|
$name = Route::getCurrentRoute()->getName() ?? '';
|
||||||
if (!(false === strpos($name, $route))) {
|
if (false !== strpos($name, $route)) {
|
||||||
return 'active';
|
return 'active';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ class General extends AbstractExtension
|
|||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$route = $args[0]; // name of the route.
|
$route = $args[0]; // name of the route.
|
||||||
$name = Route::getCurrentRoute()->getName() ?? '';
|
$name = Route::getCurrentRoute()->getName() ?? '';
|
||||||
if (!(false === strpos($name, $route))) {
|
if (false !== strpos($name, $route)) {
|
||||||
return 'menu-open';
|
return 'menu-open';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class General extends AbstractExtension
|
|||||||
[, $route, $objectType] = func_get_args();
|
[, $route, $objectType] = func_get_args();
|
||||||
$activeObjectType = $context['objectType'] ?? false;
|
$activeObjectType = $context['objectType'] ?? false;
|
||||||
|
|
||||||
if ($objectType === $activeObjectType && !(false === stripos(Route::getCurrentRoute()->getName(), $route))) {
|
if ($objectType === $activeObjectType && false !== stripos(Route::getCurrentRoute()->getName(), $route)) {
|
||||||
return 'active';
|
return 'active';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ $password = '';
|
|||||||
$database = '';
|
$database = '';
|
||||||
$port = '';
|
$port = '';
|
||||||
|
|
||||||
if (!(false === $databaseUrl)) {
|
if (false !== $databaseUrl) {
|
||||||
$options = parse_url($databaseUrl);
|
$options = parse_url($databaseUrl);
|
||||||
$host = $options['host'] ?? 'firefly_iii_db';
|
$host = $options['host'] ?? 'firefly_iii_db';
|
||||||
$username = $options['user'] ?? 'firefly';
|
$username = $options['user'] ?? 'firefly';
|
||||||
|
Loading…
Reference in New Issue
Block a user