Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
80.00% covered (warning)
80.00%
4 / 5
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
StockOutputReleaseForBillingService
80.00% covered (warning)
80.00%
4 / 5
0.00% covered (danger)
0.00%
0 / 1
2.03
0.00% covered (danger)
0.00%
0 / 1
 release
80.00% covered (warning)
80.00%
4 / 5
0.00% covered (danger)
0.00%
0 / 1
2.03
1<?php
2
3namespace Domain\StockIO\Services;
4
5use App\Events\ServiceProcessed;
6use App\Models\StockIO\StockIO;
7use App\Models\User;
8use Domain\StockIO\Enums\StockStatusEnum;
9use Domain\StockIO\Exceptions\StockStatusException;
10
11readonly 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}