<?php
declare(strict_types=1);

namespace App\Core\DTO;

final class StockMovementRequest
{
    public function __construct(
        public readonly int $itemId,
        public readonly int $warehouseId,
        public readonly string $movementType,
        public readonly string $direction,
        public readonly string $quantity,
        public readonly ?string $unitCost = null,
        public readonly ?int $batchId = null,
        public readonly ?string $referenceType = null,
        public readonly ?int $referenceId = null,
        public readonly ?string $notes = null,
    ) {}

    public function toArray(): array
    {
        return array_filter([
            'item_id' => $this->itemId,
            'warehouse_id' => $this->warehouseId,
            'movement_type' => $this->movementType,
            'direction' => $this->direction,
            'quantity' => $this->quantity,
            'unit_cost' => $this->unitCost,
            'batch_id' => $this->batchId,
            'reference_type' => $this->referenceType,
            'reference_id' => $this->referenceId,
            'notes' => $this->notes,
        ], fn($v) => $v !== null);
    }
}
