<?php

namespace App\Modules\Inventory\Stock\DTOs;

use App\Modules\Inventory\Stock\Support\InventoryStockMovementType;

final readonly class ApplyMovementInput
{
    /**
     * @param  array<string, mixed>|null  $metadata
     */
    public function __construct(
        public int $tenantId,
        public int $warehouseId,
        public int $itemId,
        public InventoryStockMovementType $type,
        public string $quantityInput,
        public ?int $actorUserId,
        public ?string $correlationId,
        public ?string $idempotencyKey,
        public string $idempotencySource = 'default',
        public ?int $unitId = null,
        public ?\DateTimeInterface $occurredAt = null,
        public ?string $referenceType = null,
        public ?int $referenceId = null,
        public ?array $metadata = null,
        public ?int $reversesMovementId = null,
    ) {}

    public function occurredAtOrNow(): \DateTimeInterface
    {
        return $this->occurredAt ?? now();
    }
}
