From c3b36dcdf733d9c793ee2aa16fdf324c22a25fab Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Tue, 1 Oct 2024 17:34:27 -0300 Subject: [PATCH] Optimizacion --- app/src/Service/Venta/Cuota.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/Service/Venta/Cuota.php b/app/src/Service/Venta/Cuota.php index 771e559..960a315 100644 --- a/app/src/Service/Venta/Cuota.php +++ b/app/src/Service/Venta/Cuota.php @@ -4,16 +4,21 @@ namespace Incoviba\Service\Venta; use DateTimeImmutable; use DateInterval; use IntlDateFormatter; +use Psr\Log\LoggerInterface; +use Incoviba\Common\Ideal; use Incoviba\Repository; use Incoviba\Model; -class Cuota +class Cuota extends Ideal\Service { public function __construct( + LoggerInterface $logger, protected Repository\Venta\Cuota $cuotaRepository, protected Pago $pagoService, protected Repository\Venta\TipoPago $tipoPagoRepository - ) {} + ) { + parent::__construct($logger); + } public function pendientes(): array { @@ -75,11 +80,11 @@ class Cuota } public function getByPie(int $pie_id): array { - try { - return $this->cuotaRepository->fetchByPie($pie_id); - } catch (EmptyResult) { - return []; - } + try { + return $this->cuotaRepository->fetchByPie($pie_id); + } catch (EmptyResult) { + return []; + } } public function getVigenteByPie(int $pie_id): array { @@ -89,13 +94,14 @@ class Cuota public function add(array $data): Model\Venta\Cuota { $tipoPago = $this->tipoPagoRepository->fetchByDescripcion('cheque'); - $fields = array_fill_keys([ + $fields = array_flip([ 'fecha', 'banco', 'valor', 'identificador' - ], 0); + ]); $filtered_data = array_intersect_key($data, $fields); + $pago_data = array_merge($filtered_data, ['tipo' => $tipoPago->id]); $pago = $this->pagoService->add($pago_data);