fix: uses last dividend created date as start date instead of last dividend date
closes #26
This commit is contained in:
@@ -61,4 +61,26 @@ class DividendsTest extends TestCase
|
||||
$this->assertCount(3, $transactions);
|
||||
$this->assertEqualsWithDelta(4.95, $dividendsReinvested * $market_data->market_value, 0.01);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function test_do_not_duplicate_recent_dividends(): void
|
||||
{
|
||||
$this->actingAs($user = User::factory()->create());
|
||||
|
||||
$portfolio = Portfolio::factory()->create();
|
||||
Transaction::factory()->buy()->yearsAgo()->portfolio($portfolio->id)->symbol('ACME')->create();
|
||||
|
||||
$holding = Holding::query()->portfolio($portfolio->id)->symbol('ACME')->first();
|
||||
|
||||
Dividend::create([
|
||||
'symbol' => 'ACME',
|
||||
'date' => now()->subDay(2),
|
||||
'dividend_amount' => .01
|
||||
]);
|
||||
|
||||
Dividend::refreshDividendData('ACME');
|
||||
|
||||
$this->assertCount(1, $holding->dividends);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user