function Validate()
 {
     if ($this->getType() == 50) {
         //If the PSE account is an accrual, it can't link to one as well.
         $this->setAccrual(NULL);
     }
     //Make sure this account doesn't point to itself as an accrual.
     if ($this->isNew() == FALSE and $this->getAccrual() == $this->getId()) {
         $this->Validator->isTrue('accrual', FALSE, TTi18n::gettext('Accrual account is invalid'));
     }
     //Make sure PS order is correct, in that types can't be separated by total or accrual accounts.
     $pseallf = new PayStubEntryAccountLinkListFactory();
     $pseallf->getByCompanyId($this->getCompany());
     if ($pseallf->getRecordCount() > 0) {
         $pseal_obj = $pseallf->getCurrent();
         $psealf = new PayStubEntryAccountListFactory();
         $psealf->getByCompanyIdAndTypeId($this->getCompany(), 40);
         if ($psealf->getRecordCount() > 0) {
             foreach ($psealf as $psea_obj) {
                 $psea_map[$psea_obj->getId()] = $psea_obj->getOrder();
             }
             unset($psea_obj);
         }
         switch ($this->getType()) {
             case 10:
                 //Earning
                 //Greater the 0, less then Total Gross Account
                 if (isset($psea_map[$pseal_obj->getTotalGross()])) {
                     $min_ps_order = 0;
                     $max_ps_order = $psea_map[$pseal_obj->getTotalGross()];
                 }
                 break;
             case 20:
                 //EE Deduction
                 //Greater then Total Gross Account, less then Total Employee Deduction
                 if (isset($psea_map[$pseal_obj->getTotalGross()]) and isset($psea_map[$pseal_obj->getTotalEmployeeDeduction()])) {
                     $min_ps_order = $psea_map[$pseal_obj->getTotalGross()];
                     $max_ps_order = $psea_map[$pseal_obj->getTotalEmployeeDeduction()];
                 }
                 break;
             case 30:
                 //ER Deduction
                 //Greater then Net Pay Account, less then Total Employer Deduction
                 if (isset($psea_map[$pseal_obj->getTotalNetPay()]) and isset($psea_map[$pseal_obj->getTotalEmployerDeduction()])) {
                     $min_ps_order = $psea_map[$pseal_obj->getTotalNetPay()];
                     $max_ps_order = $psea_map[$pseal_obj->getTotalEmployerDeduction()];
                 }
                 break;
             case 50:
                 //Accrual
                 //Greater then Total Employer Deduction
                 if (isset($psea_map[$pseal_obj->getTotalEmployerDeduction()])) {
                     $min_ps_order = $psea_map[$pseal_obj->getTotalEmployerDeduction()];
                     $max_ps_order = 10001;
                 }
                 break;
         }
         if (isset($min_ps_order) and isset($max_ps_order) and ($this->getOrder() <= $min_ps_order or $this->getOrder() >= $max_ps_order)) {
             Debug::text('PS Order... Min: ' . $min_ps_order . ' Max: ' . $max_ps_order, __FILE__, __LINE__, __METHOD__, 10);
             $this->Validator->isTrue('ps_order', FALSE, TTi18n::gettext('Order is invalid for this type of account, it must be between') . ' ' . ($min_ps_order + 1) . ' ' . TTi18n::gettext('and') . ' ' . ($max_ps_order - 1));
         }
     }
     return TRUE;
 }