Theme fixes, logo updated, reduce duplication of components
And many more updates
This commit is contained in:
@@ -125,10 +125,10 @@ class Holding extends Model
|
||||
return $query->where('symbol', $symbol);
|
||||
}
|
||||
|
||||
public function refreshDividends()
|
||||
{
|
||||
return Dividend::getDividendData($this->attributes['symbol']);
|
||||
}
|
||||
// public function refreshDividends()
|
||||
// {
|
||||
// return Dividend::getDividendData($this->attributes['symbol']);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -44,21 +44,25 @@ class MarketData extends Model
|
||||
|
||||
public static function getMarketData($symbol)
|
||||
{
|
||||
$market_data = self::firstOrNew(['symbol' => $symbol]);
|
||||
$market_data = self::firstOrNew([
|
||||
'symbol' => $symbol
|
||||
]);
|
||||
|
||||
// check if new or stale
|
||||
if (!$market_data->exists || now()->diffInMinutes($market_data->updated_at) >= config('market_data.refresh')) {
|
||||
|
||||
// get quote
|
||||
$quote = app(MarketDataInterface::class)->quote($symbol);
|
||||
// $quote = app(MarketDataInterface::class)->quote($symbol);
|
||||
|
||||
// fill data
|
||||
$market_data->fill($quote->toArray());
|
||||
// $market_data->fill($quote->toArray());
|
||||
|
||||
// save with timestamps updated
|
||||
$market_data->touch();
|
||||
|
||||
}
|
||||
|
||||
// save with timestamps updated
|
||||
$market_data->touch();
|
||||
|
||||
return $market_data;
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -45,14 +45,14 @@ class Transaction extends Model
|
||||
|
||||
$transaction->syncHolding();
|
||||
|
||||
cache()->forget('portfolio-metrics-' . $transaction->portfolio_id);
|
||||
cache()->tags(['metrics', auth()->user()->id])->flush();
|
||||
});
|
||||
|
||||
static::deleted(function ($transaction) {
|
||||
|
||||
$transaction->syncHolding();
|
||||
|
||||
cache()->forget('portfolio-metrics-' . $transaction->portfolio_id);
|
||||
cache()->tags(['metrics', auth()->user()->id])->flush();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,15 +108,15 @@ class Transaction extends Model
|
||||
return MarketData::getMarketData($this->attributes['symbol']);
|
||||
}
|
||||
|
||||
public function syncDividendsToHolding()
|
||||
{
|
||||
return Dividend::syncHoldings(['symbol' => $this->attributes['symbol']]);
|
||||
}
|
||||
// public function syncDividendsToHolding()
|
||||
// {
|
||||
// return Dividend::syncHoldings(['symbol' => $this->attributes['symbol']]);
|
||||
// }
|
||||
|
||||
public function refreshDividends()
|
||||
{
|
||||
return Dividend::getDividendData($this->attributes['symbol']);
|
||||
}
|
||||
// public function refreshDividends()
|
||||
// {
|
||||
// return Dividend::getDividendData($this->attributes['symbol']);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Writes average cost basis to a sale transaction
|
||||
@@ -181,9 +181,9 @@ class Transaction extends Model
|
||||
$holding->save();
|
||||
|
||||
// load market data while we're here
|
||||
// $this->refreshMarketData();
|
||||
$this->refreshMarketData();
|
||||
|
||||
// sync dividends to holding
|
||||
// // sync dividends to holding
|
||||
// $this->syncDividendsToHolding();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user