function getPayStubEntryAccountLinkObject()
 {
     if (is_object($this->pay_stub_entry_account_link_obj)) {
         return $this->pay_stub_entry_account_link_obj;
     } else {
         $pseallf = new PayStubEntryAccountLinkListFactory();
         $pseallf->getByCompanyID($this->getUserObject()->getCompany());
         if ($pseallf->getRecordCount() > 0) {
             $this->pay_stub_entry_account_link_obj = $pseallf->getCurrent();
             return $this->pay_stub_entry_account_link_obj;
         }
         return FALSE;
     }
 }
 static function addPresets($company_id)
 {
     if ($company_id == '') {
         Debug::text('Company ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     $clf = new CompanyListFactory();
     $clf->getById($company_id);
     if ($clf->getRecordCount() > 0) {
         $company_obj = $clf->getCurrent();
         $country = $company_obj->getCountry();
         $province = $company_obj->getProvince();
     } else {
         Debug::text('bCompany ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     //Get PayStub Link accounts
     $pseallf = new PayStubEntryAccountLinkListFactory();
     $pseallf->getByCompanyId($company_id);
     if ($pseallf->getRecordCount() > 0) {
         $psea_obj = $pseallf->getCurrent();
     } else {
         Debug::text('cCompany ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     require_once Environment::getBasePath() . '/classes/payroll_deduction/PayrollDeduction.class.php';
     $cdf = new CompanyDeductionFactory();
     $cdf->StartTransaction();
     /*
     								10 => 'Percent',
     								15 => 'Advanced Percent',
     								20 => 'Fixed Amount',
     
     								//Federal
     								100 => 'Federal Income Tax Formula',
     
     								//Province/State
     								200 => 'Province/State Income Tax Formula',
     								210 => 'Province/State UI Formula',
     */
     Debug::text('Country: ' . $country, __FILE__, __LINE__, __METHOD__, 10);
     switch (strtolower($country)) {
         case 'ca':
             $pd_obj = new PayrollDeduction($country, 'BC');
             //Pick default province for now.
             $pd_obj->setDate(time());
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Federal Income Tax');
             $cdf->setCalculation(100);
             $cdf->setCalculationOrder(100);
             $cdf->setCountry('CA');
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Federal Income%'));
             $cdf->setUserValue1($pd_obj->getBasicFederalClaimCodeAmount());
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $exclude_ids = array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Union'));
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 //var_dump($exclude_ids);
                 $cdf->setExcludePayStubEntryAccount($exclude_ids);
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Additional Income Tax');
             $cdf->setCalculation(20);
             $cdf->setCalculationOrder(105);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Additional Income Tax%'));
             $cdf->setUserValue1(0);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('CPP - Employee');
             $cdf->setCalculation(90);
             // CPP Formula
             $cdf->setCalculationOrder(80);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'CPP'));
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('CPP - Employer');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(85);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, '%CPP - Employer%'));
             $cdf->setUserValue1(100);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'CPP')));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('EI - Employee');
             $cdf->setCalculation(91);
             //EI Formula
             $cdf->setCalculationOrder(90);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'EI'));
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('EI - Employer');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(95);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, '%EI - Employer%'));
             $cdf->setUserValue1(140);
             //2006
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'EI')));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('WCB - Employer');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(95);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, '%WCB%'));
             $cdf->setUserValue1(0.0);
             //Default
             $cdf->setUserValue2(0);
             //Annual Wage Base: WCB has this, but can differ between rates/classifications.
             $cdf->setUserValue3(0);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(20);
             //Deduction
             $cdf->setName('Vacation Accrual');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(50);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 50, 'Vacation Accrual'));
             $cdf->setUserValue1(4);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 $exclude_ids = array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Accrual Release'), self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Time'));
                 $cdf->setExcludePayStubEntryAccount($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(20);
             //Deduction
             $cdf->setName('Vacation Release');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(51);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Accrual Release'));
             $cdf->setUserValue1(4);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 $exclude_ids = array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Accrual Release'), self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Time'));
                 $cdf->setExcludePayStubEntryAccount($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'us':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Federal Income Tax');
             $cdf->setCalculation(100);
             $cdf->setCalculationOrder(100);
             $cdf->setCountry('US');
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Federal Income%'));
             $cdf->setUserValue1(10);
             //Single
             $cdf->setUserValue2(1);
             //0 Allowances
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Advance Earned Income Credit (EIC)');
             $cdf->setCalculation(80);
             $cdf->setCalculationOrder(105);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Advance EIC%'));
             $cdf->setUserValue1(10);
             //Single
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Federal Unemployment Insurance - Employer');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(80);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'Fed. Unemployment Ins.'));
             $cdf->setUserValue1(0.8);
             //2009
             $cdf->setUserValue2(7000);
             $cdf->setUserValue3(0);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Social Security - Employee');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(80);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Social Security (FICA)'));
             $cdf->setUserValue1(6.2);
             //2009
             $cdf->setUserValue2(106800);
             $cdf->setUserValue3(0);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Social Security - Employer');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(85);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'Social Security%'));
             $cdf->setUserValue1(100);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Social Security (FICA)')));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Medicare - Employee');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(90);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Medicare'));
             $cdf->setUserValue1(1.45);
             //2009
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Medicare - Employer');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(95);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'Medicare'));
             $cdf->setUserValue1(100);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 //$cdf->setIncludePayStubEntryAccount( array( $psea_obj->getTotalGross() ));
                 $cdf->setIncludePayStubEntryAccount(array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Medicare')));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'cr':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(TTi18n::gettext('Income Tax'));
             $cdf->setCalculation(100);
             $cdf->setCalculationOrder(100);
             $cdf->setCountry('CR');
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Federal Income%'));
             $cdf->setUserValue1(10);
             //Single
             $cdf->setUserValue2(0);
             //0 Allowances
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
     }
     $pd_obj = new PayrollDeduction($country, $province);
     $pd_obj->setDate(time());
     Debug::text('Province/State: ' . $province, __FILE__, __LINE__, __METHOD__, 10);
     switch (strtolower($province)) {
         //Canada
         case 'ab':
         case 'bc':
         case 'sk':
         case 'mb':
         case 'qc':
         case 'on':
         case 'nl':
         case 'nb':
         case 'ns':
         case 'pe':
         case 'nt':
         case 'yt':
         case 'nu':
             $provincial_claim_amount = $pd_obj->getBasicProvinceClaimCodeAmount();
             break;
             //US
         //US
         case 'al':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ak':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance - Employer');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(32700);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance - Employee');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(32700);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ar':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(10000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'az':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Job Training');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Employee Training'));
             $cdf->setUserValue1(0.1);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ca':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Disability Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(180);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'State Disability Ins.'));
             $cdf->setUserValue1(1.1);
             //2009
             $cdf->setUserValue2(90669);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Employee Training');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Employee Training'));
             $cdf->setUserValue1(0.1);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'co':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(10000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ct':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(15000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'dc':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(9000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'de':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(10500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'fl':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ga':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'hi':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(13000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ia':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(23700);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'id':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(33200);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'il':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins. - Employer'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(12300);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'in':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ks':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ky':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'la':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ma':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(14000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'md':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'me':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(12000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'mi':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(9000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'mn':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(26000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'mo':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(12500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ms':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'mt':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(25100);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'nc':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(19300);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'nd':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(23700);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'nh':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ne':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(9000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'nj':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(28900);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(28900);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'nm':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(20900);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'nv':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(26600);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ny':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0);
             //2009
             $cdf->setUserValue2(8500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Reemployment Service Fund');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Reemployment'));
             $cdf->setUserValue1(0.075);
             //2009
             $cdf->setUserValue2(8500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Disability Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(180);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'State Disability Ins.'));
             $cdf->setUserValue1(0.5);
             //2009
             $cdf->setUserValue2(0);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'oh':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(9000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ok':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(14200);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'or':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Insurance'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(31300);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'pa':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ri':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Employment Security');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(18000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'sc':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'sd':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(9500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'tn':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'tx':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0);
             //2009
             $cdf->setUserValue2(9000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Employee Training');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Employee Training'));
             $cdf->setUserValue1(0.0);
             //2006
             $cdf->setUserValue2(9000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ut':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(27800);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'va':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'vt':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'wa':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(37500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'wi':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(12000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'wv':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'wy':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(21500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
     }
     if ($country == 'CA') {
         $cdf = new CompanyDeductionFactory();
         $cdf->setCompany($company_id);
         $cdf->setStatus(10);
         //Enabled
         $cdf->setType(10);
         //Tax
         $cdf->setName(strtoupper($province) . ' - Provincial Income Tax');
         $cdf->setCalculation(200);
         $cdf->setCalculationOrder(110);
         $cdf->setCountry('CA');
         $cdf->setProvince(strtoupper($province));
         $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Provincial Income%'));
         $cdf->setUserValue1($provincial_claim_amount);
         if ($cdf->isValid()) {
             $cdf->Save(FALSE);
             $exclude_ids = array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Union'));
             $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
             $cdf->setExcludePayStubEntryAccount($exclude_ids);
             unset($exclude_ids);
             if ($cdf->isValid()) {
                 $cdf->Save();
             }
         }
     } elseif ($country = 'US') {
         $cdf = new CompanyDeductionFactory();
         $cdf->setCompany($company_id);
         $cdf->setStatus(10);
         //Enabled
         $cdf->setType(10);
         //Tax
         $cdf->setName('State Income Tax');
         $cdf->setCalculation(200);
         $cdf->setCalculationOrder(200);
         $cdf->setCountry('US');
         $cdf->setProvince(strtoupper($province));
         $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%State Income%'));
         $cdf->setUserValue1(10);
         //Single
         $cdf->setUserValue2(1);
         //0 Allowances
         if ($cdf->isValid()) {
             $cdf->Save(FALSE);
             $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
             unset($exclude_ids);
             if ($cdf->isValid()) {
                 $cdf->Save();
             }
         }
     }
     $cdf->CommitTransaction();
     //$cdf->FailTransaction();
     return TRUE;
 }
 function getByTypeArrayByCompanyIdAndStatusId($company_id, $status_id)
 {
     $psealf = new PayStubEntryAccountListFactory();
     $psealf->getByCompanyIdAndStatusId($company_id, $status_id);
     $pseallf = new PayStubEntryAccountLinkListFactory();
     $pseallf->getByCompanyId($company_id);
     if ($pseallf->getRecordCount() == 0) {
         return FALSE;
     }
     $psea_type_map = $pseallf->getCurrent()->getPayStubEntryAccountIDToTypeIDMap();
     if ($psealf->getRecordCount() > 0) {
         foreach ($psealf as $psea_obj) {
             $entry_name_list[$psea_obj->getType()][] = $psea_obj->getId();
         }
         foreach ($entry_name_list[40] as $key => $entry_name_id) {
             if (isset($psea_type_map[$entry_name_id])) {
                 $tmp_entry_name_list[$entry_name_id] = $entry_name_list[$psea_type_map[$entry_name_id]];
             }
         }
         return $tmp_entry_name_list;
     }
     return FALSE;
 }
