Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
88.89% |
8 / 9 |
|
88.89% |
8 / 9 |
CRAP | |
0.00% |
0 / 1 |
| ProductionOrder | |
88.89% |
8 / 9 |
|
88.89% |
8 / 9 |
9.11 | |
0.00% |
0 / 1 |
| auditName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| auditLabel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| bom | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| consumptions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| outputs | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| branch | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sourceWarehouse | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| outputWarehouse | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| statusEnum | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use App\Enums\ProductionStatus; |
| 6 | use App\Support\Auditable; |
| 7 | use Illuminate\Database\Eloquent\Model; |
| 8 | |
| 9 | class ProductionOrder extends Model |
| 10 | { |
| 11 | use Auditable; |
| 12 | |
| 13 | protected $fillable = [ |
| 14 | 'number', 'bom_id', 'branch_id', 'source_warehouse_id', 'output_warehouse_id', 'planned_qty', 'actual_qty', 'status', 'note', |
| 15 | 'labor_cost', 'overhead_cost', 'unit_cost', 'started_at', 'completed_at', 'created_by', |
| 16 | ]; |
| 17 | |
| 18 | protected $casts = [ |
| 19 | 'planned_qty' => 'decimal:4', |
| 20 | 'actual_qty' => 'decimal:4', |
| 21 | 'labor_cost' => 'decimal:2', |
| 22 | 'overhead_cost' => 'decimal:2', |
| 23 | 'unit_cost' => 'decimal:4', |
| 24 | 'started_at' => 'datetime', |
| 25 | 'completed_at' => 'datetime', |
| 26 | ]; |
| 27 | |
| 28 | protected function auditName(): string |
| 29 | { |
| 30 | return 'production_order'; |
| 31 | } |
| 32 | |
| 33 | protected function auditLabel(): ?string |
| 34 | { |
| 35 | return $this->number; |
| 36 | } |
| 37 | |
| 38 | public function bom() |
| 39 | { |
| 40 | return $this->belongsTo(Bom::class); |
| 41 | } |
| 42 | |
| 43 | public function consumptions() |
| 44 | { |
| 45 | return $this->hasMany(ProductionConsumption::class); |
| 46 | } |
| 47 | |
| 48 | public function outputs() |
| 49 | { |
| 50 | return $this->hasMany(ProductionOutput::class); |
| 51 | } |
| 52 | |
| 53 | public function branch() |
| 54 | { |
| 55 | return $this->belongsTo(Branch::class); |
| 56 | } |
| 57 | |
| 58 | public function sourceWarehouse() |
| 59 | { |
| 60 | return $this->belongsTo(Warehouse::class, 'source_warehouse_id'); |
| 61 | } |
| 62 | |
| 63 | public function outputWarehouse() |
| 64 | { |
| 65 | return $this->belongsTo(Warehouse::class, 'output_warehouse_id'); |
| 66 | } |
| 67 | |
| 68 | public function statusEnum(): ProductionStatus |
| 69 | { |
| 70 | return ProductionStatus::fromStored($this->status); |
| 71 | } |
| 72 | } |