}
 if (isset($data['include_account_amount_type_id'])) {
     $cdf->setIncludeAccountAmountType($data['include_account_amount_type_id']);
 }
 if (isset($data['exclude_account_amount_type_id'])) {
     $cdf->setExcludeAccountAmountType($data['exclude_account_amount_type_id']);
 }
 if ($cdf->isValid()) {
     $cdf->Save(FALSE);
     if (isset($data['include_pay_stub_entry_account_ids'])) {
         $cdf->setIncludePayStubEntryAccount($data['include_pay_stub_entry_account_ids']);
     } else {
         $cdf->setIncludePayStubEntryAccount(array());
     }
     if (isset($data['exclude_pay_stub_entry_account_ids'])) {
         $cdf->setExcludePayStubEntryAccount($data['exclude_pay_stub_entry_account_ids']);
     } else {
         $cdf->setExcludePayStubEntryAccount(array());
     }
     if (isset($data['user_ids'])) {
         $cdf->setUser($data['user_ids']);
     } else {
         $cdf->setUser(array());
     }
     if ($cdf->isValid()) {
         $cdf->Save(TRUE);
         $cdf->CommitTransaction();
         Redirect::Page(URLBuilder::getURL(NULL, 'CompanyDeductionList.php'));
         break;
     }
 }
 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 createCompanyDeductions()
 {
     //Test Wage Base amount
     $cdf = new CompanyDeductionFactory();
     $cdf->setCompany($this->company_id);
     $cdf->setStatus(10);
     //Enabled
     $cdf->setType(10);
     //Tax
     $cdf->setName('Union Dues');
     $cdf->setCalculation(15);
     $cdf->setCalculationOrder(90);
     $cdf->setPayStubEntryAccount(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'Union Dues'));
     $cdf->setUserValue1(1);
     //10%
     $cdf->setUserValue2(3000);
     if ($cdf->isValid()) {
         $cdf->Save(FALSE);
         $cdf->setIncludePayStubEntryAccount(array($this->pay_stub_account_link_arr['total_gross']));
         if ($cdf->isValid()) {
             $cdf->Save();
         }
     }
     //Test Wage Exempt Amount
     $cdf = new CompanyDeductionFactory();
     $cdf->setCompany($this->company_id);
     $cdf->setStatus(10);
     //Enabled
     $cdf->setType(10);
     //Tax
     $cdf->setName('Union Dues2');
     $cdf->setCalculation(15);
     $cdf->setCalculationOrder(90);
     $cdf->setPayStubEntryAccount(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'Other'));
     $cdf->setUserValue1(10);
     //10%
     //$cdf->setUserValue2( 0 );
     $cdf->setUserValue3(78000);
     //Annual
     if ($cdf->isValid()) {
         $cdf->Save(FALSE);
         $cdf->setIncludePayStubEntryAccount(array($this->pay_stub_account_link_arr['total_gross']));
         if ($cdf->isValid()) {
             $cdf->Save();
         }
     }
     //Test Advanced Percent Calculation maximum amount.
     $cdf = new CompanyDeductionFactory();
     $cdf->setCompany($this->company_id);
     $cdf->setStatus(10);
     //Enabled
     $cdf->setType(10);
     //Tax
     $cdf->setName('Test Advanced Percent 1');
     $cdf->setCalculation(15);
     $cdf->setCalculationOrder(90);
     $cdf->setPayStubEntryAccount(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'Advanced Percent 1'));
     $cdf->setUserValue1(1);
     //1%
     $cdf->setUserValue2(2000);
     //Wage Base
     if ($cdf->isValid()) {
         $cdf->Save(FALSE);
         $cdf->setIncludePayStubEntryAccount(array($this->pay_stub_account_link_arr['regular_time']));
         if ($cdf->isValid()) {
             $cdf->Save();
         }
     }
     //Test Advanced Percent Calculation maximum amount.
     $cdf = new CompanyDeductionFactory();
     $cdf->setCompany($this->company_id);
     $cdf->setStatus(10);
     //Enabled
     $cdf->setType(10);
     //Tax
     $cdf->setName('Test Advanced Percent 2');
     $cdf->setCalculation(15);
     $cdf->setCalculationOrder(90);
     $cdf->setPayStubEntryAccount(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'Advanced Percent 2'));
     $cdf->setUserValue1(1);
     //1%
     $cdf->setUserValue2(2500);
     //Wage Base
     if ($cdf->isValid()) {
         $cdf->Save(FALSE);
         $cdf->setIncludePayStubEntryAccount(array($this->pay_stub_account_link_arr['regular_time']));
         if ($cdf->isValid()) {
             $cdf->Save();
         }
     }
     $cdf = new CompanyDeductionFactory();
     $cdf->setCompany($this->company_id);
     $cdf->setStatus(10);
     $cdf->setType(30);
     $cdf->setName('Test Custom Formula');
     $cdf->setCalculation(69);
     $cdf->setCalculationOrder(80);
     $cdf->setPayStubEntryAccount(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'Other2'));
     $cdf->setCompanyValue1("(#custom_value1#+#custom_value2#+#custom_value3#+#custom_value4#+#custom_value5#+#custom_value6#+#custom_value7#+#custom_value8#+#custom_value9#+#custom_value10#)/100");
     $cdf->setUserValue1(10);
     $cdf->setUserValue2(20);
     $cdf->setUserValue3(30);
     $cdf->setUserValue4(40);
     $cdf->setUserValue5(50);
     $cdf->setUserValue6(60);
     $cdf->setUserValue7(70);
     $cdf->setUserValue8(80);
     $cdf->setUserValue9(90);
     $cdf->setUserValue10(100);
     if ($cdf->isValid()) {
         $cdf->Save(FALSE);
         $cdf->setIncludePayStubEntryAccount(array($this->pay_stub_account_link_arr['total_deductions']));
         if ($cdf->isValid()) {
             $cdf->Save();
         }
     }
     $cdf = new CompanyDeductionFactory();
     $cdf->setCompany($this->company_id);
     $cdf->setStatus(10);
     $cdf->setType(20);
     $cdf->setName('Test Custom Formula 1');
     $cdf->setCalculation(69);
     $cdf->setCalculationOrder(80);
     $cdf->setPayStubEntryAccount(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'Custom1'));
     $cdf->setCompanyValue1("(#custom_value1#*((#custom_value2#+#custom_value3#)*#custom_value4#/#custom_value5#)+#custom_value6#/(#custom_value7#+#custom_value8#)+#custom_value9#+#custom_value10#)/100");
     $cdf->setUserValue1(45);
     $cdf->setUserValue2(20);
     $cdf->setUserValue3(30);
     $cdf->setUserValue4(40);
     $cdf->setUserValue5(78.12);
     $cdf->setUserValue6(60);
     $cdf->setUserValue7(44.34);
     $cdf->setUserValue8(33);
     $cdf->setUserValue9(90);
     $cdf->setUserValue10(8);
     if ($cdf->isValid()) {
         $cdf->Save(FALSE);
         $cdf->setIncludePayStubEntryAccount(array($this->pay_stub_account_link_arr['total_deductions']));
         if ($cdf->isValid()) {
             $cdf->Save();
         }
     }
     $cdf = new CompanyDeductionFactory();
     $cdf->setCompany($this->company_id);
     $cdf->setStatus(10);
     $cdf->setType(20);
     $cdf->setName('Test Custom Formula 2');
     $cdf->setCalculation(69);
     $cdf->setCalculationOrder(80);
     $cdf->setPayStubEntryAccount(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'Custom2'));
     $cdf->setCompanyValue1("values(n) = (#custom_value1#+#custom_value2#+#custom_value3#+#custom_value4#+#custom_value5#+#custom_value6#+#custom_value7#+#custom_value8#+#custom_value9#+#custom_value10#)/n\n                                include_amounts(n)=(#include_pay_stub_amount#+#include_pay_stub_ytd_amount#)/n\n                                exclude_amounts(n)=(#exclude_pay_stub_amount#+#exclude_pay_stub_ytd_amount#)/n\n                                (values(2)+include_amounts(3)+exclude_amounts(4)+#employee_hourly_rate#)/100");
     $cdf->setUserValue1(0.23);
     $cdf->setUserValue2(1114.65);
     $cdf->setUserValue3(30);
     $cdf->setUserValue4(40.55);
     $cdf->setUserValue5(55.55);
     $cdf->setUserValue6(32.33);
     $cdf->setUserValue7(44.34);
     $cdf->setUserValue8(21);
     $cdf->setUserValue9(47);
     $cdf->setUserValue10(8);
     if ($cdf->isValid()) {
         $cdf->Save(FALSE);
         $cdf->setIncludePayStubEntryAccount(array($this->pay_stub_account_link_arr['regular_time'], $this->pay_stub_account_link_arr['vacation_accrual'], $this->pay_stub_account_link_arr['advanced_percent_1'], $this->pay_stub_account_link_arr['cpp'], $this->pay_stub_account_link_arr['ei']));
         $cdf->setExcludePayStubEntryAccount(array($this->pay_stub_account_link_arr['total_gross']));
         if ($cdf->isValid()) {
             $cdf->Save();
         }
     }
     $cdf = new CompanyDeductionFactory();
     $cdf->setCompany($this->company_id);
     $cdf->setStatus(10);
     //Enabled
     $cdf->setType(10);
     //Tax
     $cdf->setName('EI - Employee');
     $cdf->setCalculation(91);
     //EI Formula
     $cdf->setCalculationOrder(90);
     $cdf->setPayStubEntryAccount(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'EI'));
     if ($cdf->isValid()) {
         $cdf->Save(FALSE);
         $cdf->setIncludePayStubEntryAccount(array($this->pay_stub_account_link_arr['total_gross']));
         if ($cdf->isValid()) {
             $cdf->Save();
         }
     }
     $cdf = new CompanyDeductionFactory();
     $cdf->setCompany($this->company_id);
     $cdf->setStatus(10);
     //Enabled
     $cdf->setType(10);
     //Tax
     $cdf->setName('CPP - Employee');
     $cdf->setCalculation(90);
     //CPP Formula
     $cdf->setCalculationOrder(91);
     $cdf->setPayStubEntryAccount(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'CPP'));
     if ($cdf->isValid()) {
         $cdf->Save(FALSE);
         $cdf->setIncludePayStubEntryAccount(array($this->pay_stub_account_link_arr['total_gross']));
         if ($cdf->isValid()) {
             $cdf->Save();
         }
     }
     return TRUE;
 }