FIX: Venta desistida pero sin resciliacion
This commit is contained in:
@ -4,6 +4,9 @@ namespace Incoviba\Controller;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Implement\Exception\EmptyRedis;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Exception\ServiceAction\Create;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Exception\ServiceAction\Update;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
@ -142,9 +145,24 @@ class Ventas
|
||||
return $view->render($response, 'ventas.desistir', compact('venta'));
|
||||
}
|
||||
public function desistida(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
||||
Service\Venta\Pago $pagoService,
|
||||
View $view, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
try {
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
} catch (Read) {
|
||||
return $view->render($response->withStatus(404), 'not_found');
|
||||
}
|
||||
if ($venta->resciliacion() === null) {
|
||||
$pagoData = [
|
||||
'fecha' => $venta->currentEstado()->fecha->format('Y-m-d'),
|
||||
'valor' => 0
|
||||
];
|
||||
try {
|
||||
$pago = $pagoService->add($pagoData);
|
||||
$ventaService->edit($venta, ['resciliacion' => $pago->id]);
|
||||
} catch (Create | Update) {}
|
||||
}
|
||||
return $view->render($response, 'ventas.desistida', compact('venta'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user