refactor: extract rate formatting logic to RateService and add tests

هذا الالتزام موجود في:
2025-05-31 15:22:50 +03:00
الأصل b19748ef20
التزام cc4e74f3f1
13 ملفات معدلة مع 278 إضافات و56 حذوفات

عرض الملف

@@ -41,9 +41,9 @@ class FetchCurrencyCommand extends Command
'SAR' => Currency::where('code', 'SAR')->first(),
};
$rate = Rate::updateOrCreate([
'city_id' => $city->id,
'currency_id' => $currency->id,
Rate::updateOrCreate([
'city_id' => $city?->id,
'currency_id' => $currency?->id,
'date' => $item['date'],
], [
'buy_price' => $item['price_buy'],
@@ -61,6 +61,8 @@ class FetchCurrencyCommand extends Command
'trace' => $e->getTraceAsString(),
]);
// todo mail when failing using resend
return Command::FAILURE;
}
}
@@ -110,7 +112,7 @@ class FetchCurrencyCommand extends Command
if (empty($data)) {
$this->warn('No historical currency data available.');
return;
return [];
}
$this->info('Last 20 Days Currency Data:');