Facturacion
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
namespace Incoviba\Service;
|
||||
|
||||
use DateTimeInterface;
|
||||
use DateTimeImmutable;
|
||||
use DateInterval;
|
||||
use Incoviba\Common\Define\Money\Provider;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResponse;
|
||||
use Incoviba\Service\Money\MiIndicador;
|
||||
@ -22,6 +24,15 @@ class Money
|
||||
return $this->providers[$name];
|
||||
}
|
||||
|
||||
public function get(string $provider, DateTimeInterface $dateTime): float
|
||||
{
|
||||
try {
|
||||
$upper = strtoupper($provider);
|
||||
return $this->getProvider($provider)->get(MiIndicador::getSymbol($provider), $dateTime);
|
||||
} catch (EmptyResponse) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public function getUF(DateTimeInterface $dateTime): float
|
||||
{
|
||||
try {
|
||||
|
@ -36,4 +36,11 @@ class MiIndicador implements Provider
|
||||
}
|
||||
return $json->serie[0]->valor;
|
||||
}
|
||||
public static function getSymbol(string $identifier): string
|
||||
{
|
||||
$upper = strtoupper($identifier);
|
||||
$output = '';
|
||||
eval("\$output = self::{$upper};");
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,10 @@ class Proyecto
|
||||
{
|
||||
return $this->proyectoRepository->fetchAllActive();
|
||||
}
|
||||
public function getEscriturando(): array
|
||||
{
|
||||
return $this->proyectoRepository->fetchAllEscriturando();
|
||||
}
|
||||
public function getById(int $venta_id): Model\Proyecto
|
||||
{
|
||||
return $this->process($this->proyectoRepository->fetchById($venta_id));
|
||||
|
@ -15,35 +15,32 @@ class Unidad
|
||||
|
||||
public function getById(int $unidad_id): Model\Venta\Unidad
|
||||
{
|
||||
$unidad = $this->unidadRepository->fetchById($unidad_id);
|
||||
$this->fillPrecios($unidad);
|
||||
return $unidad;
|
||||
return $this->process($this->unidadRepository->fetchById($unidad_id));
|
||||
}
|
||||
public function getByVenta(int $venta_id): array
|
||||
{
|
||||
return array_map([$this, 'process'], $this->unidadRepository->fetchByVenta($venta_id));
|
||||
}
|
||||
public function getByPropiedad(int $propiedad_id): array
|
||||
{
|
||||
$unidades = $this->unidadRepository->fetchByPropiedad($propiedad_id);
|
||||
array_walk($unidades, [$this, 'fillPrecios']);
|
||||
return $unidades;
|
||||
return array_map([$this, 'process'], $this->unidadRepository->fetchByPropiedad($propiedad_id));
|
||||
}
|
||||
public function getByCierre(int $cierre_id): array
|
||||
{
|
||||
$unidades = $this->unidadRepository->fetchByCierre($cierre_id);
|
||||
array_walk($unidades, [$this, 'fillPrecios']);
|
||||
return $unidades;
|
||||
return array_map([$this, 'process'], $this->unidadRepository->fetchByCierre($cierre_id));
|
||||
}
|
||||
public function getDisponiblesByProyecto(int $proyecto_id): array
|
||||
{
|
||||
$unidades = $this->unidadRepository->fetchDisponiblesByProyecto($proyecto_id);
|
||||
//array_walk($unidades, [$this, 'fillPrecios']);
|
||||
return $unidades;
|
||||
return $this->unidadRepository->fetchDisponiblesByProyecto($proyecto_id);
|
||||
}
|
||||
|
||||
protected function fillPrecios(&$unidad): void
|
||||
protected function process($unidad): Model\Venta\Unidad
|
||||
{
|
||||
try {
|
||||
$unidad->precios = $this->precioService->getByUnidad($unidad->id);
|
||||
$unidad->currentPrecio = $this->precioService->getVigenteByUnidad($unidad->id);
|
||||
} catch (EmptyResult) {
|
||||
}
|
||||
return $unidad;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user