Add price.

@param PriceAggregate $priceAggregate
@param string         $operation [optional]

@return $this
18169
public function addPriceAggregate(PriceAggregate $priceAggregate, $operation = self::ADD)
    {
        return $this->addPrices($priceAggregate->getPerTaxRate(), $operation);
    }
382636
private function forwardAdd(OperationArguments $args)
    {
        if ($args->has('expiry')) {
            return $this->addInternal($args->getKey(), $args->getValue(), $args->getExpiry());
        }
        return $this->addInternal($args->getKey(), $args->getValue());
    }
218085
public function addPrice(Price $price, $operation = self::ADD)
    {
        $percent = $this->sanitizePercent($price);

        // Prepare new tax
        if (!$this->hasTaxPercent($percent)) {
            $this->perTaxRate[$percent] = [
                'gross'   => 0,
                'net'     => 0,
                'percent' => $percent,
            ];
            ksort($this->perTaxRate, SORT_NUMERIC);
        }

        // Switch positive <> negative prices if we want to subtract price
        if ($operation == self::SUBTRACT) {
            // Make sure original object is NOT changed
            $price = clone $price;
            $price->changeSign();
        }

        // Add price
        $this->perTaxRate[$percent]['gross'] += $price->get('gross');
        $this->perTaxRate[$percent]['net']   += $price->get('net');

        // Remove tax block if price is now 0.00
        if (
            !$this->getKeepEmptyTaxRates()
            && !Price::round($this->perTaxRate[$percent]['gross'])
            && !Price::round($this->perTaxRate[$percent]['net'])
        ) {
            unset($this->perTaxRate[$percent]);
        }

        return $this;
    }
1146071
protected function getAggregate(callable $prepareAggregate)
    {
        $query = clone $this;
        $query->select = [];
        $query->order = [];
        $query = $query
            ->offset(null)
            ->limit(null)
            ->apply($prepareAggregate)
            ->apply($this->database->getTablePrefixer());

        $compiled = $this->database->getGrammar()->compileSelect($query);

        return current($this->database->selectFirst($compiled->getSQL(), $compiled->getBindings()));
    }
190035
void addSubAggs(QueryConverter queryConverter, Aggregation agg, AggregationBuilder builder) {
        Map<String, Aggregation> aggs = agg.getAggs();
        for (String key : aggs.keySet()) {
            Aggregation subAgg = aggs.get(key);
            AbstractAggregationBuilder subBuilder = queryConverter.converterAggregation(subAgg);
            if (subBuilder != null) {
                builder.subAggregation(subBuilder);
            }
        }
    }
1348641
public function processTransaction(array $transactionData, string $operation): ProcessInterface
    {
        // When hitting the process endpoint, we only need the transactionId and operation key/value pairs, and
        // optionally the transactionAmount if we are capturing a portion of the total amount.
        $transactionData = array_filter($transactionData + ['operation' => $operation], function ($k) {
            return in_array($k, ['transactionId', 'operation', 'transactionAmount']);
        }, ARRAY_FILTER_USE_KEY);

        $uri = $this->getUri('process', $this->getParameters($transactionData));
        /** @var ProcessInterface $response */
        $response = $this->performRequest((string) $uri);

        Assert::isInstanceOf($response, ProcessInterface::class, 'Invalid response');

        return $response;
    }
913994
public function append(Contract $aggregateRootType, EventStream $eventStream)
    {
        $statement = $this->insertQuery->prepare();

        try {
            while ($eventStream->hasNext()) {
                $event = $eventStream->next();

                $statement->bindValue(':aggregate_id', $event->aggregateRootIdentifier()->toString());
                $statement->bindValue(':aggregate_type', $aggregateRootType->toString());
                $statement->bindValue(':aggregate_version', $event->sequenceNumber());
                $statement->bindValue(':event_id', $event->identifier()->toString());
                $statement->bindValue(':event_payload', $this->eventSerializer->serializePayload($event));
                $statement->bindValue(':event_payload_type', $event->payloadType()->toString());
                $statement->bindValue(':event_metadata', $this->eventSerializer->serializeMetadata($event));
                $statement->bindValue(':event_metadata_type', $event->metadataType()->toString());

                $statement->execute();
                $statement->closeCursor();
            }
        } catch (\PDOException $exception) {
            // 23000 being the primary key duplicate entry error code.
            if ($exception->errorInfo[0] === '23000') {
                throw new ConcurrencyException('Concurrent modification detected.');
            }

            throw $exception;
        }
    }
