Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| StockOutputReleaseForBillingService | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
2.03 | |
0.00% |
0 / 1 |
| release | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
2.03 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\StockIO\Services; |
| 4 | |
| 5 | use App\Events\ServiceProcessed; |
| 6 | use App\Models\StockIO\StockIO; |
| 7 | use App\Models\User; |
| 8 | use Domain\StockIO\Enums\StockStatusEnum; |
| 9 | use Domain\StockIO\Exceptions\StockStatusException; |
| 10 | |
| 11 | readonly class StockOutputReleaseForBillingService |
| 12 | { |
| 13 | /** |
| 14 | * @param StockIO $stockIO |
| 15 | * @param User $user |
| 16 | * @return void |
| 17 | */ |
| 18 | public function release(StockIO $stockIO, User $user): void |
| 19 | { |
| 20 | if (!$stockIO->isSeparated()) { |
| 21 | throw new StockStatusException(__('Output is not in separated status.')); |
| 22 | } |
| 23 | $stockIO->setAttribute('status', StockStatusEnum::RELEASED_FOR_BILLING->value); |
| 24 | $stockIO->save(); |
| 25 | |
| 26 | ServiceProcessed::dispatch(self::class, $user); |
| 27 | } |
| 28 | } |