Ejemplo n.º 4
0
 $ugdf->setCompany($current_company->getId());
 $ugdf->setScript($_SERVER['SCRIPT_NAME']);
 $ugdf->setName($title);
 $ugdf->setData($setup_data);
 $ugdf->setDefault(TRUE);
 if ($ugdf->isValid()) {
     $ugdf->Save();
 }
 $ulf = new UserListFactory();
 $ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data);
 if ($ulf->getRecordCount() > 0) {
     foreach ($ulf as $u_obj) {
         $filter_data['user_ids'][] = $u_obj->getId();
     }
     if (isset($filter_data['user_ids']) and isset($filter_data['year'])) {
         $pseallf = new PayStubEntryAccountLinkListFactory();
         $pseallf->getByCompanyId($current_company->getId());
         if ($pseallf->getRecordCount() > 0) {
             $pseal_obj = $pseallf->getCurrent();
         }
         //
         //Get all data for the form.
         //
         foreach ($quarter_dates as $quarter_id => $quarter_dates_arr) {
             //Get Pay Periods in date range.
             Debug::Text('Start Date: ' . TTDate::getDate('DATE+TIME', $quarter_dates_arr['start']) . ' End Date: ' . TTDate::getDate('DATE+TIME', $quarter_dates_arr['end']), __FILE__, __LINE__, __METHOD__, 10);
             $pplf = new PayPeriodListFactory();
             $pplf->getByCompanyIdAndTransactionStartDateAndTransactionEndDate($current_company->getId(), $quarter_dates_arr['start'], $quarter_dates_arr['end']);
             if ($pplf->getRecordCount() > 0) {
                 foreach ($pplf as $pp_obj) {
                     $pay_period_ids[] = $pp_obj->getID();
Ejemplo n.º 5
0
 function createPayStubAccounts()
 {
     Debug::text('Saving.... Employee Deduction - Other', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($this->company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(20);
     $pseaf->setName('Other');
     $pseaf->setOrder(290);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     Debug::text('Saving.... Employee Deduction - Other2', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($this->company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(20);
     $pseaf->setName('Other2');
     $pseaf->setOrder(291);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     Debug::text('Saving.... Employee Deduction - EI', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($this->company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(20);
     $pseaf->setName('EI');
     $pseaf->setOrder(292);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     Debug::text('Saving.... Employee Deduction - CPP', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($this->company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(20);
     $pseaf->setName('CPP');
     $pseaf->setOrder(293);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     //Link Account EI and CPP accounts
     $pseallf = new PayStubEntryAccountLinkListFactory();
     $pseallf->getByCompanyId($this->company_id);
     if ($pseallf->getRecordCount() > 0) {
         $pseal_obj = $pseallf->getCurrent();
         $pseal_obj->setEmployeeEI(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'EI'));
         $pseal_obj->setEmployeeCPP(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'CPP'));
         $pseal_obj->Save();
     }
     return TRUE;
 }
 static function calculateLaborBurdenPercent($company_id, $user_id)
 {
     if ($company_id == '') {
         return FALSE;
     }
     if ($user_id == '') {
         return FALSE;
     }
     $end_epoch = TTDate::getTime();
     $start_epoch = TTDate::getTime() - 86400 * 180;
     //6mths
     $retval = FALSE;
     $pseallf = new PayStubEntryAccountLinkListFactory();
     $pseallf->getByCompanyID($company_id);
     if ($pseallf->getRecordCount() > 0) {
         $pself = new PayStubEntryListFactory();
         $total_gross = $pself->getAmountSumByUserIdAndEntryNameIdAndStartDateAndEndDate($user_id, $pseallf->getCurrent()->getTotalGross(), $start_epoch, $end_epoch);
         $total_employer_deductions = $pself->getAmountSumByUserIdAndEntryNameIdAndStartDateAndEndDate($user_id, $pseallf->getCurrent()->getTotalEmployerDeduction(), $start_epoch, $end_epoch);
         if (isset($total_employer_deductions['amount']) and isset($total_gross['amount'])) {
             $retval = bcmul(bcdiv($total_employer_deductions['amount'], $total_gross['amount']), 100, 2);
         }
     }
     return $retval;
 }
 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;
 }
 $status_options_filter = array(50, 60);
 /*
 if ( isset($pay_stub_amendment) AND $pay_stub_amendment->getStatus() == 55 ) {
 	$status_options_filter = array(55);
 } elseif ( isset($pay_stub_amendment) AND $pay_stub_amendment->getStatus() == 52 ) {
 	$status_options_filter = array(52);
 }
 */
 $status_options = Option::getByArray($status_options_filter, $rpsaf->getOptions('status'));
 $pay_stub_amendment_data['status_options'] = $status_options;
 $frequency_options = $rpsaf->getOptions('frequency');
 $pay_stub_amendment_data['frequency_options'] = $frequency_options;
 $percent_amount_options = $rpsaf->getOptions('percent_amount');
 $pay_stub_amendment_data['percent_amount_options'] = $percent_amount_options;
 $pay_stub_amendment_data['type_options'] = $rpsaf->getOptions('type');
 $pseallf = new PayStubEntryAccountLinkListFactory();
 $pseallf->getByCompanyId($current_company->getId());
 if ($pseallf->getRecordCount() > 0) {
     $net_pay_psea_id = $pseal_obj = $pseallf->getCurrent()->getTotalNetPay();
 }
 //$psenlf = new PayStubEntryNameListFactory();
 $psealf = new PayStubEntryAccountListFactory();
 $pay_stub_amendment_data['pay_stub_entry_name_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 20, 30, 50, 60, 65));
 $pay_stub_amendment_data['percent_amount_entry_name_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 20, 30, 40, 50, 60, 65));
 if (isset($net_pay_psea_id)) {
     unset($pay_stub_amendment_data['percent_amount_entry_name_options'][$net_pay_psea_id]);
 }
 $smarty->assign_by_ref('pay_stub_amendment_data', $pay_stub_amendment_data);
 $user_options = UserListFactory::getByCompanyIdArray($current_company->getId(), FALSE);
 $user_options = Misc::prependArray(array(-1 => TTi18n::gettext('-- ALL --')), $user_options);
 $pay_stub_amendment_data['user_options'] = $user_options;