function getData() { $psenlf = new PayStubEntryNameListFactory(); $pslf = new PayStubListFactory(); //$pslf->getByIdAndUserId($id, $current_user->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, array($sort_column => $sort_order) ); $pslf->getById($this->pay_stub_id); $pager = new Pager($pslf); foreach ($pslf as $pay_stub_obj) { //Get pay stub entries. $pself = new PayStubEntryListFactory(); $pself->getByPayStubId($pay_stub_obj->getId()); $prev_type = NULL; $description_subscript_counter = 1; foreach ($pself as $pay_stub_entry) { $description_subscript = NULL; $pay_stub_entry_name_obj = $psenlf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent(); if ($prev_type == 40 or $pay_stub_entry_name_obj->getType() != 40) { $type = $pay_stub_entry_name_obj->getType(); } if ($pay_stub_entry->getDescription() !== NULL and $pay_stub_entry->getDescription() !== FALSE) { $pay_stub_entry_descriptions[] = array('subscript' => $description_subscript_counter, 'description' => $pay_stub_entry->getDescription()); $description_subscript = $description_subscript_counter; $description_subscript_counter++; } $this->pay_stub_entries[$type][] = array('id' => $pay_stub_entry->getId(), 'pay_stub_entry_name_id' => $pay_stub_entry->getPayStubEntryNameId(), 'type' => $pay_stub_entry_name_obj->getType(), 'name' => $pay_stub_entry_name_obj->getName(), 'display_name' => $pay_stub_entry_name_obj->getDescription(), 'rate' => $pay_stub_entry->getRate(), 'units' => $pay_stub_entry->getUnits(), 'ytd_units' => $pay_stub_entry->getYTDUnits(), 'amount' => $pay_stub_entry->getAmount(), 'ytd_amount' => $pay_stub_entry->getYTDAmount(), 'description' => $pay_stub_entry->getDescription(), 'description_subscript' => $description_subscript, 'created_date' => $pay_stub_entry->getCreatedDate(), 'created_by' => $pay_stub_entry->getCreatedBy(), 'updated_date' => $pay_stub_entry->getUpdatedDate(), 'updated_by' => $pay_stub_entry->getUpdatedBy(), 'deleted_date' => $pay_stub_entry->getDeletedDate(), 'deleted_by' => $pay_stub_entry->getDeletedBy()); $prev_type = $pay_stub_entry_name_obj->getType(); } //'entries' => $pay_stub_entries, $this->pay_stub = array('id' => $pay_stub_obj->getId(), 'user_id' => $pay_stub_obj->getUser(), 'pay_period_id' => $pay_stub_obj->getPayPeriod(), 'advance' => $pay_stub_obj->getAdvance(), 'status' => $pay_stub_obj->getStatus(), 'created_date' => $pay_stub_obj->getCreatedDate(), 'created_by' => $pay_stub_obj->getCreatedBy(), 'updated_date' => $pay_stub_obj->getUpdatedDate(), 'updated_by' => $pay_stub_obj->getUpdatedBy(), 'deleted_date' => $pay_stub_obj->getDeletedDate(), 'deleted_by' => $pay_stub_obj->getDeletedBy()); //Get Pay Period information $pplf = new PayPeriodListFactory(); $pay_period_obj = $pplf->getById($pay_stub_obj->getPayPeriod())->getCurrent(); if ($pay_stub_obj->getAdvance() == TRUE) { $pp_start_date = $pay_period_obj->getStartDate(); $pp_end_date = $pay_period_obj->getAdvanceEndDate(); $pp_transaction_date = $pay_period_obj->getAdvanceTransactionDate(); } else { $pp_start_date = $pay_period_obj->getStartDate(); $pp_end_date = $pay_period_obj->getEndDate(); $pp_transaction_date = $pay_period_obj->getTransactionDate(); } $this->pay_period = array('start_date' => TTDate::getDate('DATE', $pp_start_date), 'end_date' => TTDate::getDate('DATE', $pp_end_date), 'transaction_date' => TTDate::getDate('DATE', $pp_transaction_date)); //Get User information $ulf = new UserListFactory(); $this->user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent(); //Get company information $clf = new CompanyListFactory(); $this->company_obj = $clf->getById($this->user_obj->getCompany())->getCurrent(); } }
} elseif ($date_type == 'transaction' and TTDate::getBeginDayEpoch($pp_obj->getTransactionDate()) == $pay_period_date) { $found_pay_period = TRUE; } elseif ($date_type == 'last') { //Last pay period $found_pay_period = TRUE; } if ($found_pay_period == TRUE) { echo "Found Pay Period: Start: " . TTDate::getDate('DATE', $pp_obj->getStartDate()) . ' End: ' . TTDate::getDate('DATE', $pp_obj->getEndDate()) . ' Transaction: ' . TTDate::getDate('DATE', $pp_obj->getTransactionDate()) . "\n"; $pay_period_id = $pp_obj->getId(); break; } $x++; } } if (isset($pay_period_id)) { $pslf = new PayStubListFactory(); $pslf->getByCompanyIdAndPayPeriodId($company_id, $pay_period_id); if ($pslf->getRecordCount() > 0) { echo "Export Directory: " . $output_directory . "\n"; $i = 1; foreach ($pslf as $tmp_ps_obj) { $pslf_b = new PayStubListFactory(); $pslf_b->getById($tmp_ps_obj->getId()); if ($pslf_b->getRecordCount() > 0) { $ps_obj = $pslf_b->getCurrent(); if (is_object($ps_obj->getUserObject())) { $file_name = $output_directory . DIRECTORY_SEPARATOR . 'pay_stub_' . $ps_obj->getUserObject()->getUserName() . '_' . date('Ymd', $ps_obj->getStartDate()) . '.pdf'; $output = $pslf->getPayStub($pslf_b, TRUE); if ($output !== FALSE) { echo " {$i}. Exporting Pay Stub for: " . $ps_obj->getUserObject()->getFullName() . "\t\tFile: " . $file_name . "\n"; file_put_contents($file_name, $output);
function reCalculate() { //Re-generate final pay stub //get current pay period based off their last day of work $pplf = new PayPeriodListFactory(); $pay_period_id = $pplf->getByUserIdAndEndDate($this->getUser(), $this->getLastDate())->getCurrent()->getId(); Debug::Text('Pay Period ID: ' . $pay_period_id, __FILE__, __LINE__, __METHOD__, 10); if (is_numeric($pay_period_id) == FALSE) { UserGenericStatusFactory::queueGenericStatus($this->getUserObject()->getFullName(TRUE) . ' - ' . TTi18n::gettext('Pay Stub'), 10, TTi18n::gettext('Pay Period is invalid!'), NULL); return FALSE; } if ($this->getEnableGeneratePayStub() == TRUE) { //Find out if a pay stub is already generated for the pay period we are currently in. //If it is, delete it so we can start from fresh $pslf = new PayStubListFactory(); $pslf->getByUserIdAndPayPeriodId($this->getUser(), $pay_period_id); foreach ($pslf as $pay_stub) { Debug::Text('Found Pay Stub ID: ' . $pay_stub->getId(), __FILE__, __LINE__, __METHOD__, 10); //Do not delete PAID pay stubs! if ($pay_stub->getStatus() == 10) { Debug::Text('Last Pay Stub Exists: ' . $pay_stub->getId(), __FILE__, __LINE__, __METHOD__, 10); $pay_stub->setDeleted(TRUE); $pay_stub->Save(); } } //FIXME: Make sure user isn't already in-active! Otherwise pay stub won't generate. //Check if pay stub is already generated as well, if it is, and marked paid, then //we can't re-generate it, we need to skip this step. Debug::Text('Calculating Pay Stub...', __FILE__, __LINE__, __METHOD__, 10); $cps = new CalculatePayStub(); $cps->setUser($this->getUser()); $cps->setPayPeriod($pay_period_id); $cps->calculate(); Debug::Text('Done Calculating Pay Stub', __FILE__, __LINE__, __METHOD__, 10); } else { UserGenericStatusFactory::queueGenericStatus($this->getUserObject()->getFullName(TRUE), 20, TTi18n::gettext('Not generating final pay stub!'), NULL); } //FIXME: Alert the user if they don't have enough information in TimeTrex to get accurate values. //Get insurable hours, earnings, and vacation pay now that the final pay stub is generated $ugdlf = new UserGenericDataListFactory(); $ugdlf->getByCompanyIdAndScriptAndDefault($this->getUserObject()->getCompany(), $this->getTable()); if ($ugdlf->getRecordCount() > 0) { Debug::Text('Found Company Form Setup!', __FILE__, __LINE__, __METHOD__, 10); $ugd_obj = $ugdlf->getCurrent(); $setup_data = $ugd_obj->getData(); } unset($ugd_obj); if (isset($setup_data)) { //var_dump($setup_data); if (isset($setup_data['insurable_earnings_psea_ids'])) { $insurable_earnings_psea_ids = $setup_data['insurable_earnings_psea_ids']; } else { //Fall back to Total Gross. $insurable_earnings_psea_ids = $this->getPayStubEntryAccountLinkObject()->getTotalGross(); } } //Find out the date of how far back we have to go to get insurable values. //Insurable Hours $insurable_hours_start_date = $this->getInsurablePayPeriodStartDate($this->getInsurableHoursReportPayPeriods()); //Insurable hours dont include stats!Just get total signed in hours. //If someone has just a negative bank time balance, those are NOT insurable. $udtlf = new UserDateTotalListFactory(); $worked_total_time = $udtlf->getWorkedTimeSumByUserIDAndStartDateAndEndDate($this->getUser(), $insurable_hours_start_date, $this->getLastDate()); Debug::text('Worked Total Time: ' . $worked_total_time, __FILE__, __LINE__, __METHOD__, 10); $total_hours = Misc::MoneyFormat(TTDate::getHours($worked_total_time), FALSE); Debug::Text('Total Insurable Hours: ' . $total_hours, __FILE__, __LINE__, __METHOD__, 10); $insurable_earnings_start_date = $this->getInsurablePayPeriodStartDate($this->getInsurableEarningsReportPayPeriods()); $pself = new PayStubEntryListFactory(); $total_earnings = $this->getTotalInsurableEarnings(); //$total_earnings = $pself->getAmountSumByUserIdAndEntryNameIdAndStartDateAndEndDate( $this->getUser(), $insurable_earnings_psea_ids, $insurable_earnings_start_date, $this->getLastDate(), 0 ); //$total_earnings = $total_earnings['amount']; //Note, this includes the current pay stub we just generated Debug::Text('Total Insurable Earnings: ' . $total_earnings, __FILE__, __LINE__, __METHOD__, 10); UserGenericStatusFactory::queueGenericStatus($this->getUserObject()->getFullName(TRUE) . ' - ' . TTi18n::gettext('Record of Employment'), 30, TTi18n::gettext('Insurable Hours:') . ' ' . $total_hours . ' ' . TTi18n::gettext('Insurable Earnings:') . ' ' . $total_earnings, NULL); //ReSave these if ($this->getId() != '') { $rlf = new ROEListFactory(); $rlf->getById($this->getId()); if ($rlf->getRecordCount() > 0) { $roe_obj = $rlf->getCurrent(); $roe_obj->setInsurableHours($total_hours); $roe_obj->setInsurableEarnings($total_earnings); if ($roe_obj->isValid()) { $roe_obj->Save(); } } } return TRUE; }
//Redirect } $smarty->assign('title', TTi18n::gettext($title = 'Employee Pay Stub')); // See index.php BreadCrumb::setCrumb($title); /* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'page', 'sort_column', 'sort_order', 'hide_employer_rows', 'id', 'ids'))); switch ($action) { default: if (isset($id) and !isset($ids)) { $ids = array($id); } if (count($ids) > 0) { $pslf = new PayStubListFactory(); if ($permission->Check('pay_stub', 'view')) { $pslf->getByCompanyIdAndId($current_company->getId(), $ids); } else { $pslf->getByUserIdAndId($current_user->getId(), $ids); } //foreach ($ids as $id) { $i = 0; foreach ($pslf as $pay_stub_obj) { $psealf = new PayStubEntryAccountListFactory(); //Get pay stub entries. $pself = new PayStubEntryListFactory(); $pself->getByPayStubId($pay_stub_obj->getId()); Debug::text('Pay Stub Entries: ' . $pself->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); $prev_type = NULL; $description_subscript_counter = 1;
URLBuilder::setURL($_SERVER['SCRIPT_NAME'], array('pay_period_id' => $pay_period_id, 'sort_column' => $sort_column, 'sort_order' => $sort_order, 'page' => $page)); switch ($action) { case 'Submit': default: $pplf = new PayPeriodListFactory(); $slf = new ShiftListFactory(); if (!isset($pay_period_id)) { Debug::text(' Pay Period ID NOT SET: ' . $pay_period_id, __FILE__, __LINE__, __METHOD__, 10); $pay_period_id = $pplf->getByCompanyId($current_company->getId(), 1, 2, NULL, array('start_date' => 'desc'))->getCurrent()->getId(); } Debug::text(' Pay Period ID: ' . $pay_period_id, __FILE__, __LINE__, __METHOD__, 10); $psenlf = new PayStubEntryNameListFactory(); $ulf = new UserListFactory(); $blf = new BranchListFactory(); //Get all pay stubs for this pay period $pslf = new PayStubListFactory(); $pslf->getByPayPeriodId($pay_period_id, NULL, array('advance' => '= \'f\'')); $pager = new Pager($pslf); $entry_name_ids = array(10, 22); foreach ($pslf as $pay_stub_obj) { Debug::text(' Pay Stub ID: ' . $pay_stub_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); $pself = new PayStubEntryListFactory(); //Order is very important here. We want the "last" entries to go last, as they should //have the most up to date YTD values. $pself->getByPayStubId($pay_stub_obj->getId()); $entries = NULL; foreach ($pself as $pay_stub_entry_obj) { $pay_stub_entry_name_obj = $psenlf->getById($pay_stub_entry_obj->getPayStubEntryNameId())->getCurrent(); if (in_array($pay_stub_entry_obj->getPayStubEntryNameId(), $entry_name_ids)) { Debug::text(' Found valid entry name ID: ' . $pay_stub_entry_name_obj->getName() . ' Amount: ' . $pay_stub_entry_obj->getAmount(), __FILE__, __LINE__, __METHOD__, 10); if (isset($show_ytd) and $show_ytd == 1) {
//Redirect } $smarty->assign('title', TTi18n::gettext($title = 'Employee Pay Stub')); // See index.php BreadCrumb::setCrumb($title); /* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'page', 'sort_column', 'sort_order', 'hide_employer_rows', 'id', 'ids'))); switch ($action) { default: if (isset($id) and !isset($ids)) { $ids = array($id); } if (count($ids) > 0) { $pslf = new PayStubListFactory(); if ($permission->Check('pay_stub', 'view')) { $pslf->getByCompanyIdAndId($current_company->getId(), $ids); } else { $pslf->getByUserIdAndId($current_user->getId(), $ids); $hide_employer_rows = TRUE; } $output = $pslf->getPayStub($pslf, (bool) $hide_employer_rows); if (Debug::getVerbosity() < 11) { //$output = $pdf->Output('','S'); Misc::FileDownloadHeader('pay_stub.pdf', 'application/pdf', strlen($output)); echo $output; } } break; }
function testEditMultiplePayStub() { //Test all parts of multiple pay stubs that span a year boundary. //Start 6 pay periods from the last one. Should be beginning/end of December, //Its the TRANSACTION date that counts $start_pay_period_id = count($this->pay_period_objs) - 6; Debug::text('Starting Pay Period: ' . TTDate::getDate('DATE+TIME', $this->pay_period_objs[$start_pay_period_id]->getStartDate()), __FILE__, __LINE__, __METHOD__, 10); // // First Pay Stub // //Test UnUsed YTD entries... $pay_stub = new PayStubFactory(); $pay_stub->setUser($this->user_id); $pay_stub->setPayPeriod($this->pay_period_objs[$start_pay_period_id]->getId()); $pay_stub->setStatus('NEW'); $pay_stub->setDefaultDates(); $pay_stub->loadPreviousPayStub(); $pse_accounts = array('regular_time' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 10, 'Regular Time'), 'over_time_1' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 10, 'Over Time 1'), 'vacation_accrual_release' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 10, 'Vacation Accrual Release'), 'federal_income_tax' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'Federal Income Tax'), 'state_income_tax' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'State Income Tax'), 'medicare' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 30, 'Medicare'), 'state_unemployment' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 30, 'State Unemployment Ins.'), 'vacation_accrual' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 50, 'Vacation Accrual')); $pay_stub->addEntry($pse_accounts['regular_time'], 100.01); $pay_stub->addEntry($pse_accounts['regular_time'], 10.01); $pay_stub->addEntry($pse_accounts['over_time_1'], 100.02); $pay_stub->addEntry($pse_accounts['vacation_accrual_release'], 1.0); $pay_stub->addEntry($pse_accounts['federal_income_tax'], 50.01); $pay_stub->addEntry($pse_accounts['state_income_tax'], 25.04); $pay_stub->addEntry($pse_accounts['medicare'], 10.01); $pay_stub->addEntry($pse_accounts['state_unemployment'], 15.05); $pay_stub->addEntry($pse_accounts['vacation_accrual'], 5.01); $pay_stub->setEnableProcessEntries(TRUE); $pay_stub->processEntries(); if ($pay_stub->isValid() == TRUE) { Debug::text('Pay Stub is valid, final save.', __FILE__, __LINE__, __METHOD__, 10); $first_pay_stub_id = $pay_stub_id = $pay_stub->Save(); } $pse_arr = $this->getPayStubEntryArray($pay_stub_id); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][0]['amount'], '100.01'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][0]['ytd_amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][1]['amount'], '10.01'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][1]['ytd_amount'], '110.02'); $this->assertEquals($pse_arr[$pse_accounts['over_time_1']][0]['amount'], '100.02'); $this->assertEquals($pse_arr[$pse_accounts['over_time_1']][0]['ytd_amount'], '100.02'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual_release']][0]['amount'], '1.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual_release']][0]['ytd_amount'], '1.00'); $this->assertEquals($pse_arr[$pse_accounts['federal_income_tax']][0]['amount'], '50.01'); $this->assertEquals($pse_arr[$pse_accounts['federal_income_tax']][0]['ytd_amount'], '50.01'); $this->assertEquals($pse_arr[$pse_accounts['state_income_tax']][0]['amount'], '25.04'); $this->assertEquals($pse_arr[$pse_accounts['state_income_tax']][0]['ytd_amount'], '25.04'); $this->assertEquals($pse_arr[$pse_accounts['medicare']][0]['amount'], '10.01'); $this->assertEquals($pse_arr[$pse_accounts['medicare']][0]['ytd_amount'], '10.01'); $this->assertEquals($pse_arr[$pse_accounts['state_unemployment']][0]['amount'], '15.05'); $this->assertEquals($pse_arr[$pse_accounts['state_unemployment']][0]['ytd_amount'], '15.05'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][0]['amount'], '-1.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][0]['ytd_amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][1]['amount'], '5.01'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][1]['ytd_amount'], '4.01'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_gross']][0]['amount'], '211.04'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_gross']][0]['ytd_amount'], '211.04'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_deductions']][0]['amount'], '75.05'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_deductions']][0]['ytd_amount'], '75.05'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['net_pay']][0]['amount'], '135.99'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['net_pay']][0]['ytd_amount'], '135.99'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['employer_contribution']][0]['amount'], '25.06'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['employer_contribution']][0]['ytd_amount'], '25.06'); unset($pse_arr, $pay_stub_id, $pay_stub); // // // //Second Pay Stub // // // $pay_stub = new PayStubFactory(); $pay_stub->setUser($this->user_id); $pay_stub->setPayPeriod($this->pay_period_objs[$start_pay_period_id + 1]->getId()); $pay_stub->setStatus('NEW'); $pay_stub->setDefaultDates(); $pay_stub->loadPreviousPayStub(); $pse_accounts = array('regular_time' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 10, 'Regular Time'), 'over_time_1' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 10, 'Over Time 1'), 'vacation_accrual_release' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 10, 'Vacation Accrual Release'), 'federal_income_tax' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'Federal Income Tax'), 'state_income_tax' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'State Income Tax'), 'medicare' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 30, 'Medicare'), 'state_unemployment' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 30, 'State Unemployment Ins.'), 'vacation_accrual' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 50, 'Vacation Accrual')); $pay_stub->addEntry($pse_accounts['regular_time'], 198.01); $pay_stub->addEntry($pse_accounts['regular_time'], 12.01); //$pay_stub->addEntry( $pse_accounts['over_time_1'], 111.02 ); $pay_stub->addEntry($pse_accounts['vacation_accrual_release'], 1.03); $pay_stub->addEntry($pse_accounts['federal_income_tax'], 53.01); $pay_stub->addEntry($pse_accounts['state_income_tax'], 27.04); $pay_stub->addEntry($pse_accounts['medicare'], 13.04); $pay_stub->addEntry($pse_accounts['state_unemployment'], 16.09); $pay_stub->addEntry($pse_accounts['vacation_accrual'], 6.01); $pay_stub->setEnableProcessEntries(TRUE); $pay_stub->processEntries(); if ($pay_stub->isValid() == TRUE) { Debug::text('Pay Stub is valid, final save.', __FILE__, __LINE__, __METHOD__, 10); $second_pay_stub_id = $pay_stub_id = $pay_stub->Save(); } $pse_arr = $this->getPayStubEntryArray($pay_stub_id); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][0]['amount'], '198.01'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][0]['ytd_amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][1]['amount'], '12.01'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][1]['ytd_amount'], '320.04'); $this->assertEquals($pse_arr[$pse_accounts['over_time_1']][0]['amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['over_time_1']][0]['ytd_amount'], '100.02'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual_release']][0]['amount'], '1.03'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual_release']][0]['ytd_amount'], '2.03'); $this->assertEquals($pse_arr[$pse_accounts['federal_income_tax']][0]['amount'], '53.01'); $this->assertEquals($pse_arr[$pse_accounts['federal_income_tax']][0]['ytd_amount'], '103.02'); $this->assertEquals($pse_arr[$pse_accounts['state_income_tax']][0]['amount'], '27.04'); $this->assertEquals($pse_arr[$pse_accounts['state_income_tax']][0]['ytd_amount'], '52.08'); $this->assertEquals($pse_arr[$pse_accounts['medicare']][0]['amount'], '13.04'); $this->assertEquals($pse_arr[$pse_accounts['medicare']][0]['ytd_amount'], '23.05'); $this->assertEquals($pse_arr[$pse_accounts['state_unemployment']][0]['amount'], '16.09'); $this->assertEquals($pse_arr[$pse_accounts['state_unemployment']][0]['ytd_amount'], '31.14'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][0]['amount'], '-1.03'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][0]['ytd_amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][1]['amount'], '6.01'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][1]['ytd_amount'], '8.99'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_gross']][0]['amount'], '211.05'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_gross']][0]['ytd_amount'], '422.09'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_deductions']][0]['amount'], '80.05'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_deductions']][0]['ytd_amount'], '155.10'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['net_pay']][0]['amount'], '131.00'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['net_pay']][0]['ytd_amount'], '266.99'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['employer_contribution']][0]['amount'], '29.13'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['employer_contribution']][0]['ytd_amount'], '54.19'); unset($pse_arr, $pay_stub_id, $pay_stub); // // Third Pay Stub // //Test UnUsed YTD entries... $pay_stub = new PayStubFactory(); $pay_stub->setUser($this->user_id); $pay_stub->setPayPeriod($this->pay_period_objs[$start_pay_period_id + 2]->getId()); $pay_stub->setStatus('NEW'); $pay_stub->setDefaultDates(); $pay_stub->loadPreviousPayStub(); $pse_accounts = array('regular_time' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 10, 'Regular Time'), 'over_time_1' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 10, 'Over Time 1'), 'vacation_accrual_release' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 10, 'Vacation Accrual Release'), 'federal_income_tax' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'Federal Income Tax'), 'state_income_tax' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 20, 'State Income Tax'), 'medicare' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 30, 'Medicare'), 'state_unemployment' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 30, 'State Unemployment Ins.'), 'vacation_accrual' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($this->company_id, 50, 'Vacation Accrual')); $pay_stub->addEntry($pse_accounts['regular_time'], 100.01); $pay_stub->addEntry($pse_accounts['regular_time'], 10.01); $pay_stub->addEntry($pse_accounts['over_time_1'], 100.02); $pay_stub->addEntry($pse_accounts['vacation_accrual_release'], 1.0); $pay_stub->addEntry($pse_accounts['federal_income_tax'], 50.01); $pay_stub->addEntry($pse_accounts['state_income_tax'], 25.04); $pay_stub->addEntry($pse_accounts['medicare'], 10.01); $pay_stub->addEntry($pse_accounts['state_unemployment'], 15.05); $pay_stub->addEntry($pse_accounts['vacation_accrual'], 5.01); $pay_stub->setEnableProcessEntries(TRUE); $pay_stub->processEntries(); if ($pay_stub->isValid() == TRUE) { $third_pay_stub_id = $pay_stub_id = $pay_stub->Save(); Debug::text('Pay Stub is valid, final save, ID: ' . $pay_stub_id, __FILE__, __LINE__, __METHOD__, 10); } $pse_arr = $this->getPayStubEntryArray($pay_stub_id); // // IN NEW YEAR, YTD amounts are zero'd! // $this->assertEquals($pse_arr[$pse_accounts['regular_time']][0]['amount'], '100.01'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][0]['ytd_amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][1]['amount'], '10.01'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][1]['ytd_amount'], '110.02'); $this->assertEquals($pse_arr[$pse_accounts['over_time_1']][0]['amount'], '100.02'); $this->assertEquals($pse_arr[$pse_accounts['over_time_1']][0]['ytd_amount'], '100.02'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual_release']][0]['amount'], '1.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual_release']][0]['ytd_amount'], '1.00'); $this->assertEquals($pse_arr[$pse_accounts['federal_income_tax']][0]['amount'], '50.01'); $this->assertEquals($pse_arr[$pse_accounts['federal_income_tax']][0]['ytd_amount'], '50.01'); $this->assertEquals($pse_arr[$pse_accounts['state_income_tax']][0]['amount'], '25.04'); $this->assertEquals($pse_arr[$pse_accounts['state_income_tax']][0]['ytd_amount'], '25.04'); $this->assertEquals($pse_arr[$pse_accounts['medicare']][0]['amount'], '10.01'); $this->assertEquals($pse_arr[$pse_accounts['medicare']][0]['ytd_amount'], '10.01'); $this->assertEquals($pse_arr[$pse_accounts['state_unemployment']][0]['amount'], '15.05'); $this->assertEquals($pse_arr[$pse_accounts['state_unemployment']][0]['ytd_amount'], '15.05'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][0]['amount'], '-1.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][0]['ytd_amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][1]['amount'], '5.01'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][1]['ytd_amount'], '13.00'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_gross']][0]['amount'], '211.04'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_gross']][0]['ytd_amount'], '211.04'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_deductions']][0]['amount'], '75.05'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_deductions']][0]['ytd_amount'], '75.05'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['net_pay']][0]['amount'], '135.99'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['net_pay']][0]['ytd_amount'], '135.99'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['employer_contribution']][0]['amount'], '25.06'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['employer_contribution']][0]['ytd_amount'], '25.06'); unset($pse_arr, $pay_stub_id, $pay_stub); // //Now edit the first pay stub. // $pslf = new PayStubListFactory(); $pay_stub = $pslf->getByID($first_pay_stub_id)->getCurrent(); $pay_stub->loadPreviousPayStub(); $pay_stub->deleteEntries(TRUE); $pay_stub->setEnableLinkedAccruals(FALSE); $pay_stub->addEntry($pse_accounts['regular_time'], 105.01); $pay_stub->addEntry($pse_accounts['regular_time'], 10.01); $pay_stub->addEntry($pse_accounts['over_time_1'], 100.02); $pay_stub->addEntry($pse_accounts['vacation_accrual_release'], 1.0); $pay_stub->addEntry($pse_accounts['federal_income_tax'], 50.01); $pay_stub->addEntry($pse_accounts['state_income_tax'], 25.04); $pay_stub->addEntry($pse_accounts['medicare'], 10.01); $pay_stub->addEntry($pse_accounts['state_unemployment'], 15.05); $pay_stub->addEntry($pse_accounts['vacation_accrual'], -1.0); $pay_stub->addEntry($pse_accounts['vacation_accrual'], 5.01); $pay_stub->setEnableProcessEntries(TRUE); $pay_stub->processEntries(); if ($pay_stub->isValid() == TRUE) { $pay_stub->Save(); //Recalculate all pay stubs after this one. $pslf = new PayStubListFactory(); $pslf->getById($first_pay_stub_id); if ($pslf->getRecordCount() > 0) { $ps_obj = $pslf->getCurrent(); $ps_obj->reCalculateYTD(); } unset($ps_obj); //Debug::text('Pay Stub is valid, final save, ID: '. $pay_stub_id, __FILE__, __LINE__, __METHOD__,10); } $pse_arr = $this->getPayStubEntryArray($first_pay_stub_id); //Debug::Arr($pse_arr, 'Pay Stub Entry Arr: ', __FILE__, __LINE__, __METHOD__,10); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][0]['amount'], '105.01'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][0]['ytd_amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][1]['amount'], '10.01'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][1]['ytd_amount'], '115.02'); $this->assertEquals($pse_arr[$pse_accounts['over_time_1']][0]['amount'], '100.02'); $this->assertEquals($pse_arr[$pse_accounts['over_time_1']][0]['ytd_amount'], '100.02'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual_release']][0]['amount'], '1.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual_release']][0]['ytd_amount'], '1.00'); $this->assertEquals($pse_arr[$pse_accounts['federal_income_tax']][0]['amount'], '50.01'); $this->assertEquals($pse_arr[$pse_accounts['federal_income_tax']][0]['ytd_amount'], '50.01'); $this->assertEquals($pse_arr[$pse_accounts['state_income_tax']][0]['amount'], '25.04'); $this->assertEquals($pse_arr[$pse_accounts['state_income_tax']][0]['ytd_amount'], '25.04'); $this->assertEquals($pse_arr[$pse_accounts['medicare']][0]['amount'], '10.01'); $this->assertEquals($pse_arr[$pse_accounts['medicare']][0]['ytd_amount'], '10.01'); $this->assertEquals($pse_arr[$pse_accounts['state_unemployment']][0]['amount'], '15.05'); $this->assertEquals($pse_arr[$pse_accounts['state_unemployment']][0]['ytd_amount'], '15.05'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][0]['amount'], '-1.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][0]['ytd_amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][1]['amount'], '5.01'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][1]['ytd_amount'], '4.01'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_gross']][0]['amount'], '216.04'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_gross']][0]['ytd_amount'], '216.04'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_deductions']][0]['amount'], '75.05'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_deductions']][0]['ytd_amount'], '75.05'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['net_pay']][0]['amount'], '140.99'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['net_pay']][0]['ytd_amount'], '140.99'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['employer_contribution']][0]['amount'], '25.06'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['employer_contribution']][0]['ytd_amount'], '25.06'); unset($pse_arr, $pay_stub_id, $pay_stub); // // Confirm YTD values in second pay stub are correct // Debug::Text('First Pay Stub ID: ' . $first_pay_stub_id . ' Second Pay Stub ID: ' . $second_pay_stub_id, __FILE__, __LINE__, __METHOD__, 10); $pse_arr = $this->getPayStubEntryArray($second_pay_stub_id); //Debug::Arr($pse_arr, 'Second Pay Stub Entry Arr: ', __FILE__, __LINE__, __METHOD__,10); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][0]['amount'], '198.01'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][0]['ytd_amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][1]['amount'], '12.01'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][1]['ytd_amount'], '325.04'); $this->assertEquals($pse_arr[$pse_accounts['over_time_1']][0]['amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['over_time_1']][0]['ytd_amount'], '100.02'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual_release']][0]['amount'], '1.03'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual_release']][0]['ytd_amount'], '2.03'); $this->assertEquals($pse_arr[$pse_accounts['federal_income_tax']][0]['amount'], '53.01'); $this->assertEquals($pse_arr[$pse_accounts['federal_income_tax']][0]['ytd_amount'], '103.02'); $this->assertEquals($pse_arr[$pse_accounts['state_income_tax']][0]['amount'], '27.04'); $this->assertEquals($pse_arr[$pse_accounts['state_income_tax']][0]['ytd_amount'], '52.08'); $this->assertEquals($pse_arr[$pse_accounts['medicare']][0]['amount'], '13.04'); $this->assertEquals($pse_arr[$pse_accounts['medicare']][0]['ytd_amount'], '23.05'); $this->assertEquals($pse_arr[$pse_accounts['state_unemployment']][0]['amount'], '16.09'); $this->assertEquals($pse_arr[$pse_accounts['state_unemployment']][0]['ytd_amount'], '31.14'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][0]['amount'], '-1.03'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][0]['ytd_amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][1]['amount'], '6.01'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][1]['ytd_amount'], '8.99'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_gross']][0]['amount'], '211.05'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_gross']][0]['ytd_amount'], '427.09'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_deductions']][0]['amount'], '80.05'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_deductions']][0]['ytd_amount'], '155.10'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['net_pay']][0]['amount'], '131.00'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['net_pay']][0]['ytd_amount'], '271.99'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['employer_contribution']][0]['amount'], '29.13'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['employer_contribution']][0]['ytd_amount'], '54.19'); unset($pse_arr, $pay_stub_id, $pay_stub); // // Confirm YTD values in third pay stub are correct // $pse_arr = $this->getPayStubEntryArray($third_pay_stub_id); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][0]['amount'], '100.01'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][0]['ytd_amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][1]['amount'], '10.01'); $this->assertEquals($pse_arr[$pse_accounts['regular_time']][1]['ytd_amount'], '110.02'); $this->assertEquals($pse_arr[$pse_accounts['over_time_1']][0]['amount'], '100.02'); $this->assertEquals($pse_arr[$pse_accounts['over_time_1']][0]['ytd_amount'], '100.02'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual_release']][0]['amount'], '1.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual_release']][0]['ytd_amount'], '1.00'); $this->assertEquals($pse_arr[$pse_accounts['federal_income_tax']][0]['amount'], '50.01'); $this->assertEquals($pse_arr[$pse_accounts['federal_income_tax']][0]['ytd_amount'], '50.01'); $this->assertEquals($pse_arr[$pse_accounts['state_income_tax']][0]['amount'], '25.04'); $this->assertEquals($pse_arr[$pse_accounts['state_income_tax']][0]['ytd_amount'], '25.04'); $this->assertEquals($pse_arr[$pse_accounts['medicare']][0]['amount'], '10.01'); $this->assertEquals($pse_arr[$pse_accounts['medicare']][0]['ytd_amount'], '10.01'); $this->assertEquals($pse_arr[$pse_accounts['state_unemployment']][0]['amount'], '15.05'); $this->assertEquals($pse_arr[$pse_accounts['state_unemployment']][0]['ytd_amount'], '15.05'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][0]['amount'], '-1.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][0]['ytd_amount'], '0.00'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][1]['amount'], '5.01'); $this->assertEquals($pse_arr[$pse_accounts['vacation_accrual']][1]['ytd_amount'], '13.00'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_gross']][0]['amount'], '211.04'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_gross']][0]['ytd_amount'], '211.04'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_deductions']][0]['amount'], '75.05'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['total_deductions']][0]['ytd_amount'], '75.05'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['net_pay']][0]['amount'], '135.99'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['net_pay']][0]['ytd_amount'], '135.99'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['employer_contribution']][0]['amount'], '25.06'); $this->assertEquals($pse_arr[$this->pay_stub_account_link_arr['employer_contribution']][0]['ytd_amount'], '25.06'); unset($pse_arr, $pay_stub_id, $pay_stub); return TRUE; }
function setPayStub($id) { $id = trim($id); $pslf = new PayStubListFactory(); if ($this->Validator->isResultSetWithRows('pay_stub', $pslf->getByID($id), TTi18n::gettext('Invalid Pay Stub'))) { $this->data['pay_stub_id'] = $id; return TRUE; } return FALSE; }
//as we can only determine hierarchies based on subordinates now. $pptsvf->setStatus(30); //Pending Auth $pptsvf->setAuthorized(FALSE); if ($pptsvf->isValid()) { $pptsvf->Save(); } Redirect::Page(URLBuilder::getURL(NULL, '../timesheet/ViewUserTimeSheet.php')); break; case 'recalculate pay stub': //Debug::setVerbosity(11); //Find out if a pay stub is already generated for the pay period we are currently in. //If it is, delete it so we can start from fresh $pplf = new PayPeriodListFactory(); $pplf->getByIdAndCompanyId($pay_period_id, $current_company->getId()); $pslf = new PayStubListFactory(); $pslf->getByUserIdAndPayPeriodId($filter_data['user_id'], $pay_period_id); foreach ($pslf as $pay_stub) { Debug::Text('Found Pay Stub ID: ' . $pay_stub->getId(), __FILE__, __LINE__, __METHOD__, 10); //Do not delete PAID pay stubs! if ($pay_stub->getStatus() <= 25 and $pay_stub->getTainted() === FALSE and $pay_stub->getEndDate() == $pay_period_obj->getEndDate()) { Debug::Text('Last Pay Stub Exists: ' . $pay_stub->getId(), __FILE__, __LINE__, __METHOD__, 10); $pay_stub->setDeleted(TRUE); $pay_stub->Save(); } else { Debug::Text('aNot Deleting Pay Stub: ' . $pay_stub->getId(), __FILE__, __LINE__, __METHOD__, 10); } } TTLog::addEntry($filter_data['user_id'], 'Notice', TTi18n::gettext('Calculating Employee Pay Stub for Pay Period:') . ' ' . $pay_period_id, $current_user->getID(), 'pay_stub'); //FIXME: Make sure user isn't already in-active! Otherwise pay stub won't generate. Debug::Text('Calculating Pay Stub...', __FILE__, __LINE__, __METHOD__, 10);
if ($psf->Save()) { //$psf->FailTransaction(); $psf->CommitTransaction(); //Redirect::Page( URLBuilder::getURL( array('action' => 'recalculate_paystub_ytd', 'pay_stub_ids' => array($id), 'next_page' => urlencode( URLBuilder::getURL( array('filter_pay_period_id' => $filter_pay_period_id ), '../pay_stub/PayStubList.php') ) ), '../progress_bar/ProgressBarControl.php') ); Redirect::Page(URLBuilder::getURL(array('filter_pay_period_id' => $filter_pay_period_id), '../pay_stub/PayStubList.php')); break; } else { $psf->FailTransaction(); } } } default: Debug::Text('Action: ' . $action, __FILE__, __LINE__, __METHOD__, 10); if ($id != '' and $action != 'submit') { $psealf = new PayStubEntryAccountListFactory(); $pslf = new PayStubListFactory(); $pslf->getByCompanyIdAndId($current_company->getId(), $id); if ($pslf->getRecordCount() > 0) { foreach ($pslf as $ps_obj) { //Get pay stub entries. $pself = new PayStubEntryListFactory(); $pself->getByPayStubId($ps_obj->getId()); $prev_type = NULL; $description_subscript_counter = 1; $pay_stub_entries = NULL; $pay_stub_entry_descriptions = NULL; foreach ($pself as $pay_stub_entry) { $description_subscript = NULL; //$pay_stub_entry_name_obj = $psenlf->getById( $pay_stub_entry->getPayStubEntryNameId() ) ->getCurrent(); $pay_stub_entry_account_obj = $psealf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent(); if ($prev_type == 40 or $pay_stub_entry_account_obj->getType() != 40) {
function Validate() { if ($this->getDeleted() == TRUE) { //CHeck to make sure currency isnt in-use by paystubs/employees/wages, if so, don't delete. $invalid = FALSE; $pslf = new PayStubListFactory(); $pslf->getByCurrencyId($this->getId()); if ($pslf->getRecordCount() > 0) { $invalid = TRUE; } if ($invalid == FALSE) { $ulf = new UserListFactory(); $ulf->getByCurrencyId($this->getId()); if ($ulf->getRecordCount() > 0) { $invalid = TRUE; } } if ($invalid == TRUE) { $this->Validator->isTRUE('in_use', FALSE, TTi18n::gettext('This currency is in use')); } } return TRUE; }
function calculate($epoch = NULL) { if ($this->getUserObject() == FALSE or $this->getUserObject()->getStatus() !== 10) { return FALSE; } $generic_queue_status_label = $this->getUserObject()->getFullName(TRUE) . ' - ' . TTi18n::gettext('Pay Stub'); if ($epoch == NULL or $epoch == '') { $epoch = TTDate::getTime(); } if ($this->getPayPeriodObject() == FALSE) { return FALSE; } Debug::text('bbUser Id: ' . $this->getUser() . ' Pay Period End Date: ' . TTDate::getDate('DATE+TIME', $this->getPayPeriodObject()->getEndDate()), __FILE__, __LINE__, __METHOD__, 10); $pay_stub = new PayStubFactory(); $pay_stub->StartTransaction(); $old_pay_stub_id = NULL; if ($this->getEnableCorrection() == TRUE) { Debug::text('Correction Enabled!', __FILE__, __LINE__, __METHOD__, 10); $pay_stub->setTemp(TRUE); //Check for current pay stub ID so we can compare against it. $pslf = new PayStubListFactory(); $pslf->getByUserIdAndPayPeriodId($this->getUser(), $this->getPayPeriod()); if ($pslf->getRecordCount() > 0) { $old_pay_stub_id = $pslf->getCurrent()->getId(); Debug::text('Comparing Against Pay Stub ID: ' . $old_pay_stub_id, __FILE__, __LINE__, __METHOD__, 10); } } $pay_stub->setUser($this->getUser()); $pay_stub->setPayPeriod($this->getPayPeriod()); $pay_stub->setCurrency($this->getUserObject()->getCurrency()); $pay_stub->setStatus('NEW'); //Use User Termination Date instead of ROE. if ($this->getUserObject()->getTerminationDate() != '' and $this->getUserObject()->getTerminationDate() >= $this->getPayPeriodObject()->getStartDate() and $this->getUserObject()->getTerminationDate() <= $this->getPayPeriodObject()->getEndDate()) { Debug::text('User has been terminated in this pay period!', __FILE__, __LINE__, __METHOD__, 10); $is_terminated = TRUE; } else { $is_terminated = FALSE; } if ($is_terminated == TRUE) { Debug::text('User is Terminated, assuming final pay, setting End Date to terminated date: ' . TTDate::getDate('DATE+TIME', $this->getUserObject()->getTerminationDate()), __FILE__, __LINE__, __METHOD__, 10); $pay_stub->setStartDate($pay_stub->getPayPeriodObject()->getStartDate()); $pay_stub->setEndDate($this->getUserObject()->getTerminationDate()); //Use the PS generation date instead of terminated date... //Unlikely they would pay someone before the pay stub is generated. //Perhaps still use the pay period transaction date for this too? //Anything we set won't be correct for everyone. Maybe a later date is better though? //Perhaps add to the user factory under Termination Date a: "Final Transaction Date" for this purpose? //Use the end of the current date for the transaction date, as if the employee is terminated //on the same day they are generating the pay stub, the transaction date could be before the end date //as the end date is at 11:59PM $pay_stub->setTransactionDate(TTDate::getEndDayEpoch(TTDate::getTime())); } else { Debug::text('User Termination Date is NOT set, assuming normal pay.', __FILE__, __LINE__, __METHOD__, 10); $pay_stub->setDefaultDates(); } //This must go after setting advance if ($this->getEnableCorrection() == FALSE and $pay_stub->IsUniquePayStub() == FALSE) { Debug::text('Pay Stub already exists', __FILE__, __LINE__, __METHOD__, 10); $this->CommitTransaction(); UserGenericStatusFactory::queueGenericStatus($generic_queue_status_label, 20, TTi18n::gettext('Pay Stub for this employee already exists, skipping...'), NULL); return FALSE; } if ($pay_stub->isValid() == TRUE) { $pay_stub->Save(FALSE); $pay_stub->setStatus('Open'); } else { Debug::text('Pay Stub isValid failed!', __FILE__, __LINE__, __METHOD__, 10); UserGenericStatusFactory::queueGenericStatus($generic_queue_status_label, 10, $pay_stub->Validator->getTextErrors(), NULL); $this->FailTransaction(); $this->CommitTransaction(); return FALSE; } $pay_stub->loadPreviousPayStub(); $user_date_total_arr = $this->getWageObject()->getUserDateTotalArray(); if (isset($user_date_total_arr['entries']) and is_array($user_date_total_arr['entries'])) { foreach ($user_date_total_arr['entries'] as $udt_arr) { //Allow negative amounts so flat rate premium policies can reduce an employees wage if need be. if ($udt_arr['amount'] != 0) { Debug::text('Adding Pay Stub Entry: ' . $udt_arr['pay_stub_entry'] . ' Amount: ' . $udt_arr['amount'], __FILE__, __LINE__, __METHOD__, 10); $pay_stub->addEntry($udt_arr['pay_stub_entry'], $udt_arr['amount'], TTDate::getHours($udt_arr['total_time']), $udt_arr['rate']); } else { Debug::text('NOT Adding ($0 amount) Pay Stub Entry: ' . $udt_arr['pay_stub_entry'] . ' Amount: ' . $udt_arr['amount'], __FILE__, __LINE__, __METHOD__, 10); } } } else { //No Earnings, CHECK FOR PS AMENDMENTS next for earnings. Debug::text('NO TimeSheet EARNINGS ON PAY STUB... Checking for PS amendments', __FILE__, __LINE__, __METHOD__, 10); } //Get all PS amendments and Tax / Deductions so we can determine the proper order to calculate them in. $psalf = new PayStubAmendmentListFactory(); $psalf->getByUserIdAndAuthorizedAndStartDateAndEndDate($this->getUser(), TRUE, $this->getPayPeriodObject()->getStartDate(), $this->getPayPeriodObject()->getEndDate()); $udlf = new UserDeductionListFactory(); $udlf->getByCompanyIdAndUserId($this->getUserObject()->getCompany(), $this->getUserObject()->getId()); $deduction_order_arr = $this->getOrderedDeductionAndPSAmendment($udlf, $psalf); if (is_array($deduction_order_arr) and count($deduction_order_arr) > 0) { foreach ($deduction_order_arr as $calculation_order => $data_arr) { Debug::text('Found PS Amendment/Deduction: Type: ' . $data_arr['type'] . ' Name: ' . $data_arr['name'] . ' Order: ' . $calculation_order, __FILE__, __LINE__, __METHOD__, 10); if (isset($data_arr['obj']) and is_object($data_arr['obj'])) { if ($data_arr['type'] == 'UserDeductionListFactory') { $ud_obj = $data_arr['obj']; //Determine if this deduction is valid based on start/end dates. //Determine if this deduction is valid based on min/max length of service. if ($ud_obj->getCompanyDeductionObject()->isActiveDate($pay_stub->getPayPeriodObject()->getEndDate()) == TRUE and $ud_obj->getCompanyDeductionObject()->isActiveLengthOfService($this->getUserObject(), $pay_stub->getPayPeriodObject()->getEndDate()) == TRUE) { $amount = $ud_obj->getDeductionAmount($this->getUserObject()->getId(), $pay_stub, $this->getPayPeriodObject()); Debug::text('User Deduction: ' . $ud_obj->getCompanyDeductionObject()->getName() . ' Amount: ' . $amount . ' Calculation Order: ' . $ud_obj->getCompanyDeductionObject()->getCalculationOrder(), __FILE__, __LINE__, __METHOD__, 10); //Allow negative amounts, so they can reduce previously calculated deductions or something. if (isset($amount) and $amount != 0) { $pay_stub->addEntry($ud_obj->getCompanyDeductionObject()->getPayStubEntryAccount(), $amount); } else { Debug::text('Amount is 0, skipping...', __FILE__, __LINE__, __METHOD__, 10); } } unset($amount, $ud_obj); } elseif ($data_arr['type'] == 'PayStubAmendmentListFactory') { $psa_obj = $data_arr['obj']; Debug::text('Found Pay Stub Amendment: ID: ' . $psa_obj->getID() . ' Entry Name ID: ' . $psa_obj->getPayStubEntryNameId() . ' Type: ' . $psa_obj->getType(), __FILE__, __LINE__, __METHOD__, 10); $amount = $psa_obj->getCalculatedAmount($pay_stub); if (isset($amount) and $amount != 0) { Debug::text('Pay Stub Amendment Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); $pay_stub->addEntry($psa_obj->getPayStubEntryNameId(), $amount, $psa_obj->getUnits(), $psa_obj->getRate(), $psa_obj->getDescription(), $psa_obj->getID(), NULL, NULL, $psa_obj->getYTDAdjustment()); //Keep in mind this causes pay stubs to be re-generated every time, as this modifies the updated time //to slightly more then the pay stub creation time. $psa_obj->setStatus('IN USE'); $psa_obj->Save(); } else { Debug::text('bPay Stub Amendment Amount is not set...', __FILE__, __LINE__, __METHOD__, 10); } unset($amount, $psa_obj); } } } } unset($deduction_order_arr, $calculation_order, $data_arr); $pay_stub_id = $pay_stub->getId(); $pay_stub->setEnableProcessEntries(TRUE); $pay_stub->processEntries(); if ($pay_stub->isValid() == TRUE) { Debug::text('Pay Stub is valid, final save.', __FILE__, __LINE__, __METHOD__, 10); $pay_stub->Save(); if ($this->getEnableCorrection() == TRUE) { if (isset($old_pay_stub_id)) { Debug::text('bCorrection Enabled - Doing Comparison here', __FILE__, __LINE__, __METHOD__, 10); PayStubFactory::CalcDifferences($pay_stub_id, $old_pay_stub_id); } //Delete newly created temp paystub. //This used to be in the above IF block that depended on $old_pay_stub_id //being set, however in cases where the old pay stub didn't exist //TimeTrex wouldn't delete these temporary pay stubs. //Moving this code outside that IF statement so it only depends on EnableCorrection() //to be TRUE should fix that issue. $pslf = new PayStubListFactory(); $pslf->getById($pay_stub_id); if ($pslf->getRecordCount() > 0) { $tmp_ps_obj = $pslf->getCurrent(); $tmp_ps_obj->setDeleted(TRUE); $tmp_ps_obj->Save(); unset($tmp_ps_obj); } } $pay_stub->CommitTransaction(); UserGenericStatusFactory::queueGenericStatus($generic_queue_status_label, 30, NULL, NULL); return TRUE; } Debug::text('Pay Stub is NOT valid returning FALSE', __FILE__, __LINE__, __METHOD__, 10); UserGenericStatusFactory::queueGenericStatus($generic_queue_status_label, 10, $pay_stub->Validator->getTextErrors(), NULL); $pay_stub->FailTransaction(); //Reduce transaction count by one. //$pay_stub->FailTransaction(); //Reduce transaction count by one. $pay_stub->CommitTransaction(); return FALSE; }
/* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'page', 'sort_column', 'sort_order', 'user_ids', 'show_ytd'))); URLBuilder::setURL($_SERVER['SCRIPT_NAME'], array('sort_column' => $sort_column, 'sort_order' => $sort_order, 'page' => $page)); switch ($action) { case 'Submit': default: $psenlf = new PayStubEntryNameListFactory(); $ulf = new UserListFactory(); if (!isset($user_ids) or $user_ids == '' or $user_ids[0] == 0) { //$user_ids = array_keys( $ulf->getByCompanyIdArray( $current_company->getId() ) ); $user_ids = array($current_user->getId()); } //Get all pay stubs for this pay period $pslf = new PayStubListFactory(); $pslf->getByUserIdAndCompanyId($user_ids, $current_company->getId(), NULL, NULL, array('advance' => '= \'f\''), array('user_id' => 'asc', 'pay_period_id' => 'asc')); $pager = new Pager($pslf); $pseallf = new PayStubEntryAccountLinkListFactory(); $pseallf->getByCompanyId($current_company->getId()); if ($pseallf->getRecordCount() > 0) { $pseal_obj = $pseallf->getCurrent(); $entry_name_ids = array($pseal_obj->getTotalGross(), $pseal_obj->getMonthlyAdvance(), $pseal_obj->getTotalEmployeeDeduction(), $pseal_obj->getTotalEmployerDeduction(), $pseal_obj->getTotalNetPay(), $pseal_obj->getMonthlyAdvanceDeduction(), $pseal_obj->getMonthlyAdvanceDeduction(), $pseal_obj->getVacationAccrual()); //array(10,11,18,22,23,24,25); } else { $entry_name_ids = array(); } //var_dump($entry_name_ids); $prev_user = NULL; $prev_entries = NULL; foreach ($pslf as $pay_stub_obj) {
//$f941->setDebug(FALSE); $f941->setShowBackground($show_background); $total_users = 0; foreach ($quarter_dates[$filter_data['quarter_id']] as $month_id => $quarter_dates_arr) { //Get Pay Periods in date range. Debug::Text('Start Date: ' . TTDate::getDate('DATE+TIME', $quarter_dates_arr['start']) . ' End Date: ' . TTDate::getDate('DATE+TIME', $quarter_dates_arr['end']), __FILE__, __LINE__, __METHOD__, 10); $pplf = new PayPeriodListFactory(); $pplf->getByCompanyIdAndTransactionStartDateAndTransactionEndDate($current_company->getId(), $quarter_dates_arr['start'], $quarter_dates_arr['end']); if ($pplf->getRecordCount() > 0) { foreach ($pplf as $pp_obj) { $pay_period_ids[] = $pp_obj->getID(); $pay_period_transaction_dates[$pp_obj->getID()] = $pp_obj->getTransactionDate(); } } if (isset($pay_period_ids)) { $pslf = new PayStubListFactory(); $pslf->getByCompanyIdAndPayPeriodId($current_company->getId(), $pay_period_ids); if ($pslf->getRecordCount() > 0) { foreach ($pslf as $ps_obj) { if (in_array($ps_obj->getUser(), $filter_data['user_ids'])) { $pay_stub_users[] = $ps_obj->getUser(); } } $pay_stub_users = array_unique($pay_stub_users); if (count($pay_stub_users) > $total_users) { $total_users = count($pay_stub_users); } unset($pay_stub_users); } foreach ($pay_period_ids as $pay_period_id) { //PS Account Amounts...
} $smarty->assign('title', TTi18n::gettext($title = 'Employee Pay Stub')); // See index.php BreadCrumb::setCrumb($title); /* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'page', 'sort_column', 'sort_order', 'hide_employer_rows', 'id', 'ids', 'export_type'))); $export_type = strtolower($export_type); switch ($action) { default: if (isset($id) and !isset($ids)) { $ids = array($id); } if (count($ids) > 0) { $pslf = new PayStubListFactory(); if ($permission->Check('pay_stub', 'view')) { $pslf->getByCompanyIdAndId($current_company->getId(), $ids); } else { $pslf->getByUserIdAndId($current_user->getId(), $ids); $hide_employer_rows = TRUE; } $output = $pslf->exportPayStub($pslf, $export_type); if (Debug::getVerbosity() < 11) { Misc::FileDownloadHeader('checks_' . str_replace(array('/', ',', ' '), '_', TTDate::getDate('DATE', time())) . '.pdf', 'application/pdf', strlen($output)); echo $output; exit; } } break; }
$verified_time_sheets = 0; $pending_time_sheets = 0; if ($pptsvlf->getRecordCount() > 0) { foreach ($pptsvlf as $pptsv_obj) { if ($pptsv_obj->getAuthorized() == TRUE) { $verified_time_sheets++; } elseif ($pptsv_obj->getStatus() == 30) { $pending_time_sheets++; } } } //Get total employees with time for this pay period. $udtlf = new UserDateTotalListFactory(); $total_worked_users = $udtlf->getWorkedUsersByPayPeriodId($pay_period_obj->getId()); //Count how many pay stubs for each pay period. $pslf = new PayStubListFactory(); $total_pay_stubs = $pslf->getByPayPeriodId($pay_period_obj->getId())->getRecordCount(); if ($pay_period_obj->getStatus() != 20) { $open_pay_periods = TRUE; } $pay_periods[] = array('id' => $pay_period_obj->getId(), 'company_id' => $pay_period_obj->getCompany(), 'pay_period_schedule_id' => $pay_period_obj->getPayPeriodSchedule(), 'name' => $pay_period_schedule->getName(), 'type' => Option::getByKey($pay_period_schedule->getType(), $pay_period_schedule->getOptions('type')), 'status' => Option::getByKey($pay_period_obj->getStatus(), $pay_period_obj->getOptions('status')), 'start_date' => TTDate::getDate('DATE+TIME', $pay_period_obj->getStartDate()), 'end_date' => TTDate::getDate('DATE+TIME', $pay_period_obj->getEndDate()), 'transaction_date' => TTDate::getDate('DATE+TIME', $pay_period_obj->getTransactionDate()), 'low_severity_exceptions' => $low_severity_exceptions, 'med_severity_exceptions' => $med_severity_exceptions, 'high_severity_exceptions' => $high_severity_exceptions, 'pending_requests' => $pending_requests, 'verified_time_sheets' => $verified_time_sheets, 'pending_time_sheets' => $pending_time_sheets, 'total_worked_users' => $total_worked_users, 'total_ps_amendments' => $total_ps_amendments, 'total_pay_stubs' => $total_pay_stubs, 'deleted' => $pay_period_obj->getDeleted()); } unset($total_shifts, $total_ps_amendments, $total_pay_stubs, $verified_time_sheets, $total_worked_users); } } else { Debug::Text('No pay periods pending transaction ', __FILE__, __LINE__, __METHOD__, 10); } $smarty->assign_by_ref('open_pay_periods', $open_pay_periods); $smarty->assign_by_ref('pay_periods', $pay_periods); $total_pay_periods = count($pay_periods); $smarty->assign_by_ref('total_pay_periods', $total_pay_periods);
function getPayStub($pslf = NULL, $hide_employer_rows = TRUE) { if (!is_object($pslf) and $this->getId() != '') { $pslf = new PayStubListFactory(); $pslf->getById($this->getId()); } if (get_class($pslf) !== 'PayStubListFactory') { return FALSE; } $border = 0; if ($pslf->getRecordCount() > 0) { $pdf = new TTPDF('P', 'mm', 'Letter'); $pdf->setMargins(0, 0); //$pdf->SetAutoPageBreak(TRUE, 30); $pdf->SetAutoPageBreak(FALSE); $pdf->SetFont('freeserif', '', 10); //$pdf->SetFont('FreeSans','',10); $i = 0; foreach ($pslf as $pay_stub_obj) { $psealf = new PayStubEntryAccountListFactory(); Debug::text($i . '. Pay Stub Transaction Date: ' . $pay_stub_obj->getTransactionDate(), __FILE__, __LINE__, __METHOD__, 10); //Get Pay Period information $pplf = new PayPeriodListFactory(); $pay_period_obj = $pplf->getById($pay_stub_obj->getPayPeriod())->getCurrent(); //Use Pay Stub dates, not Pay Period dates. $pp_start_date = $pay_stub_obj->getStartDate(); $pp_end_date = $pay_stub_obj->getEndDate(); $pp_transaction_date = $pay_stub_obj->getTransactionDate(); //Get pay period numbers $ppslf = new PayPeriodScheduleListFactory(); $pay_period_schedule_obj = $ppslf->getById($pay_period_obj->getPayPeriodSchedule())->getCurrent(); //Get User information $ulf = new UserListFactory(); $user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent(); //Get company information $clf = new CompanyListFactory(); $company_obj = $clf->getById($user_obj->getCompany())->getCurrent(); //Change locale to users own locale. TTi18n::setCountry($user_obj->getCountry()); TTi18n::setLanguage($user_obj->getUserPreferenceObject()->getLanguage()); TTi18n::setLocale(); // // Pay Stub Header // $pdf->AddPage(); $adjust_x = 20; $adjust_y = 10; //Logo $pdf->Image($company_obj->getLogoFileName(), Misc::AdjustXY(0, $adjust_x + 0), Misc::AdjustXY(1, $adjust_y + 0), 50, 12, '', '', '', FALSE, 300, '', FALSE, FALSE, 0, TRUE); //Company name/address $pdf->SetFont('', 'B', 14); $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(0, $adjust_y)); $pdf->Cell(75, 5, $company_obj->getName(), $border, 0, 'C'); $pdf->SetFont('', '', 10); $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(5, $adjust_y)); $pdf->Cell(75, 5, $company_obj->getAddress1() . ' ' . $company_obj->getAddress2(), $border, 0, 'C'); $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(10, $adjust_y)); $pdf->Cell(75, 5, $company_obj->getCity() . ', ' . $company_obj->getProvince() . ' ' . strtoupper($company_obj->getPostalCode()), $border, 0, 'C'); //Pay Period info $pdf->SetFont('', '', 10); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(0, $adjust_y)); $pdf->Cell(30, 5, TTi18n::gettext('Pay Start Date:') . ' ', $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(5, $adjust_y)); $pdf->Cell(30, 5, TTi18n::gettext('Pay End Date:') . ' ', $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(10, $adjust_y)); $pdf->Cell(30, 5, TTi18n::gettext('Payment Date:') . ' ', $border, 0, 'R'); $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(0, $adjust_y)); $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_start_date), $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(5, $adjust_y)); $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_end_date), $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(10, $adjust_y)); $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_transaction_date), $border, 0, 'R'); //Line $pdf->setLineWidth(1); $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(17, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY(17, $adjust_y)); $pdf->SetFont('', 'B', 14); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(19, $adjust_y)); $pdf->Cell(175, 5, TTi18n::gettext('STATEMENT OF EARNINGS AND DEDUCTIONS'), $border, 0, 'C', 0); //Line $pdf->setLineWidth(1); $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(27, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY(27, $adjust_y)); $pdf->setLineWidth(0.25); //Get pay stub entries. $pself = new PayStubEntryListFactory(); $pself->getByPayStubId($pay_stub_obj->getId()); Debug::text('Pay Stub Entries: ' . $pself->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); $prev_type = NULL; $description_subscript_counter = 1; foreach ($pself as $pay_stub_entry) { Debug::text('Pay Stub Entry Account ID: ' . $pay_stub_entry->getPayStubEntryNameId(), __FILE__, __LINE__, __METHOD__, 10); $description_subscript = NULL; $pay_stub_entry_name_obj = $psealf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent(); //Use this to put the total for each type at the end of the array. if ($prev_type == 40 or $pay_stub_entry_name_obj->getType() != 40) { $type = $pay_stub_entry_name_obj->getType(); } //Debug::text('Pay Stub Entry Name ID: '. $pay_stub_entry_name_obj->getId() .' Type ID: '. $pay_stub_entry_name_obj->getType() .' Type: '. $type, __FILE__, __LINE__, __METHOD__,10); if ($pay_stub_entry->getDescription() !== NULL and $pay_stub_entry->getDescription() !== FALSE and strlen($pay_stub_entry->getDescription()) > 0) { $pay_stub_entry_descriptions[] = array('subscript' => $description_subscript_counter, 'description' => $pay_stub_entry->getDescription()); $description_subscript = $description_subscript_counter; $description_subscript_counter++; } //If type if 40 (a total) and the amount is 0, skip it. //This if the employee has no deductions at all, it won't be displayed //on the pay stub. if ($type != 40 or $type == 40 and $pay_stub_entry->getAmount() != 0) { $pay_stub_entries[$type][] = array('id' => $pay_stub_entry->getId(), 'pay_stub_entry_name_id' => $pay_stub_entry->getPayStubEntryNameId(), 'type' => $pay_stub_entry_name_obj->getType(), 'name' => $pay_stub_entry_name_obj->getName(), 'display_name' => $pay_stub_entry_name_obj->getName(), 'rate' => $pay_stub_entry->getRate(), 'units' => $pay_stub_entry->getUnits(), 'ytd_units' => $pay_stub_entry->getYTDUnits(), 'amount' => $pay_stub_entry->getAmount(), 'ytd_amount' => $pay_stub_entry->getYTDAmount(), 'description' => $pay_stub_entry->getDescription(), 'description_subscript' => $description_subscript, 'created_date' => $pay_stub_entry->getCreatedDate(), 'created_by' => $pay_stub_entry->getCreatedBy(), 'updated_date' => $pay_stub_entry->getUpdatedDate(), 'updated_by' => $pay_stub_entry->getUpdatedBy(), 'deleted_date' => $pay_stub_entry->getDeletedDate(), 'deleted_by' => $pay_stub_entry->getDeletedBy()); } $prev_type = $pay_stub_entry_name_obj->getType(); } //There should always be pay stub entries for a pay stub. if (!isset($pay_stub_entries)) { continue; } //Debug::Arr($pay_stub_entries, 'Pay Stub Entries...', __FILE__, __LINE__, __METHOD__,10); //$pay_period_number = $pay_period_schedule_obj->getCurrentPayPeriodNumber( $pay_period_obj->getTransactionDate(), $pay_period_obj->getEndDate() ); $block_adjust_y = 30; // //Earnings // if (isset($pay_stub_entries[10])) { //Earnings Header $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(90, 5, TTi18n::gettext('Earnings'), $border, 0, 'L'); $pdf->Cell(17, 5, TTi18n::gettext('Rate'), $border, 0, 'R'); $pdf->Cell(23, 5, TTi18n::gettext('Hrs/Units'), $border, 0, 'R'); $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 10); foreach ($pay_stub_entries[10] as $pay_stub_entry) { if ($pay_stub_entry['type'] == 10) { if ($pay_stub_entry['description_subscript'] != '') { $subscript = '[' . $pay_stub_entry['description_subscript'] . ']'; } else { $subscript = NULL; } $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(88, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); $pdf->Cell(17, 5, TTi18n::formatNumber($pay_stub_entry['rate'], TRUE), $border, 0, 'R'); $pdf->Cell(23, 5, TTi18n::formatNumber($pay_stub_entry['units'], TRUE), $border, 0, 'R'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } else { //Total $pdf->SetFont('', 'B', 10); $pdf->line(Misc::AdjustXY(110, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->line(Misc::AdjustXY(131, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(90, 5, $pay_stub_entry['name'], $border, 0, 'L'); $pdf->Cell(17, 5, '', $border, 0, 'R'); $pdf->Cell(23, 5, TTi18n::formatNumber($pay_stub_entry['units'], TRUE), $border, 0, 'R'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } $block_adjust_y = $block_adjust_y + 5; } } // // Deductions // if (isset($pay_stub_entries[20])) { $max_deductions = count($pay_stub_entries[20]); //Deductions Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); if ($max_deductions > 2) { $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(40, 5, TTi18n::gettext('Deductions'), $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(90, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(40, 5, TTi18n::gettext('Deductions'), $border, 0, 'L'); } else { $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, TTi18n::gettext('Deductions'), $border, 0, 'L'); } $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $block_adjust_y = $tmp_block_adjust_y = $top_block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 10); $x = 0; $max_block_adjust_y = 0; foreach ($pay_stub_entries[20] as $pay_stub_entry) { //Start with the right side. if ($x < floor($max_deductions / 2)) { $tmp_adjust_x = 90; } else { if ($tmp_block_adjust_y != 0) { $block_adjust_y = $tmp_block_adjust_y; $tmp_block_adjust_y = 0; } $tmp_adjust_x = 0; } if ($pay_stub_entry['type'] == 20) { if ($pay_stub_entry['description_subscript'] != '') { $subscript = '[' . $pay_stub_entry['description_subscript'] . ']'; } else { $subscript = NULL; } if ($max_deductions > 2) { $pdf->setXY(Misc::AdjustXY(2, $tmp_adjust_x + $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(38, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); } else { $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(128, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); } $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } else { $block_adjust_y = $max_block_adjust_y + 0; //Total $pdf->SetFont('', 'B', 10); $pdf->line(Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, $pay_stub_entry['name'], $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } $block_adjust_y = $block_adjust_y + 5; if ($block_adjust_y > $max_block_adjust_y) { $max_block_adjust_y = $block_adjust_y; } $x++; } //Draw line to separate the two columns if ($max_deductions > 2) { $pdf->Line(Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($top_block_adjust_y - 5, $adjust_y), Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($max_block_adjust_y - 5, $adjust_y)); } unset($x, $max_deductions, $tmp_adjust_x, $max_block_adjust_y, $tmp_block_adjust_y, $top_block_adjust_y); } if (isset($pay_stub_entries[40][0])) { $block_adjust_y = $block_adjust_y + 5; //Net Pay entry $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, $pay_stub_entries[40][0]['name'], $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entries[40][0]['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entries[40][0]['ytd_amount']), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; } // //Employer Contributions // //echo "Employee Ded: <br>\n"; if (isset($pay_stub_entries[30]) and $hide_employer_rows != TRUE) { $max_deductions = count($pay_stub_entries[30]); //echo "Max Employee Ded: ". $max_deductions ."<br>\n"; //Deductions Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); if ($max_deductions > 2) { $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(40, 5, TTi18n::gettext('Employer Contributions'), $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(90, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(40, 5, TTi18n::gettext('Employer Contributions'), $border, 0, 'L'); } else { $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, TTi18n::gettext('Employer Contributions'), $border, 0, 'L'); } $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $block_adjust_y = $tmp_block_adjust_y = $top_block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 10); $x = 0; $max_block_adjust_y = 0; foreach ($pay_stub_entries[30] as $pay_stub_entry) { //Start with the right side. if ($x < floor($max_deductions / 2)) { $tmp_adjust_x = 90; } else { if ($tmp_block_adjust_y != 0) { $block_adjust_y = $tmp_block_adjust_y; $tmp_block_adjust_y = 0; } $tmp_adjust_x = 0; } if ($pay_stub_entry['type'] == 30) { if ($pay_stub_entry['description_subscript'] != '') { $subscript = '[' . $pay_stub_entry['description_subscript'] . ']'; } else { $subscript = NULL; } if ($max_deductions > 2) { $pdf->setXY(Misc::AdjustXY(2, $tmp_adjust_x + $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(38, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); } else { $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(128, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); } $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } else { $block_adjust_y = $max_block_adjust_y + 0; //Total $pdf->SetFont('', 'B', 10); $pdf->line(Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, $pay_stub_entry['name'], $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } $block_adjust_y = $block_adjust_y + 5; if ($block_adjust_y > $max_block_adjust_y) { $max_block_adjust_y = $block_adjust_y; } $x++; } //Draw line to separate the two columns if ($max_deductions > 2) { $pdf->Line(Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($top_block_adjust_y - 5, $adjust_y), Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($max_block_adjust_y - 5, $adjust_y)); } unset($x, $max_deductions, $tmp_adjust_x, $max_block_adjust_y, $tmp_block_adjust_y, $top_block_adjust_y); } // //Accruals PS accounts // if (isset($pay_stub_entries[50])) { //Accrual Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, TTi18n::gettext('Accruals'), $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('Balance'), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 10); foreach ($pay_stub_entries[50] as $pay_stub_entry) { if ($pay_stub_entry['type'] == 50) { if ($pay_stub_entry['description_subscript'] != '') { $subscript = '[' . $pay_stub_entry['description_subscript'] . ']'; } else { $subscript = NULL; } $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(128, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } $block_adjust_y = $block_adjust_y + 5; } } // //Accrual Policy Balances // $ablf = new AccrualBalanceListFactory(); $ablf->getByUserIdAndCompanyIdAndEnablePayStubBalanceDisplay($user_obj->getId(), $user_obj->getCompany(), TRUE); if ($ablf->getRecordCount() > 0) { //Accrual Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(40, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $accrual_time_header_start_x = $pdf->getX(); $accrual_time_header_start_y = $pdf->getY(); $pdf->Cell(70, 5, TTi18n::gettext('Accrual Time Balances as of ') . TTDate::getDate('DATE', time()), $border, 0, 'L'); $pdf->Cell(25, 5, TTi18n::gettext('Balance (hrs)'), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; $box_height = 5; $pdf->SetFont('', '', 10); foreach ($ablf as $ab_obj) { $balance = $ab_obj->getBalance(); if (!is_numeric($balance)) { $balance = 0; } $pdf->setXY(Misc::AdjustXY(40, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(70, 5, $ab_obj->getColumn('name'), $border, 0, 'L'); $pdf->Cell(25, 5, TTi18n::formatNumber(TTDate::getHours($balance)), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; $box_height = $box_height + 5; unset($balance); } $pdf->Rect($accrual_time_header_start_x, $accrual_time_header_start_y, 95, $box_height); unset($accrual_time_header_start_x, $accrual_time_header_start_y, $box_height); } // //Descriptions // if (isset($pay_stub_entry_descriptions) and count($pay_stub_entry_descriptions) > 0) { //Description Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(175, 5, TTi18n::gettext('Notes'), $border, 0, 'L'); $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 8); $x = 0; foreach ($pay_stub_entry_descriptions as $pay_stub_entry_description) { if ($x % 2 == 0) { $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); } else { $pdf->setXY(Misc::AdjustXY(90, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); } //$pdf->Cell(173,5, '['.$pay_stub_entry_description['subscript'].'] '.$pay_stub_entry_description['description'], $border, 0, 'L'); $pdf->Cell(85, 5, '[' . $pay_stub_entry_description['subscript'] . '] ' . $pay_stub_entry_description['description'], $border, 0, 'L'); if ($x % 2 != 0) { $block_adjust_y = $block_adjust_y + 5; } $x++; } } unset($x, $pay_stub_entry_descriptions, $pay_stub_entry_description); // // Pay Stub Footer // $block_adjust_y = 215; //Line $pdf->setLineWidth(1); $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY($block_adjust_y, $adjust_y)); //Non Negotiable $pdf->SetFont('', 'B', 14); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 3, $adjust_y)); $pdf->Cell(175, 5, TTi18n::gettext('NON NEGOTIABLE'), $border, 0, 'C', 0); //Employee Address $pdf->SetFont('', 'B', 12); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 9, $adjust_y)); $pdf->Cell(60, 5, TTi18n::gettext('CONFIDENTIAL'), $border, 0, 'C', 0); $pdf->SetFont('', '', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 14, $adjust_y)); $pdf->Cell(60, 5, $user_obj->getFullName(), $border, 0, 'C', 0); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 19, $adjust_y)); $pdf->Cell(60, 5, $user_obj->getAddress1(), $border, 0, 'C', 0); $address2_adjust_y = 0; if ($user_obj->getAddress2() != '') { $address2_adjust_y = 5; $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 24, $adjust_y)); $pdf->Cell(60, 5, $user_obj->getAddress2(), $border, 0, 'C', 0); } $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 24 + $address2_adjust_y, $adjust_y)); $pdf->Cell(60, 5, $user_obj->getCity() . ', ' . $user_obj->getProvince() . ' ' . $user_obj->getPostalCode(), $border, 1, 'C', 0); //Pay Period - Balance - ID $net_pay_amount = 0; if (isset($pay_stub_entries[40][0])) { $net_pay_amount = $pay_stub_entries[40][0]['amount']; } if (isset($pay_stub_entries[65]) and count($pay_stub_entries[65]) > 0) { $net_pay_label = TTi18n::gettext('Balance'); } else { $net_pay_label = TTi18n::gettext('Net Pay'); } /* if ( $pay_period_schedule_obj->getType() != 5 AND $pay_period_number > 0 AND $pay_period_schedule_obj->getAnnualPayPeriods() > 0 ) { $pdf->setXY( Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY($block_adjust_y+10, $adjust_y) ); $pdf->Cell(50, 5, TTi18n::gettext('Pay Period').' '. $pay_period_number .' '. TTi18n::gettext('of') .' '. $pay_period_schedule_obj->getAnnualPayPeriods(), $border, 1, 'L', 0); } */ $pdf->SetFont('', 'B', 12); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY($block_adjust_y + 17, $adjust_y)); $pdf->Cell(50, 5, $net_pay_label . ': ' . $pay_stub_obj->getCurrencyObject()->getSymbol() . $net_pay_amount . ' ' . $pay_stub_obj->getCurrencyObject()->getISOCode(), $border, 1, 'L', 0); if ($pay_stub_obj->getTainted() == TRUE) { $tainted_flag = 'T'; } else { $tainted_flag = ''; } $pdf->SetFont('', '', 8); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY($block_adjust_y + 30, $adjust_y)); $pdf->Cell(50, 5, TTi18n::gettext('Identification #:') . ' ' . str_pad($pay_stub_obj->getId(), 12, 0, STR_PAD_LEFT) . $tainted_flag, $border, 1, 'L', 0); unset($net_pay_amount, $tainted_flag); //Line $pdf->setLineWidth(1); $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 35, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY($block_adjust_y + 35, $adjust_y)); $pdf->SetFont('', '', 6); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 38, $adjust_y)); $pdf->Cell(175, 1, TTi18n::gettext('Pay Stub Generated by') . ' ' . APPLICATION_NAME, $border, 0, 'C', 0); unset($pay_period_schedule_obj, $pay_stub_entries, $pay_period_number); $i++; } $output = $pdf->Output('', 'S'); } TTi18n::setMasterLocale(); if (isset($output)) { return $output; } return FALSE; }
$ugsf->setUser($current_user->getId()); $ugsf->setBatchID($ugsf->getNextBatchId()); $ugsf->setQueue(UserGenericStatusFactory::getStaticQueue()); $ugsf->saveQueue(); $next_page = URLBuilder::getURL(array('batch_id' => $ugsf->getBatchID(), 'batch_title' => 'Generating Pay Stubs', 'batch_next_page' => $next_page), '../users/UserGenericStatusList.php'); unset($ugsf); } } break; case 'recalculate_paystub_ytd': //Debug::setVerbosity(11); Debug::Text('Recalculating Pay Stub YTDs!', __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Pay Stub ID: ' . $pay_stub_ids, __FILE__, __LINE__, __METHOD__, 10); $init_progress_bar = TRUE; //Just need the pay_stub_id of the modified pay stub. $pslf = new PayStubListFactory(); $pslf->StartTransaction(); if (is_array($pay_stub_ids)) { foreach ($pay_stub_ids as $pay_stub_id) { $pslf->getByIdAndCompanyIdAndIgnoreDeleted($pay_stub_id, $current_company->getId()); if ($pslf->getRecordCount() > 0) { $main_ps_obj = $pslf->getCurrent(); //Get all pay stubs NEWER then this one. $pslf->getByUserIdAndStartDateAndEndDate($main_ps_obj->getUser(), $main_ps_obj->getTransactionDate(), TTDate::getEndYearEpoch($main_ps_obj->getTransactionDate())); $total_pay_stubs = $pslf->getRecordCount(); if ($total_pay_stubs > 0) { if ($init_progress_bar == TRUE) { InitProgressBar(); $init_progress_bar = FALSE; } $progress_bar->setValue(0);
function getPayStubId() { //Find which pay period this effective date belongs too $pplf = new PayPeriodListFactory(); $pplf->getByUserIdAndEndDate($this->getUser(), $this->getEffectiveDate()); if ($pplf->getRecordCount() > 0) { $pp_obj = $pplf->getCurrent(); Debug::text('Found Pay Period ID: ' . $pp_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); //Percent PS amendments can't work on advances. $pslf = new PayStubListFactory(); $pslf->getByUserIdAndPayPeriodIdAndAdvance($this->getUser(), $pp_obj->getId(), FALSE); if ($pslf->getRecordCount() > 0) { $ps_obj = $pslf->getCurrent(); Debug::text('Found Pay Stub for this effective date: ' . $ps_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); return $ps_obj->getId(); } } return FALSE; }
function getPayStub($pay_period_id = FALSE) { if ($pay_period_id == FALSE) { $pay_period_id = $this->pay_period_objs[0]->getId(); } $pslf = new PayStubListFactory(); $pslf->getByUserIdAndPayPeriodId($this->user_id, $pay_period_id); if ($pslf->getRecordCount() > 0) { return $pslf->getCurrent()->getId(); } return FALSE; }
function getAmountSumByUserIdAndEntryNameIdAndStartDateAndEndDate($id, $entry_name_id, $start_date = NULL, $end_date = NULL, $exclude_id = NULL, $where = NULL, $order = NULL) { if ($id == '') { return FALSE; } if ($entry_name_id == '') { return FALSE; } if ($start_date == '') { $start_date = 0; } if ($end_date == '') { $end_date = TTDate::getTime(); } $pplf = new PayPeriodListFactory(); $pslf = new PayStubListFactory(); $ph = array('start_date' => $this->db->BindTimeStamp($start_date), 'end_date' => $this->db->BindTimeStamp($end_date), 'user_id' => $id, 'exclude_id' => (int) $exclude_id); $query = ' select sum(amount) as amount, sum(units) as units from ' . $this->getTable() . ' as a, ' . $pslf->getTable() . ' as b where a.pay_stub_id = b.id AND b.pay_period_id in (select id from ' . $pplf->getTable() . ' as y where y.pay_period_schedule_id = ( select pay_period_schedule_id from ' . $pplf->getTable() . ' as z where z.id = b.pay_period_id ) AND y.start_date >= ? AND y.start_date < ? and y.deleted =0) AND b.user_id = ? AND a.id != ? AND a.pay_stub_entry_name_id in (' . $this->getListSQL($entry_name_id, $ph) . ') AND a.deleted = 0 AND b.deleted=0 '; $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order); Debug::Text('Query: ' . $query, __FILE__, __LINE__, __METHOD__, 10); $row = $this->db->GetRow($query, $ph); if ($row['amount'] === NULL) { $row['amount'] = 0; } if ($row['units'] === NULL) { $row['units'] = 0; } Debug::text('Over All Sum for ' . $entry_name_id . ': Amount ' . $row['amount'] . ' Units: ' . $row['units'], __FILE__, __LINE__, __METHOD__, 10); return $row; }
$pslf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data); if ($pslf->getRecordCount() > 0) { if (!isset($filter_data['hide_employer_rows'])) { //Must be false, because if it isn't checked it won't be set. $filter_data['hide_employer_rows'] = FALSE; } $output = $pslf->getPayStub($pslf, (bool) $filter_data['hide_employer_rows']); if (Debug::getVerbosity() < 11) { Misc::FileDownloadHeader('pay_stub.pdf', 'application/pdf', strlen($output)); echo $output; exit; } } } elseif ($action == 'export' and $filter_data['export_type'] != 'csv') { Debug::Text('Export NON-CSV', __FILE__, __LINE__, __METHOD__, 10); $pslf = new PayStubListFactory(); //$pslf->getByUserIdAndCompanyIdAndPayPeriodId( $filter_data['user_ids'], $current_company->getId(), $filter_data['pay_period_ids']); $pslf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data); if ($pslf->getRecordCount() > 0 and strlen($filter_data['export_type']) >= 3) { $output = $pslf->exportPayStub($pslf, $filter_data['export_type']); if (Debug::getVerbosity() < 11) { if (stristr($filter_data['export_type'], 'cheque')) { Misc::FileDownloadHeader('checks_' . str_replace(array('/', ',', ' '), '_', TTDate::getDate('DATE', time())) . '.pdf', 'application/pdf', strlen($output)); } else { Misc::FileDownloadHeader('eft_' . str_replace(array('/', ',', ' '), '_', TTDate::getDate('DATE', time())) . '.txt', 'application/text', strlen($output)); } if ($output != FALSE) { echo $output; } else { echo TTi18n::gettext('No data to export.') . "<br>\n"; }
foreach ($psealf as $psea_obj) { //$report_columns[$psen_obj->getId()] = $psen_obj->getDescription(); $report_columns[$psea_obj->getId()] = $psea_obj->getName(); } //var_dump($report_columns); $report_columns = Misc::prependArray($static_columns, $report_columns); $psealf = new PayStubEntryAccountListFactory(); $psealf->getByCompanyId($current_company->getId()); if ($psealf->getRecordCount() > 0) { foreach ($psealf as $psea_obj) { $psea_arr[$psea_obj->getId()] = array('name' => $psea_obj->getName(), 'debit_account' => $psea_obj->getDebitAccount(), 'credit_account' => $psea_obj->getCreditAccount()); } } //var_dump($psea_arr); //Get all pay stubs. $pslf = new PayStubListFactory(); //$pslf->getByUserIdAndCompanyIdAndPayPeriodId( $filter_data['user_ids'], $current_company->getId(), $filter_data['pay_period_ids'] ); $pslf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data); if ($pslf->getRecordCount() > 0) { $ulf = new UserListFactory(); $blf = new BranchListFactory(); $branch_options = $blf->getByCompanyIdArray($current_company->getId()); //Get Branch ID to Branch Code mapping $branch_code_map = array(0 => 0); $blf->getByCompanyId($current_company->getId()); if ($blf->getRecordCount() > 0) { foreach ($blf as $b_obj) { $branch_code_map[$b_obj->getId()] = $b_obj->getManualID(); } } $dlf = new DepartmentListFactory();
function setPayStubStatus($status) { Debug::text('setPayStubStatus: ' . $status, __FILE__, __LINE__, __METHOD__, 10); $this->StartTransaction(); $pslf = new PayStubListFactory(); $pslf->getByPayPeriodId($this->getId()); foreach ($pslf as $pay_stub) { //Only change status of advance pay stubs if we're in the advance part of the pay period. //What if the person is too late, set status anyways? if ($pay_stub->getStatus() != $status) { Debug::text('Changing Status of Pay Stub ID: ' . $pay_stub->getId(), __FILE__, __LINE__, __METHOD__, 10); $pay_stub->setStatus($status); $pay_stub->save(); } } $this->CommitTransaction(); return TRUE; }