wip
This commit is contained in:
@@ -2,12 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\Dividend;
|
|
||||||
use App\Models\Holding;
|
use App\Models\Holding;
|
||||||
use App\Models\MarketData;
|
use App\Models\Dividend;
|
||||||
use App\Models\Transaction;
|
use App\Models\Transaction;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Database\Query\Builder;
|
|
||||||
|
|
||||||
class RefreshHoldingData extends Command
|
class RefreshHoldingData extends Command
|
||||||
{
|
{
|
||||||
@@ -48,44 +46,7 @@ class RefreshHoldingData extends Command
|
|||||||
foreach ($holdings as $holding) {
|
foreach ($holdings as $holding) {
|
||||||
$this->line('Refreshing ' . $holding->symbol);
|
$this->line('Refreshing ' . $holding->symbol);
|
||||||
|
|
||||||
$query = Transaction::where([
|
$holding->sync();
|
||||||
'portfolio_id' => $holding->portfolio_id,
|
|
||||||
'symbol' => $holding->symbol,
|
|
||||||
])->selectRaw('SUM(CASE WHEN transaction_type = "BUY" THEN quantity ELSE 0 END) AS `qty_purchases`')
|
|
||||||
->selectRaw('SUM(CASE WHEN transaction_type = "SELL" THEN quantity ELSE 0 END) AS `qty_sales`')
|
|
||||||
->selectRaw('SUM(CASE WHEN transaction_type = "BUY" THEN (quantity * cost_basis) ELSE 0 END) AS `cost_basis`')
|
|
||||||
->selectRaw('SUM(CASE WHEN transaction_type = "SELL" THEN ((sale_price - cost_basis) * quantity) ELSE 0 END) AS `realized_gains`')
|
|
||||||
->first();
|
|
||||||
|
|
||||||
$total_quantity = $query->qty_purchases - $query->qty_sales;
|
|
||||||
$average_cost_basis = $query->qty_purchases > 0
|
|
||||||
? $query->cost_basis / $query->qty_purchases
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
// pull dividend data joined with holdings/transactions
|
|
||||||
$dividends = Dividend::where([
|
|
||||||
'dividends.symbol' => $holding->symbol,
|
|
||||||
])
|
|
||||||
->select(['holdings.portfolio_id', 'dividends.date', 'dividends.symbol', 'dividends.dividend_amount'])
|
|
||||||
->selectRaw('@purchased:=(SELECT coalesce(SUM(quantity),0) FROM transactions WHERE transactions.transaction_type = "BUY" AND transactions.symbol = dividends.symbol AND date(transactions.date) <= date(dividends.date) AND holdings.portfolio_id = transactions.portfolio_id ) AS `purchased`')
|
|
||||||
->selectRaw('@sold:=(SELECT coalesce(SUM(quantity),0) FROM transactions WHERE transactions.transaction_type = "SELL" AND transactions.symbol = dividends.symbol AND date(transactions.date) <= date(dividends.date) AND holdings.portfolio_id = transactions.portfolio_id ) AS `sold`')
|
|
||||||
->selectRaw('@owned:=(@purchased - @sold) AS `owned`')
|
|
||||||
->selectRaw('@dividends_received:=(@owned * dividends.dividend_amount) AS `dividends_received`')
|
|
||||||
->join('transactions', 'transactions.symbol', 'dividends.symbol')
|
|
||||||
->join('holdings', 'transactions.portfolio_id', 'holdings.portfolio_id')
|
|
||||||
->groupBy(['holdings.portfolio_id', 'dividends.date', 'dividends.symbol', 'dividends.dividend_amount'])
|
|
||||||
->get();
|
|
||||||
|
|
||||||
// update holding
|
|
||||||
$holding->fill([
|
|
||||||
'quantity' => $total_quantity,
|
|
||||||
'average_cost_basis' => $average_cost_basis,
|
|
||||||
'total_cost_basis' => $total_quantity * $average_cost_basis,
|
|
||||||
'realized_gain_dollars' => $query->realized_gains,
|
|
||||||
'dividends_earned' => $dividends->where('portfolio_id', $holding->portfolio_id)->sum('dividends_received')
|
|
||||||
]);
|
|
||||||
|
|
||||||
$holding->save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Exports\Sheets;
|
namespace App\Exports\Sheets;
|
||||||
|
|
||||||
use App\Models\Portfolio;
|
|
||||||
use App\Models\Transaction;
|
use App\Models\Transaction;
|
||||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Imports;
|
namespace App\Imports;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use App\Imports\Sheets\SplitsSheet;
|
use App\Imports\Sheets\SplitsSheet;
|
||||||
use App\Imports\Sheets\DividendsSheet;
|
use App\Imports\Sheets\DividendsSheet;
|
||||||
use App\Imports\Sheets\MarketDataSheet;
|
use App\Imports\Sheets\MarketDataSheet;
|
||||||
@@ -10,6 +11,7 @@ use Illuminate\Support\Facades\Artisan;
|
|||||||
use Maatwebsite\Excel\Events\AfterSheet;
|
use Maatwebsite\Excel\Events\AfterSheet;
|
||||||
use App\Imports\Sheets\DailyChangesSheet;
|
use App\Imports\Sheets\DailyChangesSheet;
|
||||||
use App\Imports\Sheets\TransactionsSheet;
|
use App\Imports\Sheets\TransactionsSheet;
|
||||||
|
use Maatwebsite\Excel\Events\BeforeSheet;
|
||||||
use Maatwebsite\Excel\Concerns\Importable;
|
use Maatwebsite\Excel\Concerns\Importable;
|
||||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||||
use App\Console\Commands\RefreshHoldingData;
|
use App\Console\Commands\RefreshHoldingData;
|
||||||
@@ -26,9 +28,9 @@ class BackupImport implements WithMultipleSheets, WithEvents
|
|||||||
public function registerEvents(): array
|
public function registerEvents(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
// BeforeSheet::class => DB::commit(),
|
||||||
// AfterSheet::class => Artisan::queue(RefreshHoldingData::class),
|
// AfterSheet::class => Artisan::queue(RefreshHoldingData::class),
|
||||||
AfterSheet::class => Artisan::call(RefreshHoldingData::class)
|
// AfterSheet::class => Artisan::call(RefreshHoldingData::class)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use Exception;
|
|||||||
use App\Models\DailyChange;
|
use App\Models\DailyChange;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||||
|
use App\Imports\ValidatesPortfolioPermissions;
|
||||||
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
|
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||||
@@ -13,20 +14,11 @@ use Maatwebsite\Excel\Concerns\WithChunkReading;
|
|||||||
|
|
||||||
class DailyChangesSheet implements ToCollection, WithHeadingRow, WithValidation, SkipsEmptyRows, WithChunkReading
|
class DailyChangesSheet implements ToCollection, WithHeadingRow, WithValidation, SkipsEmptyRows, WithChunkReading
|
||||||
{
|
{
|
||||||
|
use ValidatesPortfolioPermissions;
|
||||||
|
|
||||||
public function collection(Collection $dailyChanges)
|
public function collection(Collection $dailyChanges)
|
||||||
{
|
{
|
||||||
|
$this->validatePortfolioPermissions($dailyChanges);
|
||||||
$portfolios = auth()->user()->portfolios->pluck('id');
|
|
||||||
|
|
||||||
$dailyChanges->pluck('portfolio_id')->unique()->each(function($portfolio) use ($portfolios) {
|
|
||||||
|
|
||||||
if (!$portfolios->contains($portfolio)) {
|
|
||||||
|
|
||||||
throw new Exception('You do not have permission to access that portfolio.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
DailyChange::withoutEvents(function () use ($dailyChanges) {
|
|
||||||
|
|
||||||
foreach ($dailyChanges as $dailyChange) {
|
foreach ($dailyChanges as $dailyChange) {
|
||||||
|
|
||||||
@@ -44,13 +36,12 @@ class DailyChangesSheet implements ToCollection, WithHeadingRow, WithValidation,
|
|||||||
'annotation' => $dailyChange['annotation'],
|
'annotation' => $dailyChange['annotation'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'portfolio_id' => ['required'],
|
'portfolio_id' => ['required', 'exists:portfolios,id'],
|
||||||
'date' => ['required', 'date'],
|
'date' => ['required', 'date'],
|
||||||
'total_market_value' => ['sometimes', 'nullable', 'numeric'],
|
'total_market_value' => ['sometimes', 'nullable', 'numeric'],
|
||||||
'total_cost_basis' => ['sometimes', 'nullable', 'min:0', 'numeric'],
|
'total_cost_basis' => ['sometimes', 'nullable', 'min:0', 'numeric'],
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Imports\Sheets;
|
namespace App\Imports\Sheets;
|
||||||
|
|
||||||
use App\Models\Portfolio;
|
use App\Models\Portfolio;
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||||
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
|
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
|
||||||
@@ -14,24 +13,19 @@ class PortfoliosSheet implements ToCollection, WithValidation, WithHeadingRow, S
|
|||||||
{
|
{
|
||||||
public function collection(Collection $portfolios)
|
public function collection(Collection $portfolios)
|
||||||
{
|
{
|
||||||
Portfolio::withoutEvents(function () use ($portfolios) {
|
|
||||||
|
|
||||||
foreach ($portfolios as $portfolio) {
|
foreach ($portfolios as $portfolio) {
|
||||||
|
|
||||||
auth()->user()->portfolios()
|
Portfolio::unguard();
|
||||||
->where(['id' => $portfolio['portfolio_id']])
|
|
||||||
->orWhere(['title' => $portfolio['title']])
|
|
||||||
->firstOr(function () use ($portfolio) {
|
|
||||||
|
|
||||||
return Portfolio::make()->forceFill([
|
Portfolio::updateOrCreate([
|
||||||
|
'id' => $portfolio['portfolio_id']
|
||||||
|
], [
|
||||||
'id' => $portfolio['portfolio_id'] ?? null,
|
'id' => $portfolio['portfolio_id'] ?? null,
|
||||||
'title' => $portfolio['title'],
|
'title' => $portfolio['title'],
|
||||||
'wishlist' => $portfolio['wishlist'] ?? false,
|
'wishlist' => $portfolio['wishlist'] ?? false,
|
||||||
'notes' => $portfolio['notes'],
|
'notes' => $portfolio['notes'],
|
||||||
])->save();
|
]);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Imports\Sheets;
|
namespace App\Imports\Sheets;
|
||||||
|
|
||||||
use App\Models\Holding;
|
|
||||||
use App\Models\Transaction;
|
use App\Models\Transaction;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||||
|
use App\Imports\ValidatesPortfolioPermissions;
|
||||||
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
|
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||||
@@ -13,16 +13,20 @@ use Maatwebsite\Excel\Concerns\WithChunkReading;
|
|||||||
|
|
||||||
class TransactionsSheet implements ToCollection, WithHeadingRow, WithValidation, SkipsEmptyRows, WithChunkReading
|
class TransactionsSheet implements ToCollection, WithHeadingRow, WithValidation, SkipsEmptyRows, WithChunkReading
|
||||||
{
|
{
|
||||||
|
use ValidatesPortfolioPermissions;
|
||||||
|
|
||||||
public function collection(Collection $transactions)
|
public function collection(Collection $transactions)
|
||||||
{
|
{
|
||||||
|
$this->validatePortfolioPermissions($transactions);
|
||||||
|
|
||||||
Transaction::withoutEvents(function () use ($transactions) {
|
Transaction::withoutEvents(function () use ($transactions) {
|
||||||
|
|
||||||
foreach ($transactions->sortBy('date') as $transaction) {
|
foreach ($transactions->sortBy('date') as $transaction) {
|
||||||
|
|
||||||
$transaction = Transaction::where('id', $transaction['transaction_id'])
|
Transaction::where('id', $transaction['transaction_id'])
|
||||||
->firstOr(function () use ($transaction) {
|
->firstOr(function () use ($transaction) {
|
||||||
|
|
||||||
return Transaction::make()->forceFill([
|
$transaction = Transaction::make()->forceFill([
|
||||||
'id' => $transaction['transaction_id'],
|
'id' => $transaction['transaction_id'],
|
||||||
'symbol' => $transaction['symbol'],
|
'symbol' => $transaction['symbol'],
|
||||||
'portfolio_id' => $transaction['portfolio_id'],
|
'portfolio_id' => $transaction['portfolio_id'],
|
||||||
@@ -32,21 +36,16 @@ class TransactionsSheet implements ToCollection, WithHeadingRow, WithValidation,
|
|||||||
'sale_price' => $transaction['sale_price'],
|
'sale_price' => $transaction['sale_price'],
|
||||||
'split' => $transaction['split'] ?? null,
|
'split' => $transaction['split'] ?? null,
|
||||||
'date' => $transaction['date'],
|
'date' => $transaction['date'],
|
||||||
])->save();
|
|
||||||
});
|
|
||||||
|
|
||||||
Holding::firstOrCreate([
|
|
||||||
'symbol' => $transaction['symbol'],
|
|
||||||
'portfolio_id' => $transaction['portfolio_id'],
|
|
||||||
], [
|
|
||||||
'quantity' => 0,
|
|
||||||
'average_cost_basis' => 0,
|
|
||||||
'total_cost_basis' => 0,
|
|
||||||
'realized_gain_dollars' => 0,
|
|
||||||
'dividends_earned' => 0
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$transaction->save();
|
||||||
|
|
||||||
|
return $transaction;
|
||||||
|
})
|
||||||
|
->syncHolding();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Imports;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
trait ValidatesPortfolioPermissions {
|
||||||
|
|
||||||
|
public function validatePortfolioPermissions($collection)
|
||||||
|
{
|
||||||
|
$portfolios = auth()->user()->portfolios->pluck('id');
|
||||||
|
|
||||||
|
$collection->pluck('portfolio_id')->unique()->each(function($portfolio) use ($portfolios) {
|
||||||
|
|
||||||
|
if (!$portfolios->contains($portfolio)) {
|
||||||
|
|
||||||
|
throw new Exception('You do not have permission to access that portfolio.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -164,6 +164,49 @@ class Holding extends Model
|
|||||||
// ->selectRaw('COALESCE((@total_gain_dollars / @sum_total_cost_basis) * 100,0) AS total_gain_percent')
|
// ->selectRaw('COALESCE((@total_gain_dollars / @sum_total_cost_basis) * 100,0) AS total_gain_percent')
|
||||||
->join('market_data', 'market_data.symbol', 'holdings.symbol');
|
->join('market_data', 'market_data.symbol', 'holdings.symbol');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sync()
|
||||||
|
{
|
||||||
|
// pull existing transaction data
|
||||||
|
$query = Transaction::where([
|
||||||
|
'portfolio_id' => $this->portfolio_id,
|
||||||
|
'symbol' => $this->symbol,
|
||||||
|
])->selectRaw('SUM(CASE WHEN transaction_type = "BUY" THEN quantity ELSE 0 END) AS `qty_purchases`')
|
||||||
|
->selectRaw('SUM(CASE WHEN transaction_type = "SELL" THEN quantity ELSE 0 END) AS `qty_sales`')
|
||||||
|
->selectRaw('SUM(CASE WHEN transaction_type = "BUY" THEN (quantity * cost_basis) ELSE 0 END) AS `cost_basis`')
|
||||||
|
->selectRaw('SUM(CASE WHEN transaction_type = "SELL" THEN ((sale_price - cost_basis) * quantity) ELSE 0 END) AS `realized_gains`')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$total_quantity = $query->qty_purchases - $query->qty_sales;
|
||||||
|
$average_cost_basis = $query->qty_purchases > 0
|
||||||
|
? $query->cost_basis / $query->qty_purchases
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
// pull dividend data joined with holdings/transactions
|
||||||
|
$dividends = Dividend::where([
|
||||||
|
'dividends.symbol' => $this->symbol,
|
||||||
|
])
|
||||||
|
->select(['holdings.portfolio_id', 'dividends.date', 'dividends.symbol', 'dividends.dividend_amount'])
|
||||||
|
->selectRaw('@purchased:=(SELECT coalesce(SUM(quantity),0) FROM transactions WHERE transactions.transaction_type = "BUY" AND transactions.symbol = dividends.symbol AND date(transactions.date) <= date(dividends.date) AND holdings.portfolio_id = transactions.portfolio_id ) AS `purchased`')
|
||||||
|
->selectRaw('@sold:=(SELECT coalesce(SUM(quantity),0) FROM transactions WHERE transactions.transaction_type = "SELL" AND transactions.symbol = dividends.symbol AND date(transactions.date) <= date(dividends.date) AND holdings.portfolio_id = transactions.portfolio_id ) AS `sold`')
|
||||||
|
->selectRaw('@owned:=(@purchased - @sold) AS `owned`')
|
||||||
|
->selectRaw('@dividends_received:=(@owned * dividends.dividend_amount) AS `dividends_received`')
|
||||||
|
->join('transactions', 'transactions.symbol', 'dividends.symbol')
|
||||||
|
->join('holdings', 'transactions.portfolio_id', 'holdings.portfolio_id')
|
||||||
|
->groupBy(['holdings.portfolio_id', 'dividends.date', 'dividends.symbol', 'dividends.dividend_amount'])
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// update holding
|
||||||
|
$this->fill([
|
||||||
|
'quantity' => $total_quantity,
|
||||||
|
'average_cost_basis' => $average_cost_basis,
|
||||||
|
'total_cost_basis' => $total_quantity * $average_cost_basis,
|
||||||
|
'realized_gain_dollars' => $query->realized_gains,
|
||||||
|
'dividends_earned' => $dividends->where('portfolio_id', $this->portfolio_id)->sum('dividends_received')
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -46,6 +46,10 @@ class Transaction extends Model
|
|||||||
|
|
||||||
$transaction->syncHolding();
|
$transaction->syncHolding();
|
||||||
|
|
||||||
|
$transaction->refreshMarketData();
|
||||||
|
|
||||||
|
$transaction->syncDividendsToHolding();
|
||||||
|
|
||||||
cache()->tags(['metrics', auth()->user()->id])->flush();
|
cache()->tags(['metrics', auth()->user()->id])->flush();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -174,33 +178,6 @@ class Transaction extends Model
|
|||||||
'total_cost_basis' => $this->quantity * $this->cost_basis,
|
'total_cost_basis' => $this->quantity * $this->cost_basis,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// pull existing transaction data
|
$holding->sync();
|
||||||
$query = self::where([
|
|
||||||
'portfolio_id' => $this->portfolio_id,
|
|
||||||
'symbol' => $this->symbol,
|
|
||||||
])->selectRaw('SUM(CASE WHEN transaction_type = "BUY" THEN quantity ELSE 0 END) AS `qty_purchases`')
|
|
||||||
->selectRaw('SUM(CASE WHEN transaction_type = "SELL" THEN quantity ELSE 0 END) AS `qty_sales`')
|
|
||||||
->selectRaw('SUM(CASE WHEN transaction_type = "BUY" THEN (quantity * cost_basis) ELSE 0 END) AS `cost_basis`')
|
|
||||||
->selectRaw('SUM(CASE WHEN transaction_type = "SELL" THEN ((sale_price - cost_basis) * quantity) ELSE 0 END) AS `realized_gains`')
|
|
||||||
->first();
|
|
||||||
|
|
||||||
$total_quantity = $query->qty_purchases - $query->qty_sales;
|
|
||||||
$average_cost_basis = $query->qty_purchases > 0
|
|
||||||
? $query->cost_basis / $query->qty_purchases
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
// update holding
|
|
||||||
$holding->fill([
|
|
||||||
'quantity' => $total_quantity,
|
|
||||||
'average_cost_basis' => $average_cost_basis,
|
|
||||||
'total_cost_basis' => $total_quantity * $average_cost_basis,
|
|
||||||
'realized_gain_dollars' => $query->realized_gains,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$holding->save();
|
|
||||||
|
|
||||||
$this->refreshMarketData();
|
|
||||||
|
|
||||||
$this->syncDividendsToHolding();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,8 @@
|
|||||||
"Cancel": "Cancel",
|
"Cancel": "Cancel",
|
||||||
"Save": "Save",
|
"Save": "Save",
|
||||||
"Close": "Close",
|
"Close": "Close",
|
||||||
|
"or": "or",
|
||||||
|
"and": "and",
|
||||||
|
|
||||||
"Hang on! You're doing that too much.": "Hang on! You're doing that too much.",
|
"Hang on! You're doing that too much.": "Hang on! You're doing that too much.",
|
||||||
"Delete Account": "Delete Account",
|
"Delete Account": "Delete Account",
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
"Cancel": "Cancelar",
|
"Cancel": "Cancelar",
|
||||||
"Save": "Guardar",
|
"Save": "Guardar",
|
||||||
"Close": "Cerrar",
|
"Close": "Cerrar",
|
||||||
|
"or": "o",
|
||||||
|
"and": "y",
|
||||||
|
|
||||||
"Hang on! You're doing that too much.": "¡Por favor espere un momento!",
|
"Hang on! You're doing that too much.": "¡Por favor espere un momento!",
|
||||||
"Delete Account": "Eliminar Cuenta",
|
"Delete Account": "Eliminar Cuenta",
|
||||||
|
|||||||
@@ -38,7 +38,11 @@
|
|||||||
|
|
||||||
@if ($user->portfolios->isEmpty())
|
@if ($user->portfolios->isEmpty())
|
||||||
<div class="flex justify-center items-center h-[100px] mb-8">
|
<div class="flex justify-center items-center h-[100px] mb-8">
|
||||||
<x-button label="{{ __('Create your first portfolio!') }}" class="btn-primary" link="{{ route('portfolio.create') }}" />
|
|
||||||
|
<x-button label="{{ __('Import / Export Data') }}" class="btn-primary btn-outline mr-6" link="{{ route('import-export') }}" />
|
||||||
|
<span>{{ __('or') }}</span>
|
||||||
|
<x-button label="{{ __('Create your first portfolio!') }}" class="btn-primary ml-6" link="{{ route('portfolio.create') }}" />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ new class extends Component {
|
|||||||
public function holdings(): Collection
|
public function holdings(): Collection
|
||||||
{
|
{
|
||||||
|
|
||||||
// dd(Holding::toSql());
|
|
||||||
$holdings = $this->portfolio
|
$holdings = $this->portfolio
|
||||||
->holdings()
|
->holdings()
|
||||||
->withCount(['transactions as num_transactions' => function($query) {
|
->withCount(['transactions as num_transactions' => function($query) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ new class extends Component {
|
|||||||
return $this->error($e->getMessage());
|
return $this->error($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->success(__('Successfully imported!'));
|
$this->success(__('Successfully imported!'), redirectTo: route('dashboard'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function downloadTemplate()
|
public function downloadTemplate()
|
||||||
@@ -59,7 +59,11 @@ new class extends Component {
|
|||||||
|
|
||||||
<x-slot name="actions">
|
<x-slot name="actions">
|
||||||
|
|
||||||
<x-button type="submit">
|
<x-forms.action-message class="me-3" on="saved">
|
||||||
|
{{ __('Saved.') }}
|
||||||
|
</x-forms.action-message>
|
||||||
|
|
||||||
|
<x-button type="submit" spinner="import">
|
||||||
{{ __('Import') }}
|
{{ __('Import') }}
|
||||||
</x-button>
|
</x-button>
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|||||||
Reference in New Issue
Block a user