Code Duplication    Length = 19-23 lines in 3 locations

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

@@ 516-538 (lines=23) @@
513
     *
514
     * @return double
515
     */
516
    public function getOpenWeightedPipelineAmount(
517
        AclHelper $aclHelper,
518
        \DateTime $start = null,
519
        \DateTime $end = null,
520
        $owners = []
521
    ) {
522
        $qb = $this->createQueryBuilder('o');
523
524
        $qb
525
            ->select('SUM(o.budgetAmount * o.probability)')
526
            ->andWhere('o.status = :status')
527
            ->andWhere('o.probability != 0')
528
            ->andWhere('o.probability != 1')
529
            ->setParameter('status', self::OPPORTUNITY_STATE_IN_PROGRESS_CODE);
530
531
        $this->setCreationPeriod($qb, $start, $end);
532
533
        if ($owners) {
534
            QueryUtils::applyOptimizedIn($qb, 'o.owner', $owners);
535
        }
536
537
        return $aclHelper->apply($qb)->getSingleScalarResult();
538
    }
539
540
    /**
541
     * @param AclHelper $aclHelper
@@ 575-593 (lines=19) @@
572
     *
573
     * @return int
574
     */
575
    public function getWonOpportunitiesToDateCount(
576
        AclHelper $aclHelper,
577
        \DateTime $start = null,
578
        \DateTime $end = null,
579
        $owners = []
580
    ) {
581
        $qb = $this->createQueryBuilder('o');
582
        $qb->select('COUNT(o.id)')
583
            ->andWhere('o.status = :status')
584
            ->setParameter('status', self::OPPORTUNITY_STATUS_CLOSED_WON_CODE);
585
586
        $this->setClosedPeriod($qb, $start, $end);
587
588
        if ($owners) {
589
            QueryUtils::applyOptimizedIn($qb, 'o.owner', $owners);
590
        }
591
592
        return $aclHelper->apply($qb)->getSingleScalarResult();
593
    }
594
595
    /**
596
     * @param AclHelper $aclHelper
@@ 603-621 (lines=19) @@
600
     *
601
     * @return double
602
     */
603
    public function getWonOpportunitiesToDateAmount(
604
        AclHelper $aclHelper,
605
        \DateTime $start = null,
606
        \DateTime $end = null,
607
        $owners = []
608
    ) {
609
        $qb = $this->createQueryBuilder('o');
610
        $qb->select('SUM(o.closeRevenue)')
611
            ->andWhere('o.status = :status')
612
            ->setParameter('status', self::OPPORTUNITY_STATUS_CLOSED_WON_CODE);
613
614
        $this->setClosedPeriod($qb, $start, $end);
615
616
        if ($owners) {
617
            QueryUtils::applyOptimizedIn($qb, 'o.owner', $owners);
618
        }
619
620
        return $aclHelper->apply($qb)->getSingleScalarResult();
621
    }
622
623
    /**
624
     * @param QueryBuilder $qb