diff --git a/app/Console/Commands/UpgradeDatabase.php b/app/Console/Commands/UpgradeDatabase.php index 927630bc50..b126e38850 100644 --- a/app/Console/Commands/UpgradeDatabase.php +++ b/app/Console/Commands/UpgradeDatabase.php @@ -199,7 +199,7 @@ class UpgradeDatabase extends Command [ 'rule_id' => $rule->id, 'trigger_type' => 'amount_more', - 'trigger_value' => round($bill->amount_min, $currency->decimal_places), + 'trigger_value' => round((float)$bill->amount_min, $currency->decimal_places), 'active' => 1, 'stop_processing' => 0, 'order' => 4, @@ -211,7 +211,7 @@ class UpgradeDatabase extends Command [ 'rule_id' => $rule->id, 'trigger_type' => 'amount_exactly', - 'trigger_value' => round($bill->amount_min, $currency->decimal_places), + 'trigger_value' => round((float)$bill->amount_min, $currency->decimal_places), 'active' => 1, 'stop_processing' => 0, 'order' => 3, diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index 9faf24e25f..0bee14bc8b 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -166,8 +166,8 @@ class BillController extends Controller } $currency = app('amount')->getDefaultCurrency(); - $bill->amount_min = round($bill->amount_min, $currency->decimal_places); - $bill->amount_max = round($bill->amount_max, $currency->decimal_places); + $bill->amount_min = round((float)$bill->amount_min, $currency->decimal_places); + $bill->amount_max = round((float)$bill->amount_max, $currency->decimal_places); $defaultCurrency = app('amount')->getDefaultCurrency(); // code to handle active-checkboxes diff --git a/app/Http/Controllers/Popup/ReportController.php b/app/Http/Controllers/Popup/ReportController.php index 1bdb211b1f..d07a09ab63 100644 --- a/app/Http/Controllers/Popup/ReportController.php +++ b/app/Http/Controllers/Popup/ReportController.php @@ -281,7 +281,7 @@ class ReportController extends Controller try { $attributes['endDate'] = Carbon::createFromFormat('Ymd', $attributes['endDate']); } catch (InvalidArgumentException $e) { - Log::debug('Not important error message: %s', $e->getMessage()); + Log::debug(sprintf('Not important error message: %s', $e->getMessage())); $date = Carbon::create()->startOfMonth(); $attributes['endDate'] = $date; } diff --git a/app/Http/Controllers/Rule/CreateController.php b/app/Http/Controllers/Rule/CreateController.php index 68ae618735..ce11445340 100644 --- a/app/Http/Controllers/Rule/CreateController.php +++ b/app/Http/Controllers/Rule/CreateController.php @@ -223,8 +223,8 @@ class CreateController extends Controller $triggers = ['currency_is', 'amount_more', 'amount_less', 'description_contains']; $values = [ $bill->transactionCurrency()->first()->name, - round($bill->amount_min, 12), - round($bill->amount_max, 12), + round((float)$bill->amount_min, 12), + round((float)$bill->amount_max, 12), $bill->name, ]; foreach ($triggers as $index => $trigger) { diff --git a/app/Http/Requests/JournalFormRequest.php b/app/Http/Requests/JournalFormRequest.php index c8b549e9be..e63b041a1f 100644 --- a/app/Http/Requests/JournalFormRequest.php +++ b/app/Http/Requests/JournalFormRequest.php @@ -270,6 +270,7 @@ class JournalFormRequest extends Request */ private function validateDeposit(Validator $validator): void { + $data = $validator->getData(); $selectedCurrency = (int)($data['amount_currency_id_amount'] ?? 0); $accountCurrency = (int)($data['destination_account_currency'] ?? 0); $nativeAmount = (string)($data['native_amount'] ?? ''); @@ -289,6 +290,7 @@ class JournalFormRequest extends Request */ private function validateTransfer(Validator $validator): void { + $data = $validator->getData(); $sourceCurrency = (int)($data['source_account_currency'] ?? 0); $destinationCurrency = (int)($data['destination_account_currency'] ?? 0); $sourceAmount = (string)($data['source_amount'] ?? ''); diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index b06185c07b..eba8e70d3d 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -24,8 +24,8 @@ namespace FireflyIII\Models; use Carbon\Carbon; use Crypt; -use FireflyIII\Support\Models\TransactionJournalTrait; use FireflyIII\User; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsToMany; @@ -33,7 +33,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Collection; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Illuminate\Database\Eloquent\Builder; /** @@ -58,6 +57,8 @@ use Illuminate\Database\Eloquent\Builder; * @property int order * @property int budget_id * @property string period_marker + * @property Carbon $date + * @property string $transaction_type_type * * @SuppressWarnings(PHPMD.TooManyPublicMethods) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -94,6 +95,27 @@ class TransactionJournal extends Model /** @var array */ protected $hidden = ['encrypted']; + /** + * @param Builder $query + * @param string $table + * + * @return bool + */ + public static function isJoined(Builder $query, string $table): bool + { + $joins = $query->getQuery()->joins; + if (null === $joins) { + return false; + } + foreach ($joins as $join) { + if ($join->table === $table) { + return true; + } + } + + return false; + } + /** * @param string $value * @@ -266,27 +288,6 @@ class TransactionJournal extends Model return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00')); } - /** - * @param Builder $query - * @param string $table - * - * @return bool - */ - public static function isJoined(Builder $query, string $table): bool - { - $joins = $query->getQuery()->joins; - if (null === $joins) { - return false; - } - foreach ($joins as $join) { - if ($join->table === $table) { - return true; - } - } - - return false; - } - /** * @codeCoverageIgnore * diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php index d0588e8b40..5fe1ad3db1 100644 --- a/app/Repositories/LinkType/LinkTypeRepository.php +++ b/app/Repositories/LinkType/LinkTypeRepository.php @@ -229,8 +229,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface */ public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): TransactionJournalLink { - $linkType = $this->find((int)($information['link_type_id'] ?? 0)); - if (null === $linkType->id) { + $linkType = $this->findNull((int)($information['link_type_id'] ?? 0)); + if (null === $linkType) { throw new FireflyException(sprintf('Link type #%d cannot be resolved to an actual link type', $information['link_type_id'] ?? 0)); } diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index 710e50df95..fc5526f74f 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -267,7 +267,6 @@ class TagRepository implements TagRepositoryInterface public function tagCloud(?int $year): array { // Some vars - $return = []; $tags = $this->getTagsInYear($year); $max = $this->getMaxAmount($tags); $min = $this->getMinAmount($tags); diff --git a/app/Support/Facades/Steam.php b/app/Support/Facades/Steam.php index 7a9bee11e8..d30951d449 100644 --- a/app/Support/Facades/Steam.php +++ b/app/Support/Facades/Steam.php @@ -28,8 +28,8 @@ use Illuminate\Support\Collection; use Illuminate\Support\Facades\Facade; /** - * @codeCoverageIgnore * Class Steam. + * * @method string balance(Account $account, Carbon $date) * @method string balanceIgnoreVirtual(Account $account, Carbon $date) * @method array balanceInRange(Account $account, Carbon $start, Carbon $end) @@ -42,6 +42,7 @@ use Illuminate\Support\Facades\Facade; * @method tryDecrypt($value) * @method string positive(string $amount) * + * @codeCoverageIgnore */ class Steam extends Facade { diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index e744976414..d7e3d16355 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -150,6 +150,7 @@ class General extends Twig_Extension if (null === $account) { return 'NULL'; } + /** @var Carbon $date */ $date = session('end', Carbon::now()->endOfMonth()); return app('steam')->balance($account, $date); diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php index 86c7516833..2654d304d8 100644 --- a/app/Transformers/BillTransformer.php +++ b/app/Transformers/BillTransformer.php @@ -174,8 +174,8 @@ class BillTransformer extends TransformerAbstract 'name' => $bill->name, 'currency_id' => $bill->transaction_currency_id, 'currency_code' => $bill->transactionCurrency->code, - 'amount_min' => round($bill->amount_min, 2), - 'amount_max' => round($bill->amount_max, 2), + 'amount_min' => round((float)$bill->amount_min, 2), + 'amount_max' => round((float)$bill->amount_max, 2), 'date' => $bill->date->format('Y-m-d'), 'repeat_freq' => $bill->repeat_freq, 'skip' => (int)$bill->skip,