75 lines
2.5 KiB
PHP
75 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Inventory\Infrastructure\Persistence\Eloquent;
|
|
|
|
use App\Modules\Inventory\Domain\Enums\StockMovementKind;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\Table;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
/**
|
|
* Persistence model, used only inside the Inventory Infrastructure layer.
|
|
*
|
|
* @property int $id
|
|
* @property int $stock_item_id
|
|
* @property StockMovementKind $kind
|
|
* @property int $quantity_milli
|
|
* @property int $unit_cost_hundredths
|
|
* @property int $value_cents
|
|
* @property Carbon $occurred_on
|
|
* @property Carbon $recorded_at
|
|
* @property int $user_id
|
|
* @property int|null $task_id
|
|
* @property int|null $customer_job_id
|
|
* @property int|null $machine_id
|
|
* @property int|null $quick_sale_order_line_id
|
|
* @property int|null $maintenance_record_id
|
|
* @property int|null $inventory_count_id
|
|
* @property int|null $reverses_movement_id
|
|
* @property string|null $reason
|
|
* @property string|null $supplier
|
|
* @property string|null $document_number
|
|
*/
|
|
#[Table('stock_movements')]
|
|
#[Fillable([
|
|
'stock_item_id', 'kind', 'quantity_milli', 'unit_cost_hundredths', 'value_cents', 'occurred_on', 'recorded_at', 'user_id',
|
|
'task_id', 'customer_job_id', 'machine_id', 'quick_sale_order_line_id', 'maintenance_record_id', 'inventory_count_id',
|
|
'reverses_movement_id', 'reason', 'supplier', 'document_number',
|
|
])]
|
|
class StockMovementModel extends Model
|
|
{
|
|
/**
|
|
* @return HasOne<StockMovementModel, $this>
|
|
*/
|
|
public function reversal(): HasOne
|
|
{
|
|
return $this->hasOne(StockMovementModel::class, 'reverses_movement_id');
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'stock_item_id' => 'integer',
|
|
'kind' => StockMovementKind::class,
|
|
'quantity_milli' => 'integer',
|
|
'unit_cost_hundredths' => 'integer',
|
|
'value_cents' => 'integer',
|
|
'occurred_on' => 'immutable_date',
|
|
'recorded_at' => 'immutable_datetime',
|
|
'user_id' => 'integer',
|
|
'task_id' => 'integer',
|
|
'customer_job_id' => 'integer',
|
|
'machine_id' => 'integer',
|
|
'quick_sale_order_line_id' => 'integer',
|
|
'maintenance_record_id' => 'integer',
|
|
'inventory_count_id' => 'integer',
|
|
'reverses_movement_id' => 'integer',
|
|
];
|
|
}
|
|
}
|