Optimizacion
This commit is contained in:
@ -4,16 +4,21 @@ namespace Incoviba\Service\Venta;
|
|||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
use IntlDateFormatter;
|
use IntlDateFormatter;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Incoviba\Common\Ideal;
|
||||||
use Incoviba\Repository;
|
use Incoviba\Repository;
|
||||||
use Incoviba\Model;
|
use Incoviba\Model;
|
||||||
|
|
||||||
class Cuota
|
class Cuota extends Ideal\Service
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
LoggerInterface $logger,
|
||||||
protected Repository\Venta\Cuota $cuotaRepository,
|
protected Repository\Venta\Cuota $cuotaRepository,
|
||||||
protected Pago $pagoService,
|
protected Pago $pagoService,
|
||||||
protected Repository\Venta\TipoPago $tipoPagoRepository
|
protected Repository\Venta\TipoPago $tipoPagoRepository
|
||||||
) {}
|
) {
|
||||||
|
parent::__construct($logger);
|
||||||
|
}
|
||||||
|
|
||||||
public function pendientes(): array
|
public function pendientes(): array
|
||||||
{
|
{
|
||||||
@ -75,11 +80,11 @@ class Cuota
|
|||||||
}
|
}
|
||||||
public function getByPie(int $pie_id): array
|
public function getByPie(int $pie_id): array
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return $this->cuotaRepository->fetchByPie($pie_id);
|
return $this->cuotaRepository->fetchByPie($pie_id);
|
||||||
} catch (EmptyResult) {
|
} catch (EmptyResult) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function getVigenteByPie(int $pie_id): array
|
public function getVigenteByPie(int $pie_id): array
|
||||||
{
|
{
|
||||||
@ -89,13 +94,14 @@ class Cuota
|
|||||||
public function add(array $data): Model\Venta\Cuota
|
public function add(array $data): Model\Venta\Cuota
|
||||||
{
|
{
|
||||||
$tipoPago = $this->tipoPagoRepository->fetchByDescripcion('cheque');
|
$tipoPago = $this->tipoPagoRepository->fetchByDescripcion('cheque');
|
||||||
$fields = array_fill_keys([
|
$fields = array_flip([
|
||||||
'fecha',
|
'fecha',
|
||||||
'banco',
|
'banco',
|
||||||
'valor',
|
'valor',
|
||||||
'identificador'
|
'identificador'
|
||||||
], 0);
|
]);
|
||||||
$filtered_data = array_intersect_key($data, $fields);
|
$filtered_data = array_intersect_key($data, $fields);
|
||||||
|
|
||||||
$pago_data = array_merge($filtered_data, ['tipo' => $tipoPago->id]);
|
$pago_data = array_merge($filtered_data, ['tipo' => $tipoPago->id]);
|
||||||
$pago = $this->pagoService->add($pago_data);
|
$pago = $this->pagoService->add($pago_data);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user