static function addPresets($company_id)
 {
     if ($company_id == '') {
         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 {
         return FALSE;
     }
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->StartTransaction();
     /*
     								10 => 'Earning',
     								20 => 'Employee Deduction',
     								30 => 'Employer Deduction',
     								40 => 'Total',
     								50 => 'Accrual',
     								60 => 'Advance Earning',
     								65 => 'Advance Deduction',
     */
     //See if accounts are already linked
     $pseallf = new PayStubEntryAccountLinkListFactory();
     $pseallf->getByCompanyId($company_id);
     if ($pseallf->getRecordCount() > 0) {
         $psealf = $pseallf->getCurrent();
     } else {
         $psealf = new PayStubEntryAccountLinkFactory();
         $psealf->setCompany($company_id);
     }
     Debug::text('Country: ' . $country, __FILE__, __LINE__, __METHOD__, 10);
     switch (strtolower($country)) {
         case 'ca':
             Debug::text('Saving.... Federal Taxes', __FILE__, __LINE__, __METHOD__, 10);
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('Federal Income Tax');
             $pseaf->setOrder(210);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('Provincial Income Tax');
             $pseaf->setOrder(220);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('Additional Income Tax');
             $pseaf->setOrder(230);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('CPP');
             $pseaf->setOrder(240);
             if ($pseaf->isValid()) {
                 $psea_id = $pseaf->Save();
                 $psealf->setEmployeeCPP($psea_id);
                 unset($psea_id);
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('EI');
             $pseaf->setOrder(250);
             if ($pseaf->isValid()) {
                 $psea_id = $pseaf->Save();
                 $psealf->setEmployeeEI($psea_id);
                 unset($psea_id);
             }
             //Employer Contributions
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(30);
             $pseaf->setName('CPP - Employer');
             $pseaf->setOrder(300);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(30);
             $pseaf->setName('EI - Employer');
             $pseaf->setOrder(310);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(30);
             $pseaf->setName('WCB - Employer');
             $pseaf->setOrder(320);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             Debug::text('Saving.... Vacation Accrual', __FILE__, __LINE__, __METHOD__, 10);
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(50);
             $pseaf->setName('Vacation Accrual');
             $pseaf->setOrder(400);
             if ($pseaf->isValid()) {
                 $vacation_accrual_id = $pseaf->Save();
                 Debug::text('Saving.... Earnings - Vacation Accrual Release', __FILE__, __LINE__, __METHOD__, 10);
                 $pseaf = new PayStubEntryAccountFactory();
                 $pseaf->setCompany($company_id);
                 $pseaf->setStatus(10);
                 $pseaf->setType(10);
                 $pseaf->setName('Vacation Accrual Release');
                 $pseaf->setOrder(180);
                 $pseaf->setAccrual($vacation_accrual_id);
                 if ($pseaf->isValid()) {
                     $pseaf->Save();
                 }
                 unset($vaction_accrual_id);
             }
             break;
         case 'us':
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('Federal Income Tax');
             $pseaf->setOrder(210);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('Advance EIC');
             $pseaf->setOrder(215);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('State Income Tax');
             $pseaf->setOrder(220);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('District Income Tax');
             $pseaf->setOrder(225);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('Federal Add. Income Tax');
             $pseaf->setOrder(230);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('State Add. Income Tax');
             $pseaf->setOrder(235);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('Social Security (FICA)');
             $pseaf->setOrder(240);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(30);
             $pseaf->setName('Social Security (FICA)');
             $pseaf->setOrder(340);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(30);
             $pseaf->setName('Fed. Unemployment Ins.');
             $pseaf->setOrder(342);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('State Unemployment Ins.');
             $pseaf->setOrder(240);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('Medicare');
             $pseaf->setOrder(245);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(30);
             $pseaf->setName('Medicare');
             $pseaf->setOrder(346);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(20);
             $pseaf->setName('State Disability Ins.');
             $pseaf->setOrder(250);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(30);
             $pseaf->setName('State Unemployment Ins.');
             $pseaf->setOrder(350);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(30);
             $pseaf->setName('State Employee Training');
             $pseaf->setOrder(352);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             break;
     }
     Debug::text('Province: ' . $province, __FILE__, __LINE__, __METHOD__, 10);
     switch (strtolower($province)) {
         case 'ny':
             $pseaf = new PayStubEntryAccountFactory();
             $pseaf->setCompany($company_id);
             $pseaf->setStatus(10);
             $pseaf->setType(30);
             $pseaf->setName('State Reemployment');
             $pseaf->setOrder(354);
             if ($pseaf->isValid()) {
                 $pseaf->Save();
             }
             break;
     }
     Debug::text('Saving.... Earnings - Regular Time', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(10);
     $pseaf->setName('Regular Time');
     $pseaf->setOrder(100);
     if ($pseaf->isValid()) {
         $psea_id = $pseaf->Save();
         $psealf->setRegularTime($psea_id);
         unset($psea_id);
     }
     Debug::text('Saving.... Earnings - Over Time 1', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(10);
     $pseaf->setName('Over Time 1');
     $pseaf->setOrder(150);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     Debug::text('Saving.... Earnings - Over Time 2', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(10);
     $pseaf->setName('Over Time 2');
     $pseaf->setOrder(151);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     Debug::text('Saving.... Earnings - Premium Time 1', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(10);
     $pseaf->setName('Premium 1');
     $pseaf->setOrder(170);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     Debug::text('Saving.... Earnings - Premium Time 2', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(10);
     $pseaf->setName('Premium 2');
     $pseaf->setOrder(171);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     Debug::text('Saving.... Earnings - Bonus', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(10);
     $pseaf->setName('Bonus');
     $pseaf->setOrder(185);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     Debug::text('Saving.... Earnings - Other', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(10);
     $pseaf->setName('Other');
     $pseaf->setOrder(189);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     Debug::text('Saving.... Union Dues', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(20);
     $pseaf->setName('Union Dues');
     $pseaf->setOrder(285);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     Debug::text('Saving.... Employee Benefits Plan', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(20);
     $pseaf->setName('Benefits Plan');
     $pseaf->setOrder(225);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     Debug::text('Saving.... Employer Benefits Plan', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(30);
     $pseaf->setName('Benefits Plan');
     $pseaf->setOrder(330);
     if ($pseaf->isValid()) {
         $pseaf->Save();
     }
     Debug::text('Saving.... Total Earnings', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(40);
     $pseaf->setName('Total Gross');
     $pseaf->setOrder(199);
     if ($pseaf->isValid()) {
         $psea_id = $pseaf->Save();
         $psealf->setTotalGross($psea_id);
         unset($psea_id);
     }
     Debug::text('Saving.... Total Deductions', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(40);
     $pseaf->setName('Total Deductions');
     $pseaf->setOrder(298);
     if ($pseaf->isValid()) {
         $psea_id = $pseaf->Save();
         $psealf->setTotalEmployeeDeduction($psea_id);
         unset($psea_id);
     }
     Debug::text('Saving.... Net Pay', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(40);
     $pseaf->setName('Net Pay');
     $pseaf->setOrder(299);
     if ($pseaf->isValid()) {
         $psea_id = $pseaf->Save();
         $psealf->setTotalNetPay($psea_id);
         unset($psea_id);
     }
     Debug::text('Saving.... Employer Total Cont', __FILE__, __LINE__, __METHOD__, 10);
     $pseaf = new PayStubEntryAccountFactory();
     $pseaf->setCompany($company_id);
     $pseaf->setStatus(10);
     $pseaf->setType(40);
     $pseaf->setName('Employer Total Contributions');
     $pseaf->setOrder(399);
     if ($pseaf->isValid()) {
         $psea_id = $pseaf->Save();
         $psealf->setTotalEmployerDeduction($psea_id);
         unset($psea_id);
     }
     if ($psealf->isValid() == TRUE) {
         Debug::text('Saving.... PSA Linking', __FILE__, __LINE__, __METHOD__, 10);
         $psealf->Save();
     } else {
         Debug::text('Saving.... PSA Linking FAILED!', __FILE__, __LINE__, __METHOD__, 10);
     }
     $pseaf->CommitTransaction();
     //$pseaf->FailTransaction();
     return TRUE;
 }
示例#2
0
 function createPayStubAccountLink($company_id)
 {
     $psealf = new PayStubEntryAccountLinkFactory();
     $psealf->setCompany($company_id);
     $psealf->setTotalGross(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 40, TTi18n::gettext('Total Gross')));
     $psealf->setTotalEmployeeDeduction(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 40, TTi18n::gettext('Total Deductions')));
     $psealf->setTotalEmployerDeduction(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 40, TTi18n::gettext('Employer Total Contributions')));
     $psealf->setTotalNetPay(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 40, TTi18n::gettext('Net Pay')));
     $psealf->setRegularTime(CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, TTi18n::gettext('Regular Time')));
     if ($psealf->isValid()) {
         $insert_id = $psealf->Save();
         Debug::Text('Pay Stub Account Link ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10);
         return $insert_id;
     }
     Debug::Text('Failed Creating Pay Stub Account Links!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
     Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
     $psealf->setId($data['id']);
     $psealf->setCompany($current_company->getId());
     $psealf->setTotalGross($data['total_gross']);
     $psealf->setTotalEmployeeDeduction($data['total_employee_deduction']);
     $psealf->setTotalEmployerDeduction($data['total_employer_deduction']);
     $psealf->setTotalNetPay($data['total_net_pay']);
     $psealf->setRegularTime($data['regular_time']);
     //$psealf->setMonthlyAdvance( $data['monthly_advance'] );
     //$psealf->setMonthlyAdvanceDeduction( $data['monthly_advance_deduction'] );
     if ($current_company->getCountry() == 'CA') {
         $psealf->setEmployeeCPP($data['employee_cpp']);
         $psealf->setEmployeeEI($data['employee_ei']);
     }
     if ($psealf->isValid()) {
         $psealf->Save();
         Redirect::Page(URLBuilder::getURL(array('data_saved' => TRUE), 'EditPayStubEntryAccountLink.php'));
         break;
     }
 default:
     BreadCrumb::setCrumb($title);
     $pseallf = new PayStubEntryAccountLinkListFactory();
     $pseallf->getByCompanyId($current_company->getId());
     if ($pseallf->getRecordCount() > 0) {
         $pseal_obj = $pseallf->getCurrent();
         $data = array('id' => $pseal_obj->getId(), 'total_gross' => $pseal_obj->getTotalGross(), 'total_employee_deduction' => $pseal_obj->getTotalEmployeeDeduction(), 'total_employer_deduction' => $pseal_obj->getTotalEmployerDeduction(), 'total_net_pay' => $pseal_obj->getTotalNetPay(), 'regular_time' => $pseal_obj->getRegularTime(), 'monthly_advance' => $pseal_obj->getMonthlyAdvance(), 'monthly_advance_deduction' => $pseal_obj->getMonthlyAdvanceDeduction(), 'employee_cpp' => $pseal_obj->getEmployeeCPP(), 'employee_ei' => $pseal_obj->getEmployeeEI(), 'created_date' => $pseal_obj->getCreatedDate(), 'created_by' => $pseal_obj->getCreatedBy(), 'updated_date' => $pseal_obj->getUpdatedDate(), 'updated_by' => $pseal_obj->getUpdatedBy(), 'deleted_date' => $pseal_obj->getDeletedDate(), 'deleted_by' => $pseal_obj->getDeletedBy());
     }
     $psealf_tmp = new PayStubEntryAccountListFactory();
     $data['earning_account_options'] = $psealf_tmp->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10));
     $data['employee_deduction_account_options'] = $psealf_tmp->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(20));
     $data['employer_deduction_account_options'] = $psealf_tmp->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(30));