Optimizacion
This commit is contained in:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user