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
@@ -19,7 +19,7 @@ new class extends Component
// props
public ?Portfolio $portfolio;
public ?Transaction $transaction;
public ?Transaction $transaction = null;
public ?string $portfolio_id;
@@ -53,7 +53,7 @@ new class extends Component
'required',
'numeric',
'gt:0',
new QuantityValidationRule($this->portfolio, $this->symbol, $this->transaction_type, $this->date),
new QuantityValidationRule($this->portfolio, $this->symbol, $this->transaction_type, $this->date, $this->transaction),
],
'currency' => ['required', 'exists:currencies,currency'],
'cost_basis' => 'exclude_if:transaction_type,SELL|min:0|numeric',