Precios con promociones para listado brokers
This commit is contained in:
@ -10,18 +10,21 @@ use Incoviba\Controller\API\withJson;
|
|||||||
use Incoviba\Exception\ServiceAction;
|
use Incoviba\Exception\ServiceAction;
|
||||||
use Incoviba\Repository;
|
use Incoviba\Repository;
|
||||||
use Incoviba\Service;
|
use Incoviba\Service;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Contracts
|
class Contracts
|
||||||
{
|
{
|
||||||
use withJson;
|
use withJson;
|
||||||
|
|
||||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Service\Proyecto\Broker\Contract $contractService): ResponseInterface
|
public function __invoke(ServerRequestInterface $request, ResponseInterface $response,
|
||||||
|
Service\Proyecto\Broker\Contract $contractService): ResponseInterface
|
||||||
{
|
{
|
||||||
$contracts = $contractService->getAll();
|
$contracts = $contractService->getAll();
|
||||||
|
|
||||||
return $this->withJson($response, compact('contracts'));
|
return $this->withJson($response, compact('contracts'));
|
||||||
}
|
}
|
||||||
public function getByBroker(ServerRequestInterface $request, ResponseInterface $response, Service\Proyecto\Broker\Contract $contractService,
|
public function getByBroker(ServerRequestInterface $request, ResponseInterface $response,
|
||||||
|
Service\Proyecto\Broker\Contract $contractService,
|
||||||
Service\Proyecto\Broker $brokerService, int $broker_rut): ResponseInterface
|
Service\Proyecto\Broker $brokerService, int $broker_rut): ResponseInterface
|
||||||
{
|
{
|
||||||
$output = [
|
$output = [
|
||||||
@ -36,7 +39,8 @@ class Contracts
|
|||||||
}
|
}
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
public function get(ServerRequestInterface $request, ResponseInterface $response, Service\Proyecto\Broker\Contract $contractService, int $contract_id): ResponseInterface
|
public function get(ServerRequestInterface $request, ResponseInterface $response,
|
||||||
|
Service\Proyecto\Broker\Contract $contractService, int $contract_id): ResponseInterface
|
||||||
{
|
{
|
||||||
$output = [
|
$output = [
|
||||||
'contract_id' => $contract_id,
|
'contract_id' => $contract_id,
|
||||||
@ -50,7 +54,8 @@ class Contracts
|
|||||||
|
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
public function add(ServerRequestInterface $request, ResponseInterface $response, Service\Proyecto\Broker\Contract $contractService): ResponseInterface
|
public function add(ServerRequestInterface $request, ResponseInterface $response,
|
||||||
|
Service\Proyecto\Broker\Contract $contractService): ResponseInterface
|
||||||
{
|
{
|
||||||
$input = $request->getParsedBody();
|
$input = $request->getParsedBody();
|
||||||
$output = [
|
$output = [
|
||||||
@ -82,7 +87,8 @@ class Contracts
|
|||||||
|
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
public function edit(ServerRequestInterface $request, ResponseInterface $response, Service\Proyecto\Broker\Contract $contractService, int $contract_id): ResponseInterface
|
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||||
|
Service\Proyecto\Broker\Contract $contractService, int $contract_id): ResponseInterface
|
||||||
{
|
{
|
||||||
$input = $request->getParsedBody();
|
$input = $request->getParsedBody();
|
||||||
$output = [
|
$output = [
|
||||||
@ -101,7 +107,8 @@ class Contracts
|
|||||||
|
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
public function inactive(ServerRequestInterface $request, ResponseInterface $response, Service\Proyecto\Broker\Contract $contractService, int $contract_id): ResponseInterface
|
public function inactive(ServerRequestInterface $request, ResponseInterface $response,
|
||||||
|
Service\Proyecto\Broker\Contract $contractService, int $contract_id): ResponseInterface
|
||||||
{
|
{
|
||||||
$input = $request->getParsedBody();
|
$input = $request->getParsedBody();
|
||||||
$output = [
|
$output = [
|
||||||
@ -126,7 +133,8 @@ class Contracts
|
|||||||
|
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
public function delete(ServerRequestInterface $request, ResponseInterface $response, Service\Proyecto\Broker\Contract $contractService, int $contract_id): ResponseInterface
|
public function delete(ServerRequestInterface $request, ResponseInterface $response,
|
||||||
|
Service\Proyecto\Broker\Contract $contractService, int $contract_id): ResponseInterface
|
||||||
{
|
{
|
||||||
$output = [
|
$output = [
|
||||||
'contract_id' => $contract_id,
|
'contract_id' => $contract_id,
|
||||||
@ -147,6 +155,7 @@ class Contracts
|
|||||||
Service\Proyecto\Broker\Contract $contractService,
|
Service\Proyecto\Broker\Contract $contractService,
|
||||||
Repository\Venta\Unidad $unitRepository,
|
Repository\Venta\Unidad $unitRepository,
|
||||||
Repository\Venta\Promotion $promotionRepository,
|
Repository\Venta\Promotion $promotionRepository,
|
||||||
|
LoggerInterface $logger,
|
||||||
int $contract_id): ResponseInterface
|
int $contract_id): ResponseInterface
|
||||||
{
|
{
|
||||||
$input = $request->getParsedBody();
|
$input = $request->getParsedBody();
|
||||||
@ -168,7 +177,9 @@ class Contracts
|
|||||||
'id' => $unit->id,
|
'id' => $unit->id,
|
||||||
'promotions' => $promotions
|
'promotions' => $promotions
|
||||||
];
|
];
|
||||||
} catch (ServiceAction\Read | Implement\Exception\EmptyResult) {}
|
} catch (ServiceAction\Read | Implement\Exception\EmptyResult $exception) {
|
||||||
|
$logger->debug($exception);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
|
@ -63,21 +63,19 @@ class Unidades extends Ideal\Controller
|
|||||||
try {
|
try {
|
||||||
$proyecto = $proyectoService->getById($proyecto_id);
|
$proyecto = $proyectoService->getById($proyecto_id);
|
||||||
foreach ($unidad_ids as $unidad_id) {
|
foreach ($unidad_ids as $unidad_id) {
|
||||||
|
$output['estados'][] = [
|
||||||
|
'id' => $unidad_id,
|
||||||
|
'sold' => false
|
||||||
|
];
|
||||||
try {
|
try {
|
||||||
$unidad = $unidadRepository->fetchById($unidad_id);
|
$unidad = $unidadRepository->fetchById($unidad_id);
|
||||||
} catch (Implement\Exception\EmptyResult) {
|
|
||||||
try {
|
try {
|
||||||
$output['estados'][] = [
|
$output['estados'][] = [
|
||||||
'id' => $unidad_id,
|
'id' => $unidad_id,
|
||||||
'sold' => $unidadRepository->fetchSoldByUnidad((int) $unidad_id)
|
'sold' => $unidadRepository->fetchSoldByUnidad($unidad->id)
|
||||||
];
|
];
|
||||||
} catch (Implement\Exception\EmptyResult) {
|
} catch (Implement\Exception\EmptyResult) {}
|
||||||
$output['estados'][] = [
|
} catch (Implement\Exception\EmptyResult) {}
|
||||||
'id' => $unidad_id,
|
|
||||||
'sold' => false
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Implement\Exception\EmptyResult) {}
|
} catch (Implement\Exception\EmptyResult) {}
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
|
@ -231,11 +231,14 @@ class Promotion extends Common\Ideal\Repository
|
|||||||
->joined('LEFT OUTER JOIN promotion_units pu ON pu.promotion_id = a.id')
|
->joined('LEFT OUTER JOIN promotion_units pu ON pu.promotion_id = a.id')
|
||||||
->joined('LEFT OUTER JOIN promotion_projects pp ON pp.promotion_id = a.id')
|
->joined('LEFT OUTER JOIN promotion_projects pp ON pp.promotion_id = a.id')
|
||||||
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu1 ON ptu1.proyecto = pp.project_id')
|
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu1 ON ptu1.proyecto = pp.project_id')
|
||||||
|
->joined('LEFT OUTER JOIN unidad u1 ON u1.pt = ptu1.id')
|
||||||
->joined('LEFT OUTER JOIN promotion_unit_types put ON put.promotion_id = a.id')
|
->joined('LEFT OUTER JOIN promotion_unit_types put ON put.promotion_id = a.id')
|
||||||
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu2 ON ptu2.tipo = put.unit_type_id AND ptu2.proyecto = put.project_id')
|
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu2 ON ptu2.tipo = put.unit_type_id AND ptu2.proyecto = put.project_id')
|
||||||
|
->joined('LEFT OUTER JOIN unidad u2 ON u2.pt = ptu2.id')
|
||||||
->joined('LEFT OUTER JOIN promotion_unit_lines pul ON pul.promotion_id = a.id')
|
->joined('LEFT OUTER JOIN promotion_unit_lines pul ON pul.promotion_id = a.id')
|
||||||
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu3 ON ptu3.id = put.unit_line_id')
|
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu3 ON ptu3.id = pul.unit_line_id')
|
||||||
->where('bc.contract_id = :contract_id OR pu.unit_id = :unit_id OR ptu1.unidad = :unit_id OR ptu2.unidad = :unit_id OR ptu3.unidad = :unit_id')
|
->joined('LEFT OUTER JOIN unidad u3 ON u3.pt = ptu3.id')
|
||||||
|
->where('bc.id = :contract_id OR pu.unit_id = :unit_id OR u1.id = :unit_id OR u2.id = :unit_id OR u3.id = :unit_id')
|
||||||
->group('a.id');
|
->group('a.id');
|
||||||
return $this->fetchMany($query, ['contract_id' => $contract_id, 'unit_id' => $unit_id]);
|
return $this->fetchMany($query, ['contract_id' => $contract_id, 'unit_id' => $unit_id]);
|
||||||
}
|
}
|
||||||
|
@ -92,8 +92,8 @@ class Unidad extends Ideal\Repository
|
|||||||
->select('a.*, up.prorrateo')
|
->select('a.*, up.prorrateo')
|
||||||
->from("{$this->getTable()} a")
|
->from("{$this->getTable()} a")
|
||||||
->joined($this->joinProrrateo())
|
->joined($this->joinProrrateo())
|
||||||
->joined("JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = a.`pt`
|
->joined("INNER JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = a.`pt`")
|
||||||
JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`")
|
->joined("INNER JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`")
|
||||||
->where('ptu.proyecto = ?')
|
->where('ptu.proyecto = ?')
|
||||||
->order('tu.orden');
|
->order('tu.orden');
|
||||||
return $this->fetchMany($query, [$proyecto_id]);
|
return $this->fetchMany($query, [$proyecto_id]);
|
||||||
@ -104,12 +104,12 @@ class Unidad extends Ideal\Repository
|
|||||||
->select('DISTINCT a.*, up.prorrateo')
|
->select('DISTINCT a.*, up.prorrateo')
|
||||||
->from("{$this->getTable()} a")
|
->from("{$this->getTable()} a")
|
||||||
->joined($this->joinProrrateo())
|
->joined($this->joinProrrateo())
|
||||||
->joined("JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = a.`pt`
|
->joined('INNER JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = a.`pt`')
|
||||||
JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`
|
->joined('INNER JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`')
|
||||||
LEFT OUTER JOIN `propiedad_unidad` pu ON pu.`unidad` = a.`id`
|
->joined('LEFT OUTER JOIN `propiedad_unidad` pu ON pu.`unidad` = a.`id`')
|
||||||
LEFT OUTER JOIN `venta` ON `venta`.`propiedad` = `pu`.`propiedad`
|
->joined('LEFT OUTER JOIN `venta` ON `venta`.`propiedad` = pu.`propiedad`')
|
||||||
LEFT OUTER JOIN (SELECT ev1.* FROM `estado_venta` ev1 JOIN (SELECT MAX(`id`) as 'id', `venta` FROM `estado_venta` GROUP BY `venta`) ev0 ON ev0.`id` = ev1.`id`) ev ON ev.`venta` = `venta`.`id`
|
->joined($this->joinEstadoVenta())
|
||||||
LEFT OUTER JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`")
|
->joined('LEFT OUTER JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`')
|
||||||
->where("ptu.`proyecto` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`activa` = 0)")
|
->where("ptu.`proyecto` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`activa` = 0)")
|
||||||
->order('tu.orden');
|
->order('tu.orden');
|
||||||
return $this->fetchMany($query, [$proyecto_id]);
|
return $this->fetchMany($query, [$proyecto_id]);
|
||||||
@ -120,12 +120,12 @@ class Unidad extends Ideal\Repository
|
|||||||
->select('DISTINCT a.*, up.prorrateo')
|
->select('DISTINCT a.*, up.prorrateo')
|
||||||
->from("{$this->getTable()} a")
|
->from("{$this->getTable()} a")
|
||||||
->joined($this->joinProrrateo())
|
->joined($this->joinProrrateo())
|
||||||
->joined("JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = a.`pt`
|
->joined('INNER JOIN proyecto_tipo_unidad ptu ON ptu.id = a.pt')
|
||||||
JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`
|
->joined('INNER tipo_unidad tu ON tu.id = ptu.tipo')
|
||||||
LEFT OUTER JOIN `propiedad_unidad` pu ON pu.`unidad` = a.`id`
|
->joined('LEFT OUTER JOIN propiedad_unidad pu ON pu.unidad = a.id')
|
||||||
LEFT OUTER JOIN `venta` ON `venta`.`propiedad` = pu.`propiedad`
|
->joined('LEFT OUTER JOIN venta ON venta.propiedad = pu.propiedad')
|
||||||
LEFT OUTER JOIN (SELECT ev1.* FROM `estado_venta` ev1 JOIN (SELECT MAX(`id`) as 'id', `venta` FROM `estado_venta`) ev0 ON ev0.`id` = ev1.`id`) ev ON ev.`venta` = `venta`.`id`
|
->joined($this->joinEstadoVenta())
|
||||||
LEFT OUTER JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`")
|
->joined('LEFT OUTER JOIN tipo_estado_venta tev ON tev.id = ev.estado')
|
||||||
->where("a.`descripcion` LIKE ? AND tu.`descripcion` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`activa` = 0)");
|
->where("a.`descripcion` LIKE ? AND tu.`descripcion` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`activa` = 0)");
|
||||||
return $this->fetchMany($query, [$descripcion, $tipo]);
|
return $this->fetchMany($query, [$descripcion, $tipo]);
|
||||||
}
|
}
|
||||||
@ -141,12 +141,12 @@ class Unidad extends Ideal\Repository
|
|||||||
$query = $this->connection->getQueryBuilder()
|
$query = $this->connection->getQueryBuilder()
|
||||||
->select('a.id')
|
->select('a.id')
|
||||||
->from("{$this->getTable()} a")
|
->from("{$this->getTable()} a")
|
||||||
->joined("JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = a.`pt`
|
->joined('INNER JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = a.`pt`')
|
||||||
JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`
|
->joined('INNER JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`')
|
||||||
LEFT OUTER JOIN `propiedad_unidad` pu ON pu.`unidad` = a.`id`
|
->joined('LEFT OUTER JOIN `propiedad_unidad` pu ON pu.`unidad` = a.`id`')
|
||||||
LEFT OUTER JOIN `venta` ON `venta`.`propiedad` = pu.`propiedad`
|
->joined('LEFT OUTER JOIN `venta` ON `venta`.`propiedad` = pu.`propiedad`')
|
||||||
LEFT OUTER JOIN (SELECT ev1.* FROM `estado_venta` ev1 JOIN (SELECT MAX(`id`) as 'id', `venta` FROM `estado_venta`) ev0 ON ev0.`id` = ev1.`id`) ev ON ev.`venta` = `venta`.`id`
|
->joined($this->joinEstadoVenta())
|
||||||
LEFT OUTER JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`")
|
->joined('LEFT OUTER JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`')
|
||||||
->where("a.`descripcion` LIKE ? AND tu.`descripcion` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`activa` = 0)");
|
->where("a.`descripcion` LIKE ? AND tu.`descripcion` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`activa` = 0)");
|
||||||
try {
|
try {
|
||||||
return $this->connection->execute($query, [$descripcion, $tipo])->fetchAll(PDO::FETCH_ASSOC);
|
return $this->connection->execute($query, [$descripcion, $tipo])->fetchAll(PDO::FETCH_ASSOC);
|
||||||
@ -156,6 +156,14 @@ class Unidad extends Ideal\Repository
|
|||||||
}
|
}
|
||||||
public function fetchByIdForSearch(int $unidad_id): array
|
public function fetchByIdForSearch(int $unidad_id): array
|
||||||
{
|
{
|
||||||
|
$subSubQuery = $this->connection->getQueryBuilder()
|
||||||
|
->select('MAX(id) AS id, precio')
|
||||||
|
->from('estado_precio')
|
||||||
|
->group('precio');
|
||||||
|
$subQuery = $this->connection->getQueryBuilder()
|
||||||
|
->select('ep1.*')
|
||||||
|
->from('estado_precio ep1')
|
||||||
|
->joined("($subSubQuery) ep0 ON ep0.id = ep1.id");
|
||||||
$query = $this->connection->getQueryBuilder()
|
$query = $this->connection->getQueryBuilder()
|
||||||
->select('unidad.id AS id, unidad.descripcion AS descripcion')
|
->select('unidad.id AS id, unidad.descripcion AS descripcion')
|
||||||
->columns('proyecto.id AS proyecto_id, proyecto.descripcion AS proyecto_descripcion')
|
->columns('proyecto.id AS proyecto_id, proyecto.descripcion AS proyecto_descripcion')
|
||||||
@ -167,22 +175,33 @@ class Unidad extends Ideal\Repository
|
|||||||
->joined('JOIN proyecto ON proyecto.id = ptu.proyecto')
|
->joined('JOIN proyecto ON proyecto.id = ptu.proyecto')
|
||||||
->joined('JOIN tipo_unidad tu ON tu.id = ptu.tipo')
|
->joined('JOIN tipo_unidad tu ON tu.id = ptu.tipo')
|
||||||
->joined('JOIN precio ON precio.unidad = unidad.id')
|
->joined('JOIN precio ON precio.unidad = unidad.id')
|
||||||
->joined('JOIN (SELECT ep1.* FROM estado_precio ep1 JOIN (SELECT MAX(id) AS id, precio FROM estado_precio GROUP BY precio) ep0 ON ep0.id = ep1.id) ep ON ep.precio = precio.id')
|
->joined("JOIN ({$subQuery}) ep ON ep.precio = precio.id")
|
||||||
->where('unidad.id = ?')
|
->where('unidad.id = ?')
|
||||||
->group('unidad.id');
|
->group('unidad.id');
|
||||||
return $this->connection->execute($query, [$unidad_id])->fetch(PDO::FETCH_ASSOC);
|
return $this->connection->execute($query, [$unidad_id])->fetch(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
public function fetchSoldByUnidad(int $unidad_id): Model\Venta\Unidad
|
|
||||||
|
/**
|
||||||
|
* @param int $unidad_id
|
||||||
|
* @return bool
|
||||||
|
* @throws Implement\Exception\EmptyResult
|
||||||
|
*/
|
||||||
|
public function fetchSoldByUnidad(int $unidad_id): bool
|
||||||
{
|
{
|
||||||
$query = $this->connection->getQueryBuilder()
|
$query = $this->connection->getQueryBuilder()
|
||||||
->select('a.*')
|
->select('a.id')
|
||||||
->from("{$this->getTable()} a")
|
->from("{$this->getTable()} a")
|
||||||
->joined('INNER JOIN `propiedad_unidad` pu ON pu.`unidad` = a.`id`')
|
->joined('INNER JOIN `propiedad_unidad` pu ON pu.`unidad` = a.`id`')
|
||||||
->joined('INNER JOIN `venta` ON `venta`.`propiedad` = `pu`.`propiedad`')
|
->joined('INNER JOIN `venta` ON `venta`.`propiedad` = `pu`.`propiedad`')
|
||||||
->joined('LEFT OUTER JOIN (SELECT ev1.* FROM `estado_venta` ev1 JOIN (SELECT MAX(`id`) as `id`, `venta` FROM `estado_venta`) ev0 ON ev0.`id` = ev1.`id`) ev ON ev.`venta` = `venta`.`id`')
|
->joined($this->joinEstadoVenta())
|
||||||
->joined('LEFT OUTER JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`')
|
->joined('LEFT OUTER JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`')
|
||||||
->where('a.id = :unidad_id AND tev.activa = 1');
|
->where('a.id = :unidad_id AND tev.activa = 1');
|
||||||
return $this->fetchOne($query, ['unidad_id' => $unidad_id]);
|
try {
|
||||||
|
$result = $this->connection->execute($query, ['unidad_id' => $unidad_id])->fetch(PDO::FETCH_ASSOC);
|
||||||
|
return $result !== false;
|
||||||
|
} catch (PDOException $exception) {
|
||||||
|
throw new Implement\Exception\EmptyResult($query, $exception);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -220,4 +239,16 @@ class Unidad extends Ideal\Repository
|
|||||||
{
|
{
|
||||||
return "LEFT OUTER JOIN unidad_prorrateo up ON up.unidad_id = a.id";
|
return "LEFT OUTER JOIN unidad_prorrateo up ON up.unidad_id = a.id";
|
||||||
}
|
}
|
||||||
|
protected function joinEstadoVenta(): string
|
||||||
|
{
|
||||||
|
$subSubQuery = $this->connection->getQueryBuilder()
|
||||||
|
->select('MAX(id) AS id, venta')
|
||||||
|
->from('estado_venta')
|
||||||
|
->group('venta');
|
||||||
|
$subQuery = $this->connection->getQueryBuilder()
|
||||||
|
->select('ev1.*')
|
||||||
|
->from('estado_venta ev1')
|
||||||
|
->joined("LEFT OUTER JOIN ($subSubQuery) ev0 ON ev0.id = ev1.id");
|
||||||
|
return "LEFT OUTER JOIN ({$subQuery}) ev ON ev.`venta` = `venta`.`id`";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,12 @@ class Proyecto
|
|||||||
{
|
{
|
||||||
return $this->proyectoRepository->fetchAllEscriturando();
|
return $this->proyectoRepository->fetchAllEscriturando();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $proyecto_id
|
||||||
|
* @return Model\Proyecto
|
||||||
|
* @throws Implement\Exception\EmptyResult
|
||||||
|
*/
|
||||||
public function getById(int $proyecto_id): Model\Proyecto
|
public function getById(int $proyecto_id): Model\Proyecto
|
||||||
{
|
{
|
||||||
return $this->process($this->proyectoRepository->fetchById($proyecto_id));
|
return $this->process($this->proyectoRepository->fetchById($proyecto_id));
|
||||||
|
Reference in New Issue
Block a user