subsidioRepository->fetchByVenta($venta_id); } catch (EmptyResult $exception) { throw new Read(__CLASS__, $exception); } } public function add(array $data): Model\Venta\Subsidio { $fecha = new DateTimeImmutable(); try { $fecha = new DateTimeImmutable($data['fecha']); } catch (DateMalformedStringException) {} $uf = $data['uf'] ?? $this->moneyService->getUF($fecha); $tipoPago = $this->tipoPagoRepository->fetchByDescripcion('vale vista'); $ahorro = $this->pagoService->add(['fecha' => $fecha->format('Y-m-d'), 'valor' => $this->valorService->clean($data['ahorro']) * $uf, 'uf' => $uf, 'tipo' => $tipoPago->id]); $subsidioPago = $this->pagoService->add(['fecha' => $fecha->format('Y-m-d'), 'valor' => $this->valorService->clean($data['subsidio']) * $uf, 'uf' => $uf, 'tipo' => $tipoPago->id]); $subsidio = $this->subsidioRepository->create(['pago' => $ahorro->id, 'subsidio' => $subsidioPago->id]); return $this->subsidioRepository->save($subsidio); } }