This commit is contained in:
hackerESQ
2025-01-27 20:04:03 -06:00
parent 32bf256c84
commit ea22c27710
13 changed files with 569 additions and 81 deletions
+9 -4
View File
@@ -13,10 +13,10 @@ class QuantityValidationRule implements ValidationRule
* @return void
*/
public function __construct(
protected Portfolio $portfolio,
protected string $symbol,
protected string $transactionType,
protected string $date
protected ?Portfolio $portfolio,
protected ?string $symbol,
protected ?string $transactionType,
protected ?string $date
) {
$this->portfolio = $portfolio;
$this->symbol = $symbol;
@@ -34,6 +34,11 @@ class QuantityValidationRule implements ValidationRule
*/
public function validate(string $attribute, mixed $value, \Closure $fail): void
{
if (is_null($this->portfolio) || is_null($this->symbol) || is_null($this->transactionType) || is_null($this->date)) {
//
$fail(__('The quantity must not be greater than the available quantity.'));
}
if ($this->transactionType == 'SELL') {
$purchase_qty = $this->portfolio->transactions()