diff --git a/app/Exports/Sheets/TransactionsSheet.php b/app/Exports/Sheets/TransactionsSheet.php index 5773709..13bfd1c 100644 --- a/app/Exports/Sheets/TransactionsSheet.php +++ b/app/Exports/Sheets/TransactionsSheet.php @@ -29,8 +29,7 @@ class TransactionsSheet implements FromCollection, WithHeadings, WithTitle '52 Week Low', '52 Week High', 'Market Data Refresh Date', - 'Gain/Loss Dollars', - 'Owner ID' + 'Gain/Loss Dollars' ]; } diff --git a/app/Imports/BackupImport.php b/app/Imports/BackupImport.php index 6f7ea90..2b92723 100644 --- a/app/Imports/BackupImport.php +++ b/app/Imports/BackupImport.php @@ -20,11 +20,8 @@ class BackupImport implements WithMultipleSheets { return [ 'Portfolios' => new PortfoliosSheet, - 'Transactions' => new TransactionsSheet, - 'Market Data' => new MarketDataSheet, - 'Dividends' => new DividendsSheet, - 'Splits' => new SplitsSheet, - 'Daily Changes' => new DailyChangesSheet, + // 'Transactions' => new TransactionsSheet, + // 'Daily Changes' => new DailyChangesSheet, ]; } } diff --git a/app/Imports/Sheets/DividendsSheet.php b/app/Imports/Sheets/DividendsSheet.php deleted file mode 100644 index 7ad798a..0000000 --- a/app/Imports/Sheets/DividendsSheet.php +++ /dev/null @@ -1,29 +0,0 @@ -sortBy('date') as $row) { - - Dividend::updateOrCreate([ - 'symbol' => $row['symbol'], - 'date' => $row['date'], - ],[ - 'symbol' => $row['symbol'], - 'dividend_amount' => $row['amount'] ?? 0, - 'date' => $row['date'], - ]); - } - } -} diff --git a/app/Imports/Sheets/MarketDataSheet.php b/app/Imports/Sheets/MarketDataSheet.php deleted file mode 100644 index 98ffebe..0000000 --- a/app/Imports/Sheets/MarketDataSheet.php +++ /dev/null @@ -1,35 +0,0 @@ -sortBy('symbol') as $row) { - - MarketData::updateOrCreate( - [ - 'symbol' => $row['symbol'] - ], - [ - 'symbol' => $row['symbol'], - 'name' => $row['name'], - 'market_value' => $row['market_value'], - 'fifty_two_week_low' => $row['52_week_low'], - 'fifty_two_week_high' => $row['52_week_high'], - 'dividend_date' => $row['dividend_date'], - 'splits_synced_to_holdings_at' => $row['splits_synced_to_holdings_at'] - ] - ); - } - } -} diff --git a/app/Imports/Sheets/PortfoliosSheet.php b/app/Imports/Sheets/PortfoliosSheet.php index 258ea77..e71d2d5 100644 --- a/app/Imports/Sheets/PortfoliosSheet.php +++ b/app/Imports/Sheets/PortfoliosSheet.php @@ -14,18 +14,18 @@ class PortfoliosSheet implements ToCollection, WithHeadingRow, SkipsEmptyRows public function collection(Collection $portfolios) { - foreach ($portfolios->sortBy('date') as $row) { + foreach ($portfolios->sortBy('date') as $portfolio) { - Portfolio::myPortfolios() - ->where(['id' => $row['id']]) - ->orWhere(['title' => $row['title']]) - ->firstOr(function () use ($row) { + auth()->user()->portfolios() + ->where(['id' => $portfolio['id']]) + ->orWhere(['title' => $portfolio['title']]) + ->firstOr(function () use ($portfolio) { return Portfolio::make()->forceFill([ - 'id' => $row['id'] ?? null, - 'title' => $row['title'], - 'wishlist' => $row['wishlist'] ?? false, - 'notes' => $row['notes'], + 'id' => $portfolio['id'] ?? null, + 'title' => $portfolio['title'], + 'wishlist' => $portfolio['wishlist'] ?? false, + 'notes' => $portfolio['notes'], ])->save(); }); } diff --git a/app/Imports/Sheets/SplitsSheet.php b/app/Imports/Sheets/SplitsSheet.php deleted file mode 100644 index 3cc4d1f..0000000 --- a/app/Imports/Sheets/SplitsSheet.php +++ /dev/null @@ -1,29 +0,0 @@ -sortBy('date') as $row) { - - Split::updateOrCreate([ - 'symbol' => $row['symbol'], - 'date' => $row['date'], - ],[ - 'symbol' => $row['symbol'], - 'split_amount' => $row['split'], - 'date' => $row['date'], - ]); - } - } -} diff --git a/lang/en.json b/lang/en.json index c82de4b..9450d90 100644 --- a/lang/en.json +++ b/lang/en.json @@ -91,6 +91,7 @@ "Upload or recover your Investbrain portfolio and holdings.": "Upload or recover your Investbrain portfolio and holdings.", "Download all of your portfolios and transactions.": "Download all of your portfolios and transactions.", "Import / Export Data": "Import / Export Data", + "Successfully imported!": "Successfully imported!", "Select a file": "Select a file", "Download Export": "Download Export", "Your email address is unverified.": "Your email address is unverified.", diff --git a/lang/es.json b/lang/es.json index a142b3c..e3f4a71 100644 --- a/lang/es.json +++ b/lang/es.json @@ -91,6 +91,7 @@ "Upload or recover your Investbrain portfolio and holdings.": "Sube o recupera tu portafolio y participaciones de Investbrain.", "Download all of your portfolios and transactions.": "Descarga todos tus portafolios y transacciones.", "Import / Export Data": "Importar / Exportar Datos", + "Successfully imported!": "¡Importado con éxito!", "Select a file": "Seleccionar un archivo", "Download Export": "Descargar Exportación", "Your email address is unverified.": "Tu dirección de correo electrónico no está verificada.", diff --git a/resources/views/holding/show.blade.php b/resources/views/holding/show.blade.php index b2c8a25..f62da28 100644 --- a/resources/views/holding/show.blade.php +++ b/resources/views/holding/show.blade.php @@ -73,6 +73,15 @@ {{ Number::currency($holding->dividends_earned ?? 0) }}

+

+ {{ __('Market Data Age') }}: + {{ \Carbon\Carbon::parse($market_data->updated_at)->diffForHumans() }} +

+ + + + +

{{ __('52 week') }}: @@ -83,16 +92,7 @@ />

- -

- {{ __('Market Data Age') }}: - {{ \Carbon\Carbon::parse($market_data->updated_at)->diffForHumans() }} -

- -
- - - +

{{ __('Forward PE') }}: {{ $market_data->forward_pe }} diff --git a/resources/views/import-export.blade.php b/resources/views/import-export.blade.php index 0468cfb..e3735b5 100644 --- a/resources/views/import-export.blade.php +++ b/resources/views/import-export.blade.php @@ -1,37 +1,14 @@

- - - {{ __('Import') }} - - - - {{ __('Upload or recover your Investbrain portfolio and holdings.') }} - - - - - -
- @livewire('import-portfolios-field') -
- -
- - - - - {{ __('Import') }} - - -
+ @livewire('import-portfolios-field') +
- + {{ __('Export') }} @@ -42,11 +19,9 @@ -
@livewire('export-portfolios-button') -
diff --git a/resources/views/livewire/import-portfolios-field.blade.php b/resources/views/livewire/import-portfolios-field.blade.php index cffae08..9cb9743 100644 --- a/resources/views/livewire/import-portfolios-field.blade.php +++ b/resources/views/livewire/import-portfolios-field.blade.php @@ -3,6 +3,7 @@ use Livewire\WithFileUploads; use Livewire\Volt\Component; use Mary\Traits\Toast; +use App\Imports\BackupImport; new class extends Component { use Toast; @@ -12,12 +13,41 @@ new class extends Component { public $file; // methods - public function mount() + public function import() { - // + $import = (new BackupImport)->import($this->file); + + $this->success(__('Successfully imported!')); + + // Artisan::queue(RefreshHoldingData::class); } }; ?> - + + + {{ __('Import') }} + + + + {{ __('Upload or recover your Investbrain portfolio and holdings.') }} + + + + +
+ +
+ +
+ + + + + {{ __('Import') }} + + +
+ +