Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
66.67% covered (warning)
66.67%
2 / 3
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
StockMovement
66.67% covered (warning)
66.67%
2 / 3
66.67% covered (warning)
66.67%
2 / 3
3.33
0.00% covered (danger)
0.00%
0 / 1
 product
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 reference
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 warehouse
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Models;
4
5use App\Models\admin\Product;
6use Illuminate\Database\Eloquent\Model;
7
8/**
9 * §5.4's general stock ledger — only Manufacturing writes to it as of
10 * Phase 9 (production_in / production_out). Retrofitting the existing
11 * purchase/sale flows to also post here is a separate, larger change.
12 */
13class StockMovement extends Model
14{
15    protected $fillable = ['branch_id', 'warehouse_id', 'product_id', 'qty', 'type', 'reference_type', 'reference_id', 'note', 'created_by'];
16
17    protected $casts = [
18        'qty' => 'decimal:4',
19    ];
20
21    public function product()
22    {
23        return $this->belongsTo(Product::class);
24    }
25
26    public function reference()
27    {
28        return $this->morphTo();
29    }
30
31    public function warehouse()
32    {
33        return $this->belongsTo(Warehouse::class);
34    }
35}