function testCR_2007a_BiWeekly_Single_LowIncome() { Debug::text('CR - BiWeekly - Beginning of 2007 01-Jan-07: ', __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('CR', NULL); $pd_obj->setDate(strtotime('01-Jan-07')); $pd_obj->setAnnualPayPeriods(26); //Bi-Weekly $pd_obj->setFederalFilingStatus(10); //Single $pd_obj->setFederalAllowance(1); //$pd_obj->setUserCurrency('CRC'); $pd_obj->setGrossPayPeriodIncome(260000.0); $this->assertEquals($this->mf($pd_obj->getGrossPayPeriodIncome()), '260000.00'); $this->assertEquals($this->mf($pd_obj->getFederalPayPeriodDeductions()), '3993.85'); //100.73 }
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 testCA_2006a_MAXEI_LowIncome() { Debug::text('CA - MAXEI - Beginning of 2006 01-Jan-06: ', __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('CA', 'BC'); $pd_obj->setDate(strtotime('01-Jan-06')); $pd_obj->setEnableCPPAndEIDeduction(TRUE); //Deduct CPP/EI. $pd_obj->setAnnualPayPeriods(26); $pd_obj->setFederalTotalClaimAmount(9039); $pd_obj->setProvincialTotalClaimAmount(0); $pd_obj->setWCBRate(0.18); $pd_obj->setEIExempt(FALSE); $pd_obj->setCPPExempt(FALSE); $pd_obj->setFederalTaxExempt(FALSE); $pd_obj->setProvincialTaxExempt(FALSE); $pd_obj->setYearToDateCPPContribution(0); $pd_obj->setYearToDateEIContribution(728.3); //729.30 - 1.00 $pd_obj->setGrossPayPeriodIncome(587.0); //var_dump($pd_obj->getArray()); $this->assertEquals($this->mf($pd_obj->getGrossPayPeriodIncome()), '587.00'); $this->assertEquals($this->mf($pd_obj->getEmployeeEI()), '1.00'); $this->assertEquals($this->mf($pd_obj->getEmployerEI()), '1.40'); }
function testCA_2013a_Example4() { Debug::text('CA - Example1 - Beginning of 01-Jan-2013: ', __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('CA', 'BC'); $pd_obj->setDate(strtotime('01-Jan-2013')); $pd_obj->setEnableCPPAndEIDeduction(TRUE); //Deduct CPP/EI. $pd_obj->setAnnualPayPeriods(26); $pd_obj->setFederalTotalClaimAmount(11038); $pd_obj->setProvincialTotalClaimAmount(10276); $pd_obj->setWCBRate(0); $pd_obj->setEIExempt(FALSE); $pd_obj->setCPPExempt(FALSE); $pd_obj->setFederalTaxExempt(FALSE); $pd_obj->setProvincialTaxExempt(FALSE); $pd_obj->setYearToDateCPPContribution(0); $pd_obj->setYearToDateEIContribution(0); $pd_obj->setGrossPayPeriodIncome(1560); $this->assertEquals($this->mf($pd_obj->getGrossPayPeriodIncome()), '1560'); $this->assertEquals($this->mf($pd_obj->getFederalPayPeriodDeductions()), '148.89'); $this->assertEquals($this->mf($pd_obj->getProvincialPayPeriodDeductions()), '56.91'); }
$test_data[$country][$province_code]['income'][] = $income + $variance; $test_data[$country][$province_code]['federal_claim'] = $static_test_data[$country]['federal_claim']; $test_data[$country][$province_code]['provincial_claim'] = $static_test_data[$country]['provincial_claim']; $test_data[$country][$province_code]['income'] = array_unique($test_data[$country][$province_code]['income']); $prev_income = $income; $prev_status = isset($tax_row['status']) ? $tax_row['status'] : NULL; $prev_province = $province_code; $i++; unset($income); } } foreach ($test_data[$country][$province_code]['provincial_claim'] as $provincial_claim) { foreach ($test_data[$country][$province_code]['federal_claim'] as $federal_claim) { foreach ($test_data[$country][$province_code]['income'] as $income) { $pd_obj = new PayrollDeduction($country, $province_code); $pd_obj->setDate($effective_date); $pd_obj->setAnnualPayPeriods($pay_periods); $pd_obj->setEnableCPPAndEIDeduction(TRUE); //Deduct CPP/EI. $pd_obj->setFederalTotalClaimAmount($federal_claim); $pd_obj->setProvincialTotalClaimAmount($provincial_claim); $pd_obj->setEIExempt(FALSE); $pd_obj->setCPPExempt(FALSE); $pd_obj->setFederalTaxExempt(FALSE); $pd_obj->setProvincialTaxExempt(FALSE); $pd_obj->setYearToDateCPPContribution(0); $pd_obj->setYearToDateEIContribution(0); $pd_obj->setGrossPayPeriodIncome($income); $retarr[] = array('country' => $country, 'province' => $province_code, 'date' => date('m/d/y', $effective_date), 'pay_periods' => $pay_periods, 'federal_claim' => $pd_obj->getFederalTotalClaimAmount(), 'provincial_claim' => $pd_obj->getProvincialTotalClaimAmount(), 'gross_income' => $income, 'federal_deduction' => Misc::MoneyFormat($pd_obj->getFederalPayPeriodDeductions(), FALSE), 'provincial_deduction' => Misc::MoneyFormat($pd_obj->getProvincialPayPeriodDeductions(), FALSE)); } }
function testUS_2013a_FederalUI_State_Max() { Debug::text('US - SemiMonthly - Beginning of 2013 01-Jan-2013: ', __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('US', 'MO'); $pd_obj->setDate(strtotime('01-Jan-2013')); $pd_obj->setAnnualPayPeriods(24); //Semi-Monthly $pd_obj->setFederalFilingStatus(10); //Single $pd_obj->setFederalAllowance(0); $pd_obj->setStateUIRate(3.51); $pd_obj->setStateUIWageBase(11000); $pd_obj->setYearToDateSocialSecurityContribution(0); $pd_obj->setYearToDateFederalUIContribution(173.3); //174.30 $pd_obj->setYearToDateStateUIContribution(0); $pd_obj->setFederalTaxExempt(FALSE); $pd_obj->setProvincialTaxExempt(FALSE); $pd_obj->setGrossPayPeriodIncome(1000.0); //var_dump($pd_obj->getArray()); $this->assertEquals($this->mf($pd_obj->getGrossPayPeriodIncome()), '1000.00'); $this->assertEquals($this->mf($pd_obj->getFederalEmployerUI()), '1.00'); }
function getDeductionAmount($user_id, $pay_stub_obj, $pay_period_obj) { if ($user_id == '') { Debug::Text('Missing User ID: ', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } if (!is_object($pay_stub_obj)) { Debug::Text('Missing Pay Stub Object: ', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } if (!is_object($pay_period_obj)) { Debug::Text('Missing Pay Period Object: ', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } //Calculates the deduction. $cd_obj = $this->getCompanyDeductionObject(); $annual_pay_periods = $pay_period_obj->getPayPeriodScheduleObject()->getAnnualPayPeriods(); if (!is_object($cd_obj)) { return FALSE; } require_once Environment::getBasePath() . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'payroll_deduction' . DIRECTORY_SEPARATOR . 'PayrollDeduction.class.php'; $retval = 0; Debug::Text('Company Deduction: ID: ' . $cd_obj->getID() . ' Name: ' . $cd_obj->getName() . ' Calculation ID: ' . $cd_obj->getCalculation(), __FILE__, __LINE__, __METHOD__, 10); switch ($cd_obj->getCalculation()) { case 10: //Basic Percent if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); $retval = bcmul($amount, bcdiv($percent, 100)); break; case 15: //Advanced Percent if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $wage_base = $cd_obj->getUserValue2(); } else { $wage_base = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $exempt_amount = $cd_obj->getUserValue3(); } else { $exempt_amount = $this->getUserValue3(); } //Annual Wage Base is the maximum earnings that an employee can earn before they are no longer eligible for this deduction //Annual Deduction Amount Debug::Text('Percent: ' . $percent . ' Wage Base: ' . $wage_base . ' Exempt Amount: ' . $exempt_amount, __FILE__, __LINE__, __METHOD__, 10); if ($percent != 0) { if ($exempt_amount > 0) { $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), bcdiv($exempt_amount, $annual_pay_periods)); Debug::Text('Amount After Exemption: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); } else { $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); } if ($wage_base > 0) { //*NOTE: If the first pay stub in TimeTrex is near the end of the year, and the employee has already exceeded the wage base amount //the payroll admin needs to make sure they add a YTD Adjustment for each Include PS Accounts that this calculation is based on, //NOT the total amount they have paid for the resulting calculation, as that has no effect whatsoever. //getCalculationYTDAmount is the previous pay stub YTD amount, but it includes any YTD Adjustments in the current pay stub too. $ytd_amount = $cd_obj->getCalculationYTDAmount($pay_stub_obj); Debug::Text('Wage Base is set: ' . $wage_base . ' Amount: ' . $amount . ' Current YTD: ' . $ytd_amount, __FILE__, __LINE__, __METHOD__, 10); //Possible calcations: // //Wage Base: 3000 //Amount: 500 YTD: 0 = 500 //Amount: 500 YTD: 2900 = 100 //Amount: 500 YTD: 3100 = 0 //Amount: 3500 YTD: 0 = 3000 //AMount: 3500 YTD: 2900 = 100 //Amount: 3500 YTD: 3100 = 0 //Check to see if YTD is less than wage base. $remaining_wage_base = bcsub($wage_base, $ytd_amount); Debug::Text('Remaining Wage Base to be calculated: ' . $remaining_wage_base, __FILE__, __LINE__, __METHOD__, 10); if ($remaining_wage_base > 0) { if ($amount > $remaining_wage_base) { $amount = $remaining_wage_base; } } else { $amount = 0; //Exceeded wage base, nothing to calculate. } unset($remaining_wage_base); } else { Debug::Text('Wage Base is NOT set: ' . $wage_base, __FILE__, __LINE__, __METHOD__, 10); } $retval = bcmul($amount, bcdiv($percent, 100)); } else { $retval = 0; } if ($percent >= 0 and $retval < 0) { $retval = 0; } unset($amount, $ytd_amount, $percent, $wage_base); break; case 17: //Advanced Percent (Range Bracket) if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $min_wage = $cd_obj->getUserValue2(); } else { $min_wage = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $max_wage = $cd_obj->getUserValue3(); } else { $max_wage = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $annual_deduction_amount = $cd_obj->getUserValue4(); } else { $annual_deduction_amount = $this->getUserValue4(); } if ($this->getUserValue5() == '') { $annual_fixed_amount = $cd_obj->getUserValue5(); } else { $annual_fixed_amount = $this->getUserValue5(); } $min_wage = bcdiv($min_wage, $annual_pay_periods); $max_wage = bcdiv($max_wage, $annual_pay_periods); $annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods); $annual_fixed_amount = bcdiv($annual_fixed_amount, $annual_pay_periods); Debug::Text('Percent: ' . $percent . ' Min Wage: ' . $min_wage . ' Max Wage: ' . $max_wage . ' Annual Deduction: ' . $annual_deduction_amount, __FILE__, __LINE__, __METHOD__, 10); if ($percent != 0) { $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $annual_deduction_amount); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); if ($amount >= $min_wage and $amount <= $max_wage) { $retval = bcadd(bcmul($amount, bcdiv($percent, 100)), $annual_fixed_amount); } } else { $retval = 0; } if ($percent >= 0 and $retval < 0) { $retval = 0; } unset($amount, $percent, $min_wage, $max_wage, $annual_deduction_amount, $annual_fixed_amount); break; case 18: //Advanced Percent (Tax Bracket) if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $wage_base = $cd_obj->getUserValue2(); } else { $wage_base = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $exempt_amount = $cd_obj->getUserValue3(); } else { $exempt_amount = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $annual_deduction_amount = $cd_obj->getUserValue4(); } else { $annual_deduction_amount = $this->getUserValue4(); } Debug::Text('Percent: ' . $percent . ' Wage Base: ' . $wage_base . ' Exempt Amount: ' . $exempt_amount, __FILE__, __LINE__, __METHOD__, 10); if ($percent != 0) { if ($exempt_amount > 0) { $pp_exempt_amount = bcdiv($exempt_amount, $annual_pay_periods); } else { $pp_exempt_amount = 0; } //Debug::Text('PP Exempt Amount: '. $pp_exempt_amount, __FILE__, __LINE__, __METHOD__,10); if ($wage_base > 0) { $pp_wage_base_amount = bcdiv($wage_base, $annual_pay_periods); } else { $pp_wage_base_amount = 0; } if ($annual_deduction_amount > 0) { $pp_annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods); } else { $pp_annual_deduction_amount = 0; } //Debug::Text('PP Wage Base Base Amount: '. $pp_wage_base_amount, __FILE__, __LINE__, __METHOD__,10); $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $pp_annual_deduction_amount); //Debug::Text('Calculation Pay Stub Amount: '. $cd_obj->getCalculationPayStubAmount( $pay_stub_obj ), __FILE__, __LINE__, __METHOD__,10); if ($pp_wage_base_amount > 0 and $amount > $pp_wage_base_amount) { //Debug::Text('Exceeds Wage Base...'. $amount, __FILE__, __LINE__, __METHOD__,10); $amount = bcsub($pp_wage_base_amount, $pp_exempt_amount); } else { //Debug::Text('Under Wage Base...'. $amount, __FILE__, __LINE__, __METHOD__,10); $amount = bcsub($amount, $pp_exempt_amount); } Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); $retval = bcmul($amount, bcdiv($percent, 100)); } else { $retval = 0; } if ($percent >= 0 and $retval < 0) { $retval = 0; } unset($amount, $percent, $wage_base, $pp_wage_base_amount, $pp_exempt_amount, $annual_deduction_amount, $pp_annual_deduction_amount); break; case 19: //Advanced Percent (Tax Bracket Alternate) /* This is designed to be used for single line item tax calculations, in that the formula looks like this, where only ONE bracket would be applied to the employee, NOT all: Wage between 0 - 10,000 calculate 10% Wage between 10,001 - 20,000 calculate 15% + $1000 (10% of 10,000 as per above) Wage between 20,001 - 30,000 calculate 20% + $2500 (10% of 10,000 as first bracket, and 15% of 10,000 as per 2nd bracket) */ if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $min_wage = $cd_obj->getUserValue2(); } else { $min_wage = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $max_wage = $cd_obj->getUserValue3(); } else { $max_wage = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $annual_deduction_amount = $cd_obj->getUserValue4(); } else { $annual_deduction_amount = $this->getUserValue4(); } if ($this->getUserValue5() == '') { $annual_fixed_amount = $cd_obj->getUserValue5(); } else { $annual_fixed_amount = $this->getUserValue5(); } $min_wage = bcdiv($min_wage, $annual_pay_periods); $max_wage = bcdiv($max_wage, $annual_pay_periods); $annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods); $annual_fixed_amount = bcdiv($annual_fixed_amount, $annual_pay_periods); Debug::Text('Percent: ' . $percent . ' Min Wage: ' . $min_wage . ' Max Wage: ' . $max_wage . ' Annual Deduction: ' . $annual_deduction_amount, __FILE__, __LINE__, __METHOD__, 10); if ($percent != 0) { $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $annual_deduction_amount); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); if ($amount >= $min_wage and $amount <= $max_wage) { $retval = bcadd(bcmul(bcsub($amount, $min_wage), bcdiv($percent, 100)), $annual_fixed_amount); } } else { $retval = 0; } if ($percent >= 0 and $retval < 0) { $retval = 0; } unset($amount, $percent, $min_wage, $max_wage, $annual_deduction_amount, $annual_fixed_amount); break; case 20: //Fixed amount if ($this->getUserValue1() == FALSE) { $amount = $cd_obj->getUserValue1(); } else { $amount = $this->getUserValue1(); } $retval = $amount; unset($amount); break; case 30: //Fixed Amount (Range Bracket) if ($this->getUserValue1() == '') { $fixed_amount = $cd_obj->getUserValue1(); } else { $fixed_amount = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $min_wage = $cd_obj->getUserValue2(); } else { $min_wage = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $max_wage = $cd_obj->getUserValue3(); } else { $max_wage = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $annual_deduction_amount = $cd_obj->getUserValue4(); } else { $annual_deduction_amount = $this->getUserValue4(); } $min_wage = bcdiv($min_wage, $annual_pay_periods); $max_wage = bcdiv($max_wage, $annual_pay_periods); $annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods); Debug::Text('Amount: ' . $fixed_amount . ' Min Wage: ' . $min_wage . ' Max Wage: ' . $max_wage . ' Annual Deduction: ' . $annual_deduction_amount, __FILE__, __LINE__, __METHOD__, 10); if ($fixed_amount != 0) { $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $annual_deduction_amount); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); if ($amount >= $min_wage and $amount <= $max_wage) { $retval = $fixed_amount; } } else { $retval = 0; } unset($fixed_amount, $amount, $percent, $min_wage, $max_wage, $annual_deduction_amount); break; case 52: //Fixed Amount (w/Limit) if ($this->getUserValue1() == '') { $fixed_amount = $cd_obj->getUserValue1(); } else { $fixed_amount = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $target_amount = $cd_obj->getUserValue2(); } else { $target_amount = $this->getUserValue2(); } Debug::Text('Amount: ' . $fixed_amount . ' Target Amount: ' . $target_amount, __FILE__, __LINE__, __METHOD__, 10); $retval = 0; if ($fixed_amount != 0) { $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); if ($amount !== $target_amount) { if (abs($fixed_amount) < abs(bcsub($amount, $target_amount))) { //Use full fixed amount Debug::Text('Not within reach of target, use full fixed amount...', __FILE__, __LINE__, __METHOD__, 10); $retval = $fixed_amount; } else { Debug::Text('Within reach of target, use partial fixed amount...', __FILE__, __LINE__, __METHOD__, 10); //Use partial fixed_amount $retval = bcadd(abs($amount), $target_amount); } } } $retval = abs($retval); unset($fixed_amount, $tmp_amount, $amount, $min_limit, $max_limit); break; case 69: // Custom Formulas if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $user_value2 = $cd_obj->getUserValue2(); } else { $user_value2 = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $user_value3 = $cd_obj->getUserValue3(); } else { $user_value3 = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $user_value4 = $cd_obj->getUserValue4(); } else { $user_value4 = $this->getUserValue4(); } if ($this->getUserValue5() == '') { $user_value5 = $cd_obj->getUserValue5(); } else { $user_value5 = $this->getUserValue5(); } if ($this->getUserValue6() == '') { $user_value6 = $cd_obj->getUserValue6(); } else { $user_value6 = $this->getUserValue6(); } if ($this->getUserValue7() == '') { $user_value7 = $cd_obj->getUserValue7(); } else { $user_value7 = $this->getUserValue7(); } if ($this->getUserValue8() == '') { $user_value8 = $cd_obj->getUserValue8(); } else { $user_value8 = $this->getUserValue8(); } if ($this->getUserValue9() == '') { $user_value9 = $cd_obj->getUserValue9(); } else { $user_value9 = $this->getUserValue9(); } if ($this->getUserValue10() == '') { $user_value10 = $cd_obj->getUserValue10(); } else { $user_value10 = $this->getUserValue10(); } // evaluate math expressions as the company_value1 and user_value1-10 defined by user. $company_value1 = $cd_obj->getCompanyValue1(); // Custom Formula $variables = array(); $formula_variables = array_keys((array) TTMath::parseColumnsFromFormula($company_value1)); Debug::Arr($formula_variables, 'Formula Variables: ', __FILE__, __LINE__, __METHOD__, 10); if (is_array($formula_variables)) { if (in_array('currency_conversion_rate', $formula_variables) and is_object($this->getUserObject()) and is_object($this->getUserObject()->getCurrencyObject())) { $currency_iso_code = $this->getUserObject()->getCurrencyObject()->getISOCode(); $currency_conversion_rate = $this->getUserObject()->getCurrencyObject()->getConversionRate(); Debug::Text('Currency Variables: Rate: ' . $currency_conversion_rate . ' ISO: ' . $currency_iso_code, __FILE__, __LINE__, __METHOD__, 10); } //First pass to gather any necessary data based on variables if (in_array('employee_hourly_rate', $formula_variables) or in_array('employee_annual_wage', $formula_variables) or in_array('employee_wage_average_weekly_hours', $formula_variables)) { $uwlf = TTnew('UserWageListFactory'); $uwlf->getWageByUserIdAndPayPeriodEndDate($this->getUser(), $pay_period_obj->getEndDate()); if ($uwlf->getRecordCount() > 0) { $uwf = $uwlf->getCurrent(); $employee_hourly_rate = $uwf->getHourlyRate(); $employee_annual_wage = $uwf->getAnnualWage(); $employee_wage_average_weekly_hours = TTDate::getHours($uwf->getWeeklyTime()); } else { $employee_hourly_rate = 0; $employee_annual_wage = 0; $employee_wage_average_weekly_hours = 0; } Debug::Text('Employee Hourly Rate: ' . $employee_hourly_rate, __FILE__, __LINE__, __METHOD__, 10); } if ($cd_obj->getCompanyValue2() != '' and $cd_obj->getCompanyValue2() > 0 and $cd_obj->getCompanyValue3() != '' and $cd_obj->getCompanyValue3() > 0) { Debug::Text('Formula Lookback enable: ' . $cd_obj->getCompanyValue2(), __FILE__, __LINE__, __METHOD__, 10); foreach ($formula_variables as $formula_variable) { if (strpos($formula_variable, 'lookback_') !== FALSE) { Debug::Text('Lookback variables exist...', __FILE__, __LINE__, __METHOD__, 10); $lookback_dates = $cd_obj->getLookbackStartAndEndDates($pay_period_obj); $lookback_pay_stub_dates = $cd_obj->getLookbackPayStubs($this->getUser(), $pay_period_obj); break; } } } //Second pass to define variables. foreach ($formula_variables as $formula_variable) { if (!isset($variables[$formula_variable])) { switch ($formula_variable) { case 'custom_value1': $variables[$formula_variable] = $user_value1; break; case 'custom_value2': $variables[$formula_variable] = $user_value2; break; case 'custom_value3': $variables[$formula_variable] = $user_value3; break; case 'custom_value4': $variables[$formula_variable] = $user_value4; break; case 'custom_value5': $variables[$formula_variable] = $user_value5; break; case 'custom_value6': $variables[$formula_variable] = $user_value6; break; case 'custom_value7': $variables[$formula_variable] = $user_value7; break; case 'custom_value8': $variables[$formula_variable] = $user_value8; break; case 'custom_value9': $variables[$formula_variable] = $user_value9; break; case 'custom_value10': $variables[$formula_variable] = $user_value10; break; case 'employee_hourly_rate': $variables[$formula_variable] = $employee_hourly_rate; break; case 'employee_annual_wage': $variables[$formula_variable] = $employee_annual_wage; break; case 'employee_wage_average_weekly_hours': $variables[$formula_variable] = $employee_wage_average_weekly_hours; break; case 'annual_pay_periods': $variables[$formula_variable] = $annual_pay_periods; break; case 'pay_period_start_date': $variables[$formula_variable] = $pay_period_obj->getStartDate(); break; case 'pay_period_end_date': $variables[$formula_variable] = $pay_period_obj->getEndDate(); break; case 'pay_period_transaction_date': $variables[$formula_variable] = $pay_period_obj->getTransactionDate(); break; case 'employee_hire_date': $variables[$formula_variable] = $this->getUserObject()->getHireDate(); break; case 'employee_termination_date': $variables[$formula_variable] = $this->getUserObject()->getTerminationDate(); break; case 'employee_birth_date': $variables[$formula_variable] = $this->getUserObject()->getBirthDate(); break; case 'currency_iso_code': $variables[$formula_variable] = $currency_iso_code; break; case 'currency_conversion_rate': $variables[$formula_variable] = $currency_conversion_rate; break; case 'include_pay_stub_amount': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 10); break; case 'include_pay_stub_ytd_amount': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 30); break; case 'include_pay_stub_units': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 20); break; case 'include_pay_stub_ytd_units': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 40); break; case 'exclude_pay_stub_amount': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, NULL, 10); break; case 'exclude_pay_stub_ytd_amount': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, NULL, 30); break; case 'exclude_pay_stub_units': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, NULL, 20); break; case 'exclude_pay_stub_ytd_units': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, NULL, 40); break; case 'pay_stub_amount': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 10, 10); break; case 'pay_stub_ytd_amount': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 30, 30); break; case 'pay_stub_units': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 20, 20); break; case 'pay_stub_ytd_units': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 40, 40); break; //Lookback variables. //Lookback variables. case 'lookback_total_pay_stubs': $variables[$formula_variable] = isset($lookback_pay_stub_dates['total_pay_stubs']) ? $lookback_pay_stub_dates['total_pay_stubs'] : 0; break; case 'lookback_start_date': $variables[$formula_variable] = isset($lookback_dates['start_date']) ? $lookback_dates['start_date'] : 0; break; case 'lookback_end_date': $variables[$formula_variable] = isset($lookback_dates['end_date']) ? $lookback_dates['end_date'] : 0; break; case 'lookback_first_pay_stub_start_date': $variables[$formula_variable] = isset($lookback_pay_stub_dates['first_pay_stub_start_date']) ? $lookback_pay_stub_dates['first_pay_stub_start_date'] : 0; break; case 'lookback_first_pay_stub_end_date': $variables[$formula_variable] = isset($lookback_pay_stub_dates['first_pay_stub_end_date']) ? $lookback_pay_stub_dates['first_pay_stub_end_date'] : 0; break; case 'lookback_first_pay_stub_transaction_date': $variables[$formula_variable] = isset($lookback_pay_stub_dates['first_pay_stub_transaction_date']) ? $lookback_pay_stub_dates['first_pay_stub_transaction_date'] : 0; break; case 'lookback_last_pay_stub_start_date': $variables[$formula_variable] = isset($lookback_pay_stub_dates['last_pay_stub_start_date']) ? $lookback_pay_stub_dates['last_pay_stub_start_date'] : 0; break; case 'lookback_last_pay_stub_end_date': $variables[$formula_variable] = isset($lookback_pay_stub_dates['last_pay_stub_end_date']) ? $lookback_pay_stub_dates['last_pay_stub_end_date'] : 0; break; case 'lookback_last_pay_stub_transaction_date': $variables[$formula_variable] = isset($lookback_pay_stub_dates['last_pay_stub_transaction_date']) ? $lookback_pay_stub_dates['last_pay_stub_end_date'] : 0; break; case 'lookback_include_pay_stub_amount': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(10); break; case 'lookback_include_pay_stub_ytd_amount': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(30); break; case 'lookback_include_pay_stub_units': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(20); break; case 'lookback_include_pay_stub_ytd_units': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(40); break; case 'lookback_exclude_pay_stub_amount': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(NULL, 10); break; case 'lookback_exclude_pay_stub_ytd_amount': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(NULL, 30); break; case 'lookback_exclude_pay_stub_units': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(NULL, 20); break; case 'lookback_exclude_pay_stub_ytd_units': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(NULL, 40); break; case 'lookback_pay_stub_amount': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(10, 10); break; case 'lookback_pay_stub_ytd_amount': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(30, 30); break; case 'lookback_pay_stub_units': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(20, 20); break; case 'lookback_pay_stub_ytd_units': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(40, 40); break; } } } unset($uwlf, $uwf, $employee_hourly_rate, $employee_annual_wage, $employee_wage_average_weekly_hours, $annual_pay_periods, $lookback_dates, $lookback_pay_stub_dates, $currency_iso_code, $currency_conversion_rate); } //Debug::Arr( $variables, 'Formula Variable values: ', __FILE__, __LINE__, __METHOD__, 10 ); Debug::Arr(array(str_replace("\r", '; ', $company_value1), str_replace("\r", '; ', TTMath::translateVariables($company_value1, $variables))), 'Original/Translated Formula: ', __FILE__, __LINE__, __METHOD__, 10); $retval = TTMath::evaluate(TTMath::translateVariables($company_value1, $variables)); Debug::Text('Formula Retval: ' . $retval, __FILE__, __LINE__, __METHOD__, 10); break; case 80: //US Earning Income Credit (EIC). Repealed as of 31-Dec-2010. if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('US', NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); if (is_object($this->getUserObject())) { $currency_id = $this->getUserObject()->getCurrency(); $pd_obj->setUserCurrency($currency_id); Debug::Text('User Currency ID: ' . $currency_id, __FILE__, __LINE__, __METHOD__, 10); } $pd_obj->setEICFilingStatus($user_value1); $pd_obj->setGrossPayPeriodIncome($amount); //Allow negative value, infact it always should be. $retval = $pd_obj->getEIC(); break; case 82: //US - Medicare - Employee //US - Medicare - Employee case 83: //US - Medicare - Employer //US - Medicare - Employer case 84: //US - Social Security - Employee //US - Social Security - Employee case 85: //US - Social Security - Employer if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('US', NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); if (is_object($this->getUserObject())) { $currency_id = $this->getUserObject()->getCurrency(); $pd_obj->setUserCurrency($currency_id); Debug::Text('User Currency ID: ' . $currency_id, __FILE__, __LINE__, __METHOD__, 10); } $pd_obj->setGrossPayPeriodIncome($amount); switch ($cd_obj->getCalculation()) { case 82: //US - Medicare - Employee $pd_obj->setMedicareFilingStatus($user_value1); $pd_obj->setYearToDateGrossIncome($cd_obj->getCalculationYTDAmount($pay_stub_obj)); $retval = $pd_obj->getEmployeeMedicare(); break; case 83: //US - Medicare - Employer $retval = $pd_obj->getEmployerMedicare(); break; case 84: //US - Social Security - Employee $retval = $pd_obj->getEmployeeSocialSecurity(); break; case 85: //US - Social Security - Employer $retval = $pd_obj->getEmployerSocialSecurity(); break; } break; case 90: //Canada - CPP $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('CA', NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); $pd_obj->setEnableCPPAndEIDeduction(TRUE); if ($this->getPayStubEntryAccountLinkObject()->getEmployeeCPP() != '') { Debug::Text('Found Employee CPP account link!: ', __FILE__, __LINE__, __METHOD__, 10); $previous_ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); $current_ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); Debug::text('YTD CPP Contribution: Previous Amount: ' . $previous_ytd_cpp_arr['ytd_amount'] . ' Current Amount: ' . $current_ytd_cpp_arr['amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateCPPContribution(bcadd($previous_ytd_cpp_arr['ytd_amount'], $current_ytd_cpp_arr['ytd_amount'])); unset($previous_ytd_cpp_arr, $current_ytd_cpp_arr); } $pd_obj->setGrossPayPeriodIncome($amount); $retval = $pd_obj->getEmployeeCPP(); if ($retval < 0) { $retval = 0; } break; case 91: //Canada - EI $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('CA', NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); $pd_obj->setEnableCPPAndEIDeduction(TRUE); if ($this->getPayStubEntryAccountLinkObject()->getEmployeeEI() != '') { Debug::Text('Found Employee EI account link!: ', __FILE__, __LINE__, __METHOD__, 10); $previous_ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); $current_ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); Debug::text('YTD EI Contribution: Previous Amount: ' . $previous_ytd_ei_arr['ytd_amount'] . ' Current Amount: ' . $current_ytd_ei_arr['amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateEIContribution(bcadd($previous_ytd_ei_arr['ytd_amount'], $current_ytd_ei_arr['ytd_amount'])); unset($previous_ytd_ei_arr, $current_ytd_ei_arr); } $pd_obj->setGrossPayPeriodIncome($amount); $retval = $pd_obj->getEmployeeEI(); if ($retval < 0) { $retval = 0; } break; case 100: //Federal Income Tax if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $user_value2 = $cd_obj->getUserValue2(); } else { $user_value2 = $this->getUserValue2(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue2: ' . $user_value2, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction($this->getCompanyDeductionObject()->getCountry(), NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); if (is_object($this->getUserObject())) { $currency_id = $this->getUserObject()->getCurrency(); $pd_obj->setUserCurrency($currency_id); Debug::Text('User Currency ID: ' . $currency_id, __FILE__, __LINE__, __METHOD__, 10); } if ($this->getCompanyDeductionObject()->getCountry() == 'CA') { //CA $pd_obj->setFederalTotalClaimAmount($user_value1); $pd_obj->setEnableCPPAndEIDeduction(TRUE); //$pself = TTnew( 'PayStubEntryListFactory' ); if ($this->getPayStubEntryAccountLinkObject()->getEmployeeCPP() != '') { Debug::Text('Found Employee CPP account link!: ', __FILE__, __LINE__, __METHOD__, 10); //Check to see if CPP was calculated on the CURRENT pay stub, if not assume they are CPP exempt. //Single this calculation formula doesn't know directly if the user was CPP exempt or not, we have to assume it by //the calculate CPP on the current pay stub. However if the CPP calculation is done AFTER this, it may mistakenly assume they are exempt. //Make sure we handle the maximum CPP contribution cases properly as well. $current_cpp = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); if (isset($current_cpp['amount']) and $current_cpp['amount'] == 0) { Debug::Text('Current CPP: ' . $current_cpp['amount'] . ' Setting CPP exempt in Federal Income Tax calculation...', __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setCPPExempt(TRUE); } $ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); Debug::text('YTD CPP Contribution: ' . $ytd_cpp_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateCPPContribution($ytd_cpp_arr['ytd_amount']); unset($ytd_cpp_arr, $current_cpp); } if ($this->getPayStubEntryAccountLinkObject()->getEmployeeEI() != '') { Debug::Text('Found Employee EI account link!: ', __FILE__, __LINE__, __METHOD__, 10); //See comment above regarding CPP exempt. $current_ei = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); if (isset($current_ei['amount']) and $current_ei['amount'] == 0) { Debug::Text('Current EI: ' . $current_ei['amount'] . ' Setting EI exempt in Federal Income Tax calculation...', __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setEIExempt(TRUE); } $ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); Debug::text('YTD EI Contribution: ' . $ytd_ei_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateEIContribution($ytd_ei_arr['ytd_amount']); unset($ytd_ei_arr, $current_ei); } } elseif ($this->getCompanyDeductionObject()->getCountry() == 'US') { //US $pd_obj->setFederalFilingStatus($user_value1); $pd_obj->setFederalAllowance($user_value2); } elseif ($this->getCompanyDeductionObject()->getCountry() == 'CR') { //CR $pd_obj->setFederalFilingStatus($user_value1); //Single/Married $pd_obj->setFederalAllowance($user_value2); //Allownces/Children } $pd_obj->setGrossPayPeriodIncome($amount); $retval = $pd_obj->getFederalPayPeriodDeductions(); if ($retval < 0) { $retval = 0; } break; case 200: //Province Income Tax if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $user_value2 = $cd_obj->getUserValue2(); } else { $user_value2 = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $user_value3 = $cd_obj->getUserValue3(); } else { $user_value3 = $this->getUserValue3(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue2: ' . $user_value2, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue3: ' . $user_value3, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction($this->getCompanyDeductionObject()->getCountry(), $this->getCompanyDeductionObject()->getProvince()); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); $pd_obj->setGrossPayPeriodIncome($amount); if ($this->getCompanyDeductionObject()->getCountry() == 'CA') { Debug::Text('Canada Pay Period Deductions...', __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setProvincialTotalClaimAmount($user_value1); $pd_obj->setEnableCPPAndEIDeduction(TRUE); //$pself = TTnew( 'PayStubEntryListFactory' ); if ($this->getPayStubEntryAccountLinkObject()->getEmployeeCPP() != '') { Debug::Text('Found Employee CPP account link!: ', __FILE__, __LINE__, __METHOD__, 10); //Check to see if CPP was calculated on the CURRENT pay stub, if not assume they are CPP exempt. //Single this calculation formula doesn't know directly if the user was CPP exempt or not, we have to assume it by //the calculate CPP on the current pay stub. However if the CPP calculation is done AFTER this, it may mistakenly assume they are exempt. //Make sure we handle the maximum CPP contribution cases properly as well. $current_cpp = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); if (isset($current_cpp['amount']) and $current_cpp['amount'] == 0) { Debug::Text('Current CPP: ' . $current_cpp['amount'] . ' Setting CPP exempt in Provincial Income Tax calculation...', __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setCPPExempt(TRUE); } $ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); Debug::text('YTD CPP Contribution: ' . $ytd_cpp_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateCPPContribution($ytd_cpp_arr['ytd_amount']); unset($ytd_cpp_arr, $current_cpp); } if ($this->getPayStubEntryAccountLinkObject()->getEmployeeEI() != '') { Debug::Text('Found Employee EI account link!: ', __FILE__, __LINE__, __METHOD__, 10); //See comment above regarding CPP exempt. $current_ei = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); if (isset($current_ei['amount']) and $current_ei['amount'] == 0) { Debug::Text('Current EI: ' . $current_ei['amount'] . ' Setting EI exempt in Provincial Income Tax calculation...', __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setEIExempt(TRUE); } $ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); Debug::text('YTD EI Contribution: ' . $ytd_ei_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateEIContribution($ytd_ei_arr['ytd_amount']); unset($ytd_ei_arr, $current_ei); } $retval = $pd_obj->getProvincialPayPeriodDeductions(); } elseif ($this->getCompanyDeductionObject()->getCountry() == 'US') { Debug::Text('US Pay Period Deductions...', __FILE__, __LINE__, __METHOD__, 10); //Need to set Federal settings here. $udlf = TTnew('UserDeductionListFactory'); $udlf->getByUserIdAndCountryID($user_id, $this->getCompanyDeductionObject()->getCountry()); if ($udlf->getRecordCount() > 0) { Debug::Text('Found Federal User Deduction...', __FILE__, __LINE__, __METHOD__, 10); $tmp_ud_obj = $udlf->getCurrent(); if ($tmp_ud_obj->getUserValue1() == '') { $tmp_user_value1 = $tmp_ud_obj->getCompanyDeductionObject()->getUserValue1(); } else { $tmp_user_value1 = $tmp_ud_obj->getUserValue1(); } if ($tmp_ud_obj->getUserValue2() == '') { $tmp_user_value2 = $tmp_ud_obj->getCompanyDeductionObject()->getUserValue2(); } else { $tmp_user_value2 = $tmp_ud_obj->getUserValue2(); } Debug::Text('TmpUserValue1: ' . $tmp_user_value1, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('TmpUserValue2: ' . $tmp_user_value2, __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setFederalFilingStatus($tmp_user_value1); $pd_obj->setFederalAllowance($tmp_user_value2); unset($tmp_ud_obj, $tmp_user_value1, $tmp_user_value1); } unset($udlf); $pd_obj->setStateFilingStatus($user_value1); $pd_obj->setStateAllowance($user_value2); $pd_obj->setUserValue1($user_value1); $pd_obj->setUserValue2($user_value2); $pd_obj->setUserValue3($user_value3); $retval = $pd_obj->getStatePayPeriodDeductions(); } if ($retval < 0) { $retval = 0; } break; case 300: //District Income Tax if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $user_value2 = $cd_obj->getUserValue2(); } else { $user_value2 = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $user_value3 = $cd_obj->getUserValue3(); } else { $user_value3 = $this->getUserValue3(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue2: ' . $user_value2, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue3: ' . $user_value3, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('District: ' . $this->getCompanyDeductionObject()->getDistrict(), __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction($this->getCompanyDeductionObject()->getCountry(), $this->getCompanyDeductionObject()->getProvince(), $this->getCompanyDeductionObject()->getDistrict()); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); $pd_obj->setDistrictFilingStatus($user_value1); $pd_obj->setDistrictAllowance($user_value2); $pd_obj->setUserValue1($user_value1); $pd_obj->setUserValue2($user_value2); $pd_obj->setUserValue3($user_value3); $pd_obj->setGrossPayPeriodIncome($amount); $retval = $pd_obj->getDistrictPayPeriodDeductions(); if ($retval < 0) { $retval = 0; } break; } Debug::Text('Deduction Amount: ' . $retval, __FILE__, __LINE__, __METHOD__, 10); //Allow negative values, as some advanced tax bracket setups require this. if ($retval < 0) { //Debug::Text('Deduction was negative, setting to 0...', __FILE__, __LINE__, __METHOD__,10); Debug::Text('Deduction was negative...', __FILE__, __LINE__, __METHOD__, 10); //$retval = 0; } return $retval; }
function testMD_2011b_BiWeekly_Married_HighIncome() { Debug::text('US - BiWeekly - Beginning of 2011 01-Jan-2011: ', __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('US', 'MD', 'ALL'); $pd_obj->setDate(strtotime('01-Jan-2011')); $pd_obj->setAnnualPayPeriods(26); //Bi-Weekly $pd_obj->setFederalFilingStatus(20); //Single $pd_obj->setFederalAllowance(2); $pd_obj->setStateFilingStatus(20); //Single $pd_obj->setStateAllowance(2); $pd_obj->setUserValue3(3.2); //County Rate $pd_obj->setFederalTaxExempt(FALSE); $pd_obj->setProvincialTaxExempt(FALSE); $pd_obj->setGrossPayPeriodIncome(5000.0); $this->assertEquals($this->mf($pd_obj->getGrossPayPeriodIncome()), '5000.00'); $this->assertEquals($this->mf($pd_obj->getFederalPayPeriodDeductions()), '804.81'); $this->assertEquals($this->mf($pd_obj->getStatePayPeriodDeductions()), '371.82'); }
function testDC_2006a_SemiMonthly_Married_HighIncome_8Allowances() { Debug::text('US - SemiMonthly - Beginning of 2006 01-Jan-06: ', __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('US', 'DC'); $pd_obj->setDate(strtotime('01-Jan-06')); $pd_obj->setAnnualPayPeriods(24); //Semi-Monthly $pd_obj->setFederalFilingStatus(10); //Single $pd_obj->setFederalAllowance(1); $pd_obj->setStateFilingStatus(30); //Married - Separately $pd_obj->setStateAllowance(8); $pd_obj->setFederalTaxExempt(FALSE); $pd_obj->setProvincialTaxExempt(FALSE); $pd_obj->setGrossPayPeriodIncome(4000.0); //var_dump($pd_obj->getArray()); $this->assertEquals($this->mf($pd_obj->getGrossPayPeriodIncome()), '4000.00'); $this->assertEquals($this->mf($pd_obj->getFederalPayPeriodDeductions()), '823.73'); //823.73 $this->assertEquals($this->mf($pd_obj->getStatePayPeriodDeductions()), '263.41'); //263.41 }
function testON_2007a_SemiMonthly_Claim1_MedIncome() { Debug::text('ON - SemiMonthly - Beginning of 2007 01-Jan-07: ', __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('CA', 'ON'); //$pd_obj = new PayrollDeduction(); //$pd_obj->setCountry('CA'); //$pd_obj->setProvince('BC'); $pd_obj->setDate(strtotime('01-Jan-07')); $pd_obj->setEnableCPPAndEIDeduction(TRUE); //Deduct CPP/EI. $pd_obj->setAnnualPayPeriods(24); $pd_obj->setFederalTotalClaimAmount(8929); $pd_obj->setProvincialTotalClaimAmount(8553); $pd_obj->setWCBRate(0.18); $pd_obj->setEIExempt(FALSE); $pd_obj->setCPPExempt(FALSE); $pd_obj->setFederalTaxExempt(FALSE); $pd_obj->setProvincialTaxExempt(FALSE); $pd_obj->setYearToDateCPPContribution(0); $pd_obj->setYearToDateEIContribution(0); $pd_obj->setGrossPayPeriodIncome(2830.0); $this->assertEquals($this->mf($pd_obj->getGrossPayPeriodIncome()), '2830.00'); Debug::text('Prov Ded: ' . $pd_obj->getProvincialPayPeriodDeductions(), __FILE__, __LINE__, __METHOD__, 10); $this->assertEquals($this->mf($pd_obj->getProvincialPayPeriodDeductions()), '212.50'); //214.00 }
function testVT_2007a_SemiMonthly_Married_HighIncome_8Allowances() { Debug::text('US - SemiMonthly - Beginning of 2007 01-Jan-07: ', __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('US', 'VT'); $pd_obj->setDate(strtotime('01-Jan-07')); $pd_obj->setAnnualPayPeriods(24); //Semi-Monthly $pd_obj->setFederalFilingStatus(10); //Single $pd_obj->setFederalAllowance(1); $pd_obj->setStateFilingStatus(20); //Married $pd_obj->setStateAllowance(8); $pd_obj->setFederalTaxExempt(FALSE); $pd_obj->setProvincialTaxExempt(FALSE); $pd_obj->setGrossPayPeriodIncome(4000.0); //var_dump($pd_obj->getArray()); $this->assertEquals($this->mf($pd_obj->getGrossPayPeriodIncome()), '4000.00'); $this->assertEquals($this->mf($pd_obj->getFederalPayPeriodDeductions()), '812.20'); //812.20 $this->assertEquals($this->mf($pd_obj->getStatePayPeriodDeductions()), '106.05'); //106.05 }
function testAL_2007a_SemiMonthly_Married_HighIncome_2Allowances() { Debug::text('US - SemiMonthly - Beginning of 2007 01-Jan-07: ', __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('US', 'AL'); $pd_obj->setDate(strtotime('01-Jan-07')); $pd_obj->setAnnualPayPeriods(52); //Weekly $pd_obj->setFederalFilingStatus(20); //Married $pd_obj->setFederalAllowance(2); $pd_obj->setStateFilingStatus(20); //Married $pd_obj->setUserValue2(2); $pd_obj->setFederalTaxExempt(FALSE); $pd_obj->setProvincialTaxExempt(FALSE); $pd_obj->setGrossPayPeriodIncome(435.0); $this->assertEquals($this->mf($pd_obj->getGrossPayPeriodIncome()), '435.00'); $this->assertEquals($this->mf($pd_obj->getFederalPayPeriodDeductions()), '15.04'); //15.04 $this->assertEquals($this->mf($pd_obj->getStatePayPeriodDeductions()), '9.41'); //9.41 }
function _getData($format = NULL) { $this->tmp_data = array('pay_stub_entry' => array()); $columns = $this->getColumnDataConfig(); $filter_data = $this->getFilterConfig(); $form_data = $this->formatFormConfig(); require_once Environment::getBasePath() . '/classes/payroll_deduction/PayrollDeduction.class.php'; $pd_obj = new PayrollDeduction('US', 'WA'); //State doesn't matter. $pd_obj->setDate($filter_data['end_date']); $social_security_wage_limit = $pd_obj->getSocialSecurityMaximumEarnings(); $medicare_additional_threshold_limit = $pd_obj->getMedicareAdditionalEmployerThreshold(); Debug::Text('Social Security Wage Limit: ' . $social_security_wage_limit . ' Medicare Threshold: ' . $medicare_additional_threshold_limit . ' Date: ' . TTDate::getDate('DATE', $filter_data['end_date']), __FILE__, __LINE__, __METHOD__, 10); //Need to get totals up to the beginning of this quarter so we can determine if any employees have exceeded the social security limit. $pself = TTnew('PayStubEntryListFactory'); $ytd_filter_data = $filter_data; $ytd_filter_data['end_date'] = $ytd_filter_data['start_date'] - 1; $ytd_filter_data['start_date'] = TTDate::getBeginYearEpoch($ytd_filter_data['start_date']); $pself->getAPIReportByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $ytd_filter_data); //Debug::Arr($ytd_filter_data, 'YTD Filter Data: Row Count: '. $pself->getRecordCount(), __FILE__, __LINE__, __METHOD__,10); if ($pself->getRecordCount() > 0) { foreach ($pself as $pse_obj) { $user_id = $pse_obj->getColumn('user_id'); //Make sure we don't add this to the unique user_id list. //Always use middle day epoch, otherwise multiple entries could exist for the same day. $date_stamp = TTDate::getMiddleDayEpoch(TTDate::strtotime($pse_obj->getColumn('pay_stub_transaction_date'))); $branch = $pse_obj->getColumn('default_branch'); $department = $pse_obj->getColumn('default_department'); $pay_stub_entry_name_id = $pse_obj->getPayStubEntryNameId(); if (!isset($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp])) { $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp] = array('pay_period_start_date' => strtotime($pse_obj->getColumn('pay_stub_start_date')), 'pay_period_end_date' => strtotime($pse_obj->getColumn('pay_stub_end_date')), 'pay_period_transaction_date' => strtotime($pse_obj->getColumn('pay_stub_transaction_date')), 'pay_period' => strtotime($pse_obj->getColumn('pay_stub_transaction_date'))); } if (isset($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id])) { $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id] = bcadd($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id], $pse_obj->getColumn('amount')); } else { $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id] = $pse_obj->getColumn('amount'); } } if (isset($this->tmp_data['pay_stub_entry']) and is_array($this->tmp_data['pay_stub_entry'])) { foreach ($this->tmp_data['pay_stub_entry'] as $user_id => $data_a) { foreach ($data_a as $date_stamp => $data_b) { if (!isset($this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'])) { $this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] = 0; } $this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] += Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['social_security_wages']['include_pay_stub_entry_account'], $form_data['social_security_wages']['exclude_pay_stub_entry_account']); //Include tips in this amount as well. $this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] += Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['social_security_tips']['include_pay_stub_entry_account'], $form_data['social_security_tips']['exclude_pay_stub_entry_account']); //Handle additional medicare wages in excess of 200,000 if (!isset($this->tmp_data['ytd_pay_stub_entry'][$user_id]['medicare_wages'])) { $this->tmp_data['ytd_pay_stub_entry'][$user_id]['medicare_wages'] = 0; } $this->tmp_data['ytd_pay_stub_entry'][$user_id]['medicare_wages'] += Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['medicare_wages']['include_pay_stub_entry_account'], $form_data['medicare_wages']['exclude_pay_stub_entry_account']); } } } //Debug::Arr($this->tmp_data['ytd_pay_stub_entry'], 'YTD Tmp Raw Data: ', __FILE__, __LINE__, __METHOD__,10); } unset($pse_obj, $user_id, $date_stamp, $branch, $department, $pay_stub_entry_name_id, $this->tmp_data['pay_stub_entry']); //Get just the data for the quarter now. $pself->getAPIReportByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data); if ($pself->getRecordCount() > 0) { foreach ($pself as $pse_obj) { $user_id = $this->user_ids[] = $pse_obj->getColumn('user_id'); //Always use middle day epoch, otherwise multiple entries could exist for the same day. $date_stamp = TTDate::getMiddleDayEpoch(TTDate::strtotime($pse_obj->getColumn('pay_stub_transaction_date'))); $branch = $pse_obj->getColumn('default_branch'); $department = $pse_obj->getColumn('default_department'); $pay_stub_entry_name_id = $pse_obj->getPayStubEntryNameId(); if (!isset($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp])) { $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp] = array('pay_period_start_date' => strtotime($pse_obj->getColumn('pay_stub_start_date')), 'pay_period_end_date' => strtotime($pse_obj->getColumn('pay_stub_end_date')), 'pay_period_transaction_date' => strtotime($pse_obj->getColumn('pay_stub_transaction_date')), 'pay_period' => strtotime($pse_obj->getColumn('pay_stub_transaction_date'))); } if (isset($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id])) { $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id] = bcadd($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id], $pse_obj->getColumn('amount')); } else { $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id] = $pse_obj->getColumn('amount'); } } if (isset($this->tmp_data['pay_stub_entry']) and is_array($this->tmp_data['pay_stub_entry'])) { foreach ($this->tmp_data['pay_stub_entry'] as $user_id => $data_a) { foreach ($data_a as $date_stamp => $data_b) { $quarter_month = TTDate::getYearQuarterMonthNumber($date_stamp); //Debug::Text('Quarter Month: '. $quarter_month .' Epoch: '. TTDate::getDate('DATE', $date_stamp), __FILE__, __LINE__, __METHOD__,10); $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['wages'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['wages']['include_pay_stub_entry_account'], $form_data['wages']['exclude_pay_stub_entry_account']); $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['income_tax'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['income_tax']['include_pay_stub_entry_account'], $form_data['income_tax']['exclude_pay_stub_entry_account']); //FIXME: If employees are excluded from Social Security, it will still include total wages //resulting in the 941 form being incorrect in its calculation. //Add Form Setup tab field to select the Social Security tax/deductions? //However there can often be two of them, is just the employee one enough? We could use the employees and include/exclude accounts from that at least then. $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['social_security_wages']['include_pay_stub_entry_account'], $form_data['social_security_wages']['exclude_pay_stub_entry_account']); //Handle social security wage limit. if (!isset($this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'])) { $this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] = 0; } if ($this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] < $social_security_wage_limit) { $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['social_security_wages']['include_pay_stub_entry_account'], $form_data['social_security_wages']['exclude_pay_stub_entry_account']); $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_tips'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['social_security_tips']['include_pay_stub_entry_account'], $form_data['social_security_tips']['exclude_pay_stub_entry_account']); if ($this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] + $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] + $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_tips'] > $social_security_wage_limit) { $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] = $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] - ($this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] + $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] + $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_tips'] - $social_security_wage_limit); $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_tips'] = 0; $this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] = $social_security_wage_limit; } else { $this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] += $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages']; $this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] += $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_tips']; } } else { $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] = 0; $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_tips'] = 0; } $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['medicare_wages'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['medicare_wages']['include_pay_stub_entry_account'], $form_data['medicare_wages']['exclude_pay_stub_entry_account']); $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['medicare_additional_wages'] = 0; //Handle medicare additional wage limit, only consider wages earned above the threshold to be "medicare_additional_wages" if (!isset($this->tmp_data['ytd_pay_stub_entry'][$user_id]['medicare_wages'])) { $this->tmp_data['ytd_pay_stub_entry'][$user_id]['medicare_wages'] = 0; } if ($this->tmp_data['ytd_pay_stub_entry'][$user_id]['medicare_wages'] > $medicare_additional_threshold_limit) { $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['medicare_additional_wages'] = $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['medicare_wages']; } else { if ($this->tmp_data['ytd_pay_stub_entry'][$user_id]['medicare_wages'] + $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['medicare_wages'] > $medicare_additional_threshold_limit) { $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['medicare_additional_wages'] = $this->tmp_data['ytd_pay_stub_entry'][$user_id]['medicare_wages'] + $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['medicare_wages'] - $medicare_additional_threshold_limit; } else { $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['medicare_additional_wages'] = 0; } } //Debug::Text('User ID: '. $user_id .' DateStamp: '. $date_stamp .' YTD Medicare Additional Wages: '. $this->tmp_data['ytd_pay_stub_entry'][$user_id]['medicare_wages'] .' This Pay Stub: '. $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['medicare_additional_wages'], __FILE__, __LINE__, __METHOD__,10); $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['sick_wages'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['sick_wages']['include_pay_stub_entry_account'], $form_data['sick_wages']['exclude_pay_stub_entry_account']); $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['eic'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['eic']['include_pay_stub_entry_account'], $form_data['eic']['exclude_pay_stub_entry_account']); //Separate data used for reporting, grouping, sorting, from data specific used for the Form. if (!isset($this->form_data['pay_period'][$quarter_month][$date_stamp])) { $this->form_data['pay_period'][$quarter_month][$date_stamp] = Misc::preSetArrayValues(array(), array('l2', 'l3', 'l5a', 'l5b', 'l5c', 'l5d', 'l7', 'l9', 'l5a2', 'l5b2', 'l5c2', 'l5d', 'l8', 'l10'), 0); } $this->form_data['pay_period'][$quarter_month][$date_stamp]['l2'] += $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['wages']; $this->form_data['pay_period'][$quarter_month][$date_stamp]['l3'] += $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['income_tax']; $this->form_data['pay_period'][$quarter_month][$date_stamp]['l5a'] += $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages']; $this->form_data['pay_period'][$quarter_month][$date_stamp]['l5b'] += $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_tips']; $this->form_data['pay_period'][$quarter_month][$date_stamp]['l5c'] += $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['medicare_wages']; $this->form_data['pay_period'][$quarter_month][$date_stamp]['l5d'] += $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['medicare_additional_wages']; //$this->form_data['pay_period'][$quarter_month][$date_stamp]['l9'] += $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['eic']; $this->form_data['pay_period'][$quarter_month][$date_stamp]['l5f'] = 0; //Not implemented currently. //Calculated fields, make sure we don't use += on these. $this->form_data['pay_period'][$quarter_month][$date_stamp]['l5a2'] = bcmul($this->form_data['pay_period'][$quarter_month][$date_stamp]['l5a'], $this->getF941Object()->social_security_rate); $this->form_data['pay_period'][$quarter_month][$date_stamp]['l5b2'] = bcmul($this->form_data['pay_period'][$quarter_month][$date_stamp]['l5b'], $this->getF941Object()->social_security_rate); $this->form_data['pay_period'][$quarter_month][$date_stamp]['l5c2'] = bcmul($this->form_data['pay_period'][$quarter_month][$date_stamp]['l5c'], $this->getF941Object()->medicare_rate); $this->form_data['pay_period'][$quarter_month][$date_stamp]['l5d2'] = bcmul($this->form_data['pay_period'][$quarter_month][$date_stamp]['l5d'], $this->getF941Object()->medicare_additional_rate); $this->form_data['pay_period'][$quarter_month][$date_stamp]['l5e'] = bcadd($this->form_data['pay_period'][$quarter_month][$date_stamp]['l5a2'], bcadd($this->form_data['pay_period'][$quarter_month][$date_stamp]['l5b2'], bcadd($this->form_data['pay_period'][$quarter_month][$date_stamp]['l5c2'], $this->form_data['pay_period'][$quarter_month][$date_stamp]['l5d2']))); $this->form_data['pay_period'][$quarter_month][$date_stamp]['l6'] = bcadd($this->form_data['pay_period'][$quarter_month][$date_stamp]['l3'], bcadd($this->form_data['pay_period'][$quarter_month][$date_stamp]['l5e'], $this->form_data['pay_period'][$quarter_month][$date_stamp]['l5f'])); //Calculate amounts for Schedule B. $this->form_data['pay_period'][$quarter_month][$date_stamp]['l10'] = $this->form_data['pay_period'][$quarter_month][$date_stamp]['l6']; //Add L6 -> L9 if they are implemented later. } } //Total all pay periods by month_id if (isset($this->form_data['pay_period'])) { foreach ($this->form_data['pay_period'] as $month_id => $pp_data) { $this->form_data['quarter'][$month_id] = Misc::ArrayAssocSum($pp_data, NULL, 8); } //Total all quarters. if (isset($this->form_data['quarter'])) { $this->form_data['total'] = Misc::ArrayAssocSum($this->form_data['quarter'], NULL, 6); } } } } $this->user_ids = array_unique($this->user_ids); //Used to get the total number of employees. //Debug::Arr($this->user_ids, 'User IDs: ', __FILE__, __LINE__, __METHOD__,10); Debug::Arr($this->form_data, 'Form Raw Data: ', __FILE__, __LINE__, __METHOD__, 10); //Debug::Arr($this->tmp_data, 'Tmp Raw Data: ', __FILE__, __LINE__, __METHOD__,10); //Get user data for joining. $ulf = TTnew('UserListFactory'); $ulf->getAPISearchByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data); Debug::Text(' User Total Rows: ' . $ulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); $this->getProgressBarObject()->start($this->getAMFMessageID(), $ulf->getRecordCount(), NULL, TTi18n::getText('Retrieving Data...')); foreach ($ulf as $key => $u_obj) { $this->tmp_data['user'][$u_obj->getId()] = (array) $u_obj->getObjectAsArray($this->getColumnDataConfig()); $this->getProgressBarObject()->set($this->getAMFMessageID(), $key); } //Debug::Arr($this->tmp_data['user'], 'User Raw Data: ', __FILE__, __LINE__, __METHOD__,10); return TRUE; }
function getDeductionAmount($user_id, $pay_stub_obj, $pay_period_obj) { if ($user_id == '') { Debug::Text('Missing User ID: ', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } if (!is_object($pay_stub_obj)) { Debug::Text('Missing Pay Stub Object: ', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } if (!is_object($pay_period_obj)) { Debug::Text('Missing Pay Period Object: ', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } //Calculates the deduction. $cd_obj = $this->getCompanyDeductionObject(); $annual_pay_periods = $pay_period_obj->getPayPeriodScheduleObject()->getAnnualPayPeriods(); if (!is_object($cd_obj)) { return FALSE; } require_once Environment::getBasePath() . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'payroll_deduction' . DIRECTORY_SEPARATOR . 'PayrollDeduction.class.php'; $retval = 0; Debug::Text('Company Deduction: ID: ' . $cd_obj->getID() . ' Name: ' . $cd_obj->getName() . ' Calculation ID: ' . $cd_obj->getCalculation(), __FILE__, __LINE__, __METHOD__, 10); switch ($cd_obj->getCalculation()) { case 10: //Basic Percent if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); $retval = bcmul($amount, bcdiv($percent, 100)); break; case 15: //Advanced Percent if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $wage_base = $cd_obj->getUserValue2(); } else { $wage_base = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $exempt_amount = $cd_obj->getUserValue3(); } else { $exempt_amount = $this->getUserValue3(); } //Annual Wage Base is the maximum earnings that an employee can earn before they are no longer eligible for this deduction //Annual Deduction Amount Debug::Text('Percent: ' . $percent . ' Wage Base: ' . $wage_base . ' Exempt Amount: ' . $exempt_amount, __FILE__, __LINE__, __METHOD__, 10); if ($percent != 0) { if ($exempt_amount > 0) { $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), bcdiv($exempt_amount, $annual_pay_periods)); Debug::Text('Amount After Exemption: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); } else { $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); } if ($wage_base > 0) { //*NOTE: If the first pay stub in TimeTrex is near the end of the year, and the employee has already exceeded the wage base amount //the payroll admin needs to make sure they add a YTD Adjustment for each Include PS Accounts that this calculation is based on, //NOT the total amount they have paid for the resulting calculation, as that has no effect whatsoever. //getCalculationYTDAmount is the previous pay stub YTD amount, but it includes any YTD Adjustments in the current pay stub too. $ytd_amount = $cd_obj->getCalculationYTDAmount($pay_stub_obj); Debug::Text('Wage Base is set: ' . $wage_base . ' Amount: ' . $amount . ' Current YTD: ' . $ytd_amount, __FILE__, __LINE__, __METHOD__, 10); //Possible calcations: // //Wage Base: 3000 //Amount: 500 YTD: 0 = 500 //Amount: 500 YTD: 2900 = 100 //Amount: 500 YTD: 3100 = 0 //Amount: 3500 YTD: 0 = 3000 //AMount: 3500 YTD: 2900 = 100 //Amount: 3500 YTD: 3100 = 0 //Check to see if YTD is less than wage base. $remaining_wage_base = bcsub($wage_base, $ytd_amount); Debug::Text('Remaining Wage Base to be calculated: ' . $remaining_wage_base, __FILE__, __LINE__, __METHOD__, 10); if ($remaining_wage_base > 0) { if ($amount > $remaining_wage_base) { $amount = $remaining_wage_base; } } else { $amount = 0; //Exceeded wage base, nothing to calculate. } unset($remaining_wage_base); } else { Debug::Text('Wage Base is NOT set: ' . $wage_base, __FILE__, __LINE__, __METHOD__, 10); } $retval = bcmul($amount, bcdiv($percent, 100)); } else { $retval = 0; } if ($percent >= 0 and $retval < 0) { $retval = 0; } unset($amount, $ytd_amount, $percent, $wage_base); break; case 17: //Advanced Percent (Range Bracket) if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $min_wage = $cd_obj->getUserValue2(); } else { $min_wage = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $max_wage = $cd_obj->getUserValue3(); } else { $max_wage = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $annual_deduction_amount = $cd_obj->getUserValue4(); } else { $annual_deduction_amount = $this->getUserValue4(); } if ($this->getUserValue5() == '') { $annual_fixed_amount = $cd_obj->getUserValue5(); } else { $annual_fixed_amount = $this->getUserValue5(); } $min_wage = bcdiv($min_wage, $annual_pay_periods); $max_wage = bcdiv($max_wage, $annual_pay_periods); $annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods); $annual_fixed_amount = bcdiv($annual_fixed_amount, $annual_pay_periods); Debug::Text('Percent: ' . $percent . ' Min Wage: ' . $min_wage . ' Max Wage: ' . $max_wage . ' Annual Deduction: ' . $annual_deduction_amount, __FILE__, __LINE__, __METHOD__, 10); if ($percent != 0) { $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $annual_deduction_amount); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); if ($amount >= $min_wage and $amount <= $max_wage) { $retval = bcadd(bcmul($amount, bcdiv($percent, 100)), $annual_fixed_amount); } } else { $retval = 0; } if ($percent >= 0 and $retval < 0) { $retval = 0; } unset($amount, $percent, $min_wage, $max_wage, $annual_deduction_amount, $annual_fixed_amount); break; case 18: //Advanced Percent (Tax Bracket) if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $wage_base = $cd_obj->getUserValue2(); } else { $wage_base = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $exempt_amount = $cd_obj->getUserValue3(); } else { $exempt_amount = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $annual_deduction_amount = $cd_obj->getUserValue4(); } else { $annual_deduction_amount = $this->getUserValue4(); } Debug::Text('Percent: ' . $percent . ' Wage Base: ' . $wage_base . ' Exempt Amount: ' . $exempt_amount, __FILE__, __LINE__, __METHOD__, 10); if ($percent != 0) { if ($exempt_amount > 0) { $pp_exempt_amount = bcdiv($exempt_amount, $annual_pay_periods); } else { $pp_exempt_amount = 0; } //Debug::Text('PP Exempt Amount: '. $pp_exempt_amount, __FILE__, __LINE__, __METHOD__,10); if ($wage_base > 0) { $pp_wage_base_amount = bcdiv($wage_base, $annual_pay_periods); } else { $pp_wage_base_amount = 0; } if ($annual_deduction_amount > 0) { $pp_annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods); } else { $pp_annual_deduction_amount = 0; } //Debug::Text('PP Wage Base Base Amount: '. $pp_wage_base_amount, __FILE__, __LINE__, __METHOD__,10); $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $pp_annual_deduction_amount); //Debug::Text('Calculation Pay Stub Amount: '. $cd_obj->getCalculationPayStubAmount( $pay_stub_obj ), __FILE__, __LINE__, __METHOD__,10); if ($pp_wage_base_amount > 0 and $amount > $pp_wage_base_amount) { //Debug::Text('Exceeds Wage Base...'. $amount, __FILE__, __LINE__, __METHOD__,10); $amount = bcsub($pp_wage_base_amount, $pp_exempt_amount); } else { //Debug::Text('Under Wage Base...'. $amount, __FILE__, __LINE__, __METHOD__,10); $amount = bcsub($amount, $pp_exempt_amount); } Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); $retval = bcmul($amount, bcdiv($percent, 100)); } else { $retval = 0; } if ($percent >= 0 and $retval < 0) { $retval = 0; } unset($amount, $percent, $wage_base, $pp_wage_base_amount, $pp_exempt_amount, $annual_deduction_amount, $pp_annual_deduction_amount); break; case 19: //Advanced Percent (Tax Bracket Alternate) /* This is designed to be used for single line item tax calculations, in that the formula looks like this, where only ONE bracket would be applied to the employee, NOT all: Wage between 0 - 10,000 calculate 10% Wage between 10,001 - 20,000 calculate 15% + $1000 (10% of 10,000 as per above) Wage between 20,001 - 30,000 calculate 20% + $2500 (10% of 10,000 as first bracket, and 15% of 10,000 as per 2nd bracket) */ if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $min_wage = $cd_obj->getUserValue2(); } else { $min_wage = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $max_wage = $cd_obj->getUserValue3(); } else { $max_wage = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $annual_deduction_amount = $cd_obj->getUserValue4(); } else { $annual_deduction_amount = $this->getUserValue4(); } if ($this->getUserValue5() == '') { $annual_fixed_amount = $cd_obj->getUserValue5(); } else { $annual_fixed_amount = $this->getUserValue5(); } $min_wage = bcdiv($min_wage, $annual_pay_periods); $max_wage = bcdiv($max_wage, $annual_pay_periods); $annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods); $annual_fixed_amount = bcdiv($annual_fixed_amount, $annual_pay_periods); Debug::Text('Percent: ' . $percent . ' Min Wage: ' . $min_wage . ' Max Wage: ' . $max_wage . ' Annual Deduction: ' . $annual_deduction_amount, __FILE__, __LINE__, __METHOD__, 10); if ($percent != 0) { $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $annual_deduction_amount); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); if ($amount >= $min_wage and $amount <= $max_wage) { $retval = bcadd(bcmul(bcsub($amount, $min_wage), bcdiv($percent, 100)), $annual_fixed_amount); } } else { $retval = 0; } if ($percent >= 0 and $retval < 0) { $retval = 0; } unset($amount, $percent, $min_wage, $max_wage, $annual_deduction_amount, $annual_fixed_amount); break; case 20: //Fixed amount if ($this->getUserValue1() == FALSE) { $amount = $cd_obj->getUserValue1(); } else { $amount = $this->getUserValue1(); } $retval = $amount; unset($amount); break; case 30: //Fixed Amount (Range Bracket) if ($this->getUserValue1() == '') { $fixed_amount = $cd_obj->getUserValue1(); } else { $fixed_amount = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $min_wage = $cd_obj->getUserValue2(); } else { $min_wage = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $max_wage = $cd_obj->getUserValue3(); } else { $max_wage = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $annual_deduction_amount = $cd_obj->getUserValue4(); } else { $annual_deduction_amount = $this->getUserValue4(); } $min_wage = bcdiv($min_wage, $annual_pay_periods); $max_wage = bcdiv($max_wage, $annual_pay_periods); $annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods); Debug::Text('Amount: ' . $fixed_amount . ' Min Wage: ' . $min_wage . ' Max Wage: ' . $max_wage . ' Annual Deduction: ' . $annual_deduction_amount, __FILE__, __LINE__, __METHOD__, 10); if ($fixed_amount != 0) { $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $annual_deduction_amount); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); if ($amount >= $min_wage and $amount <= $max_wage) { $retval = $fixed_amount; } } else { $retval = 0; } unset($fixed_amount, $amount, $percent, $min_wage, $max_wage, $annual_deduction_amount); break; case 52: //Fixed Amount (w/Limit) if ($this->getUserValue1() == '') { $fixed_amount = $cd_obj->getUserValue1(); } else { $fixed_amount = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $target_amount = $cd_obj->getUserValue2(); } else { $target_amount = $this->getUserValue2(); } Debug::Text('Amount: ' . $fixed_amount . ' Target Amount: ' . $target_amount, __FILE__, __LINE__, __METHOD__, 10); $retval = 0; if ($fixed_amount != 0) { $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); if ($amount !== $target_amount) { if (abs($fixed_amount) < abs(bcsub($amount, $target_amount))) { //Use full fixed amount Debug::Text('Not within reach of target, use full fixed amount...', __FILE__, __LINE__, __METHOD__, 10); $retval = $fixed_amount; } else { Debug::Text('Within reach of target, use partial fixed amount...', __FILE__, __LINE__, __METHOD__, 10); //Use partial fixed_amount $retval = bcadd(abs($amount), $target_amount); } } } $retval = abs($retval); unset($fixed_amount, $tmp_amount, $amount, $min_limit, $max_limit); break; case 80: //US Earning Income Credit (EIC) if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('US', NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); if (is_object($this->getUserObject())) { $currency_id = $this->getUserObject()->getCurrency(); $pd_obj->setUserCurrency($currency_id); Debug::Text('User Currency ID: ' . $currency_id, __FILE__, __LINE__, __METHOD__, 10); } $pd_obj->setEICFilingStatus($user_value1); $pd_obj->setGrossPayPeriodIncome($amount); //Allow negative value, infact it always should be. $retval = $pd_obj->getEIC(); break; case 90: //Canada - CPP $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('CA', NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); $pd_obj->setEnableCPPAndEIDeduction(TRUE); if ($this->getPayStubEntryAccountLinkObject()->getEmployeeCPP() != '') { Debug::Text('Found Employee CPP account link!: ', __FILE__, __LINE__, __METHOD__, 10); $previous_ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); $current_ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); Debug::text('YTD CPP Contribution: Previous Amount: ' . $previous_ytd_cpp_arr['ytd_amount'] . ' Current Amount: ' . $current_ytd_cpp_arr['amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateCPPContribution(bcadd($previous_ytd_cpp_arr['ytd_amount'], $current_ytd_cpp_arr['ytd_amount'])); unset($previous_ytd_cpp_arr, $current_ytd_cpp_arr); } $pd_obj->setGrossPayPeriodIncome($amount); $retval = $pd_obj->getEmployeeCPP(); if ($retval < 0) { $retval = 0; } break; case 91: //Canada - EI $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('CA', NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); $pd_obj->setEnableCPPAndEIDeduction(TRUE); if ($this->getPayStubEntryAccountLinkObject()->getEmployeeEI() != '') { Debug::Text('Found Employee EI account link!: ', __FILE__, __LINE__, __METHOD__, 10); $previous_ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); $current_ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); Debug::text('YTD EI Contribution: Previous Amount: ' . $previous_ytd_ei_arr['ytd_amount'] . ' Current Amount: ' . $current_ytd_ei_arr['amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateEIContribution(bcadd($previous_ytd_ei_arr['ytd_amount'], $current_ytd_ei_arr['ytd_amount'])); unset($previous_ytd_ei_arr, $current_ytd_ei_arr); } $pd_obj->setGrossPayPeriodIncome($amount); $retval = $pd_obj->getEmployeeEI(); if ($retval < 0) { $retval = 0; } break; case 100: //Federal Income Tax if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $user_value2 = $cd_obj->getUserValue2(); } else { $user_value2 = $this->getUserValue2(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue2: ' . $user_value2, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction($this->getCompanyDeductionObject()->getCountry(), NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); if (is_object($this->getUserObject())) { $currency_id = $this->getUserObject()->getCurrency(); $pd_obj->setUserCurrency($currency_id); Debug::Text('User Currency ID: ' . $currency_id, __FILE__, __LINE__, __METHOD__, 10); } if ($this->getCompanyDeductionObject()->getCountry() == 'CA') { //CA $pd_obj->setFederalTotalClaimAmount($user_value1); $pd_obj->setEnableCPPAndEIDeduction(TRUE); //$pself = new PayStubEntryListFactory(); if ($this->getPayStubEntryAccountLinkObject()->getEmployeeCPP() != '') { Debug::Text('Found Employee CPP account link!: ', __FILE__, __LINE__, __METHOD__, 10); //$ytd_cpp_arr = $pself->getYTDAmountSumByUserIdAndEntryNameIDAndYear( $this->getUser(), $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP(), $pay_period_obj->getTransactionDate() ); $ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); Debug::text('YTD CPP Contribution: ' . $ytd_cpp_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateCPPContribution($ytd_cpp_arr['ytd_amount']); unset($ytd_cpp_arr); } if ($this->getPayStubEntryAccountLinkObject()->getEmployeeEI() != '') { Debug::Text('Found Employee EI account link!: ', __FILE__, __LINE__, __METHOD__, 10); //$ytd_ei_arr = $pself->getYTDAmountSumByUserIdAndEntryNameIDAndYear( $this->getUser(), $this->getPayStubEntryAccountLinkObject()->getEmployeeEI(), $pay_period_obj->getTransactionDate() ); $ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); Debug::text('YTD EI Contribution: ' . $ytd_ei_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateEIContribution($ytd_ei_arr['ytd_amount']); unset($ytd_ei_arr); } } elseif ($this->getCompanyDeductionObject()->getCountry() == 'US') { //US $pd_obj->setFederalFilingStatus($user_value1); $pd_obj->setFederalAllowance($user_value2); } elseif ($this->getCompanyDeductionObject()->getCountry() == 'CR') { //CR $pd_obj->setFederalFilingStatus($user_value1); //Single/Married $pd_obj->setFederalAllowance($user_value2); //Allownces/Children } $pd_obj->setGrossPayPeriodIncome($amount); $retval = $pd_obj->getFederalPayPeriodDeductions(); if ($retval < 0) { $retval = 0; } break; case 200: //Province Income Tax if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $user_value2 = $cd_obj->getUserValue2(); } else { $user_value2 = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $user_value3 = $cd_obj->getUserValue3(); } else { $user_value3 = $this->getUserValue3(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue2: ' . $user_value2, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue3: ' . $user_value3, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction($this->getCompanyDeductionObject()->getCountry(), $this->getCompanyDeductionObject()->getProvince()); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); $pd_obj->setGrossPayPeriodIncome($amount); if ($this->getCompanyDeductionObject()->getCountry() == 'CA') { Debug::Text('Canada Pay Period Deductions...', __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setProvincialTotalClaimAmount($user_value1); $pd_obj->setEnableCPPAndEIDeduction(TRUE); //$pself = new PayStubEntryListFactory(); if ($this->getPayStubEntryAccountLinkObject()->getEmployeeCPP() != '') { Debug::Text('Found Employee CPP account link!: ', __FILE__, __LINE__, __METHOD__, 10); $ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); Debug::text('YTD CPP Contribution: ' . $ytd_cpp_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateCPPContribution($ytd_cpp_arr['ytd_amount']); unset($ytd_cpp_arr); } if ($this->getPayStubEntryAccountLinkObject()->getEmployeeEI() != '') { Debug::Text('Found Employee EI account link!: ', __FILE__, __LINE__, __METHOD__, 10); //$ytd_ei_arr = $pself->getYTDAmountSumByUserIdAndEntryNameIDAndYear( $this->getUser(), $this->getPayStubEntryAccountLinkObject()->getEmployeeEI(), $pay_period_obj->getTransactionDate() ); $ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); Debug::text('YTD EI Contribution: ' . $ytd_ei_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateEIContribution($ytd_ei_arr['ytd_amount']); unset($ytd_ei_arr); } $retval = $pd_obj->getProvincialPayPeriodDeductions(); } elseif ($this->getCompanyDeductionObject()->getCountry() == 'US') { Debug::Text('US Pay Period Deductions...', __FILE__, __LINE__, __METHOD__, 10); //Need to set Federal settings here. $udlf = new UserDeductionListFactory(); $udlf->getByUserIdAndCountryID($user_id, $this->getCompanyDeductionObject()->getCountry()); if ($udlf->getRecordCount() > 0) { Debug::Text('Found Federal User Deduction...', __FILE__, __LINE__, __METHOD__, 10); $tmp_ud_obj = $udlf->getCurrent(); if ($tmp_ud_obj->getUserValue1() == '') { $tmp_user_value1 = $tmp_ud_obj->getCompanyDeductionObject()->getUserValue1(); } else { $tmp_user_value1 = $tmp_ud_obj->getUserValue1(); } if ($tmp_ud_obj->getUserValue2() == '') { $tmp_user_value2 = $tmp_ud_obj->getCompanyDeductionObject()->getUserValue2(); } else { $tmp_user_value2 = $tmp_ud_obj->getUserValue2(); } Debug::Text('TmpUserValue1: ' . $tmp_user_value1, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('TmpUserValue2: ' . $tmp_user_value2, __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setFederalFilingStatus($tmp_user_value1); $pd_obj->setFederalAllowance($tmp_user_value2); unset($tmp_ud_obj, $tmp_user_value1, $tmp_user_value1); } unset($udlf); $pd_obj->setStateFilingStatus($user_value1); $pd_obj->setStateAllowance($user_value2); $pd_obj->setUserValue1($user_value1); $pd_obj->setUserValue2($user_value2); $pd_obj->setUserValue3($user_value3); $retval = $pd_obj->getStatePayPeriodDeductions(); } if ($retval < 0) { $retval = 0; } break; case 300: //District Income Tax if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $user_value2 = $cd_obj->getUserValue2(); } else { $user_value2 = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $user_value3 = $cd_obj->getUserValue3(); } else { $user_value3 = $this->getUserValue3(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue2: ' . $user_value2, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue3: ' . $user_value3, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('District: ' . $this->getCompanyDeductionObject()->getDistrict(), __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction($this->getCompanyDeductionObject()->getCountry(), $this->getCompanyDeductionObject()->getProvince(), $this->getCompanyDeductionObject()->getDistrict()); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); $pd_obj->setDistrictFilingStatus($user_value1); $pd_obj->setDistrictAllowance($user_value2); $pd_obj->setUserValue1($user_value1); $pd_obj->setUserValue2($user_value2); $pd_obj->setUserValue3($user_value3); $pd_obj->setGrossPayPeriodIncome($amount); $retval = $pd_obj->getDistrictPayPeriodDeductions(); if ($retval < 0) { $retval = 0; } break; } Debug::Text('Deduction Amount: ' . $retval, __FILE__, __LINE__, __METHOD__, 10); //Allow negative values, as some advanced tax bracket setups require this. if ($retval < 0) { //Debug::Text('Deduction was negative, setting to 0...', __FILE__, __LINE__, __METHOD__,10); Debug::Text('Deduction was negative...', __FILE__, __LINE__, __METHOD__, 10); //$retval = 0; } return $retval; }
function CompanyDeductions($country = NULL, $province = NULL, $district = NULL, $industry = NULL) { // //Additional Information: http://www.payroll-taxes.com/state-tax.htm // //Get PayStub Link accounts $pseallf = TTnew('PayStubEntryAccountLinkListFactory'); $pseallf->getByCompanyId($this->getCompany()); if ($pseallf->getRecordCount() > 0) { $psea_obj = $pseallf->getCurrent(); } else { Debug::text('Company ID: ' . $this->getCompany(), __FILE__, __LINE__, __METHOD__, 10); return FALSE; } require_once Environment::getBasePath() . '/classes/payroll_deduction/PayrollDeduction.class.php'; $pd_obj = new PayrollDeduction($country, $province); $pd_obj->setDate(time()); $cdf = TTnew('CompanyDeductionFactory'); $cdf->StartTransaction(); Debug::text('Country: ' . $country, __FILE__, __LINE__, __METHOD__, 10); if ($country != '' and $province == '') { switch ($country) { case 'ca': $pd_obj = new PayrollDeduction($country, 'BC'); //Pick default province for now. $pd_obj->setDate(time()); //Federal Income Tax $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'CA - Federal Income Tax', 'calculation_id' => 100, 'calculation_order' => 100, 'country' => strtoupper($country), 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'CA - Federal Income Tax'), 'user_value1' => $pd_obj->getBasicFederalClaimCodeAmount(), 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'RRSP'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'Union Dues')))); $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'CA - Addl. Income Tax', 'calculation_id' => 20, 'calculation_order' => 105, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'CA - Addl. Income Tax'), 'user_value1' => 0)); //CPP $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'CPP - Employee', 'calculation_id' => 90, 'calculation_order' => 80, 'minimum_user_age' => 18, 'maximum_user_age' => 70, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'CPP'), 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement')))); $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'CPP - Employer', 'calculation_id' => 10, 'calculation_order' => 85, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, 'CPP - Employer'), 'include_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'CPP')), 'user_value1' => 100)); //EI $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'EI - Employee', 'calculation_id' => 91, 'calculation_order' => 90, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'EI'), 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement')))); $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'EI - Employer', 'calculation_id' => 10, 'calculation_order' => 95, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, 'EI - Employer'), 'include_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'EI')), 'user_value1' => 140)); $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'WCB - Employer', 'calculation_id' => 15, 'calculation_order' => 96, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, 'WCB - Employer'), 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement')), 'user_value1' => 0.0, 'user_value2' => 0, 'user_value3' => 0)); break; case 'us': //Federal Income Tax $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'US - Federal Income Tax', 'calculation_id' => 100, 'calculation_order' => 100, 'country' => strtoupper($country), 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'US - Federal Income Tax'), 'user_value1' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'US - Addl. Income Tax', 'calculation_id' => 20, 'calculation_order' => 105, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'US - Federal Addl. Income Tax'), 'user_value1' => 0)); //Federal Unemployment Insurance. $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'US - Federal Unemployment Insurance', 'calculation_id' => 15, 'calculation_order' => 80, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, 'US - Federal Unemployment Insurance'), 'user_value1' => $pd_obj->getFederalUIMinimumRate(), 'user_value2' => $pd_obj->getFederalUIMaximumEarnings(), 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Social Security $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'Social Security - Employee', 'calculation_id' => 84, 'calculation_order' => 80, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'Social Security (FICA)'), 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'Social Security - Employer', 'calculation_id' => 85, 'calculation_order' => 81, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, 'Social Security (FICA)'), 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Medicare $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'Medicare - Employee', 'calculation_id' => 82, 'calculation_order' => 90, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'Medicare'), 'user_value1' => 10, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => 'Medicare - Employer', 'calculation_id' => 83, 'calculation_order' => 91, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, 'Medicare'), 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; } unset($pd_obj); } //Canada if ($country == 'ca' and $province != '') { $vacation_data = array('primary_percent' => 0, 'secondary_percent' => 0, 'secondary_length_of_service' => 0); Debug::text('Province: ' . $province, __FILE__, __LINE__, __METHOD__, 10); switch ($province) { //CA case 'bc': case 'ab': case 'mb': case 'qc': case 'nu': case 'nt': $vacation_data = array('primary_percent' => 4, 'secondary_percent' => 6, 'secondary_length_of_service' => 6); break; case 'nb': case 'ns': case 'pe': $vacation_data = array('primary_percent' => 4, 'secondary_percent' => 6, 'secondary_length_of_service' => 9); break; case 'on': case 'yt': $vacation_data = array('primary_percent' => 4, 'secondary_percent' => 0, 'secondary_length_of_service' => 0); break; case 'sk': $vacation_data = array('primary_percent' => 4, 'secondary_percent' => 8, 'secondary_length_of_service' => 11); break; case 'nl': $vacation_data = array('primary_percent' => 4, 'secondary_percent' => 6, 'secondary_length_of_service' => 16); break; } if (!in_array($province, array('on', 'yt'))) { $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 20, 'name' => strtoupper($province) . ' - Vacation Accrual - 0-' . ($vacation_data['secondary_length_of_service'] - 1) . ' Years', 'calculation_id' => 10, 'calculation_order' => 50, 'minimum_length_of_service_unit_id' => 40, 'minimum_length_of_service' => 0, 'maximum_length_of_service_unit_id' => 40, 'maximum_length_of_service' => $vacation_data['secondary_length_of_service'] - 0.003, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(50, 'Vacation Accrual'), 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Vacation - Accrual Release'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Vacation - No Accrual'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Tips')), 'user_value1' => $vacation_data['primary_percent'])); } $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 20, 'name' => strtoupper($province) . ' - Vacation Accrual - ' . ($vacation_data['secondary_length_of_service'] - 0) . '+ Years', 'calculation_id' => 10, 'calculation_order' => 51, 'minimum_length_of_service_unit_id' => 40, 'minimum_length_of_service' => $vacation_data['secondary_length_of_service'], 'maximum_length_of_service_unit_id' => 40, 'maximum_length_of_service' => 0, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(50, 'Vacation Accrual'), 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Vacation - Accrual Release'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Vacation - No Accrual'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Tips')), 'user_value1' => $vacation_data['secondary_percent'])); if (!in_array($province, array('on', 'yt'))) { $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 20, 'name' => strtoupper($province) . ' - Vacation No Accrual - 0-' . ($vacation_data['secondary_length_of_service'] - 1) . ' Years', 'calculation_id' => 10, 'calculation_order' => 50, 'minimum_length_of_service_unit_id' => 40, 'minimum_length_of_service' => 0, 'maximum_length_of_service_unit_id' => 40, 'maximum_length_of_service' => $vacation_data['secondary_length_of_service'] - 0.003, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Vacation - No Accrual'), 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Vacation - Accrual Release'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Vacation - No Accrual'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Tips')), 'user_value1' => $vacation_data['primary_percent'])); } $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 20, 'name' => strtoupper($province) . ' - Vacation No Accrual - ' . ($vacation_data['secondary_length_of_service'] - 0) . '+ Years', 'calculation_id' => 10, 'calculation_order' => 51, 'minimum_length_of_service_unit_id' => 40, 'minimum_length_of_service' => $vacation_data['secondary_length_of_service'], 'maximum_length_of_service_unit_id' => 40, 'maximum_length_of_service' => 0, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Vacation - No Accrual'), 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Vacation - Accrual Release'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Vacation - No Accrual'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Tips')), 'user_value1' => $vacation_data['secondary_percent'])); $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Provincial Income Tax', 'calculation_id' => 200, 'calculation_order' => 101, 'country' => strtoupper($country), 'province' => strtoupper($province), 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Provincial Income Tax'), 'user_value1' => $pd_obj->getBasicProvinceClaimCodeAmount(), 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'RRSP'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'Union Dues')))); } if ($country == 'us' and $province != '') { if (in_array($province, array('al', 'az', 'ar', 'ca', 'co', 'ct', 'de', 'dc', 'ga', 'hi', 'id', 'il', 'in', 'ia', 'ks', 'ky', 'la', 'me', 'md', 'ma', 'mi', 'mn', 'ms', 'mo', 'mt', 'ne', 'nj', 'nm', 'ny', 'nc', 'nd', 'oh', 'ok', 'or', 'pa', 'ri', 'sc', 'ut', 'vt', 'va', 'wi', 'wv'))) { //State Income Tax $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - State Income Tax', 'calculation_id' => 200, 'calculation_order' => 200, 'country' => strtoupper($country), 'province' => strtoupper($province), 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - State Income Tax'), 'user_value1' => 10, 'user_value2' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - State Addl. Income Tax', 'calculation_id' => 20, 'calculation_order' => 205, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - State Addl. Income Tax'), 'user_value1' => 0)); } //Default to unemployment rates to 0. $company_state_unemployment_rate = 0; $company_state_unemployment_wage_base = 0; $state_unemployment_rate = 0; $state_unemployment_wage_base = 0; Debug::text('Province: ' . $province, __FILE__, __LINE__, __METHOD__, 10); switch ($province) { //US case 'al': //alabama //Unemployment Insurance - Employee $state_unemployment_wage_base = 8000; //Employment Security Asmt $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Employment Security Assessment', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Employment Security Assessment'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'ak': //alaska //Unemployment Insurance - Employee //Unemployment Insurance - Employer $company_state_unemployment_wage_base = $state_unemployment_wage_base = 35800; break; case 'az': //arizona //Unemployment Insurance - Employee $state_unemployment_wage_base = 7000; //Surcharge $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Job Training Surcharge', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Job Training Surcharge'), 'user_value1' => 0.6, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'ar': //arkansas //Unemployment Insurance - Employee $state_unemployment_wage_base = 12000; break; case 'ca': //california //Unemployment Insurance - Employee $state_unemployment_wage_base = 7000; //Disability Insurance $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Disability Insurance', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Disability Insurance'), 'user_value1' => 1.0, 'user_value2' => 95585, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Employee Training Tax $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Employee Training Tax', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Employee Training Tax'), 'user_value1' => 0.1, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'co': //colorado //Unemployment Insurance - Employee $state_unemployment_wage_base = 11000; break; case 'ct': //connecticut //Unemployment Insurance - Employee $state_unemployment_wage_base = 15000; break; case 'de': //delaware //Unemployment Insurance - Employee $state_unemployment_wage_base = 10500; break; case 'dc': //d.c. //Unemployment Insurance - Employee $state_unemployment_wage_base = 9000; //Administrative Assessment $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Administrative Assessment', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Administrative Assessment'), 'user_value1' => 0.2, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'fl': //florida //Unemployment Insurance - Employee $state_unemployment_wage_base = 8000; break; case 'ga': //georgia //Unemployment Insurance - Employee $state_unemployment_wage_base = 8500; //Administrative Assessment $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Administrative Assessment', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Administrative Assessment'), 'user_value1' => 0.08, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'hi': //hawaii //Unemployment Insurance - Employee $state_unemployment_wage_base = 38800; //E&T Assessment $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - E&T Assessment', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - E&T Assessment'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Health Insurance $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Health Insurance', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Health Insurance'), 'user_value1' => 0.0, 'user_value2' => 0, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Disability Insurance $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Disability Insurance', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Disability Insurance'), 'user_value1' => 0.0, 'user_value2' => 46970.56, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'id': //idaho //Unemployment Insurance - Employee $state_unemployment_wage_base = 34100; //Administrative Reserve $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Administrative Reserve', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Administrative Reserve'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Workforce Development $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Workforce Development', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Workforce Development'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'il': //illinois //Unemployment Insurance - Employee $state_unemployment_wage_base = 13560; break; case 'in': //indiana //Unemployment Insurance - Employee $state_unemployment_wage_base = 9500; //County Tax /* $this->createPayStubAccount( array( 'company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 20, 'name' => strtoupper($province) .' - County Income Tax', 'ps_order' => 210, ) ); */ break; case 'ia': //iowa //Unemployment Insurance - Employee $state_unemployment_wage_base = 25300; //Reserve Fund $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Reserve Fund', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Reserve Fund'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Surcharge $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Surcharge', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Surcharge'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'ks': //kansas //Unemployment Insurance - Employee $state_unemployment_wage_base = 8000; break; case 'ky': //kentucky //Unemployment Insurance - Employee $state_unemployment_wage_base = 9000; break; case 'la': //louisiana //Unemployment Insurance - Employee $state_unemployment_wage_base = 7700; break; case 'me': //maine //Unemployment Insurance - Employee $state_unemployment_wage_base = 12000; //Competitive Skills $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Competitive Skills', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Competitive Skills'), 'user_value1' => 0.06, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'md': //maryland //Unemployment Insurance - Employee $state_unemployment_wage_base = 8500; break; case 'ma': //massachusetts //Unemployment Insurance - Employee $state_unemployment_wage_base = 14000; //Health Insurance $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Health Insurance', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Health Insurance'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Workforce Training Fund $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Workforce Training Fund', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Workforce Training Fund'), 'user_value1' => 0.06, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'mi': //michigan //Unemployment Insurance - Employee $state_unemployment_wage_base = 9500; break; case 'mn': //minnesota //Unemployment Insurance - Employee $state_unemployment_wage_base = 28000; //Workforce Enhancement Fee $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Workforce Enhancement Fee', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Workforce Enhancement Fee'), 'user_value1' => 0.1, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'ms': //mississippi //Unemployment Insurance - Employee $state_unemployment_wage_base = 14000; //Training Contribution $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Training Contribution', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Training Contribution'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'mo': //missouri //Unemployment Insurance - Employee $state_unemployment_wage_base = 13000; break; case 'mt': //montana //Unemployment Insurance - Employee $state_unemployment_wage_base = 27000; //Administrative Fund $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Administrative Fund', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Administrative Fund'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'ne': //nebraska //Unemployment Insurance - Employee $state_unemployment_wage_base = 9000; //SUIT $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - SUIT', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - SUIT'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'nv': //nevada //Unemployment Insurance - Employee $state_unemployment_wage_base = 26400; //Career Enhancement $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Career Enhancement', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Career Enhancement'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'nh': //new hampshire //Unemployment Insurance - Employee $state_unemployment_wage_base = 14000; //Administrative Contribution $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Administrative Contribution', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Administrative Contribution'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'nm': //new mexico //Unemployment Insurance - Employee $state_unemployment_wage_base = 22400; //State Trust Fund $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - State Trust Fund', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - State Trust Fund'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'nj': //new jersey //Unemployment Insurance - Employee //Unemployment Insurance - Employer $state_unemployment_wage_base = 30300; //Disability Insurance - Employee $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Disability Insurance - Employee', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Disability Insurance'), 'user_value1' => 0.2, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Disability Insurance - Employer $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Disability Insurance - Employer', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Disability Insurance'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Workforce Development - Employee $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Workforce Development - Employee', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Workforce Development'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Workforce Development - Employer $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Workforce Development - Employer', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Workforce Development'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Healthcare Subsidy - Employee $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Healthcare Subsidy - Employee', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Healthcare Subsidy'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Healthcare Subsidy - Employer $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Healthcare Subsidy - Employer', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Healthcare Subsidy'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Family Leave Insurance $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Family Leave Insurance', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Family Leave Insurance'), 'user_value1' => 0.08, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'ny': //new york //Unemployment Insurance - Employee $company_state_unemployment_wage_base = $state_unemployment_wage_base = 8500; //Reemployment Service Fund $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Reemployment Service Fund', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Reemployment Service Fund'), 'user_value1' => 0.075, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Disability Insurance - Employee $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Disability Insurance', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Disability Insurance'), 'user_value1' => 0.5, 'user_value2' => 0, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Disability Insurance - Male $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Disability Insurance - Male', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Disability Insurance - Male'), 'user_value1' => 0.0, 'user_value2' => 6000, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Disability Insurance - Female $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Disability Insurance - Female', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Disability Insurance - Female'), 'user_value1' => 0.0, 'user_value2' => 6000, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Metropolitan Commuter Tax $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Metropolitan Commuter Tax', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Metropolitan Commuter Tax'), 'user_value1' => 0.34, 'user_value2' => 0, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'nc': //north carolina //Unemployment Insurance - Employee $state_unemployment_wage_base = 20400; break; case 'nd': //north dakota //Unemployment Insurance - Employee $state_unemployment_wage_base = 27900; break; case 'oh': //ohio //Unemployment Insurance - Employee $state_unemployment_wage_base = 9000; break; case 'ok': //oklahoma //Unemployment Insurance - Employee $state_unemployment_wage_base = 19100; break; case 'or': //oregon //Unemployment Insurance - Employee $state_unemployment_wage_base = 33000; //Workers Benefit - Employee $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Workers Benefit - Employee', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Workers Benefit'), 'user_value1' => 0.014, 'user_value2' => 0, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Workers Benefit - Employer $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Workers Benefit - Employer', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Workers Benefit'), 'user_value1' => 0.014, 'user_value2' => 0, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Tri-Met Transit District $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Tri-Met Transit District', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Tri-Met Transit District'), 'user_value1' => 0.7018, 'user_value2' => 0, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Lane Transit District $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Lane Transit District', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Lane Transit District'), 'user_value1' => 0.68, 'user_value2' => 0, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Special Payroll Tax offset $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Special Payroll Tax Offset', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Special Payroll Tax Offset'), 'user_value1' => 0.09, 'user_value2' => 0, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'pa': //pennsylvania //Unemployment Insurance - Employee //Unemployment Insurance - Employer $state_unemployment_wage_base = 0; $company_state_unemployment_wage_base = 8000; break; case 'ri': //rhode island //Employment Security $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Employment Security', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Employment Security'), 'user_value1' => 0.09, 'user_value2' => 19600, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Job Development Fund $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Job Development Fund', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Job Development Fund'), 'user_value1' => 0.51, 'user_value2' => 19600, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Temporary Disability Insurance $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Temporary Disability Insurance', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Temporary Disability Ins.'), 'user_value1' => 1.2, 'user_value2' => 60000, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'sc': //south carolina //Unemployment Insurance - Employee $state_unemployment_wage_base = 12000; //Contingency Assessment $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Contingency Assessment', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Contingency Assessment'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'sd': //south dakota //Unemployment Insurance - Employee $state_unemployment_wage_base = 12000; //Investment Fee $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Investment Fee', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Investment Fee'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //UI Surcharge $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - UI Surcharge', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - UI Surcharge'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'tn': //tennessee //Unemployment Insurance - Employee $state_unemployment_wage_base = 9000; //Job Skills Fee $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Job Skills Fee', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Job Skills Fee'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'tx': //texas //Unemployment Insurance - Employee $state_unemployment_wage_base = 9000; //Employment & Training $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Employment & Training', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Employment & Training'), 'user_value1' => 0.1, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //UI Obligation Assessment $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - UI Obligation Assessment', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - UI Obligation Assessment'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'ut': //utah //Unemployment Insurance - Employee $state_unemployment_wage_base = 29500; break; case 'vt': //vermont //Unemployment Insurance - Employee $state_unemployment_wage_base = 16000; break; case 'va': //virginia //Unemployment Insurance - Employee $state_unemployment_wage_base = 8000; break; case 'wa': //washington //Unemployment Insurance - Employee $state_unemployment_wage_base = 38200; //Industrial Insurance - Employee $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Industrial Insurance - Employee', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Industrial Insurance'), 'user_value1' => 0.0, 'user_value2' => 0, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Industrial Insurance - Employer $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Industrial Insurance - Employer', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Industrial Insurance'), 'user_value1' => 0.0, 'user_value2' => 0, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); //Employment Admin Fund $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Employment Admin Fund', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Employment Admin Fund'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; case 'wv': //west virginia //Unemployment Insurance - Employee $state_unemployment_wage_base = 12000; break; case 'wi': //wisconsin //Unemployment Insurance - Employee $state_unemployment_wage_base = 13000; break; case 'wy': //wyoming //Unemployment Insurance - Employee $state_unemployment_wage_base = 23000; //Employment Support Fund $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Employment Support Fund', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Employment Support Fund'), 'user_value1' => 0.0, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); break; } //Unemployment insurance must go below the above state settings so it has the proper rate/wage_base for //State Unemployement Insurace, deducted from employer if (in_array($province, array('ak', 'al', 'ar', 'az', 'ca', 'co', 'ct', 'dc', 'de', 'fl', 'ga', 'hi', 'ia', 'id', 'il', 'in', 'ks', 'ky', 'la', 'ma', 'md', 'me', 'mi', 'mn', 'mo', 'ms', 'mt', 'nc', 'nd', 'ne', 'nh', 'nj', 'nm', 'nv', 'ny', 'oh', 'ok', 'or', 'pa', 'sc', 'sd', 'tn', 'tx', 'ut', 'va', 'vt', 'wa', 'wi', 'wv', 'wy'))) { $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Unemployment Insurance - Employer', 'calculation_id' => 15, 'calculation_order' => 185, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(30, strtoupper($province) . ' - Unemployment Insurance'), 'user_value1' => $state_unemployment_rate, 'user_value2' => $state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); } //State Unemployement Insurace, deducted from employee if (in_array($province, array('ak', 'nj', 'pa'))) { $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 10, 'name' => strtoupper($province) . ' - Unemployment Insurance - Employee', 'calculation_id' => 15, 'calculation_order' => 186, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, strtoupper($province) . ' - Unemployment Insurance'), 'user_value1' => $company_state_unemployment_rate, 'user_value2' => $company_state_unemployment_wage_base, 'user_value3' => 0, 'include_pay_stub_entry_account' => array($psea_obj->getTotalGross()), 'exclude_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Loan'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(10, 'Expense Reimbursement'), $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, '401(k)')))); } } //Default accounts, only created if country and province are not defined. if ($country == '' and $province == '' and $district == '') { $this->createCompanyDeduction(array('company_id' => $this->getCompany(), 'status_id' => 10, 'type_id' => 20, 'name' => 'Loan Repayment', 'calculation_id' => 52, 'calculation_order' => 200, 'pay_stub_entry_account_id' => $this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(20, 'Loan Repayment'), 'user_value1' => 25, 'user_value2' => 0, 'include_pay_stub_entry_account' => array($this->getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName(50, 'Loan Balance')))); } $cdf->CommitTransaction(); return TRUE; }
function testPE_2008a_SemiMonthly_Claim1_MedIncome() { Debug::text('PE - SemiMonthly - Beginning of 2008 01-Jan-08: ', __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('CA', 'PE'); $pd_obj->setDate(strtotime('01-Jan-08')); $pd_obj->setEnableCPPAndEIDeduction(TRUE); //Deduct CPP/EI. $pd_obj->setAnnualPayPeriods(24); $pd_obj->setFederalTotalClaimAmount(9600); $pd_obj->setProvincialTotalClaimAmount(7708); $pd_obj->setWCBRate(0.18); $pd_obj->setEIExempt(FALSE); $pd_obj->setCPPExempt(FALSE); $pd_obj->setFederalTaxExempt(FALSE); $pd_obj->setProvincialTaxExempt(FALSE); $pd_obj->setYearToDateCPPContribution(0); $pd_obj->setYearToDateEIContribution(0); $pd_obj->setGrossPayPeriodIncome(2763.0); $this->assertEquals($this->mf($pd_obj->getGrossPayPeriodIncome()), '2763.00'); Debug::text('Prov Ded: ' . $pd_obj->getProvincialPayPeriodDeductions(), __FILE__, __LINE__, __METHOD__, 10); $this->assertEquals($this->mf($pd_obj->getProvincialPayPeriodDeductions()), '288.09'); //285.90 }