function getSalesCommissionType(){ if($this->_sct == FALSE){ $sct = new SI_SalesCommissionType(); if($this->sales_com == 'Y' && $this->sales_com_type_id > 0){ if($sct->get($this->sales_com_type_id) === FALSE){ $this->error = "SI_Project::getSalesCommissionType(): Error getting sales commission: ".$sct->getLastError(); return FALSE; } $this->_sct = $sct; }elseif($this->sales_com == 'N'){ $this->_sct = $sct; }else{ $this->error = "SI_Project::getSalesCommissionType(): Invalid sales commission setting: {$this->sales_com}"; return FALSE; } } return $this->_sct; }
function _calcCommission(){ $task = $this->getTask(); if($task === FALSE) return FALSE; $amount = 0.00; if($this->sales_com_type_id > 0){ $task = $this->getTask(); if(!$task->isSpec() || ($task->isSpec() && $task->isCompleted())){ $sct = new SI_SalesCommissionType(); if($sct->get($this->sales_com_type_id) === FALSE){ $this->error = "SI_TaskActivity::_calcCommission(): Error getting sales commission type: ".$sct->getLastError(); return FALSE; } //debug_message("Found price of ".$this->price." and cost of ".$this->cost."\n"); $amount = round($sct->calculateCommission($this->price, $this->cost), 2); if($amount === FALSE){ $this->error = "SI_TaskActivity::_calcCommission(): Error calculating commission: ".$sct->getLastError(); return FALSE; } } } $this->com_amount = $amount; return TRUE; }