This commit is contained in:
Juan Pablo Vial
2025-03-03 14:57:22 -03:00
parent d165440483
commit 8f16f33a1e
56 changed files with 749 additions and 105 deletions

View File

@ -4,6 +4,8 @@ namespace Incoviba\Service\Venta;
use Exception;
use DateTimeInterface;
use DateTimeImmutable;
use DateMalformedStringException;
use Incoviba\Exception\ServiceAction\Read;
use PDOException;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Repository;
@ -112,9 +114,19 @@ class Pago
{
return [];
}
/**
* @param int $venta_id
* @return Model\Venta\Pago
* @throws Read
*/
public function getDevolucionByVenta(int $venta_id): Model\Venta\Pago
{
return $this->process($this->pagoRepository->fetchDevolucionByVenta($venta_id));
try {
return $this->process($this->pagoRepository->fetchDevolucionByVenta($venta_id));
} catch (EmptyResult $exception) {
throw new Read(__CLASS__, $exception);
}
}
public function add(array $data): Model\Venta\Pago
@ -122,7 +134,7 @@ class Pago
if (!isset($data['uf'])) {
try {
$data['uf'] = $this->ufService->get(new DateTimeImmutable($data['fecha']));
} catch (\DateMalformedStringException) {
} catch (DateMalformedStringException) {
$data['uf'] = 0;
}
}
@ -147,14 +159,14 @@ class Pago
if (array_key_exists('fecha', $data)) {
try {
$data['fecha'] = (new DateTimeImmutable($data['fecha']))->format('Y-m-d');
} catch (\DateMalformedStringException) {
} catch (DateMalformedStringException) {
$data['fecha'] = (new DateTimeImmutable())->format('Y-m-d');
}
}
if (array_key_exists('uf', $data)) {
try {
$data['uf'] = $this->ufService->get(new DateTimeImmutable($data['fecha']));
} catch (\DateMalformedStringException) {
} catch (DateMalformedStringException) {
$data['uf'] = 0;
}
}
@ -171,7 +183,7 @@ class Pago
try {
$this->pagoRepository->remove($pago);
return true;
} catch (EmptyResult|PDOException) {
} catch (PDOException) {
return false;
}
}