wip import backup
This commit is contained in:
@@ -29,8 +29,7 @@ class TransactionsSheet implements FromCollection, WithHeadings, WithTitle
|
|||||||
'52 Week Low',
|
'52 Week Low',
|
||||||
'52 Week High',
|
'52 Week High',
|
||||||
'Market Data Refresh Date',
|
'Market Data Refresh Date',
|
||||||
'Gain/Loss Dollars',
|
'Gain/Loss Dollars'
|
||||||
'Owner ID'
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,8 @@ class BackupImport implements WithMultipleSheets
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'Portfolios' => new PortfoliosSheet,
|
'Portfolios' => new PortfoliosSheet,
|
||||||
'Transactions' => new TransactionsSheet,
|
// 'Transactions' => new TransactionsSheet,
|
||||||
'Market Data' => new MarketDataSheet,
|
// 'Daily Changes' => new DailyChangesSheet,
|
||||||
'Dividends' => new DividendsSheet,
|
|
||||||
'Splits' => new SplitsSheet,
|
|
||||||
'Daily Changes' => new DailyChangesSheet,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Imports\Sheets;
|
|
||||||
|
|
||||||
use App\Models\Dividend;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
|
||||||
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
|
|
||||||
class DividendsSheet implements ToCollection, WithHeadingRow, SkipsEmptyRows
|
|
||||||
{
|
|
||||||
// use Importable;
|
|
||||||
|
|
||||||
public function collection(Collection $dividend)
|
|
||||||
{
|
|
||||||
foreach ($dividend->sortBy('date') as $row) {
|
|
||||||
|
|
||||||
Dividend::updateOrCreate([
|
|
||||||
'symbol' => $row['symbol'],
|
|
||||||
'date' => $row['date'],
|
|
||||||
],[
|
|
||||||
'symbol' => $row['symbol'],
|
|
||||||
'dividend_amount' => $row['amount'] ?? 0,
|
|
||||||
'date' => $row['date'],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Imports\Sheets;
|
|
||||||
|
|
||||||
use App\Models\MarketData;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
|
||||||
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
|
|
||||||
class MarketDataSheet implements ToCollection, WithHeadingRow, SkipsEmptyRows
|
|
||||||
{
|
|
||||||
// use Importable;
|
|
||||||
|
|
||||||
public function collection(Collection $market_data)
|
|
||||||
{
|
|
||||||
foreach ($market_data->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']
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,18 +14,18 @@ class PortfoliosSheet implements ToCollection, WithHeadingRow, SkipsEmptyRows
|
|||||||
|
|
||||||
public function collection(Collection $portfolios)
|
public function collection(Collection $portfolios)
|
||||||
{
|
{
|
||||||
foreach ($portfolios->sortBy('date') as $row) {
|
foreach ($portfolios->sortBy('date') as $portfolio) {
|
||||||
|
|
||||||
Portfolio::myPortfolios()
|
auth()->user()->portfolios()
|
||||||
->where(['id' => $row['id']])
|
->where(['id' => $portfolio['id']])
|
||||||
->orWhere(['title' => $row['title']])
|
->orWhere(['title' => $portfolio['title']])
|
||||||
->firstOr(function () use ($row) {
|
->firstOr(function () use ($portfolio) {
|
||||||
|
|
||||||
return Portfolio::make()->forceFill([
|
return Portfolio::make()->forceFill([
|
||||||
'id' => $row['id'] ?? null,
|
'id' => $portfolio['id'] ?? null,
|
||||||
'title' => $row['title'],
|
'title' => $portfolio['title'],
|
||||||
'wishlist' => $row['wishlist'] ?? false,
|
'wishlist' => $portfolio['wishlist'] ?? false,
|
||||||
'notes' => $row['notes'],
|
'notes' => $portfolio['notes'],
|
||||||
])->save();
|
])->save();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Imports\Sheets;
|
|
||||||
|
|
||||||
use App\Models\Split;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
|
||||||
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
|
|
||||||
class SplitsSheet implements ToCollection, WithHeadingRow, SkipsEmptyRows
|
|
||||||
{
|
|
||||||
// use Importable;
|
|
||||||
|
|
||||||
public function collection(Collection $dividend)
|
|
||||||
{
|
|
||||||
foreach ($dividend->sortBy('date') as $row) {
|
|
||||||
|
|
||||||
Split::updateOrCreate([
|
|
||||||
'symbol' => $row['symbol'],
|
|
||||||
'date' => $row['date'],
|
|
||||||
],[
|
|
||||||
'symbol' => $row['symbol'],
|
|
||||||
'split_amount' => $row['split'],
|
|
||||||
'date' => $row['date'],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -91,6 +91,7 @@
|
|||||||
"Upload or recover your Investbrain portfolio and holdings.": "Upload or recover your Investbrain portfolio and holdings.",
|
"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.",
|
"Download all of your portfolios and transactions.": "Download all of your portfolios and transactions.",
|
||||||
"Import / Export Data": "Import / Export Data",
|
"Import / Export Data": "Import / Export Data",
|
||||||
|
"Successfully imported!": "Successfully imported!",
|
||||||
"Select a file": "Select a file",
|
"Select a file": "Select a file",
|
||||||
"Download Export": "Download Export",
|
"Download Export": "Download Export",
|
||||||
"Your email address is unverified.": "Your email address is unverified.",
|
"Your email address is unverified.": "Your email address is unverified.",
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
"Upload or recover your Investbrain portfolio and holdings.": "Sube o recupera tu portafolio y participaciones de Investbrain.",
|
"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.",
|
"Download all of your portfolios and transactions.": "Descarga todos tus portafolios y transacciones.",
|
||||||
"Import / Export Data": "Importar / Exportar Datos",
|
"Import / Export Data": "Importar / Exportar Datos",
|
||||||
|
"Successfully imported!": "¡Importado con éxito!",
|
||||||
"Select a file": "Seleccionar un archivo",
|
"Select a file": "Seleccionar un archivo",
|
||||||
"Download Export": "Descargar Exportación",
|
"Download Export": "Descargar Exportación",
|
||||||
"Your email address is unverified.": "Tu dirección de correo electrónico no está verificada.",
|
"Your email address is unverified.": "Tu dirección de correo electrónico no está verificada.",
|
||||||
|
|||||||
@@ -73,6 +73,15 @@
|
|||||||
{{ Number::currency($holding->dividends_earned ?? 0) }}
|
{{ Number::currency($holding->dividends_earned ?? 0) }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p class="pt-2 text-sm">
|
||||||
|
{{ __('Market Data Age') }}:
|
||||||
|
{{ \Carbon\Carbon::parse($market_data->updated_at)->diffForHumans() }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</x-ib-card>
|
||||||
|
|
||||||
|
<x-ib-card title="{{ __('Fundamentals') }}" class="md:col-span-4">
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<span class="font-bold">{{ __('52 week') }}: </span>
|
<span class="font-bold">{{ __('52 week') }}: </span>
|
||||||
|
|
||||||
@@ -84,15 +93,6 @@
|
|||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="pt-2 text-sm">
|
|
||||||
{{ __('Market Data Age') }}:
|
|
||||||
{{ \Carbon\Carbon::parse($market_data->updated_at)->diffForHumans() }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</x-ib-card>
|
|
||||||
|
|
||||||
<x-ib-card title="{{ __('Fundamentals') }}" class="md:col-span-4">
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<span class="font-bold">{{ __('Forward PE') }}: </span>
|
<span class="font-bold">{{ __('Forward PE') }}: </span>
|
||||||
{{ $market_data->forward_pe }}
|
{{ $market_data->forward_pe }}
|
||||||
|
|||||||
@@ -1,37 +1,14 @@
|
|||||||
<x-app-layout>
|
<x-app-layout>
|
||||||
|
|
||||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||||
<x-forms.form-section submit="updateProfileInformation">
|
|
||||||
<x-slot name="title">
|
|
||||||
{{ __('Import') }}
|
|
||||||
</x-slot>
|
|
||||||
|
|
||||||
<x-slot name="description">
|
|
||||||
{{ __('Upload or recover your Investbrain portfolio and holdings.') }}
|
|
||||||
</x-slot>
|
|
||||||
|
|
||||||
<x-slot name="form">
|
|
||||||
|
|
||||||
<!-- Name -->
|
|
||||||
<div class="col-span-6 sm:col-span-4">
|
|
||||||
@livewire('import-portfolios-field')
|
@livewire('import-portfolios-field')
|
||||||
</div>
|
|
||||||
|
|
||||||
</x-slot>
|
|
||||||
|
|
||||||
<x-slot name="actions">
|
|
||||||
|
|
||||||
<x-button type="submit">
|
|
||||||
{{ __('Import') }}
|
|
||||||
</x-button>
|
|
||||||
</x-slot>
|
|
||||||
</x-forms.form-section>
|
|
||||||
|
|
||||||
<x-section-border />
|
<x-section-border />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||||
<x-forms.action-section submit="updateProfileInformation">
|
<x-forms.action-section>
|
||||||
<x-slot name="title">
|
<x-slot name="title">
|
||||||
{{ __('Export') }}
|
{{ __('Export') }}
|
||||||
</x-slot>
|
</x-slot>
|
||||||
@@ -42,11 +19,9 @@
|
|||||||
|
|
||||||
<x-slot name="content">
|
<x-slot name="content">
|
||||||
|
|
||||||
<!-- Name -->
|
|
||||||
<div class="col-span-6 sm:col-span-4">
|
<div class="col-span-6 sm:col-span-4">
|
||||||
@livewire('export-portfolios-button')
|
@livewire('export-portfolios-button')
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
use Livewire\WithFileUploads;
|
use Livewire\WithFileUploads;
|
||||||
use Livewire\Volt\Component;
|
use Livewire\Volt\Component;
|
||||||
use Mary\Traits\Toast;
|
use Mary\Traits\Toast;
|
||||||
|
use App\Imports\BackupImport;
|
||||||
|
|
||||||
new class extends Component {
|
new class extends Component {
|
||||||
use Toast;
|
use Toast;
|
||||||
@@ -12,12 +13,41 @@ new class extends Component {
|
|||||||
public $file;
|
public $file;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public function mount()
|
public function import()
|
||||||
{
|
{
|
||||||
|
|
||||||
//
|
$import = (new BackupImport)->import($this->file);
|
||||||
|
|
||||||
|
$this->success(__('Successfully imported!'));
|
||||||
|
|
||||||
|
// Artisan::queue(RefreshHoldingData::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; ?>
|
}; ?>
|
||||||
|
|
||||||
<x-file wire:model="file" label="{{ __('Select a file') }}" hint="" accept="application/pdf" required />
|
<x-forms.form-section submit="import">
|
||||||
|
<x-slot name="title">
|
||||||
|
{{ __('Import') }}
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<x-slot name="description">
|
||||||
|
{{ __('Upload or recover your Investbrain portfolio and holdings.') }}
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<x-slot name="form">
|
||||||
|
|
||||||
|
<div class="col-span-6 sm:col-span-4">
|
||||||
|
<x-file wire:model="file" label="{{ __('Select a file') }}" hint="" accept=".xlsx" required />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<x-slot name="actions">
|
||||||
|
|
||||||
|
<x-button type="submit">
|
||||||
|
{{ __('Import') }}
|
||||||
|
</x-button>
|
||||||
|
</x-slot>
|
||||||
|
</x-forms.form-section>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user