Edit reservation
This commit is contained in:
@ -4,6 +4,7 @@ namespace Incoviba\Service\Venta;
|
||||
use DateMalformedStringException;
|
||||
use Exception;
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Exception\ServiceAction\Update;
|
||||
use PDOException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
@ -85,13 +86,20 @@ class Credito extends Ideal\Service
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @param Model\Venta\Credito $credito
|
||||
* @param array $data
|
||||
* @return Model\Venta\Credito
|
||||
* @throws Update
|
||||
*/
|
||||
public function edit(Model\Venta\Credito $credito, array $data): Model\Venta\Credito
|
||||
{
|
||||
$uf = $this->moneyService->getUF($credito->pago->fecha);
|
||||
if (array_key_exists('fecha', $data)) {
|
||||
$fecha = new DateTimeImmutable($data['fecha']);
|
||||
try {
|
||||
$fecha = new DateTimeImmutable($data['fecha']);
|
||||
} catch (DateMalformedStringException $exception) {
|
||||
throw new Update(__CLASS__, $exception);
|
||||
}
|
||||
$data['fecha'] = $fecha->format('Y-m-d');
|
||||
$uf = $this->moneyService->getUF($fecha);
|
||||
$data['uf'] = $uf;
|
||||
@ -112,6 +120,10 @@ class Credito extends Ideal\Service
|
||||
}
|
||||
$credito->pago = $this->pagoService->edit($credito->pago, $filteredDataPago);
|
||||
|
||||
return $this->creditoRepository->edit($credito, $filteredData);
|
||||
try {
|
||||
return $this->creditoRepository->edit($credito, $filteredData);
|
||||
} catch (EmptyResult $exception) {
|
||||
throw new Update(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user