Bridge/Doctrine/ORM/Repository/ShipmentRuleRepository.php
protected function getFindOneBySaleQuery()
    {
        if (null !== $this->findOneBySaleQuery) {
            return $this->findOneBySaleQuery;
        }

        $qb = $this->createQueryBuilder('r');
        $e = $qb->expr();

        return $this->findOneBySaleQuery = $qb
            ->andWhere($e->orX(
                $e->andX(
                    $e->eq('r.vatMode', ':net_mode'),
                    $e->lte('r.baseTotal', ':net_base')
                ),
                $e->andX(
                    $e->eq('r.vatMode', ':ati_mode'),
                    $e->lte('r.baseTotal', ':ati_base')
                )
            ))
            ->andWhere($e->orX(
                'r.methods IS EMPTY',
                $e->isMemberOf(':method', 'r.methods')
            ))
            ->andWhere($e->orX(
                'r.countries IS EMPTY',
                $e->isMemberOf(':country', 'r.countries')
            ))
            ->andWhere($e->orX(
                'r.customerGroups IS EMPTY',
                $e->isMemberOf(':group', 'r.customerGroups')
            ))
            ->andWhere($e->orX(
                'r.startAt IS NULL',
                $e->lte('r.startAt', ':date')
            ))
            ->andWhere($e->orX(
                'r.endAt IS NULL',
                $e->gte('r.endAt', ':date')
            ))
            ->getQuery()
            ->setMaxResults(1)
            ->useQueryCache(true);
    }
protected function getFindOneBySaleQuery()
    {
        if (null !== $this->findOneBySaleQuery) {
            return $this->findOneBySaleQuery;
        }

        $qb = $this->createQueryBuilder('r');
        $e = $qb->expr();

        return $this->findOneBySaleQuery = $qb
            ->andWhere($e->orX(
                $e->andX(
                    $e->eq('r.vatMode', ':net_mode'),
                    $e->lte('r.baseTotal', ':net_base')
                ),
                $e->andX(
                    $e->eq('r.vatMode', ':ati_mode'),
                    $e->lte('r.baseTotal', ':ati_base')
                )
            ))
            ->andWhere($e->orX(
                'r.methods IS EMPTY',
                $e->isMemberOf(':method', 'r.methods')
            ))
            ->andWhere($e->orX(
                'r.countries IS EMPTY',
                $e->isMemberOf(':country', 'r.countries')
            ))
            ->andWhere($e->orX(
                'r.customerGroups IS EMPTY',
                $e->isMemberOf(':group', 'r.customerGroups')
            ))
            ->andWhere($e->orX(
                'r.startAt IS NULL',
                $e->lte('r.startAt', ':date')
            ))
            ->andWhere($e->orX(
                'r.endAt IS NULL',
                $e->gte('r.endAt', ':date')
            ))
            ->getQuery()
            ->setMaxResults(1)
            ->useQueryCache(true);
    }
Returns the "find one by sale" query.

@return \Doctrine\ORM\Query