Skip to content

Commit

Permalink
Remove Array first, when trying to get rate offset percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-muvirimi committed Sep 26, 2023
1 parent ff996c4 commit 3e1f207
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/Traits/ScrapesRates.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use DateTime;
use Exception;
use GuzzleHttp\Client;
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -192,16 +191,16 @@ private function cleanRate(string $value, string $locale): float
* if value is not within a 30 percentile range then it is invalid
* Handles cases where it may be in cents
*/
$max = Rate::query()->where('rate_currency', $this->currency)->enabled()->updated()->max('rate');
$min = Rate::query()->where('rate_currency', $this->currency)->enabled()->updated()->min('rate');
$max = Rate::query()->where('rate_currency', $this->rate_currency)->enabled()->updated()->max('rate');
$min = Rate::query()->where('rate_currency', $this->rate_currency)->enabled()->updated()->min('rate');

if ($min && $max) {
$amount = floatval($amount);

if ($amount > (Arr::first($max) * 1.3) || $amount < (Arr::first($min) * 0.7)) {
if ($amount > ($max * 1.3) || $amount < ($min * 0.7)) {
$amount /= 100;

if ($amount > (Arr::first($max) * 1.3) || $amount < (Arr::first($min) * 0.7)) {
if ($amount > ($max * 1.3) || $amount < ($min * 0.7)) {
$amount = 0;
}
}
Expand Down

0 comments on commit 3e1f207

Please sign in to comment.