Escriturar

This commit is contained in:
2023-12-20 08:44:49 -03:00
parent 1ba53c9e12
commit 379a33a4da
11 changed files with 430 additions and 16 deletions

View File

@ -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;
}
}