Code Duplication    Length = 16-19 lines in 3 locations

src/OroCRM/Bundle/SalesBundle/Entity/Repository/OpportunityRepository.php 3 locations

@@ 324-340 (lines=17) @@
321
     *
322
     * @return double
323
     */
324
    public function getTotalServicePipelineAmount(AclHelper $aclHelper, DateTime $start, DateTime $end)
325
    {
326
        $qb = $this->createQueryBuilder('o');
327
328
        $qb
329
            ->select('SUM(o.budgetAmount)')
330
            ->andWhere($qb->expr()->between('o.createdAt', ':start', ':end'))
331
            ->andWhere('o.closeDate IS NULL')
332
            ->andWhere('o.status = :status')
333
            ->andWhere('o.probability != 0')
334
            ->andWhere('o.probability != 1')
335
            ->setParameter('start', $start)
336
            ->setParameter('end', $end)
337
            ->setParameter('status', 'in_progress');
338
339
        return $aclHelper->apply($qb)->getSingleScalarResult();
340
    }
341
342
    /**
343
     * @param AclHelper $aclHelper
@@ 349-367 (lines=19) @@
346
     *
347
     * @return double
348
     */
349
    public function getTotalServicePipelineAmountInProgress(
350
        AclHelper $aclHelper,
351
        DateTime $start,
352
        DateTime $end
353
    ) {
354
        $qb = $this->createQueryBuilder('o');
355
356
        $qb
357
            ->select('SUM(o.budgetAmount)')
358
            ->andWhere($qb->expr()->between('o.createdAt', ':start', ':end'))
359
            ->andWhere('o.status = :status')
360
            ->andWhere('o.probability != 0')
361
            ->andWhere('o.probability != 1')
362
            ->setParameter('start', $start)
363
            ->setParameter('end', $end)
364
            ->setParameter('status', 'in_progress');
365
366
        return $aclHelper->apply($qb)->getSingleScalarResult();
367
    }
368
369
    /**
370
     * @param AclHelper $aclHelper
@@ 396-411 (lines=16) @@
393
     *
394
     * @return double
395
     */
396
    public function getOpenWeightedPipelineAmount(AclHelper $aclHelper, DateTime $start, DateTime $end)
397
    {
398
        $qb = $this->createQueryBuilder('o');
399
400
        $qb
401
            ->select('SUM(o.budgetAmount * o.probability)')
402
            ->andWhere($qb->expr()->between('o.createdAt', ':start', ':end'))
403
            ->andWhere('o.status = :status')
404
            ->andWhere('o.probability != 0')
405
            ->andWhere('o.probability != 1')
406
            ->setParameter('start', $start)
407
            ->setParameter('end', $end)
408
            ->setParameter('status', 'in_progress');
409
410
        return $aclHelper->apply($qb)->getSingleScalarResult();
411
    }
412
}
413