86855
public function sumRowMetadata($rowToSum, $aggregationOperations = array())
    {
        if (!empty($rowToSum->metadata)
            && !$this->isSummaryRow()
        ) {
            $aggregatedMetadata = array();

            if (is_array($aggregationOperations)) {
                // we need to aggregate value before value is overwritten by maybe another row
                foreach ($aggregationOperations as $column => $operation) {
                    $thisMetadata = $this->getMetadata($column);
                    $sumMetadata  = $rowToSum->getMetadata($column);

                    if ($thisMetadata === false && $sumMetadata === false) {
                        continue;
                    }

                    $aggregatedMetadata[$column] = $this->getColumnValuesMerged($operation, $thisMetadata, $sumMetadata, $this, $rowToSum, $column);
                }
            }

            // We shall update metadata, and keep the metadata with the _most visits or pageviews_, rather than first or last seen
            $visits = max($rowToSum->getColumn(Metrics::INDEX_PAGE_NB_HITS) || $rowToSum->getColumn(Metrics::INDEX_NB_VISITS),
                // Old format pre-1.2, @see also method doSumVisitsMetrics()
                $rowToSum->getColumn('nb_actions') || $rowToSum->getColumn('nb_visits'));
            if (($visits && $visits > $this->maxVisitsSummed)
                || empty($this->metadata)
            ) {
                $this->maxVisitsSummed = $visits;
                $this->metadata = $rowToSum->metadata;
            }

            foreach ($aggregatedMetadata as $column => $value) {
                // we need to make sure aggregated value is used, and not metadata from $rowToSum
                $this->setMetadata($column, $value);
            }
        }
    }
1323054
public function addAnd($value , $operator = null) {
        
        /*@var $criterion QueryCriterionInterface */
        $criterion = end($this->storedQueryCriteria);
        $criterion->addAnd($value, $operator);
        return $this;
    }
576252
protected function _prepareCommand($operation, $args)
	{
	    $args = ($args) ?:$this->args;
	    $command = new Command($this->service, $operation, $args);
	    
	    if ($this->context) {
	        $command->setContext($this->context);
	    } else {
	        $command->setContext($this->broker->getDefaultContext());
	    }
	    
	    if ($this->identity) {
	        $command->setIdentity($this->identity);
	    } else {
	        $command->setIdentity($this->broker->getDefaultIdentity());
	    }
	    
	    return $command;
	}
944224
public function addTransaction(Transaction $transaction)
    {
        $transaction->setAgreement($this);
        $this->transactions->add($transaction);

        return $this;
    }
919102
public function addPreOperation(LdapOperationInterface ...$operations)
    {
        foreach ($operations as $operation) {
            $this->preOperations[] = $operation;
        }

        return $this;
    }
1185749
public function withSum($relation, $field, $subQuery = true)
    {
        return $this->withAggregate($relation, 'sum', $field, $subQuery);
    }
110847
public function setAggregateValue($var)
    {
        GPBUtil::checkString($var, True);
        $this->aggregate_value = $var;
        $this->has_aggregate_value = true;

        return $this;
    }
340040
public function queue($operation, $args = null, $options = [])
	{
		$command = $this->_prepareCommand($operation, $args);
		return $this->broker->queue($command, $options);
	}
921614
public function setPrice(Money $price): self
    {
        $this->updateCurrency($price);
        $this->price = (int) $price->getAmount();
        $this->updateTotalPrice();

        return $this;
    }
1068498
public function setOperation(\CampaignChain\CoreBundle\Entity\Operation $operation)
    {
        $this->operation = $operation;

        return $this;
    }