<?php
namespace Incoviba\Service\Venta;

use Incoviba\Repository;
use Incoviba\Model;

class Pie
{
    public function __construct(
        protected Repository\Venta\Pie $pieRepository,
        protected Cuota $cuotaService
    ) {}

    public function getById(int $pie_id): Model\Venta\Pie
    {
        $pie = $this->pieRepository->fetchById($pie_id);
        $pie->cuotasArray = $this->cuotaService->getVigenteByPie($pie_id);
        return $pie;
    }

    public function add(array $data): Model\Venta\Pie
    {
        $pie = $this->pieRepository->create($data);
        return $this->pieRepository->save($pie);
    }
    public function addCuota(array $data): Model\Venta\Cuota
    {
        return $this->cuotaService->add($data);
    }
}
