mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various code cleanup.
This commit is contained in:
parent
0312ba8ad7
commit
e3e0e12fef
@ -90,6 +90,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property int $opposing_id // ID of the opposing transaction, used in collector
|
||||
* @property bool $encrypted // is the journal encrypted
|
||||
* @property bool reconciled
|
||||
* @property string transaction_category_encrypted
|
||||
* @property string transaction_journal_category_encrypted
|
||||
* @property string transaction_budget_encrypted
|
||||
* @property string transaction_journal_budget_encrypted
|
||||
* @property string type
|
||||
* @property string name
|
||||
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
||||
*/
|
||||
class Transaction extends Model
|
||||
|
@ -50,18 +50,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property Collection $tags
|
||||
* @property mixed user_id
|
||||
* @property mixed transactions
|
||||
* @property int transaction_count
|
||||
* @property Carbon interest_date
|
||||
* @property Carbon book_date
|
||||
* @property Carbon process_date
|
||||
* @property bool encrypted
|
||||
* @property int order
|
||||
* @property int budget_id
|
||||
* @property string period_marker
|
||||
* @property Carbon $date
|
||||
* @property string $transaction_type_type
|
||||
* @property int $id
|
||||
* @property int transaction_count
|
||||
* @property Carbon interest_date
|
||||
* @property Carbon book_date
|
||||
* @property Carbon process_date
|
||||
* @property bool encrypted
|
||||
* @property int order
|
||||
* @property int budget_id
|
||||
* @property string period_marker
|
||||
* @property Carbon $date
|
||||
* @property string $transaction_type_type
|
||||
* @property int $id
|
||||
* @property TransactionType $transactionType
|
||||
* @property Collection budgets
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
|
@ -155,7 +155,7 @@ class BelongsUser implements Rule
|
||||
*/
|
||||
private function validateAccountId(int $value): bool
|
||||
{
|
||||
$count = Account::where('id', '=', (int)$value)->where('user_id', '=', auth()->user()->id)->count();
|
||||
$count = Account::where('id', '=', $value)->where('user_id', '=', auth()->user()->id)->count();
|
||||
|
||||
return 1 === $count;
|
||||
}
|
||||
|
@ -72,7 +72,6 @@ class FixerIOv2 implements ExchangeRateInterface
|
||||
'http://data.fixer.io/api/%s?access_key=%s&base=%s&symbols=%s',
|
||||
$date->format('Y-m-d'), $apiKey, $fromCurrency->code, $toCurrency->code
|
||||
);
|
||||
$statusCode = -1;
|
||||
Log::debug(sprintf('Going to request exchange rate using URI %s', str_replace($apiKey, 'xxxx', $uri)));
|
||||
$client = new Client;
|
||||
try {
|
||||
|
@ -33,6 +33,7 @@ use Preferences as Prefs;
|
||||
*/
|
||||
class Amount
|
||||
{
|
||||
/** @noinspection MoreThanThreeArgumentsInspection */
|
||||
/**
|
||||
* bool $sepBySpace is $localeconv['n_sep_by_space']
|
||||
* int $signPosn = $localeconv['n_sign_posn']
|
||||
@ -116,10 +117,11 @@ class Amount
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = true): string
|
||||
public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = null): string
|
||||
{
|
||||
$locale = explode(',', (string)trans('config.locale'));
|
||||
$locale = array_map('trim', $locale);
|
||||
$coloured = $coloured ?? true;
|
||||
$locale = explode(',', (string)trans('config.locale'));
|
||||
$locale = array_map('trim', $locale);
|
||||
setlocale(LC_MONETARY, $locale);
|
||||
$float = round($amount, 12);
|
||||
$info = localeconv();
|
||||
@ -205,6 +207,7 @@ class Amount
|
||||
*/
|
||||
public function getDefaultCurrency(): TransactionCurrency
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $this->getDefaultCurrencyByUser($user);
|
||||
|
@ -47,14 +47,14 @@ class AccountList implements BinderInterface
|
||||
if (auth()->check()) {
|
||||
|
||||
$collection = new Collection;
|
||||
if ($value === 'allAssetAccounts') {
|
||||
if ('allAssetAccounts' === $value) {
|
||||
/** @var \Illuminate\Support\Collection $collection */
|
||||
$collection = auth()->user()->accounts()
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->where('account_types.type', AccountType::ASSET)
|
||||
->get(['accounts.*']);
|
||||
}
|
||||
if ($value !== 'allAssetAccounts') {
|
||||
if ('allAssetAccounts' !== $value) {
|
||||
|
||||
$list = [];
|
||||
$incoming = explode(',', $value);
|
||||
@ -62,7 +62,7 @@ class AccountList implements BinderInterface
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (\count($list) === 0) {
|
||||
if (0 === \count($list)) {
|
||||
Log::error('Account list is empty.');
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class BudgetList implements BinderInterface
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (\count($list) === 0) {
|
||||
if (0 === \count($list)) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class BudgetList implements BinderInterface
|
||||
->get();
|
||||
|
||||
// add empty budget if applicable.
|
||||
if (\in_array(0, $list)) {
|
||||
if (\in_array(0, $list, true)) {
|
||||
$collection->push(new Budget);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class CategoryList implements BinderInterface
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (\count($list) === 0) {
|
||||
if (0 === \count($list)) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ class CategoryList implements BinderInterface
|
||||
->get();
|
||||
|
||||
// add empty category if applicable.
|
||||
if (\in_array(0, $list)) {
|
||||
if (\in_array(0, $list, true)) {
|
||||
$collection->push(new Category);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class Date implements BinderInterface
|
||||
try {
|
||||
$date = new Carbon($value);
|
||||
} catch (Exception $e) {
|
||||
Log::error('Could not parse date "' . $value . '" for user #' . auth()->user()->id);
|
||||
Log::error(sprintf('Could not parse date "%s" for user #%d: %s', $value, auth()->user()->id, $e->getMessage()));
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
|
||||
|
@ -27,30 +27,14 @@ use FireflyIII\Import\Prerequisites\PrerequisitesInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Routing\Route;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Log;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class ImportProvider.
|
||||
*/
|
||||
class ImportProvider implements BinderInterface
|
||||
{
|
||||
/**
|
||||
* @param string $value
|
||||
* @param Route $route
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value, Route $route): string
|
||||
{
|
||||
$providers = array_keys(self::getProviders());
|
||||
if (\in_array($value, $providers, true)) {
|
||||
return $value;
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@ -99,4 +83,20 @@ class ImportProvider implements BinderInterface
|
||||
|
||||
return $providers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param Route $route
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value, Route $route): string
|
||||
{
|
||||
$providers = array_keys(self::getProviders());
|
||||
if (\in_array($value, $providers, true)) {
|
||||
return $value;
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class JournalList implements BinderInterface
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (\count($list) === 0) {
|
||||
if (0 === \count($list)) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class SimpleJournalList implements BinderInterface
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (\count($list) === 0) {
|
||||
if (0 === \count($list)) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class TagList implements BinderInterface
|
||||
$list[] = strtolower(trim($entry));
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (\count($list) === 0) {
|
||||
if (0 === \count($list)) {
|
||||
Log::error('Tag list is empty.');
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
@ -61,7 +61,7 @@ class TagList implements BinderInterface
|
||||
|
||||
$collection = $allTags->filter(
|
||||
function (Tag $tag) use ($list) {
|
||||
return \in_array(strtolower($tag->tag), $list);
|
||||
return \in_array(strtolower($tag->tag), $list, true);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -50,7 +50,7 @@ class CacheProperties
|
||||
/**
|
||||
* @param $property
|
||||
*/
|
||||
public function addProperty($property)
|
||||
public function addProperty($property): void
|
||||
{
|
||||
$this->properties->push($property);
|
||||
}
|
||||
@ -87,14 +87,14 @@ class CacheProperties
|
||||
/**
|
||||
* @param $data
|
||||
*/
|
||||
public function store($data)
|
||||
public function store($data): void
|
||||
{
|
||||
Cache::forever($this->hash, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
private function hash()
|
||||
private function hash(): void
|
||||
{
|
||||
$content = '';
|
||||
foreach ($this->properties as $property) {
|
||||
|
@ -36,6 +36,7 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
use Form;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Log;
|
||||
use RuntimeException;
|
||||
@ -251,7 +252,7 @@ class ExpandedForm
|
||||
{
|
||||
$options = $options ?? [];
|
||||
$value = $value ?? 1;
|
||||
$options['checked'] = true === $checked ? true : false;
|
||||
$options['checked'] = true === $checked;
|
||||
|
||||
if (Session::has('preFilled')) {
|
||||
$preFilled = session('preFilled');
|
||||
@ -688,13 +689,13 @@ class ExpandedForm
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param array $options
|
||||
* @param string $name
|
||||
* @param null $value
|
||||
* @param array|null $options
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
* @return HtmlString
|
||||
*/
|
||||
public function ruleGroupListWithEmpty(string $name, $value = null, array $options = null)
|
||||
public function ruleGroupListWithEmpty(string $name, $value = null, array $options = null): HtmlString
|
||||
{
|
||||
$options = $options ?? [];
|
||||
$options['class'] = 'form-control';
|
||||
@ -877,6 +878,7 @@ class ExpandedForm
|
||||
}
|
||||
} catch (RuntimeException $e) {
|
||||
// don't care about session errors.
|
||||
Log::debug(sprintf('Run time: %s', $e->getMessage()));
|
||||
}
|
||||
if ($value instanceof Carbon) {
|
||||
$value = $value->format('Y-m-d');
|
||||
@ -929,6 +931,8 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
private function currencyField(string $name, string $view, $value = null, array $options = null): string
|
||||
{
|
||||
|
@ -51,11 +51,11 @@ class FireflyConfig
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $default
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return \FireflyIII\Models\Configuration|null
|
||||
*/
|
||||
public function get(string $name, $default = null): ?Configuration
|
||||
public function get(string $name, $default = null): ?Configuration
|
||||
{
|
||||
$fullName = 'ff-config-' . $name;
|
||||
if (Cache::has($fullName)) {
|
||||
@ -79,7 +79,7 @@ class FireflyConfig
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $default
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return \FireflyIII\Models\Configuration|null
|
||||
*/
|
||||
|
@ -58,7 +58,7 @@ class ChooseAccountsHandler implements BunqJobConfigurationInterface
|
||||
$config = $this->repository->getConfiguration($this->importJob);
|
||||
$mapping = $config['mapping'] ?? [];
|
||||
$complete = \count($mapping) > 0;
|
||||
if ($complete === true) {
|
||||
if (true === $complete) {
|
||||
// move job to correct stage to download transactions
|
||||
$this->repository->setStage($this->importJob, 'go-for-import');
|
||||
}
|
||||
@ -79,12 +79,12 @@ class ChooseAccountsHandler implements BunqJobConfigurationInterface
|
||||
$config = $this->repository->getConfiguration($this->importJob);
|
||||
$accounts = $config['accounts'] ?? [];
|
||||
$mapping = $data['account_mapping'] ?? [];
|
||||
$applyRules = (int)$data['apply_rules'] === 1;
|
||||
$applyRules = 1 === (int)$data['apply_rules'];
|
||||
$final = [];
|
||||
if (\count($accounts) === 0) {
|
||||
if (0 === \count($accounts)) {
|
||||
throw new FireflyException('No bunq accounts found. Import cannot continue.'); // @codeCoverageIgnore
|
||||
}
|
||||
if (\count($mapping) === 0) {
|
||||
if (0 === \count($mapping)) {
|
||||
$messages = new MessageBag;
|
||||
$messages->add('nomap', (string)trans('import.bunq_no_mapping'));
|
||||
|
||||
@ -116,7 +116,7 @@ class ChooseAccountsHandler implements BunqJobConfigurationInterface
|
||||
{
|
||||
$config = $this->repository->getConfiguration($this->importJob);
|
||||
$accounts = $config['accounts'] ?? [];
|
||||
if (\count($accounts) === 0) {
|
||||
if (0 === \count($accounts)) {
|
||||
throw new FireflyException('No bunq accounts found. Import cannot continue.'); // @codeCoverageIgnore
|
||||
}
|
||||
// list the users accounts:
|
||||
|
@ -183,7 +183,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
|
||||
{
|
||||
$canBeMapped = config('csv.import_roles.' . $name . '.mappable');
|
||||
|
||||
return $canBeMapped === true && $requested === true;
|
||||
return true === $canBeMapped && true === $requested;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -247,7 +247,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
|
||||
$collection = $this->repository->getAttachments($this->importJob);
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($collection as $attachment) {
|
||||
if ($attachment->filename === 'import_file') {
|
||||
if ('import_file' === $attachment->filename) {
|
||||
$content = $this->attachments->getAttachmentContent($attachment);
|
||||
break;
|
||||
}
|
||||
@ -274,7 +274,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
|
||||
*/
|
||||
public function getValuesForMapping(Reader $reader, array $config, array $columnConfig): array
|
||||
{
|
||||
$offset = isset($config['has-headers']) && $config['has-headers'] === true ? 1 : 0;
|
||||
$offset = isset($config['has-headers']) && true === $config['has-headers'] ? 1 : 0;
|
||||
try {
|
||||
$stmt = (new Statement)->offset($offset);
|
||||
// @codeCoverageIgnoreStart
|
||||
@ -295,7 +295,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
|
||||
continue;
|
||||
}
|
||||
$value = trim($line[$columnIndex]);
|
||||
if (\strlen($value) === 0) {
|
||||
if ('' === $value) {
|
||||
// value is empty, ignore it.
|
||||
continue;
|
||||
}
|
||||
@ -309,7 +309,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
|
||||
$columnConfig[$columnIndex]['values'] = array_unique($columnConfig[$columnIndex]['values']);
|
||||
asort($columnConfig[$columnIndex]['values']);
|
||||
// if the count of this array is zero, there is nothing to map.
|
||||
if (\count($columnConfig[$columnIndex]['values']) === 0) {
|
||||
if (0 === \count($columnConfig[$columnIndex]['values'])) {
|
||||
unset($columnConfig[$columnIndex]);
|
||||
}
|
||||
}
|
||||
|
@ -76,10 +76,10 @@ class ConfigureRolesHandler implements FileConfigurationInterface
|
||||
if (\in_array($role, ['amount', 'amount_credit', 'amount_debit'])) {
|
||||
$hasAmount = true;
|
||||
}
|
||||
if ($role === 'foreign-currency-code') {
|
||||
if ('foreign-currency-code' === $role) {
|
||||
$hasForeignCode = true;
|
||||
}
|
||||
if ($role === 'amount_foreign') {
|
||||
if ('amount_foreign' === $role) {
|
||||
$hasForeignAmount = true;
|
||||
}
|
||||
}
|
||||
@ -122,7 +122,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
|
||||
$count = $config['column-count'];
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
$role = $data['role'][$i] ?? '_ignore';
|
||||
$mapping = (isset($data['map'][$i]) && $data['map'][$i] === '1');
|
||||
$mapping = (isset($data['map'][$i]) && '1' === $data['map'][$i]);
|
||||
$config['column-roles'][$i] = $role;
|
||||
$config['column-do-mapping'][$i] = $mapping;
|
||||
Log::debug(sprintf('Column %d has been given role %s (mapping: %s)', $i, $role, var_export($mapping, true)));
|
||||
@ -130,7 +130,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
|
||||
$config = $this->ignoreUnmappableColumns($config);
|
||||
$messages = $this->configurationComplete($config);
|
||||
|
||||
if ($messages->count() === 0) {
|
||||
if (0 === $messages->count()) {
|
||||
$this->repository->setStage($this->importJob, 'ready_to_run');
|
||||
if ($this->isMappingNecessary($config)) {
|
||||
$this->repository->setStage($this->importJob, 'map');
|
||||
@ -175,7 +175,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
|
||||
public function getExamplesFromFile(Reader $reader, array $config): void
|
||||
{
|
||||
$limit = (int)config('csv.example_rows', 5);
|
||||
$offset = isset($config['has-headers']) && $config['has-headers'] === true ? 1 : 0;
|
||||
$offset = isset($config['has-headers']) && true === $config['has-headers'] ? 1 : 0;
|
||||
|
||||
// make statement.
|
||||
try {
|
||||
@ -214,7 +214,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
|
||||
public function getHeaders(Reader $reader, array $config): array
|
||||
{
|
||||
$headers = [];
|
||||
if (isset($config['has-headers']) && $config['has-headers'] === true) {
|
||||
if (isset($config['has-headers']) && true === $config['has-headers']) {
|
||||
try {
|
||||
$stmt = (new Statement)->limit(1)->offset(0);
|
||||
$records = $stmt->process($reader);
|
||||
@ -273,7 +273,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
|
||||
$collection = $this->repository->getAttachments($this->importJob);
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($collection as $attachment) {
|
||||
if ($attachment->filename === 'import_file') {
|
||||
if ('import_file' === $attachment->filename) {
|
||||
$content = $this->attachments->getAttachmentContent($attachment);
|
||||
break;
|
||||
}
|
||||
|
@ -57,10 +57,10 @@ class ConfigureUploadHandler implements FileConfigurationInterface
|
||||
// collect values:
|
||||
$importId = isset($data['csv_import_account']) ? (int)$data['csv_import_account'] : 0;
|
||||
$delimiter = (string)$data['csv_delimiter'];
|
||||
$config['has-headers'] = (int)($data['has_headers'] ?? 0.0) === 1;
|
||||
$config['has-headers'] = 1 === (int)($data['has_headers'] ?? 0.0);
|
||||
$config['date-format'] = (string)$data['date_format'];
|
||||
$config['delimiter'] = 'tab' === $delimiter ? "\t" : $delimiter;
|
||||
$config['apply-rules'] = (int)($data['apply_rules'] ?? 0.0) === 1;
|
||||
$config['apply-rules'] = 1 === (int)($data['apply_rules'] ?? 0.0);
|
||||
$config['specifics'] = $this->getSpecifics($data);
|
||||
// validate values:
|
||||
$account = $this->accountRepos->findNull($importId);
|
||||
|
@ -123,7 +123,7 @@ class NewFileJobHandler implements FileConfigurationInterface
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($attachments as $attachment) {
|
||||
// if file is configuration file, store it into the job.
|
||||
if ($attachment->filename === 'configuration_file') {
|
||||
if ('configuration_file' === $attachment->filename) {
|
||||
$this->storeConfig($attachment);
|
||||
}
|
||||
}
|
||||
@ -162,7 +162,7 @@ class NewFileJobHandler implements FileConfigurationInterface
|
||||
}
|
||||
|
||||
// if file is configuration file, store it into the job.
|
||||
if ($attachment->filename === 'configuration_file') {
|
||||
if ('configuration_file' === $attachment->filename) {
|
||||
$this->storeConfig($attachment);
|
||||
}
|
||||
}
|
||||
@ -179,10 +179,10 @@ class NewFileJobHandler implements FileConfigurationInterface
|
||||
{
|
||||
$content = $this->attachments->getAttachmentContent($attachment);
|
||||
$result = mb_detect_encoding($content, 'UTF-8', true);
|
||||
if ($result === false) {
|
||||
if (false === $result) {
|
||||
return false;
|
||||
}
|
||||
if ($result !== 'ASCII' && $result !== 'UTF-8') {
|
||||
if ('ASCII' !== $result && 'UTF-8' !== $result) {
|
||||
return false; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
@ -194,7 +194,6 @@ class NewFileJobHandler implements FileConfigurationInterface
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function storeConfig(Attachment $attachment): void
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
|
||||
$config['account_mapping'] = $final;
|
||||
$config['apply-rules'] = $applyRules;
|
||||
$this->repository->setConfiguration($this->importJob, $config);
|
||||
if ($final === [0 => 0] || \count($final) === 0) {
|
||||
if ($final === [0 => 0] || 0 === \count($final)) {
|
||||
$messages->add('count', (string)trans('import.spectre_no_mapping'));
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
|
||||
Log::debug('Now in ChooseAccountsHandler::getnextData()');
|
||||
$config = $this->importJob->configuration;
|
||||
$accounts = $config['accounts'] ?? [];
|
||||
if (\count($accounts) === 0) {
|
||||
if (0 === \count($accounts)) {
|
||||
throw new FireflyException('It seems you have no accounts with this bank. The import cannot continue.'); // @codeCoverageIgnore
|
||||
}
|
||||
$converted = [];
|
||||
@ -128,15 +128,15 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
|
||||
$login = null;
|
||||
$logins = $config['all-logins'] ?? [];
|
||||
$selected = $config['selected-login'] ?? 0;
|
||||
if (\count($logins) === 0) {
|
||||
if (0 === \count($logins)) {
|
||||
throw new FireflyException('It seems you have no configured logins in this import job. The import cannot continue.'); // @codeCoverageIgnore
|
||||
}
|
||||
Log::debug(sprintf('Selected login to use is %d', $selected));
|
||||
if ($selected === 0) {
|
||||
if (0 === $selected) {
|
||||
$login = new Login($logins[0]);
|
||||
Log::debug(sprintf('Will use login %d (%s %s)', $login->getId(), $login->getProviderName(), $login->getCountryCode()));
|
||||
}
|
||||
if ($selected !== 0) {
|
||||
if (0 !== $selected) {
|
||||
foreach ($logins as $loginArray) {
|
||||
$loginId = $loginArray['id'] ?? -1;
|
||||
if ($loginId === $selected) {
|
||||
|
@ -82,7 +82,7 @@ class ChooseLoginHandler implements SpectreJobConfigurationInterface
|
||||
Log::debug(sprintf('The selected login by the user is #%d', $selectedLogin));
|
||||
|
||||
// if selected login is zero, create a new one.
|
||||
if ($selectedLogin === 0) {
|
||||
if (0 === $selectedLogin) {
|
||||
Log::debug('Login is zero, get Spectre customer + token and store it in config.');
|
||||
$customer = $this->getCustomer($this->importJob);
|
||||
// get a token for the user and redirect to next stage
|
||||
|
@ -226,7 +226,6 @@ class ImportTransaction
|
||||
* Calculate the amount of this transaction.
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function calculateAmount(): string
|
||||
{
|
||||
@ -258,7 +257,7 @@ class ImportTransaction
|
||||
if ($conversion === -1) {
|
||||
$result = app('steam')->negative($result);
|
||||
}
|
||||
if ($conversion === 1) {
|
||||
if (1 === $conversion) {
|
||||
$result = app('steam')->positive($result);
|
||||
}
|
||||
Log::debug(sprintf('convertedAmount after conversion is %s', $result));
|
||||
@ -301,7 +300,7 @@ class ImportTransaction
|
||||
if ($conversion === -1) {
|
||||
$result = app('steam')->negative($result);
|
||||
}
|
||||
if ($conversion === 1) {
|
||||
if (1 === $conversion) {
|
||||
$result = app('steam')->positive($result);
|
||||
}
|
||||
Log::debug(sprintf('Foreign amount after conversion is %s', $result));
|
||||
|
@ -80,7 +80,7 @@ class StageImportDataHandler
|
||||
$bunqAccountId = $bunqAccount['id'] ?? 0;
|
||||
$localId = $mapping[$bunqAccountId] ?? 0;
|
||||
Log::debug(sprintf('Looping accounts, now at bunq account #%d and local account #%d', $bunqAccountId, $localId));
|
||||
if ($localId !== 0 && $bunqAccountId !== 0) {
|
||||
if (0 !== $localId && 0 !== $bunqAccountId) {
|
||||
$localAccount = $this->getLocalAccount((int)$localId);
|
||||
$collection[] = $this->getTransactionsFromBunq($bunqAccountId, $localAccount);
|
||||
}
|
||||
@ -122,7 +122,7 @@ class StageImportDataHandler
|
||||
|
||||
Log::debug(sprintf('Amount is %s %s', $amount->getCurrency(), $amount->getValue()));
|
||||
$expected = AccountType::EXPENSE;
|
||||
if (bccomp($amount->getValue(), '0') === 1) {
|
||||
if (1 === bccomp($amount->getValue(), '0')) {
|
||||
// amount + means that its a deposit.
|
||||
$expected = AccountType::REVENUE;
|
||||
$type = TransactionType::DEPOSIT;
|
||||
@ -131,7 +131,7 @@ class StageImportDataHandler
|
||||
$destination = $this->convertToAccount($counterParty, $expected);
|
||||
|
||||
// switch source and destination if necessary.
|
||||
if (bccomp($amount->getValue(), '0') === 1) {
|
||||
if (1 === bccomp($amount->getValue(), '0')) {
|
||||
Log::debug('Will make it a deposit.');
|
||||
[$source, $destination] = [$destination, $source];
|
||||
}
|
||||
@ -187,11 +187,12 @@ class StageImportDataHandler
|
||||
* @param string $expectedType
|
||||
*
|
||||
* @return LocalAccount
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function convertToAccount(LabelMonetaryAccount $party, string $expectedType): LocalAccount
|
||||
{
|
||||
Log::debug('in convertToAccount()');
|
||||
if ($party->getIban() !== null) {
|
||||
if (null !== $party->getIban()) {
|
||||
// find opposing party by IBAN first.
|
||||
$result = $this->accountRepository->findByIbanNull($party->getIban(), [$expectedType]);
|
||||
if (null !== $result) {
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Routine\Fake;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -33,7 +32,6 @@ use Log;
|
||||
class StageAhoyHandler
|
||||
{
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Routine\Fake;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -33,7 +32,6 @@ use Log;
|
||||
class StageNewHandler
|
||||
{
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
|
@ -205,7 +205,7 @@ class ImportableConverter
|
||||
$transactionType = $this->getTransactionType($source->accountType->type, $destination->accountType->type);
|
||||
$currency = $currency ?? $this->getCurrency($source, $destination);
|
||||
|
||||
if ($transactionType === 'unknown') {
|
||||
if ('unknown' === $transactionType) {
|
||||
$message = sprintf(
|
||||
'Cannot determine transaction type. Source account is a %s, destination is a %s', $source->accountType->type, $destination->accountType->type
|
||||
);
|
||||
@ -282,14 +282,14 @@ class ImportableConverter
|
||||
if ($destination->accountType->type === AccountType::ASSET) {
|
||||
// destination is asset, might have currency preference:
|
||||
$destinationCurrencyId = (int)$this->accountRepository->getMetaValue($destination, 'currency_id');
|
||||
$currency = $destinationCurrencyId === 0 ? $this->defaultCurrency : $this->currencyMapper->map($destinationCurrencyId, []);
|
||||
$currency = 0 === $destinationCurrencyId ? $this->defaultCurrency : $this->currencyMapper->map($destinationCurrencyId, []);
|
||||
Log::debug(sprintf('Destination is an asset account, and has currency preference %s', $currency->code));
|
||||
}
|
||||
|
||||
if ($source->accountType->type === AccountType::ASSET) {
|
||||
// source is asset, might have currency preference:
|
||||
$sourceCurrencyId = (int)$this->accountRepository->getMetaValue($source, 'currency_id');
|
||||
$currency = $sourceCurrencyId === 0 ? $this->defaultCurrency : $this->currencyMapper->map($sourceCurrencyId, []);
|
||||
$currency = 0 === $sourceCurrencyId ? $this->defaultCurrency : $this->currencyMapper->map($sourceCurrencyId, []);
|
||||
Log::debug(sprintf('Source is an asset account, and has currency preference %s', $currency->code));
|
||||
}
|
||||
if (null === $currency) {
|
||||
|
@ -123,7 +123,7 @@ class LineReader
|
||||
/** @var array $config */
|
||||
$config = $this->importJob->configuration;
|
||||
Log::debug('now in getLines()');
|
||||
$offset = isset($config['has-headers']) && $config['has-headers'] === true ? 1 : 0;
|
||||
$offset = isset($config['has-headers']) && true === $config['has-headers'] ? 1 : 0;
|
||||
try {
|
||||
$stmt = (new Statement)->offset($offset);
|
||||
// @codeCoverageIgnoreStart
|
||||
@ -151,7 +151,7 @@ class LineReader
|
||||
$collection = $this->repository->getAttachments($this->importJob);
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($collection as $attachment) {
|
||||
if ($attachment->filename === 'import_file') {
|
||||
if ('import_file' === $attachment->filename) {
|
||||
$content = $this->attachments->getAttachmentContent($attachment);
|
||||
break;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ class MappingConverger
|
||||
$value = trim($value);
|
||||
$originalRole = $this->roles[$columnIndex] ?? '_ignore';
|
||||
Log::debug(sprintf('Now at column #%d (%s), value "%s"', $columnIndex, $originalRole, $value));
|
||||
if ($originalRole !== '_ignore' && \strlen($value) > 0) {
|
||||
if ('_ignore' !== $originalRole && \strlen($value) > 0) {
|
||||
|
||||
// is a mapped value present?
|
||||
$mapped = $this->mapping[$columnIndex][$value] ?? 0;
|
||||
|
@ -53,7 +53,7 @@ class OpposingAccountMapper
|
||||
$expectedType = AccountType::EXPENSE;
|
||||
$result = null;
|
||||
Log::debug(sprintf('Going to search for accounts of type %s', $expectedType));
|
||||
if (bccomp($amount, '0') === 1) {
|
||||
if (1 === bccomp($amount, '0')) {
|
||||
// more than zero.
|
||||
$expectedType = AccountType::REVENUE;
|
||||
Log::debug(sprintf('Because amount is %s, will instead search for accounts of type %s', $amount, $expectedType));
|
||||
|
@ -57,7 +57,7 @@ class StageAuthenticatedHandler
|
||||
$config = $this->importJob->configuration;
|
||||
$logins = $config['all-logins'] ?? [];
|
||||
Log::debug(sprintf('%d logins in config', \count($logins)));
|
||||
if (\count($logins) === 0) {
|
||||
if (0 === \count($logins)) {
|
||||
// get logins from Spectre.
|
||||
$logins = $this->getLogins();
|
||||
$config['all-logins'] = $logins;
|
||||
|
@ -60,7 +60,7 @@ class StageImportDataHandler
|
||||
$config = $this->importJob->configuration;
|
||||
$accounts = $config['accounts'] ?? [];
|
||||
Log::debug(sprintf('Count of accounts in array is %d', \count($accounts)));
|
||||
if (\count($accounts) === 0) {
|
||||
if (0 === \count($accounts)) {
|
||||
throw new FireflyException('There are no accounts in this import job. Cannot continue.'); // @codeCoverageIgnore
|
||||
}
|
||||
$toImport = $config['account_mapping'] ?? [];
|
||||
@ -124,14 +124,14 @@ class StageImportDataHandler
|
||||
$amount = $transaction->getAmount();
|
||||
$source = $originalSource;
|
||||
$destination = $this->mapper->map(null, $amount, $destinationData);
|
||||
$notes = (string)trans('import.imported_from_account', ['account' => $spectreAccount->getName()]) . ' ' . "\n";
|
||||
$notes = trans('import.imported_from_account', ['account' => $spectreAccount->getName()]) . ' ' . "\n";
|
||||
$foreignAmount = null;
|
||||
$foreignCurrencyCode = null;
|
||||
|
||||
$currencyCode = $transaction->getCurrencyCode();
|
||||
$type = 'withdrawal';
|
||||
// switch source and destination if amount is greater than zero.
|
||||
if (bccomp($amount, '0') === 1) {
|
||||
if (1 === bccomp($amount, '0')) {
|
||||
[$source, $destination] = [$destination, $source];
|
||||
$type = 'deposit';
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ class Navigation
|
||||
// if period is 1M and diff in month is 2 and new DOM = 1, sub a day:
|
||||
$months = ['1M', 'month', 'monthly'];
|
||||
$difference = $date->month - $theDate->month;
|
||||
if (\in_array($repeatFreq, $months) && 2 === $difference && 1 === $date->day) {
|
||||
if (2 === $difference && 1 === $date->day && \in_array($repeatFreq, $months, true)) {
|
||||
$date->subDay();
|
||||
}
|
||||
|
||||
@ -199,14 +199,14 @@ class Navigation
|
||||
if (isset($modifierMap[$repeatFreq])) {
|
||||
$currentEnd->$function($modifierMap[$repeatFreq]);
|
||||
|
||||
if (\in_array($repeatFreq, $subDay)) {
|
||||
if (\in_array($repeatFreq, $subDay, true)) {
|
||||
$currentEnd->subDay();
|
||||
}
|
||||
|
||||
return $currentEnd;
|
||||
}
|
||||
$currentEnd->$function();
|
||||
if (\in_array($repeatFreq, $subDay)) {
|
||||
if (\in_array($repeatFreq, $subDay, true)) {
|
||||
$currentEnd->subDay();
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,7 @@ class Preferences
|
||||
try {
|
||||
Preference::where('user_id', auth()->user()->id)->where('name', $name)->delete();
|
||||
} catch (Exception $e) {
|
||||
Log::debug(sprintf('Not interesting: %s', $e->getMessage()));
|
||||
// don't care.
|
||||
}
|
||||
|
||||
@ -80,7 +81,7 @@ class Preferences
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $default
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return \FireflyIII\Models\Preference|null
|
||||
*/
|
||||
@ -137,7 +138,7 @@ class Preferences
|
||||
try {
|
||||
$preference->delete();
|
||||
} catch (Exception $e) {
|
||||
Log::debug(sprintf('Could not delete preference #%d', $preference->id));
|
||||
Log::debug(sprintf('Could not delete preference #%d: %s', $preference->id, $e->getMessage()));
|
||||
}
|
||||
$preference = null;
|
||||
}
|
||||
|
@ -101,6 +101,8 @@ class Modifier
|
||||
try {
|
||||
$compareDate = new Carbon($compare);
|
||||
} catch (Exception $e) {
|
||||
Log::debug(sprintf('Not interesting: %s', $e->getMessage()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -118,6 +120,8 @@ class Modifier
|
||||
try {
|
||||
$compareDate = new Carbon($compare);
|
||||
} catch (Exception $e) {
|
||||
Log::debug(sprintf('Not interesting: %s', $e->getMessage()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -135,6 +139,8 @@ class Modifier
|
||||
try {
|
||||
$compareDate = new Carbon($compare);
|
||||
} catch (Exception $e) {
|
||||
Log::debug(sprintf('Not interesting: %s', $e->getMessage()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ class Search implements SearchInterface
|
||||
public function getWordsAsString(): string
|
||||
{
|
||||
$string = implode(' ', $this->words);
|
||||
if (0 === \strlen($string)) {
|
||||
if ('' === $string) {
|
||||
return \is_string($this->originalQuery) ? $this->originalQuery : '';
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ class Search implements SearchInterface
|
||||
/**
|
||||
* @param string $query
|
||||
*/
|
||||
public function parseQuery(string $query)
|
||||
public function parseQuery(string $query): void
|
||||
{
|
||||
$filteredQuery = $query;
|
||||
$this->originalQuery = $query;
|
||||
@ -171,7 +171,7 @@ class Search implements SearchInterface
|
||||
/**
|
||||
* @param int $limit
|
||||
*/
|
||||
public function setLimit(int $limit)
|
||||
public function setLimit(int $limit): void
|
||||
{
|
||||
$this->limit = $limit;
|
||||
}
|
||||
@ -179,7 +179,7 @@ class Search implements SearchInterface
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user)
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
@ -242,13 +242,13 @@ class Search implements SearchInterface
|
||||
/**
|
||||
* @param string $string
|
||||
*/
|
||||
private function extractModifier(string $string)
|
||||
private function extractModifier(string $string): void
|
||||
{
|
||||
$parts = explode(':', $string);
|
||||
if (2 === \count($parts) && \strlen(trim((string)$parts[0])) > 0 && \strlen(trim((string)$parts[1]))) {
|
||||
if (2 === \count($parts) && \strlen(trim((string)$parts[0])) > 0 && '' !== trim((string)$parts[1])) {
|
||||
$type = trim((string)$parts[0]);
|
||||
$value = trim((string)$parts[1]);
|
||||
if (\in_array($type, $this->validModifiers)) {
|
||||
if (\in_array($type, $this->validModifiers, true)) {
|
||||
// filter for valid type
|
||||
$this->modifiers->push(['type' => $type, 'value' => $value]);
|
||||
}
|
||||
@ -292,9 +292,9 @@ class Search implements SearchInterface
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function strposArray(string $haystack, array $needle)
|
||||
private function strposArray(string $haystack, array $needle): bool
|
||||
{
|
||||
if (0 === \strlen($haystack)) {
|
||||
if ('' === $haystack) {
|
||||
return false;
|
||||
}
|
||||
foreach ($needle as $what) {
|
||||
|
@ -30,6 +30,7 @@ use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class Steam.
|
||||
@ -249,7 +250,7 @@ class Steam
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Encryption\DecryptException
|
||||
*/
|
||||
public function decrypt(int $isEncrypted, string $value)
|
||||
public function decrypt(int $isEncrypted, string $value): string
|
||||
{
|
||||
if (1 === $isEncrypted) {
|
||||
return Crypt::decrypt($value);
|
||||
@ -366,6 +367,7 @@ class Steam
|
||||
$value = Crypt::decrypt($value);
|
||||
} catch (DecryptException $e) {
|
||||
// do not care.
|
||||
Log::debug(sprintf('Not interesting: %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
@ -83,7 +83,8 @@ class AmountFormat extends Twig_Extension
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'formatAmountByAccount',
|
||||
function (AccountModel $account, string $amount, bool $coloured = true): string {
|
||||
function (AccountModel $account, string $amount, bool $coloured = null): string {
|
||||
$coloured = $coloured ?? true;
|
||||
/** @var AccountRepositoryInterface $accountRepos */
|
||||
$accountRepos = app(AccountRepositoryInterface::class);
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
@ -113,7 +114,9 @@ class AmountFormat extends Twig_Extension
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'formatAmountByCurrency',
|
||||
function (TransactionCurrency $currency, string $amount, bool $coloured = true): string {
|
||||
function (TransactionCurrency $currency, string $amount, bool $coloured = null): string {
|
||||
$coloured = $coloured ?? true;
|
||||
|
||||
return app('amount')->formatAnything($currency, $amount, $coloured);
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
@ -129,7 +132,9 @@ class AmountFormat extends Twig_Extension
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'formatAmountBySymbol',
|
||||
function (string $amount, string $symbol, int $decimalPlaces = 2, bool $coloured = true): string {
|
||||
function (string $amount, string $symbol, int $decimalPlaces = null, bool $coloured = null): string {
|
||||
$decimalPlaces = $decimalPlaces ?? 2;
|
||||
$coloured = $coloured ?? true;
|
||||
$currency = new TransactionCurrency;
|
||||
$currency->symbol = $symbol;
|
||||
$currency->decimal_places = $decimalPlaces;
|
||||
|
@ -136,12 +136,12 @@ class Transaction extends Twig_Extension
|
||||
}
|
||||
|
||||
// transaction has a budget
|
||||
if (null !== $transaction->transaction_budget_id && $txt === '') {
|
||||
if (null !== $transaction->transaction_budget_id && '' === $txt) {
|
||||
$name = app('steam')->tryDecrypt($transaction->transaction_budget_name);
|
||||
$txt = sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$transaction->transaction_budget_id]), $name, $name);
|
||||
}
|
||||
|
||||
if ($txt === '') {
|
||||
if ('' === $txt) {
|
||||
// see if the transaction has a budget:
|
||||
$budgets = $transaction->budgets()->get();
|
||||
if (0 === $budgets->count()) {
|
||||
@ -174,12 +174,12 @@ class Transaction extends Twig_Extension
|
||||
}
|
||||
|
||||
// transaction has a category:
|
||||
if (null !== $transaction->transaction_category_id && $txt === '') {
|
||||
if (null !== $transaction->transaction_category_id && '' === $txt) {
|
||||
$name = app('steam')->tryDecrypt($transaction->transaction_category_name);
|
||||
$txt = sprintf('<a href="%s" title="%s">%s</a>', route('categories.show', [$transaction->transaction_category_id]), $name, $name);
|
||||
}
|
||||
|
||||
if ($txt === '') {
|
||||
if ('' === $txt) {
|
||||
// see if the transaction has a category:
|
||||
$categories = $transaction->categories()->get();
|
||||
if (0 === $categories->count()) {
|
||||
@ -229,14 +229,14 @@ class Transaction extends Twig_Extension
|
||||
$type = $transaction->account_type;
|
||||
|
||||
// name is present in object, use that one:
|
||||
if (bccomp($transaction->transaction_amount, '0') === -1 && null !== $transaction->opposing_account_id) {
|
||||
if (null !== $transaction->opposing_account_id && bccomp($transaction->transaction_amount, '0') === -1) {
|
||||
$name = $transaction->opposing_account_name;
|
||||
$transactionId = (int)$transaction->opposing_account_id;
|
||||
$type = $transaction->opposing_account_type;
|
||||
}
|
||||
|
||||
// Find the opposing account and use that one:
|
||||
if (bccomp($transaction->transaction_amount, '0') === -1 && null === $transaction->opposing_account_id) {
|
||||
if (null === $transaction->opposing_account_id && bccomp($transaction->transaction_amount, '0') === -1) {
|
||||
// if the amount is negative, find the opposing account and use that one:
|
||||
$journalId = $transaction->journal_id;
|
||||
/** @var TransactionModel $other */
|
||||
@ -259,7 +259,7 @@ class Transaction extends Twig_Extension
|
||||
}
|
||||
|
||||
if (AccountType::CASH === $type) {
|
||||
$txt = '<span class="text-success">(' . (string)trans('firefly.cash') . ')</span>';
|
||||
$txt = '<span class="text-success">(' . trans('firefly.cash') . ')</span>';
|
||||
|
||||
return $txt;
|
||||
}
|
||||
@ -285,7 +285,7 @@ class Transaction extends Twig_Extension
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($transaction->attachmentCount === null) {
|
||||
if (null === $transaction->attachmentCount) {
|
||||
$journalId = (int)$transaction->journal_id;
|
||||
$count = Attachment::whereNull('deleted_at')
|
||||
->where('attachable_type', TransactionJournal::class)
|
||||
@ -355,11 +355,11 @@ class Transaction extends Twig_Extension
|
||||
public function isSplit(TransactionModel $transaction): string
|
||||
{
|
||||
$res = '';
|
||||
if ($transaction->is_split === true) {
|
||||
if (true === $transaction->is_split) {
|
||||
$res = '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>';
|
||||
}
|
||||
|
||||
if ($transaction->is_split === null) {
|
||||
if (null === $transaction->is_split) {
|
||||
$journalId = (int)$transaction->journal_id;
|
||||
$count = TransactionModel::where('transaction_journal_id', $journalId)->whereNull('deleted_at')->count();
|
||||
if ($count > 2) {
|
||||
@ -387,13 +387,13 @@ class Transaction extends Twig_Extension
|
||||
$type = $transaction->account_type;
|
||||
|
||||
// name is present in object, use that one:
|
||||
if (1 === bccomp($transaction->transaction_amount, '0') && null !== $transaction->opposing_account_id) {
|
||||
if (null !== $transaction->opposing_account_id && 1 === bccomp($transaction->transaction_amount, '0')) {
|
||||
$name = $transaction->opposing_account_name;
|
||||
$transactionId = (int)$transaction->opposing_account_id;
|
||||
$type = $transaction->opposing_account_type;
|
||||
}
|
||||
// Find the opposing account and use that one:
|
||||
if (1 === bccomp($transaction->transaction_amount, '0') && null === $transaction->opposing_account_id) {
|
||||
if (null === $transaction->opposing_account_id && 1 === bccomp($transaction->transaction_amount, '0')) {
|
||||
$journalId = $transaction->journal_id;
|
||||
/** @var TransactionModel $other */
|
||||
$other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)
|
||||
@ -410,7 +410,7 @@ class Transaction extends Twig_Extension
|
||||
}
|
||||
|
||||
if (AccountType::CASH === $type) {
|
||||
$txt = '<span class="text-success">(' . (string)trans('firefly.cash') . ')</span>';
|
||||
$txt = '<span class="text-success">(' . trans('firefly.cash') . ')</span>';
|
||||
|
||||
return $txt;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class TransactionJournal extends Twig_Extension
|
||||
if (null === $result) {
|
||||
return false;
|
||||
}
|
||||
if (\strlen((string)$result) === 0) {
|
||||
if ('' === (string)$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ class General extends Twig_Extension
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
protected function formatDate()
|
||||
protected function formatDate(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'formatDate',
|
||||
@ -330,7 +330,7 @@ class General extends Twig_Extension
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
protected function phpdate()
|
||||
protected function phpdate(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'phpdate',
|
||||
|
@ -45,7 +45,7 @@ class Rule extends Twig_Extension
|
||||
foreach ($ruleActions as $key) {
|
||||
$possibleActions[$key] = (string)trans('firefly.rule_action_' . $key . '_choice');
|
||||
}
|
||||
unset($key, $ruleActions);
|
||||
unset($ruleActions);
|
||||
asort($possibleActions);
|
||||
|
||||
return $possibleActions;
|
||||
@ -84,7 +84,7 @@ class Rule extends Twig_Extension
|
||||
$possibleTriggers[$key] = (string)trans('firefly.rule_trigger_' . $key . '_choice');
|
||||
}
|
||||
}
|
||||
unset($key, $ruleTriggers);
|
||||
unset($ruleTriggers);
|
||||
asort($possibleTriggers);
|
||||
|
||||
return $possibleTriggers;
|
||||
|
Loading…
Reference in New Issue
Block a user