fix: uses last dividend created date as start date instead of last dividend date

closes #26
This commit is contained in:
hackerESQ
2024-11-14 01:25:03 -06:00
parent 3040cbf49a
commit 1c63e2b856
2 changed files with 29 additions and 7 deletions
+22
View File
@@ -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);
}
}