add force option for dividends and splits

This commit is contained in:
hackerESQ
2024-09-19 21:25:56 -05:00
parent 80b25115a3
commit e69a8fa4e6
2 changed files with 15 additions and 6 deletions
+8 -3
View File
@@ -13,7 +13,8 @@ class RefreshDividendData extends Command
*
* @var string
*/
protected $signature = 'refresh:dividend-data';
protected $signature = 'refresh:dividend-data
{--force : Refresh all holdings}';
/**
* The console command description.
@@ -39,9 +40,13 @@ class RefreshDividendData extends Command
*/
public function handle()
{
$holdings = Holding::where('quantity', '>', 0)->distinct()->get(['symbol']);
$holdings = Holding::distinct();
foreach ($holdings as $holding) {
if (!($this->option('force') ?? false)) {
$holdings->where('quantity', '>', 0);
}
foreach ($holdings->get(['symbol']) as $holding) {
$this->line('Refreshing ' . $holding->symbol);
Dividend::refreshDividendData($holding->symbol);
+7 -3
View File
@@ -14,7 +14,7 @@ class RefreshSplitData extends Command
* @var string
*/
protected $signature = 'refresh:split-data
{--force= : Don\'t ask to confirm.}';
{--force : Refresh all holdings}';
/**
* The console command description.
@@ -40,9 +40,13 @@ class RefreshSplitData extends Command
*/
public function handle()
{
$holdings = Holding::where('quantity', '>', 0)->distinct()->get(['symbol']);
$holdings = Holding::distinct();
foreach ($holdings as $holding) {
if (!($this->option('force') ?? false)) {
$holdings->where('quantity', '>', 0);
}
foreach ($holdings->get(['symbol']) as $holding) {
$this->line('Refreshing ' . $holding->symbol);
Split::refreshSplitData($holding->symbol);