Programming Language PHP

Namespace Oro\Bundle\SalesBundle\Entity

Class Opportunity

Method/Function setProbability

Total Examples 1

1 code examples of PHP Oro\Bundle\SalesBundle\Entity\Opportunity::setProbability extracted from open source projects

Was this example useful?
0
                                                    public function preUpdate(Opportunity $entity, PreUpdateEventArgs $args)
    {
        if (null === $entity->getStatus()) {
            return;
        }

        if (!$args->hasChangedField('status')) {
            return;
        }

        if ($this->hasWorkflowRestriction($entity)) {
            return;
        }

        $probability = $this->getDefaultProbability($entity->getStatus()->getId());
        if (null === $probability) {
            return;
        }

        $oldProbability = $probability;

        if (null !== $args->getOldValue('status')) {
            $oldProbability = $this->getDefaultProbability($args->getOldValue('status')->getId());
        }

        // don't change if it's already overwritten
        if ($oldProbability !== $entity->getProbability()) {
            return;
        }

        $entity->setProbability($probability);
        $this->recomputeChangeSet($args);
    }