Escriturar
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Venta;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
@ -8,14 +9,13 @@ class Pie
|
||||
{
|
||||
public function __construct(
|
||||
protected Repository\Venta\Pie $pieRepository,
|
||||
protected Cuota $cuotaService
|
||||
protected Cuota $cuotaService,
|
||||
protected Pago $pagoService
|
||||
) {}
|
||||
|
||||
public function getById(int $pie_id): Model\Venta\Pie
|
||||
{
|
||||
$pie = $this->pieRepository->fetchById($pie_id);
|
||||
$pie->cuotasArray = $this->cuotaService->getVigenteByPie($pie_id);
|
||||
return $pie;
|
||||
return $this->process($this->pieRepository->fetchById($pie_id));
|
||||
}
|
||||
|
||||
public function add(array $data): Model\Venta\Pie
|
||||
@ -31,4 +31,18 @@ class Pie
|
||||
{
|
||||
return $this->pieRepository->edit($pie, $data);
|
||||
}
|
||||
public function reajustar(Model\Venta\Pie $pie, array $data): Model\Venta\Pie
|
||||
{
|
||||
$pago = $this->pagoService->add($data);
|
||||
return $this->pieRepository->edit($pie, ['reajuste' => $pago->id]);
|
||||
}
|
||||
|
||||
protected function process(Model\Venta\Pie $pie): Model\Venta\Pie
|
||||
{
|
||||
$pie->cuotasArray = $this->cuotaService->getVigenteByPie($pie->id);
|
||||
try {
|
||||
$pie->asociados = $this->pieRepository->fetchAsociados($pie->id);
|
||||
} catch (EmptyResult) {}
|
||||
return $pie;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user