fix: quantity validation should not count current transaction

This commit is contained in:
hackerESQ
2025-08-29 15:47:18 -05:00
parent afcafa6031
commit a0bd776abb
6 changed files with 61 additions and 8 deletions
+4 -2
View File
@@ -122,19 +122,21 @@ class TransactionFactory extends Factory
]);
}
public function buy(): static
public function buy($quantity = 1): static
{
return $this->state(fn (array $attributes) => [
'transaction_type' => 'BUY',
'quantity' => $quantity,
'cost_basis' => $this->faker->randomFloat(2, 10, 500),
'sale_price' => null,
]);
}
public function sell(): static
public function sell($quantity = 1): static
{
return $this->state(fn (array $attributes) => [
'transaction_type' => 'SELL',
'quantity' => $quantity,
'sale_price' => $this->faker->randomFloat(2, 10, 500),
'cost_basis' => null,
]);