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\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Contracts
|
||||
{
|
||||
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();
|
||||
|
||||
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
|
||||
{
|
||||
$output = [
|
||||
@ -36,7 +39,8 @@ class Contracts
|
||||
}
|
||||
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 = [
|
||||
'contract_id' => $contract_id,
|
||||
@ -50,7 +54,8 @@ class Contracts
|
||||
|
||||
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();
|
||||
$output = [
|
||||
@ -82,7 +87,8 @@ class Contracts
|
||||
|
||||
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();
|
||||
$output = [
|
||||
@ -101,7 +107,8 @@ class Contracts
|
||||
|
||||
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();
|
||||
$output = [
|
||||
@ -126,7 +133,8 @@ class Contracts
|
||||
|
||||
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 = [
|
||||
'contract_id' => $contract_id,
|
||||
@ -147,6 +155,7 @@ class Contracts
|
||||
Service\Proyecto\Broker\Contract $contractService,
|
||||
Repository\Venta\Unidad $unitRepository,
|
||||
Repository\Venta\Promotion $promotionRepository,
|
||||
LoggerInterface $logger,
|
||||
int $contract_id): ResponseInterface
|
||||
{
|
||||
$input = $request->getParsedBody();
|
||||
@ -168,7 +177,9 @@ class Contracts
|
||||
'id' => $unit->id,
|
||||
'promotions' => $promotions
|
||||
];
|
||||
} catch (ServiceAction\Read | Implement\Exception\EmptyResult) {}
|
||||
} catch (ServiceAction\Read | Implement\Exception\EmptyResult $exception) {
|
||||
$logger->debug($exception);
|
||||
}
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
|
@ -63,21 +63,19 @@ class Unidades extends Ideal\Controller
|
||||
try {
|
||||
$proyecto = $proyectoService->getById($proyecto_id);
|
||||
foreach ($unidad_ids as $unidad_id) {
|
||||
$output['estados'][] = [
|
||||
'id' => $unidad_id,
|
||||
'sold' => false
|
||||
];
|
||||
try {
|
||||
$unidad = $unidadRepository->fetchById($unidad_id);
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
try {
|
||||
$output['estados'][] = [
|
||||
'id' => $unidad_id,
|
||||
'sold' => $unidadRepository->fetchSoldByUnidad((int) $unidad_id)
|
||||
'sold' => $unidadRepository->fetchSoldByUnidad($unidad->id)
|
||||
];
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
$output['estados'][] = [
|
||||
'id' => $unidad_id,
|
||||
'sold' => false
|
||||
];
|
||||
}
|
||||
}
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
}
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
|
Reference in New Issue
Block a user