public function applyAttribution()
    {
        if ($this->valid && $this->cost && Stat::TYPE_ACCEPTED === $this->status) {
            // check if an id exists and attribution field exists b/c sometimes its not a well-formed entity
            if ($this->contact->getId() && !property_exists($this->contact, 'attribution')) {
                $this->contact = $this->contactModel->getEntity($this->contact->getId());
            }
            $originalAttribution = $this->contact->getAttribution();
            // Attribution is always a negative number to represent cost.
            $this->attribution = ($this->cost * -1);
            $this->contact->addUpdatedField(
                'attribution',
                $originalAttribution + $this->attribution,
                $originalAttribution
            );
            $this->dispatchContextCreate();

            if (!$this->imported) {
                // contacts imported via file upload hit this method via a pre-save event so dont save here.
                $this->contactModel->saveEntity($this->contact);
            }
        }
    }
public function applyAttribution()
    {
        if ($this->valid && $this->cost && Stat::TYPE_ACCEPTED === $this->status) {
            // check if an id exists and attribution field exists b/c sometimes its not a well-formed entity
            if ($this->contact->getId() && !property_exists($this->contact, 'attribution')) {
                $this->contact = $this->contactModel->getEntity($this->contact->getId());
            }
            $originalAttribution = $this->contact->getAttribution();
            // Attribution is always a negative number to represent cost.
            $this->attribution = ($this->cost * -1);
            $this->contact->addUpdatedField(
                'attribution',
                $originalAttribution + $this->attribution,
                $originalAttribution
            );
            $this->dispatchContextCreate();

            if (!$this->imported) {
                // contacts imported via file upload hit this method via a pre-save event so dont save here.
                $this->contactModel->saveEntity($this->contact);
            }
        }
    }
public function applyAttribution ( ) { if ( $ this -> valid && $ this -> cost && Stat :: TYPE_ACCEPTED === $ this -> status ) { // check if an id exists and attribution field exists b/c sometimes its not a well-formed entity if ( $ this -> contact -> getId ( ) && ! property_exists ( $ this -> contact , 'attribution' ) ) { $ this -> contact = $ this -> contactModel -> getEntity ( $ this -> contact -> getId ( ) ) ; } $ originalAttribution = $ this -> contact -> getAttribution ( ) ; // Attribution is always a negative number to represent cost. $ this -> attribution = ( $ this -> cost * - 1 ) ; $ this -> contact -> addUpdatedField ( 'attribution' , $ originalAttribution + $ this -> attribution , $ originalAttribution ) ; $ this -> dispatchContextCreate ( ) ; if ( ! $ this -> imported ) { // contacts imported via file upload hit this method via a pre-save event so dont save here. $ this -> contactModel -> saveEntity ( $ this -> contact ) ; } } }
Apply attribution if we accepted the lead.

@throws \Exception
Apply attribution if we accepted the lead .