Cuotas con detalle de UF y de Pies asociados
This commit is contained in:
@ -98,10 +98,21 @@ class Ventas
|
||||
return $view->render($response, 'ventas.add', compact('regiones', 'proyectos'));
|
||||
}
|
||||
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
||||
Repository\Venta $ventaRepository,
|
||||
View $view, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
return $view->render($response, 'ventas.pies.cuotas', compact('venta'));
|
||||
$asociadas = [];
|
||||
if (isset($venta->formaPago()->pie->asociado)) {
|
||||
$asociadas []= $ventaService->getByPie($venta->formaPago()->pie->asociado->id);
|
||||
foreach ($venta->formaPago()->pie->asociado->asociados() as $asociado) {
|
||||
if ($venta->formaPago()->pie->id === $asociado->id) {
|
||||
continue;
|
||||
}
|
||||
$asociadas []= $ventaService->getByPie($asociado->id);
|
||||
}
|
||||
}
|
||||
return $view->render($response, 'ventas.pies.cuotas', compact('venta', 'asociadas'));
|
||||
}
|
||||
public function escriturar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
||||
Repository\Contabilidad\Banco $bancoRepository, View $view, int $venta_id): ResponseInterface
|
||||
|
@ -10,7 +10,9 @@ use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Pies
|
||||
{
|
||||
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, Repository\Contabilidad\Banco $bancoRepository, View $view, int $pie_id): ResponseInterface
|
||||
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService,
|
||||
Repository\Venta $ventaRepository, Repository\Contabilidad\Banco $bancoRepository,
|
||||
View $view, int $pie_id): ResponseInterface
|
||||
{
|
||||
$pie = $pieService->getById($pie_id);
|
||||
$venta = $ventaRepository->fetchByPie($pie_id);
|
||||
@ -18,6 +20,6 @@ class Pies
|
||||
usort($bancos, function(Model\Contabilidad\Banco $a, Model\Contabilidad\Banco $b) {
|
||||
return strcmp($a->nombre, $b->nombre);
|
||||
});
|
||||
return $view->render($response, 'ventas.pies.cuotas', compact('pie', 'venta', 'bancos'));
|
||||
return $view->render($response, 'ventas.pies.cuotas', compact('pie', 'venta', 'bancos', 'ventaRepository'));
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +83,10 @@ class Venta extends Service
|
||||
{
|
||||
return $this->ventaRepository->fetchByIdForList($venta_id);
|
||||
}
|
||||
public function getByPie(int $pie_id): Model\Venta
|
||||
{
|
||||
return $this->process($this->ventaRepository->fetchByPie($pie_id));
|
||||
}
|
||||
|
||||
protected function process(Model\Venta $venta): Model\Venta
|
||||
{
|
||||
|
@ -30,6 +30,7 @@ class Pago
|
||||
try {
|
||||
$estado = $this->estadoPagoRepository->create($data);
|
||||
$this->estadoPagoRepository->save($estado);
|
||||
$this->getUF($pago);
|
||||
return true;
|
||||
} catch (PDOException) {
|
||||
return false;
|
||||
@ -162,7 +163,7 @@ class Pago
|
||||
protected function getUF(Model\Venta\Pago $pago): ?float
|
||||
{
|
||||
if (($pago->uf === null or $pago->uf === 0.0)
|
||||
and $pago->currentEstado->tipoEstadoPago->descripcion === 'abonado'
|
||||
and in_array($pago->currentEstado->tipoEstadoPago->descripcion, ['depositado', 'abonado'])
|
||||
and $pago->currentEstado->fecha <= new DateTimeImmutable()) {
|
||||
$uf = $this->moneyService->getUF($pago->currentEstado->fecha);
|
||||
if ($uf !== 0.0) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace Incoviba\Service\Venta;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Common\Implement\Repository\Factory;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
@ -47,6 +48,9 @@ class Pie
|
||||
try {
|
||||
$pie->asociados = $this->pieRepository->fetchAsociados($pie->id);
|
||||
} catch (EmptyResult) {}
|
||||
if (isset($pie->asociado)) {
|
||||
$pie->asociado = $this->getById($pie->asociado->id);
|
||||
}
|
||||
return $pie;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user