adds dividend re-investment feature
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
{{ $attributes->merge(['class' => 'bg-slate-100 dark:bg-base-200 rounded-lg']) }}
|
||||
>
|
||||
|
||||
<h2 class="text-xl mb-2"> {{ $title }} </h2>
|
||||
<h2 class="text-xl mb-2 flex items-center truncate"> {{ $title }} </h2>
|
||||
|
||||
{{ $slot }}
|
||||
</x-card>
|
||||
@@ -33,10 +33,10 @@
|
||||
<div class="mt-6 grid md:grid-cols-9 gap-5">
|
||||
|
||||
<x-ib-card class="md:col-span-5">
|
||||
<x-slot:title class="pb-2">
|
||||
<x-slot:title>
|
||||
|
||||
{{ $holding->market_data->symbol }}
|
||||
<span class="text-sm"> {{ $holding->market_data->name }} </span>
|
||||
<span class="text-sm ml-2"> {{ $holding->market_data->name }} </span>
|
||||
</x-slot:title>
|
||||
|
||||
@livewire('holding-market-data', ['holding' => $holding])
|
||||
@@ -100,15 +100,27 @@
|
||||
|
||||
</x-ib-card>
|
||||
|
||||
<x-ib-card title="{{ __('Dividends') }}" class="md:col-span-3">
|
||||
<x-ib-card class="md:col-span-3">
|
||||
|
||||
<x-slot:title>
|
||||
{{ __('Dividends') }}
|
||||
|
||||
<x-ib-flex-spacer/>
|
||||
|
||||
<x-button
|
||||
title="{{ __('Dividend options') }}"
|
||||
icon="o-ellipsis-vertical"
|
||||
class="btn-circle btn-ghost btn-sm text-secondary"
|
||||
@click="$dispatch('toggle-dividend-options')"
|
||||
/>
|
||||
</x-slot:title>
|
||||
|
||||
<x-ib-modal
|
||||
key="dividend-options"
|
||||
title="{{ __('Dividend options') }}"
|
||||
>
|
||||
@livewire('manage-transaction-form', [
|
||||
'portfolio' => $portfolio,
|
||||
'symbol' => $holding->market_data->symbol,
|
||||
@livewire('holding-dividend-options-form', [
|
||||
'holding' => $holding
|
||||
])
|
||||
|
||||
</x-ib-modal>
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Holding;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Attributes\{Computed};
|
||||
use Livewire\Volt\Component;
|
||||
use Mary\Traits\Toast;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
new class extends Component {
|
||||
use Toast;
|
||||
|
||||
// props
|
||||
public Holding $holding;
|
||||
|
||||
public Bool $reinvest_dividends = false;
|
||||
|
||||
// methods
|
||||
public function rules()
|
||||
{
|
||||
|
||||
return [
|
||||
'reinvest_dividends' => ['required', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
$this->reinvest_dividends = $this->holding?->reinvest_dividends ?? false;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->holding->update($this->validate());
|
||||
|
||||
$this->success(__('Dividend options saved'));
|
||||
|
||||
$this->dispatch('toggle-dividend-options');
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div class="" x-data="{ }">
|
||||
<x-ib-form wire:submit="save" class="">
|
||||
|
||||
<x-toggle
|
||||
label="{{ __('Reinvest dividends') }}"
|
||||
wire:model="reinvest_dividends"
|
||||
right
|
||||
hint="{{ __('Automatically generate buy transactions for any dividends earned.') }}"
|
||||
/>
|
||||
|
||||
<x-slot:actions>
|
||||
|
||||
<x-button
|
||||
label="{{ __('Save') }}"
|
||||
type="submit"
|
||||
icon="o-paper-airplane"
|
||||
class="btn-primary"
|
||||
spinner="save"
|
||||
/>
|
||||
</x-slot:actions>
|
||||
</x-ib-form>
|
||||
|
||||
</div>
|
||||
@@ -89,7 +89,7 @@ new class extends Component {
|
||||
@if (!$hideCancel)
|
||||
<x-button label="{{ __('Cancel') }}" link="/dashboard" />
|
||||
@endif
|
||||
<x-button label="{{ $portfolio ? 'Update' : 'Create' }}" type="submit" icon="o-paper-airplane" class="btn-primary" spinner="save" />
|
||||
<x-button label="{{ $portfolio ? __('Update') : __('Create') }}" type="submit" icon="o-paper-airplane" class="btn-primary" spinner="save" />
|
||||
</x-slot:actions>
|
||||
</x-ib-form>
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ new class extends Component {
|
||||
@endif
|
||||
|
||||
<x-button
|
||||
label="{{ $transaction ? 'Update' : 'Create' }}"
|
||||
label="{{ $transaction ? __('Update') : __('Create') }}"
|
||||
type="submit"
|
||||
icon="o-paper-airplane"
|
||||
class="btn-primary"
|
||||
|
||||
@@ -88,7 +88,7 @@ new class extends Component {
|
||||
{{ $row->date->format('M d, Y') }}
|
||||
@endscope
|
||||
@scope('cell_split', $row)
|
||||
{{ $row->split ? 'Yes' : '' }}
|
||||
{{ $row->split ? __('Yes') : '' }}
|
||||
@endscope
|
||||
@scope('cell_transaction_type', $row)
|
||||
<x-badge
|
||||
|
||||
Reference in New Issue
Block a user