Cleanup
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Contabilidad;
|
||||
|
||||
use PDOException;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Define\Cartola\Banco;
|
||||
@ -273,12 +274,12 @@ class Cartola extends Service
|
||||
$data['abono'] ?? 0,
|
||||
$data['saldo']
|
||||
);
|
||||
} catch (Exception\EmptyResult $exception) {
|
||||
} catch (Exception\EmptyResult) {
|
||||
$data['cuenta_id'] = $cuenta->id;
|
||||
$movimiento = $this->movimientoRepository->create($data);
|
||||
try {
|
||||
return $this->movimientoRepository->save($movimiento);
|
||||
} catch (\PDOException $exception) {
|
||||
} catch (PDOException $exception) {
|
||||
$this->logger->critical(var_export($data,true));
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ trait isExcel
|
||||
* @throws PhpSpreadsheet\Exception
|
||||
* @throws PhpSpreadsheet\Calculation\Exception
|
||||
*/
|
||||
protected function findTitlesRow(PhpSpreadsheet\Worksheet\RowIterator &$rowIterator, string $firstTitle, int $columnOffset = 1, bool $caseInsensitive = false): ?PhpSpreadsheet\Worksheet\Row
|
||||
protected function findTitlesRow(PhpSpreadsheet\Worksheet\RowIterator $rowIterator, string $firstTitle, int $columnOffset = 1, bool $caseInsensitive = false): ?PhpSpreadsheet\Worksheet\Row
|
||||
{
|
||||
if ($caseInsensitive) {
|
||||
$firstTitle = strtolower($firstTitle);
|
||||
@ -100,11 +100,6 @@ trait isExcel
|
||||
if ($columnOffset > 1) {
|
||||
$cellIterator->seek($columnOffset);
|
||||
}
|
||||
foreach ($exitValues as $exitValue) {
|
||||
if ($cellIterator->current()->getCalculatedValue() === $exitValue) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return in_array($cellIterator->current()->getCalculatedValue(), $exitValues, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Contabilidad\Cartola;
|
||||
|
||||
use Incoviba\Common\Ideal\Cartola\Banco;
|
||||
use InvalidArgumentException;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use Incoviba\Common\Ideal\Cartola\Banco;
|
||||
|
||||
trait withSubBancos
|
||||
{
|
||||
|
||||
@ -15,8 +15,8 @@ class Semanal extends Ideal\Service
|
||||
protected Repository\Contabilidad\Deposito $depositoRepository,
|
||||
protected Service\Contabilidad\Cartola $cartolaService,
|
||||
protected Service\Contabilidad\Movimiento $movimientoService,
|
||||
protected Service\Contabilidad\Informe\Tesoreria\Excel $excelService,
|
||||
protected Service\Contabilidad\Informe\Tesoreria\PDF $pdfService)
|
||||
protected Service\Contabilidad\Informe\Tesoreria\Input\Excel $excelService,
|
||||
protected Service\Contabilidad\Informe\Tesoreria\Output\PDF $pdfService)
|
||||
{
|
||||
parent::__construct($logger);
|
||||
}
|
||||
@ -31,6 +31,6 @@ class Semanal extends Ideal\Service
|
||||
}
|
||||
return $this->anterior;
|
||||
}
|
||||
public function build(DateTimeInterface $fecha): array
|
||||
{}
|
||||
/*public function build(DateTimeInterface $fecha): array
|
||||
{}*/
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class SaldosContables extends Ideal\Service
|
||||
'saldo' => $this->getSaldo($dataMovimiento)
|
||||
];
|
||||
try {
|
||||
$movimiento = $this->movimientoRepository->fetchByCuentaAndFechaAndCargoAndAbonoAndSaldo($cuenta->id, $dataMovimiento->fecha, $data['cargo'], $data['abono'], $data['saldo']);
|
||||
$movimiento = $this->movimientoRepository->fetchByCuentaAndFechaAndGlosaAndCargoAndAbonoAndSaldo($cuenta->id, $dataMovimiento->fecha, $data['glosa'], $data['cargo'], $data['abono'], $data['saldo']);
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
$movimiento = $this->movimientoRepository->create($data);
|
||||
$movimiento = $this->movimientoRepository->save($movimiento);
|
||||
|
||||
@ -5,6 +5,7 @@ use DateInterval;
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
@ -94,7 +95,7 @@ class Output extends Ideal\Service
|
||||
$dataInmobiliaria->sociedad = $inmobiliaria;
|
||||
try {
|
||||
$cuentas = $this->cuentaService->getAllActiveByInmobiliaria($inmobiliaria->rut);
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
} catch (Read) {
|
||||
return $dataInmobiliaria;
|
||||
}
|
||||
foreach ($cuentas as $cuenta) {
|
||||
|
||||
@ -17,7 +17,7 @@ class Movimientos
|
||||
|
||||
const INGRESOS = 'ingresos';
|
||||
const EGRESOS = 'egresos';
|
||||
public function addDap(string $tipo, array $movimientos)
|
||||
public function addDap(string $tipo, array $movimientos): self
|
||||
{
|
||||
foreach ($movimientos as $movimiento) {
|
||||
$this->dap->{$tipo} []= $movimiento;
|
||||
@ -66,11 +66,7 @@ class Movimientos
|
||||
$date = $movimiento->fecha;
|
||||
}
|
||||
if ($movimiento->fecha !== $date) {
|
||||
if ($movimiento->cuenta->inmobiliaria->rut === $sociedad_rut) {
|
||||
$temp []= $movimiento;
|
||||
}
|
||||
$date = $movimiento->fecha;
|
||||
continue;
|
||||
}
|
||||
if ($movimiento->cuenta->inmobiliaria->rut === $sociedad_rut) {
|
||||
$temp []= $movimiento;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
namespace Incoviba\Service\Inmobiliaria;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal\Service;
|
||||
use Incoviba\Common\Implement;
|
||||
@ -16,19 +17,37 @@ class Cuenta extends Service
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws Read
|
||||
*/
|
||||
public function getAllActive(): array
|
||||
{
|
||||
$cuentas = array_map([$this, 'process'], $this->cuentaRepository->fetchAll());
|
||||
return array_values(array_filter($cuentas, function(Model\Inmobiliaria\Cuenta $cuenta) {
|
||||
return $cuenta->currentEstado()->active;
|
||||
}));
|
||||
try {
|
||||
$cuentas = array_map([$this, 'process'], $this->cuentaRepository->fetchAll());
|
||||
return array_values(array_filter($cuentas, function(Model\Inmobiliaria\Cuenta $cuenta) {
|
||||
return $cuenta->currentEstado()->active;
|
||||
}));
|
||||
} catch (Implement\Exception\EmptyResult $exception) {
|
||||
throw new Read(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $inmobiliaria_rut
|
||||
* @return array
|
||||
* @throws Read
|
||||
*/
|
||||
public function getAllActiveByInmobiliaria(int $inmobiliaria_rut): array
|
||||
{
|
||||
$cuentas = array_map([$this, 'process'], $this->cuentaRepository->fetchByInmobiliaria($inmobiliaria_rut));
|
||||
return array_values(array_filter($cuentas, function(Model\Inmobiliaria\Cuenta $cuenta) {
|
||||
return $cuenta->currentEstado()->active;
|
||||
}));
|
||||
try {
|
||||
$cuentas = array_map([$this, 'process'], $this->cuentaRepository->fetchByInmobiliaria($inmobiliaria_rut));
|
||||
return array_values(array_filter($cuentas, function(Model\Inmobiliaria\Cuenta $cuenta) {
|
||||
return $cuenta->currentEstado()->active;
|
||||
}));
|
||||
} catch (Implement\Exception\EmptyResult $exception) {
|
||||
throw new Read(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
public function add(array $data): Model\Inmobiliaria\Cuenta
|
||||
{
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Inmobiliaria;
|
||||
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use PDOException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
@ -73,7 +74,7 @@ class Proveedor extends Ideal\Service
|
||||
}
|
||||
$filteredData = $this->proveedorRepository->filterData($data);
|
||||
return $this->process($this->proveedorRepository->edit($proveedor, $filteredData));
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
} catch (Read | Implement\Exception\EmptyResult) {
|
||||
return $proveedor;
|
||||
}
|
||||
}
|
||||
@ -82,7 +83,7 @@ class Proveedor extends Ideal\Service
|
||||
try {
|
||||
$this->proveedorRepository->remove($proveedor);
|
||||
return true;
|
||||
} catch (Implement\Exception\EmptyResult | PDOException) {
|
||||
} catch (PDOException) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ class Login
|
||||
protected function cryptoJs_aes_decrypt($data, $key): string
|
||||
{
|
||||
$data = base64_decode($data);
|
||||
if (substr($data, 0, 8) != "Salted__") {
|
||||
if (!str_starts_with($data, "Salted__")) {
|
||||
return false;
|
||||
}
|
||||
$salt = substr($data, 8, 8);
|
||||
|
||||
@ -3,6 +3,7 @@ namespace Incoviba\Service;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -17,9 +18,18 @@ class Persona extends Ideal\Service
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $rut
|
||||
* @return Model\Persona
|
||||
* @throws Read
|
||||
*/
|
||||
public function getById(int $rut): Model\Persona
|
||||
{
|
||||
return $this->process($this->personaRepository->fetchById($rut));
|
||||
try {
|
||||
return $this->process($this->personaRepository->fetchById($rut));
|
||||
} catch (Implement\Exception\EmptyResult $exception) {
|
||||
throw new Read(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
public function add(array $data): Model\Persona
|
||||
{
|
||||
|
||||
@ -36,7 +36,7 @@ class Terreno extends Ideal\Service
|
||||
return $proyecto->terreno;
|
||||
}
|
||||
try {
|
||||
// Valor 1o Enero
|
||||
// Valor 1o enero
|
||||
return $this->getValorContable($proyecto, $lastNovember->add(new DateInterval('P1M'))->add(new DateInterval('P1D')));
|
||||
} catch (Implement\Exception\EmptyResponse) {}
|
||||
if ($proyecto->terreno->fecha === null) {
|
||||
|
||||
@ -9,7 +9,12 @@ class Redis
|
||||
{
|
||||
public function __construct(protected ClientInterface $client) {}
|
||||
|
||||
public function get(string $name): mixed
|
||||
/**
|
||||
* @param string $name
|
||||
* @return string|null
|
||||
* @throws EmptyRedis
|
||||
*/
|
||||
public function get(string $name): ?string
|
||||
{
|
||||
try {
|
||||
if (!$this->client->exists($name)) {
|
||||
|
||||
@ -102,7 +102,7 @@ class Search
|
||||
{
|
||||
try {
|
||||
return $this->unidadRepository->fetchDisponiblesIdsByDescripcionAndTipo($query, $tipo);
|
||||
} catch (EmptyResponse) {
|
||||
} catch (EmptyResult) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Service;
|
||||
|
||||
use PDOException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Repository;
|
||||
@ -39,7 +40,7 @@ class Sociedad extends Ideal\Service
|
||||
} catch (EmptyResult) {
|
||||
try {
|
||||
return $this->process($this->sociedadRepository->save($this->sociedadRepository->create($data)));
|
||||
} catch (EmptyResult) {
|
||||
} catch (PDOException) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ namespace Incoviba\Service;
|
||||
use Exception;
|
||||
use DateTimeImmutable;
|
||||
use DateInterval;
|
||||
use DateMalformedStringException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal\Service;
|
||||
use Incoviba\Common\Implement;
|
||||
@ -98,7 +99,7 @@ class Venta extends Service
|
||||
public function getFacturacionById(int $venta_id): array
|
||||
{
|
||||
$venta = $this->getById($venta_id);
|
||||
$escritura = (in_array($venta->currentEstado()->tipoEstadoVenta->descripcion, ['escriturando'])) ? $venta->currentEstado()->fecha : $venta->fecha;
|
||||
$escritura = (in_array($venta->currentEstado()->tipoEstadoVenta->descripcion, ['escriturando', 'firmado por inmobiliaria'])) ? $venta->currentEstado()->fecha : $venta->fecha;
|
||||
$data = [
|
||||
'id' => $venta->id,
|
||||
'fecha' => $venta->fecha->format('Y-m-d'),
|
||||
@ -289,7 +290,7 @@ class Venta extends Service
|
||||
{
|
||||
try {
|
||||
$fecha = new DateTimeImmutable($data['fecha']);
|
||||
} catch (\DateMalformedStringException) {
|
||||
} catch (DateMalformedStringException) {
|
||||
$fecha = new DateTimeImmutable();
|
||||
}
|
||||
$estadoData = [
|
||||
@ -348,7 +349,7 @@ class Venta extends Service
|
||||
{
|
||||
try {
|
||||
$fecha = new DateTimeImmutable($data['fecha_reajuste']);
|
||||
} catch (\DateMalformedStringException) {
|
||||
} catch (DateMalformedStringException) {
|
||||
$fecha = new DateTimeImmutable();
|
||||
}
|
||||
$reajusteData = [
|
||||
@ -363,7 +364,7 @@ class Venta extends Service
|
||||
{
|
||||
try {
|
||||
$fecha = new DateTimeImmutable($data['fecha_pago']);
|
||||
} catch (\DateMalformedStringException) {
|
||||
} catch (DateMalformedStringException) {
|
||||
$fecha = new DateTimeImmutable();
|
||||
}
|
||||
$uf = $this->moneyService->getUF($fecha);
|
||||
@ -389,7 +390,7 @@ class Venta extends Service
|
||||
{
|
||||
try {
|
||||
$fecha = new DateTimeImmutable($data['fecha']);
|
||||
} catch (\DateMalformedStringException) {
|
||||
} catch (DateMalformedStringException) {
|
||||
$fecha = new DateTimeImmutable();
|
||||
}
|
||||
$uf = $this->moneyService->getUF($fecha);
|
||||
@ -399,15 +400,15 @@ class Venta extends Service
|
||||
'subsidio' => $this->valorService->clean($data['valor_subsidio']),
|
||||
'uf' => $uf
|
||||
];
|
||||
$subsidio = $this->addSubsidio($subsidioData);
|
||||
$this->ventaRepository->edit($venta, ['subsidio' => $subsidio->id]);
|
||||
$formaPago = $this->addFormaPago($subsidioData);
|
||||
$this->ventaRepository->edit($venta, ['subsidio' => $formaPago->subsidio->id]);
|
||||
}
|
||||
|
||||
protected function editCredito(Model\Venta $venta, array $data): void
|
||||
{
|
||||
try {
|
||||
$fecha = new DateTimeImmutable($data['fecha']);
|
||||
} catch (\DateMalformedStringException) {
|
||||
} catch (DateMalformedStringException) {
|
||||
$fecha = new DateTimeImmutable();
|
||||
}
|
||||
$uf = $this->moneyService->getUF($fecha);
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
namespace Incoviba\Service\Venta;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -27,8 +28,18 @@ class BonoPie
|
||||
}
|
||||
return $bono;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $venta_id
|
||||
* @return Model\Venta\BonoPie
|
||||
* @throws Read
|
||||
*/
|
||||
public function getByVenta(int $venta_id): Model\Venta\BonoPie
|
||||
{
|
||||
return $this->bonoPieRepository->fetchByVenta($venta_id);
|
||||
try {
|
||||
return $this->bonoPieRepository->fetchByVenta($venta_id);
|
||||
} catch (EmptyResult $exception) {
|
||||
throw new Read(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ class Cierre
|
||||
public function getByProyecto(int $proyecto_id): array
|
||||
{
|
||||
$cierres = $this->cierreRepository->fetchByProyecto($proyecto_id);
|
||||
foreach ($cierres as &$cierre) {
|
||||
foreach ($cierres as $cierre) {
|
||||
$cierre->estados = $this->estadoCierreRepository->fetchByCierre($cierre->id);
|
||||
$cierre->current = $this->estadoCierreRepository->fetchCurrentByCierre($cierre->id);
|
||||
$cierre->unidades = $this->unidadRepository->fetchByCierre($cierre->id);
|
||||
@ -30,7 +30,7 @@ class Cierre
|
||||
$cierre->estados = $this->estadoCierreRepository->fetchByCierre($cierre_id);
|
||||
$cierre->current = $this->estadoCierreRepository->fetchCurrentByCierre($cierre_id);
|
||||
$cierre->unidades = $this->unidadRepository->fetchByCierre($cierre_id);
|
||||
foreach ($cierre->unidades as &$unidad) {
|
||||
foreach ($cierre->unidades as $unidad) {
|
||||
$unidad->currentPrecio = $this->precioRepository->fetchByUnidadAndDate($unidad->id, $cierre->dateTime->format('Y-m-d'));
|
||||
}
|
||||
$cierre->valoresCierre = $this->valorCierreRepository->fetchByCierre($cierre_id);
|
||||
|
||||
@ -3,6 +3,8 @@ namespace Incoviba\Service\Venta;
|
||||
|
||||
use Exception;
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Repository;
|
||||
@ -24,9 +26,18 @@ class Credito extends Ideal\Service
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $venta_id
|
||||
* @return Model\Venta\Credito
|
||||
* @throws Read
|
||||
*/
|
||||
public function getByVenta(int $venta_id): Model\Venta\Credito
|
||||
{
|
||||
return $this->creditoRepository->fetchByVenta($venta_id);
|
||||
try {
|
||||
return $this->creditoRepository->fetchByVenta($venta_id);
|
||||
} catch (EmptyResult $exception) {
|
||||
throw new Read(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -3,6 +3,7 @@ namespace Incoviba\Service\Venta;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use DateInterval;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use IntlDateFormatter;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
@ -3,6 +3,7 @@ namespace Incoviba\Service\Venta;
|
||||
|
||||
use Exception;
|
||||
use DateTimeImmutable;
|
||||
use DateMalformedStringException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
@ -65,7 +66,7 @@ class Escritura extends Ideal\Service
|
||||
}
|
||||
try {
|
||||
$data['fecha'] = (new DateTimeImmutable($data['fecha']))->format('Y-m-d');
|
||||
} catch (\DateMalformedStringException) {
|
||||
} catch (DateMalformedStringException) {
|
||||
unset($data['fecha']);
|
||||
}
|
||||
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Venta;
|
||||
|
||||
use Incoviba\Service\Valor;
|
||||
use Error;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service\Valor;
|
||||
|
||||
class FormaPago extends Ideal\Service
|
||||
{
|
||||
@ -28,22 +30,22 @@ class FormaPago extends Ideal\Service
|
||||
$formaPago = new Model\Venta\FormaPago();
|
||||
try {
|
||||
$formaPago->pie = $this->pieService->getByVenta($venta_id);
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
} catch (Read) {}
|
||||
try {
|
||||
$formaPago->bonoPie = $this->bonoPieService->getByVenta($venta_id);
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
} catch (Read) {}
|
||||
try {
|
||||
$formaPago->credito = $this->creditoService->getByVenta($venta_id);
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
} catch (Read) {}
|
||||
try {
|
||||
$formaPago->escritura = $this->escrituraRepository->fetchByVenta($venta_id);
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
try {
|
||||
$formaPago->subsidio = $this->subsidioService->getByVenta($venta_id);
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
} catch (Read) {}
|
||||
try {
|
||||
$formaPago->devolucion = $this->pagoService->getDevolucionByVenta($venta_id);
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
} catch (Read) {}
|
||||
try {
|
||||
$formaPago->cuotasAbono = $this->cuotaRepository->fetchByVenta($venta_id);
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
@ -66,7 +68,7 @@ class FormaPago extends Ideal\Service
|
||||
$method = 'add' . str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
|
||||
$obj = $this->{$method}($data);
|
||||
$forma_pago->{$name} = $obj;
|
||||
} catch (\Error $error) {
|
||||
} catch (Error $error) {
|
||||
$this->logger->critical($error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ namespace Incoviba\Service\Venta;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Common\Implement\Repository\Factory;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
@ -20,7 +21,11 @@ class Pie
|
||||
}
|
||||
public function getByVenta(int $venta_id): Model\Venta\Pie
|
||||
{
|
||||
return $this->process($this->pieRepository->fetchByVenta($venta_id));
|
||||
try {
|
||||
return $this->process($this->pieRepository->fetchByVenta($venta_id));
|
||||
} catch (EmptyResult $exception) {
|
||||
throw new Read(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
public function add(array $data): Model\Venta\Pie
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Venta;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
@ -8,29 +10,58 @@ class Precio
|
||||
{
|
||||
public function __construct(protected Repository\Venta\Precio $precioRepository, protected Repository\Venta\EstadoPrecio $estadoPrecioRepository) {}
|
||||
|
||||
/**
|
||||
* @param int $proyecto_id
|
||||
* @return array
|
||||
* @throws Read
|
||||
*/
|
||||
public function getByProyecto(int $proyecto_id): array
|
||||
{
|
||||
$precios = $this->precioRepository->fetchByProyecto($proyecto_id);
|
||||
foreach ($precios as &$precio) {
|
||||
$precio->estados = $this->estadoPrecioRepository->fetchByPrecio($precio->id);
|
||||
$precio->current = $this->estadoPrecioRepository->fetchCurrentByPrecio($precio->id);
|
||||
try {
|
||||
$precios = $this->precioRepository->fetchByProyecto($proyecto_id);
|
||||
foreach ($precios as $precio) {
|
||||
$precio->estados = $this->estadoPrecioRepository->fetchByPrecio($precio->id);
|
||||
$precio->current = $this->estadoPrecioRepository->fetchCurrentByPrecio($precio->id);
|
||||
}
|
||||
return $precios;
|
||||
} catch (EmptyResult $exception) {
|
||||
throw new Read(__CLASS__, $exception);
|
||||
}
|
||||
return $precios;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $unidad_id
|
||||
* @return Model\Venta\Precio
|
||||
* @throws Read
|
||||
*/
|
||||
public function getVigenteByUnidad(int $unidad_id): Model\Venta\Precio
|
||||
{
|
||||
$precio = $this->precioRepository->fetchVigenteByUnidad($unidad_id);
|
||||
$precio->estados = $this->estadoPrecioRepository->fetchByPrecio($precio->id);
|
||||
$precio->current = $this->estadoPrecioRepository->fetchCurrentByPrecio($precio->id);
|
||||
return $precio;
|
||||
}
|
||||
public function getByUnidad(int $unidad_id): array
|
||||
{
|
||||
$precios = $this->precioRepository->fetchByUnidad($unidad_id);
|
||||
foreach ($precios as &$precio) {
|
||||
try {
|
||||
$precio = $this->precioRepository->fetchVigenteByUnidad($unidad_id);
|
||||
$precio->estados = $this->estadoPrecioRepository->fetchByPrecio($precio->id);
|
||||
$precio->current = $this->estadoPrecioRepository->fetchCurrentByPrecio($precio->id);
|
||||
return $precio;
|
||||
} catch (EmptyResult $exception) {
|
||||
throw new Read(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $unidad_id
|
||||
* @return array
|
||||
* @throws Read
|
||||
*/
|
||||
public function getByUnidad(int $unidad_id): array
|
||||
{
|
||||
try {
|
||||
$precios = $this->precioRepository->fetchByUnidad($unidad_id);
|
||||
foreach ($precios as $precio) {
|
||||
$precio->estados = $this->estadoPrecioRepository->fetchByPrecio($precio->id);
|
||||
$precio->current = $this->estadoPrecioRepository->fetchCurrentByPrecio($precio->id);
|
||||
}
|
||||
return $precios;
|
||||
} catch (EmptyResult $exception) {
|
||||
throw new Read(__CLASS__, $exception);
|
||||
}
|
||||
return $precios;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
namespace Incoviba\Service\Venta;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Incoviba\Model;
|
||||
@ -51,10 +52,10 @@ class PropiedadUnidad
|
||||
try {
|
||||
$unidad->precios = $this->precioService->getByUnidad($unidad->id);
|
||||
$unidad->currentPrecio = $this->precioService->getVigenteByUnidad($unidad->id);
|
||||
if ($unidad->valor === 0 or $unidad->valor === null) {
|
||||
if ($unidad->valor === null or $unidad->valor === 0) {
|
||||
$unidad->valor = $unidad->currentPrecio->valor;
|
||||
}
|
||||
} catch (EmptyResult) {}
|
||||
} catch (Read) {}
|
||||
return $unidad;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Venta;
|
||||
|
||||
use Exception;
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Service;
|
||||
@ -19,9 +20,18 @@ class Subsidio
|
||||
protected Service\Valor $valorService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param int $venta_id
|
||||
* @return Model\Venta\Subsidio
|
||||
* @throws Read
|
||||
*/
|
||||
public function getByVenta(int $venta_id): Model\Venta\Subsidio
|
||||
{
|
||||
return $this->subsidioRepository->fetchByVenta($venta_id);
|
||||
try {
|
||||
return $this->subsidioRepository->fetchByVenta($venta_id);
|
||||
} catch (EmptyResult $exception) {
|
||||
throw new Read(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Venta;
|
||||
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use PDOException;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
@ -60,8 +62,7 @@ class Unidad
|
||||
try {
|
||||
$unidad->precios = $this->precioService->getByUnidad($unidad->id);
|
||||
$unidad->currentPrecio = $this->precioService->getVigenteByUnidad($unidad->id);
|
||||
} catch (EmptyResult) {
|
||||
}
|
||||
} catch (Read) {}
|
||||
return $unidad;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user