chore: code style
This commit is contained in:
@@ -38,9 +38,9 @@ class CaptureDailyChange extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Portfolio::with('holdings.market_data')->get()->each(function($portfolio){
|
||||
Portfolio::with('holdings.market_data')->get()->each(function ($portfolio) {
|
||||
|
||||
$this->line('Capturing daily change for ' . $portfolio->title);
|
||||
$this->line('Capturing daily change for '.$portfolio->title);
|
||||
|
||||
$total_cost_basis = $portfolio->holdings->sum('total_cost_basis');
|
||||
|
||||
@@ -48,7 +48,7 @@ class CaptureDailyChange extends Command
|
||||
|
||||
$realized_gains = $portfolio->holdings->sum('realized_gain_dollars');
|
||||
|
||||
$total_market_value = $portfolio->holdings->sum(function($holding) {
|
||||
$total_market_value = $portfolio->holdings->sum(function ($holding) {
|
||||
return $holding->market_data->market_value * $holding->quantity;
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ class CaptureDailyChange extends Command
|
||||
'total_cost_basis' => $total_cost_basis,
|
||||
'total_gain' => $total_market_value - $total_cost_basis,
|
||||
'total_dividends_earned' => $total_dividends,
|
||||
'realized_gains' => $realized_gains
|
||||
'realized_gains' => $realized_gains,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Holding;
|
||||
use App\Models\Dividend;
|
||||
use App\Models\Holding;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class RefreshDividendData extends Command
|
||||
@@ -43,17 +43,17 @@ class RefreshDividendData extends Command
|
||||
{
|
||||
$holdings = Holding::distinct();
|
||||
|
||||
if (!($this->option('force') ?? false)) {
|
||||
if (! ($this->option('force') ?? false)) {
|
||||
$holdings->where('quantity', '>', 0);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->option('user')) {
|
||||
$holdings->myHoldings($this->option('user'));
|
||||
}
|
||||
|
||||
foreach ($holdings->get(['symbol']) as $holding) {
|
||||
$this->line('Refreshing ' . $holding->symbol);
|
||||
|
||||
$this->line('Refreshing '.$holding->symbol);
|
||||
|
||||
Dividend::refreshDividendData($holding->symbol);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,18 +42,18 @@ class RefreshMarketData extends Command
|
||||
public function handle()
|
||||
{
|
||||
$force = $this->option('force') ?? false;
|
||||
|
||||
|
||||
// get all symbols from market data
|
||||
$holdings = Holding::where('quantity', '>', 0)
|
||||
->select(['symbol'])
|
||||
->distinct();
|
||||
|
||||
->select(['symbol'])
|
||||
->distinct();
|
||||
|
||||
if ($this->option('user')) {
|
||||
$holdings->myHoldings($this->option('user'));
|
||||
}
|
||||
|
||||
foreach ($holdings->get() as $holding) {
|
||||
$this->line('Refreshing ' . $holding->symbol);
|
||||
$this->line('Refreshing '.$holding->symbol);
|
||||
|
||||
MarketData::getMarketData($holding->symbol, $force);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Split;
|
||||
use App\Models\Holding;
|
||||
use App\Models\Split;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class RefreshSplitData extends Command
|
||||
@@ -42,14 +42,14 @@ class RefreshSplitData extends Command
|
||||
{
|
||||
$holdings = Holding::distinct();
|
||||
|
||||
if (!($this->option('force') ?? false)) {
|
||||
if (! ($this->option('force') ?? false)) {
|
||||
$holdings->where('quantity', '>', 0);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($holdings->get(['symbol']) as $holding) {
|
||||
$this->line('Refreshing ' . $holding->symbol);
|
||||
|
||||
$this->line('Refreshing '.$holding->symbol);
|
||||
|
||||
Split::refreshSplitData($holding->symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Console\Commands;
|
||||
use App\Models\Portfolio;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Console\PromptsForMissingInput;
|
||||
|
||||
use function Laravel\Prompts\search;
|
||||
|
||||
class SyncDailyChange extends Command implements PromptsForMissingInput
|
||||
@@ -61,14 +62,14 @@ class SyncDailyChange extends Command implements PromptsForMissingInput
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
|
||||
|
||||
$portfolio = Portfolio::findOrFail($this->argument('portfolio_id'));
|
||||
|
||||
$this->line('Syncing daily change history... This may take a moment.');
|
||||
|
||||
$portfolio->syncDailyChanges();
|
||||
|
||||
$this->line('Awesome! Daily change history for '. $portfolio->title .' has been completed.');
|
||||
$this->line('Awesome! Daily change history for '.$portfolio->title.' has been completed.');
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class SyncHoldingData extends Command
|
||||
}
|
||||
|
||||
foreach ($holdings->get() as $holding) {
|
||||
$this->line('Refreshing ' . $holding->symbol);
|
||||
$this->line('Refreshing '.$holding->symbol);
|
||||
|
||||
$holding->syncTransactionsAndDividends();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user