<?php

namespace App\Modules\Procurement\Services;

use Illuminate\Database\Eloquent\Collection;

/**
 * Pending receipt reuse: quarantine invalid lines first, then hydrate only valid lines.
 */
final class GoodsReceiptReusePreparationService
{
    public function __construct(
        private readonly GoodsReceiptQuarantineService $quarantine,
        private readonly GoodsReceiptHydrationService $hydration,
    ) {}

    /**
     * @return Collection<int, \App\Modules\Procurement\Models\GoodsReceiptItem>
     */
    public function preparePendingReuse(int $tenantId, int $goodsReceiptId): Collection
    {
        $this->quarantine->quarantineInvalidLinesOnReceipt($tenantId, $goodsReceiptId);

        return $this->hydration->hydrateForReceipt($tenantId, $goodsReceiptId);
    }
}
