Separacion de Promocion de Contrato y Precio
"Simplificacion" de datos en listado de precios
This commit is contained in:
@ -128,6 +128,21 @@ class Contract extends Common\Ideal\Repository
|
||||
return $this->fetchOne($query, ['project_id' => $projectId, 'broker_rut' => $brokerRut, 'state' => Model\Proyecto\Broker\Contract\State\Type::ACTIVE->value]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $promotion_id
|
||||
* @return array
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchByPromotion(int $promotion_id): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select('a.*')
|
||||
->from("{$this->getTable()} a")
|
||||
->joined('INNER JOIN promotion_contracts pc ON pc.contract_id = a.id')
|
||||
->where('pc.promotion_id = :promotion_id');
|
||||
return $this->fetchMany($query, ['promotion_id' => $promotion_id]);
|
||||
}
|
||||
|
||||
protected function statusJoin(): string
|
||||
{
|
||||
return 'INNER JOIN (SELECT bcs1.* FROM broker_contract_states bcs1 INNER JOIN (SELECT MAX(id) AS id, contract_id FROM broker_contract_states GROUP BY contract_id) bcs0 ON bcs0.id = bcs1.id) bcs ON bcs.contract_id = a.id';
|
||||
|
Reference in New Issue
Block a user