예제 #1
0
     if (isset($user_total_ps_entries[$user_id][$pay_stub_entry_name_id])) {
         $user_total_ps_entries[$user_id][$pay_stub_entry_name_id] = bcadd($user_total_ps_entries[$user_id][$pay_stub_entry_name_id], $pse_obj->getColumn('amount'), 2);
     } else {
         $user_total_ps_entries[$user_id][$pay_stub_entry_name_id] = $pse_obj->getColumn('amount');
     }
 }
 $lines_arr[$quarter_id]['p1_1'] = Misc::sumMultipleColumns($ps_entries, $column_ps_entry_name_map['p1_1']);
 $lines_arr[$quarter_id]['p1_2'] = Misc::sumMultipleColumns($ps_entries, $column_ps_entry_name_map['p1_2']);
 $lines_arr[$quarter_id]['p3_under_cutoff'] = 0;
 //Get Line3 for each user.
 foreach ($user_quarter_ps_entries[$quarter_id] as $user_id => $user_quarter_ps_entry_arr) {
     $user_quarter_lines_arr[$user_id]['p1_1'] = Misc::sumMultipleColumns($user_quarter_ps_entry_arr, $column_ps_entry_name_map['p1_1']);
     $user_quarter_lines_arr[$user_id]['p1_2'] = Misc::sumMultipleColumns($user_quarter_ps_entry_arr, $column_ps_entry_name_map['p1_2']);
     $tmp_quarter_user_payment = $user_quarter_lines_arr[$user_id]['p1_1'] - $user_quarter_lines_arr[$user_id]['p1_2'];
     $user_total_lines_arr[$user_id]['p1_1'] = Misc::sumMultipleColumns($user_total_ps_entries[$user_id], $column_ps_entry_name_map['p1_1']);
     $user_total_lines_arr[$user_id]['p1_2'] = Misc::sumMultipleColumns($user_total_ps_entries[$user_id], $column_ps_entry_name_map['p1_2']);
     $tmp_total_user_payment = $user_total_lines_arr[$user_id]['p1_1'] - $user_total_lines_arr[$user_id]['p1_2'];
     Debug::Text('User ID: ' . $user_id . ' Quarter Payment: ' . $tmp_quarter_user_payment . ' Total Payment: ' . $tmp_total_user_payment, __FILE__, __LINE__, __METHOD__, 10);
     if ($tmp_total_user_payment <= $payments_over_cutoff) {
         Debug::Text('Under - Under Cutoff: ' . $tmp_quarter_user_payment, __FILE__, __LINE__, __METHOD__, 10);
         $lines_arr[$quarter_id]['p3_under_cutoff'] += $tmp_quarter_user_payment;
     } else {
         //Handle under cutoff
         $tmp_user_remaining_under_cutoff = $payments_over_cutoff - ($tmp_total_user_payment - $tmp_quarter_user_payment);
         if ($tmp_user_remaining_under_cutoff > 0) {
             Debug::Text('Under - Over Cutoff, Remaining: ' . $tmp_user_remaining_under_cutoff, __FILE__, __LINE__, __METHOD__, 10);
             $lines_arr[$quarter_id]['p3_under_cutoff'] += $payments_over_cutoff - ($tmp_total_user_payment - $tmp_quarter_user_payment);
         } else {
             Debug::Text('Under - WAY Over Cutoff, None remaining...', __FILE__, __LINE__, __METHOD__, 10);
         }
     }
예제 #2
0
 function _outputPDFForm($format = NULL)
 {
     $show_background = TRUE;
     if ($format == 'pdf_form_print' or $format == 'pdf_form_print_government') {
         $show_background = FALSE;
     }
     Debug::Text('Generating Form... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10);
     $setup_data = $this->getFormConfig();
     $filter_data = $this->getFilterConfig();
     //Debug::Arr($setup_data, 'Setup Data: ', __FILE__, __LINE__, __METHOD__,10);
     //Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__,10);
     //Debug::Arr($this->data, 'Data: ', __FILE__, __LINE__, __METHOD__,10);
     //$last_row = count($this->form_data)-1;
     //$total_row = $last_row+1;
     $current_company = $this->getUserObject()->getCompanyObject();
     if (!is_object($current_company)) {
         Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     $this->sortFormData();
     //Make sure forms are sorted.
     if ($format == 'efile_xml') {
         $t619 = $this->getT619Object();
         $t619->setStatus($setup_data['status_id']);
         $t619->transmitter_number = isset($setup_data['transmitter_number']) ? $setup_data['transmitter_number'] : NULL;
         $t619->transmitter_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName();
         $t619->transmitter_address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1();
         $t619->transmitter_address2 = (isset($setup_data['address2']) and $setup_data['address2'] != '') ? $setup_data['address2'] : $current_company->getAddress2();
         $t619->transmitter_city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity();
         $t619->transmitter_province = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince();
         $t619->transmitter_postal_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode();
         $t619->contact_name = $this->getUserObject()->getFullName();
         $t619->contact_phone = $current_company->getWorkPhone();
         $t619->contact_email = $this->getUserObject()->getWorkEmail();
         $this->getFormObject()->addForm($t619);
     }
     $t4 = $this->getT4Object();
     if (isset($setup_data['include_t4_back']) and $setup_data['include_t4_back'] == 1) {
         $t4->setShowInstructionPage(TRUE);
     }
     if (stristr($format, 'government')) {
         $form_type = 'government';
     } else {
         $form_type = 'employee';
     }
     Debug::Text('Form Type: ' . $form_type, __FILE__, __LINE__, __METHOD__, 10);
     $t4->setType($form_type);
     $t4->setStatus($setup_data['status_id']);
     $t4->year = TTDate::getYear($filter_data['start_date']);
     $t4->payroll_account_number = (isset($setup_data['payroll_account_number']) and $setup_data['payroll_account_number'] != '') ? $setup_data['payroll_account_number'] : $current_company->getBusinessNumber();
     $t4->company_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName();
     $i = 0;
     if (is_array($this->form_data)) {
         foreach ($this->form_data as $row) {
             //if ( $i == $last_row ) {
             //	continue;
             //}
             if (!isset($row['user_id'])) {
                 Debug::Text('User ID not set!', __FILE__, __LINE__, __METHOD__, 10);
                 continue;
             }
             $ulf = TTnew('UserListFactory');
             $ulf->getById((int) $row['user_id']);
             if ($ulf->getRecordCount() == 1) {
                 $user_obj = $ulf->getCurrent();
                 $ee_data = array('first_name' => $user_obj->getFirstName(), 'middle_name' => $user_obj->getMiddleName(), 'last_name' => $user_obj->getLastName(), 'address1' => $user_obj->getAddress1(), 'address2' => $user_obj->getAddress2(), 'city' => $user_obj->getCity(), 'province' => $user_obj->getProvince(), 'employment_province' => $user_obj->getProvince(), 'postal_code' => $user_obj->getPostalCode(), 'sin' => $user_obj->getSIN(), 'employee_number' => $user_obj->getEmployeeNumber(), 'l14' => $row['income'], 'l22' => $row['tax'], 'l16' => $row['employee_cpp'], 'l24' => $row['ei_earnings'], 'l26' => $row['cpp_earnings'], 'l18' => $row['employee_ei'], 'l44' => $row['union_dues'], 'l20' => $row['rpp'], 'l46' => $row['charity'], 'l52' => $row['pension_adjustment'], 'l50' => $setup_data['rpp_number'], 'cpp_exempt' => FALSE, 'ei_exempt' => FALSE, 'other_box_0_code' => NULL, 'other_box_0' => NULL, 'other_box_1_code' => NULL, 'other_box_1' => NULL, 'other_box_2_code' => NULL, 'other_box_2' => NULL, 'other_box_3_code' => NULL, 'other_box_3' => NULL, 'other_box_4_code' => NULL, 'other_box_4' => NULL, 'other_box_5_code' => NULL, 'other_box_5' => NULL);
                 //Get User Tax / Deductions by Pay Stub Account.
                 $udlf = TTnew('UserDeductionListFactory');
                 if (isset($setup_data['employee_cpp']['include_pay_stub_entry_account'])) {
                     $udlf->getByUserIdAndPayStubEntryAccountID($user_obj->getId(), $setup_data['employee_cpp']['include_pay_stub_entry_account']);
                     //FIXME: What if they were CPP exempt because of age, so no CPP was taken off, but they are assigned to the Tax/Deduction?
                     //Don't think there is much we can do about this for now.
                     if ($setup_data['employee_cpp']['include_pay_stub_entry_account'] != 0 and $udlf->getRecordCount() == 0 and $row['employee_cpp'] == 0) {
                         //Debug::Text('CPP Exempt!', __FILE__, __LINE__, __METHOD__,10);
                         $ee_data['cpp_exempt'] = TRUE;
                     }
                 }
                 if (isset($setup_data['employee_ei']['include_pay_stub_entry_account'])) {
                     $udlf->getByUserIdAndPayStubEntryAccountID($user_obj->getId(), $setup_data['employee_ei']['include_pay_stub_entry_account']);
                     if ($setup_data['employee_ei']['include_pay_stub_entry_account'] != 0 and $udlf->getRecordCount() == 0 and $row['employee_ei'] == 0) {
                         //Debug::Text('EI Exempt!', __FILE__, __LINE__, __METHOD__,10);
                         $ee_data['ei_exempt'] = TRUE;
                     }
                 }
                 if ($row['other_box_0'] > 0 and isset($setup_data['other_box'][0]['box']) and $setup_data['other_box'][0]['box'] != '') {
                     $ee_data['other_box_0_code'] = $setup_data['other_box'][0]['box'];
                     $ee_data['other_box_0'] = $row['other_box_0'];
                 }
                 if ($row['other_box_1'] > 0 and isset($setup_data['other_box'][1]['box']) and $setup_data['other_box'][1]['box'] != '') {
                     $ee_data['other_box_1_code'] = $setup_data['other_box'][1]['box'];
                     $ee_data['other_box_1'] = $row['other_box_1'];
                 }
                 if ($row['other_box_2'] > 0 and isset($setup_data['other_box'][2]['box']) and $setup_data['other_box'][2]['box'] != '') {
                     $ee_data['other_box_2_code'] = $setup_data['other_box'][2]['box'];
                     $ee_data['other_box_2'] = $row['other_box_2'];
                 }
                 if ($row['other_box_3'] > 0 and isset($setup_data['other_box'][3]['box']) and $setup_data['other_box'][3]['box'] != '') {
                     $ee_data['other_box_3_code'] = $setup_data['other_box'][3]['box'];
                     $ee_data['other_box_3'] = $row['other_box_3'];
                 }
                 if ($row['other_box_4'] > 0 and isset($setup_data['other_box'][4]['box']) and $setup_data['other_box'][4]['box'] != '') {
                     $ee_data['other_box_4_code'] = $setup_data['other_box'][4]['box'];
                     $ee_data['other_box_4'] = $row['other_box_4'];
                 }
                 if ($row['other_box_5'] > 0 and isset($setup_data['other_box'][5]['box']) and $setup_data['other_box'][5]['box'] != '') {
                     $ee_data['other_box_5_code'] = $setup_data['other_box'][5]['box'];
                     $ee_data['other_box_5'] = $row['other_box_5'];
                 }
                 $t4->addRecord($ee_data);
                 unset($ee_data);
                 $i++;
             }
         }
         $this->getFormObject()->addForm($t4);
     }
     //Handle T4Summary
     $t4s = $this->getT4SumObject();
     $t4s->setStatus($setup_data['status_id']);
     $t4s->year = $t4->year;
     $t4s->payroll_account_number = $t4->payroll_account_number;
     $t4s->company_name = $t4->company_name;
     $t4s->company_address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1();
     $t4s->company_address2 = (isset($setup_data['address2']) and $setup_data['address2'] != '') ? $setup_data['address2'] : $current_company->getAddress2();
     $t4s->company_city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity();
     $t4s->company_province = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince();
     $t4s->company_postal_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode();
     $t4s->l76 = $this->getUserObject()->getFullName();
     //Contact name.
     $t4s->l78 = $current_company->getWorkPhone();
     $total_row = Misc::ArrayAssocSum($this->form_data);
     $t4s->l88 = count($this->form_data);
     $t4s->l14 = $total_row['income'];
     $t4s->l22 = $total_row['tax'];
     $t4s->l16 = $total_row['employee_cpp'];
     $t4s->l18 = $total_row['employee_ei'];
     $t4s->l27 = $total_row['employer_cpp'];
     $t4s->l19 = $total_row['employer_ei'];
     $t4s->l20 = $total_row['rpp'];
     $t4s->l52 = $total_row['pension_adjustment'];
     $total_deductions = Misc::MoneyFormat(Misc::sumMultipleColumns($total_row, array('tax', 'employee_cpp', 'employee_ei', 'employer_cpp', 'employer_ei')), FALSE);
     $t4s->l82 = $total_deductions;
     $this->getFormObject()->addForm($t4s);
     if ($format == 'efile_xml') {
         $output_format = 'XML';
         $file_name = 't4_efile_' . date('Y_m_d') . '.xml';
         $mime_type = 'applications/octet-stream';
         //Force file to download.
     } else {
         $output_format = 'PDF';
         $file_name = $this->file_name . '.pdf';
         $mime_type = $this->file_mime_type;
     }
     $output = $this->getFormObject()->output($output_format);
     if (!is_array($output)) {
         return array('file_name' => $file_name, 'mime_type' => $mime_type, 'data' => $output);
     }
     return $output;
 }
예제 #3
0
     $x = 0;
     foreach ($raw_rows as $user_id => $raw_row) {
         $user_obj = $ulf->getById($user_id)->getCurrent();
         $tmp_rows[$x]['user_id'] = $user_id;
         $tmp_rows[$x]['full_name'] = $user_obj->getFullName(TRUE);
         //$tmp_rows[$x]['province'] = Option::getByKey($user_obj->getProvince(), $user_obj->getOptions('province') );
         //$tmp_rows[$x]['province'] = $user_obj->getProvince();
         $tmp_rows[$x]['province'] = $user_obj->getProvince();
         $tmp_rows[$x]['country'] = $user_obj->getCountry();
         $tmp_rows[$x]['title'] = Option::getByKey($user_obj->getTitle(), $title_options, NULL);
         $tmp_rows[$x]['group'] = Option::getByKey($user_obj->getGroup(), $group_options);
         $tmp_rows[$x]['default_branch'] = Option::getByKey($user_obj->getDefaultBranch(), $branch_options, NULL);
         $tmp_rows[$x]['default_department'] = Option::getByKey($user_obj->getDefaultDepartment(), $department_options, NULL);
         $tmp_rows[$x]['sin'] = $user_obj->getSIN();
         foreach ($column_ps_entry_name_map as $column_key => $ps_entry_map) {
             $tmp_rows[$x][$column_key] = Misc::MoneyFormat(Misc::sumMultipleColumns($raw_rows[$user_id], $ps_entry_map), FALSE);
         }
         $x++;
     }
 }
 //var_dump($tmp_rows);
 //Skip grouping if they are displaying T4's
 if ($action != 'display_t4s' and isset($filter_data['primary_group_by']) and $filter_data['primary_group_by'] != '0') {
     Debug::Text('Primary Grouping Data By: ' . $filter_data['primary_group_by'], __FILE__, __LINE__, __METHOD__, 10);
     $ignore_elements = array_keys($static_columns);
     $filter_data['column_ids'] = array_diff($filter_data['column_ids'], $ignore_elements);
     //Add the group by element back in
     if (isset($filter_data['secondary_group_by']) and $filter_data['secondary_group_by'] != 0) {
         array_unshift($filter_data['column_ids'], $filter_data['primary_group_by'], $filter_data['secondary_group_by']);
     } else {
         array_unshift($filter_data['column_ids'], $filter_data['primary_group_by']);
예제 #4
0
                     if ($tax_deduction_arr['calculation_id'] == 200 and $tax_deduction_arr['province'] != '') {
                         //State Wages/Taxes
                         //Handle two states here, just check if $tmp_rows[$x]['state_1'] isset,
                         //if it is, move on to state 2.
                         $tmp_rows[$x]['state_1'] = $tax_deduction_arr['province'];
                         $tmp_rows[$x]['state_wage_1'] = Misc::MoneyFormat(Misc::sumMultipleColumns($raw_rows[$user_id], $tax_deduction_arr['include']), FALSE);
                         $tmp_rows[$x]['state_tax_1'] = Misc::MoneyFormat(Misc::sumMultipleColumns($raw_rows[$user_id], array($tax_deduction_arr['pay_stub_entry_account_id'])), FALSE);
                     } elseif ($tax_deduction_arr['calculation_id'] == 300 and ($tax_deduction_arr['district'] != '' or $tax_deduction_arr['company_value1'] != '')) {
                         //District Wages/Taxes
                         if ($tax_deduction_arr['district'] == '' and $tax_deduction_arr['company_value1'] != '') {
                             $tmp_rows[$x]['district_1'] = $tax_deduction_arr['company_value1'];
                         } else {
                             $tmp_rows[$x]['district_1'] = $tax_deduction_arr['district'];
                         }
                         $tmp_rows[$x]['district_wage_1'] = Misc::MoneyFormat(Misc::sumMultipleColumns($raw_rows[$user_id], $tax_deduction_arr['include']), FALSE);
                         $tmp_rows[$x]['district_tax_1'] = Misc::MoneyFormat(Misc::sumMultipleColumns($raw_rows[$user_id], array($tax_deduction_arr['pay_stub_entry_account_id'])), FALSE);
                     } else {
                         //Debug::Text('Not State or Local income tax: '. $tax_deduction_arr['id'] .' Calculation: '. $tax_deduction_arr['calculation_id'] .' District: '. $tax_deduction_arr['district'] .' UserValue5: '.$tax_deduction_arr['user_value5'] .' CompanyValue1: '. $tax_deduction_arr['company_value1'], __FILE__, __LINE__, __METHOD__,10);
                     }
                 } else {
                     Debug::Text('DID NOT Find user in Tax Deduction ID: ' . $tax_deduction_arr['id'], __FILE__, __LINE__, __METHOD__, 10);
                 }
             }
         } else {
             Debug::Text('No Tax Deductions...', __FILE__, __LINE__, __METHOD__, 10);
         }
         $x++;
     }
 }
 //print_r($tmp_rows);
 if (isset($tmp_rows)) {
예제 #5
0
 function _outputPDFForm($format = NULL)
 {
     $show_background = TRUE;
     if ($format == 'pdf_form_print' or $format == 'pdf_form_print_government') {
         $show_background = FALSE;
     }
     Debug::Text('Generating Form... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10);
     $setup_data = $this->getFormConfig();
     $filter_data = $this->getFilterConfig();
     //Debug::Arr($setup_data, 'Setup Data: ', __FILE__, __LINE__, __METHOD__,10);
     //Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__,10);
     //Debug::Arr($this->data, 'Data: ', __FILE__, __LINE__, __METHOD__,10);
     //$last_row = count($this->form_data)-1;
     //$total_row = $last_row+1;
     $current_company = $this->getUserObject()->getCompanyObject();
     if (!is_object($current_company)) {
         Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     $this->sortFormData();
     //Make sure forms are sorted.
     if ($format == 'efile_xml') {
         $t619 = $this->getT619Object();
         $t619->setStatus($setup_data['status_id']);
         $t619->transmitter_number = isset($setup_data['transmitter_number']) ? $setup_data['transmitter_number'] : NULL;
         $t619->transmitter_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName();
         $t619->transmitter_address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1();
         $t619->transmitter_address2 = (isset($setup_data['address2']) and $setup_data['address2'] != '') ? $setup_data['address2'] : $current_company->getAddress2();
         $t619->transmitter_city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity();
         $t619->transmitter_province = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince();
         $t619->transmitter_postal_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode();
         $t619->contact_name = $this->getUserObject()->getFullName();
         $t619->contact_phone = $current_company->getWorkPhone();
         $t619->contact_email = $this->getUserObject()->getWorkEmail();
         $this->getFormObject()->addForm($t619);
     }
     $t4a = $this->getT4AObject();
     if (isset($setup_data['include_t4a_back']) and $setup_data['include_t4a_back'] == 1) {
         $t4a->setShowInstructionPage(TRUE);
     }
     if (stristr($format, 'government')) {
         $form_type = 'government';
     } else {
         $form_type = 'employee';
     }
     Debug::Text('Form Type: ' . $form_type, __FILE__, __LINE__, __METHOD__, 10);
     $t4a->setType($form_type);
     $t4a->setStatus($setup_data['status_id']);
     $t4a->year = TTDate::getYear($filter_data['start_date']);
     $t4a->payroll_account_number = (isset($setup_data['payroll_account_number']) and $setup_data['payroll_account_number'] != '') ? $setup_data['payroll_account_number'] : $current_company->getBusinessNumber();
     $t4a->company_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName();
     $i = 0;
     foreach ($this->form_data as $row) {
         //if ( $i == $last_row ) {
         //	continue;
         //}
         if (!isset($row['user_id'])) {
             Debug::Text('User ID not set!', __FILE__, __LINE__, __METHOD__, 10);
             continue;
         }
         $ulf = TTnew('UserListFactory');
         $ulf->getById((int) $row['user_id']);
         if ($ulf->getRecordCount() == 1) {
             $user_obj = $ulf->getCurrent();
             $ee_data = array('first_name' => $user_obj->getFirstName(), 'middle_name' => $user_obj->getMiddleName(), 'last_name' => $user_obj->getLastName(), 'address1' => $user_obj->getAddress1(), 'address2' => $user_obj->getAddress2(), 'city' => $user_obj->getCity(), 'province' => $user_obj->getProvince(), 'employment_province' => $user_obj->getProvince(), 'postal_code' => $user_obj->getPostalCode(), 'sin' => $user_obj->getSIN(), 'employee_number' => $user_obj->getEmployeeNumber(), 'l16' => $row['pension'], 'l22' => $row['income_tax'], 'l18' => $row['lump_sum_payment'], 'l20' => $row['self_employed_commission'], 'l24' => $row['annuities'], 'l48' => $row['service_fees'], 'other_box_0_code' => NULL, 'other_box_0' => NULL, 'other_box_1_code' => NULL, 'other_box_1' => NULL, 'other_box_2_code' => NULL, 'other_box_2' => NULL, 'other_box_3_code' => NULL, 'other_box_3' => NULL, 'other_box_4_code' => NULL, 'other_box_4' => NULL, 'other_box_5_code' => NULL, 'other_box_5' => NULL);
             if ($row['other_box_0'] > 0 and isset($setup_data['other_box'][0]['box']) and $setup_data['other_box'][0]['box'] != '') {
                 $ee_data['other_box_0_code'] = $setup_data['other_box'][0]['box'];
                 $ee_data['other_box_0'] = $row['other_box_0'];
             }
             if ($row['other_box_1'] > 0 and isset($setup_data['other_box'][1]['box']) and $setup_data['other_box'][1]['box'] != '') {
                 $ee_data['other_box_1_code'] = $setup_data['other_box'][1]['box'];
                 $ee_data['other_box_1'] = $row['other_box_1'];
             }
             if ($row['other_box_2'] > 0 and isset($setup_data['other_box'][2]['box']) and $setup_data['other_box'][2]['box'] != '') {
                 $ee_data['other_box_2_code'] = $setup_data['other_box'][2]['box'];
                 $ee_data['other_box_2'] = $row['other_box_2'];
             }
             if ($row['other_box_3'] > 0 and isset($setup_data['other_box'][3]['box']) and $setup_data['other_box'][3]['box'] != '') {
                 $ee_data['other_box_3_code'] = $setup_data['other_box'][3]['box'];
                 $ee_data['other_box_3'] = $row['other_box_3'];
             }
             if ($row['other_box_4'] > 0 and isset($setup_data['other_box'][4]['box']) and $setup_data['other_box'][4]['box'] != '') {
                 $ee_data['other_box_4_code'] = $setup_data['other_box'][4]['box'];
                 $ee_data['other_box_4'] = $row['other_box_4'];
             }
             $t4a->addRecord($ee_data);
             unset($ee_data);
             $i++;
         }
     }
     $this->getFormObject()->addForm($t4a);
     //Handle T4ASummary
     $t4as = $this->getT4ASumObject();
     $t4as->setStatus($setup_data['status_id']);
     $t4as->year = $t4a->year;
     $t4as->payroll_account_number = $t4a->payroll_account_number;
     $t4as->company_name = $t4a->company_name;
     $t4as->company_address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1();
     $t4as->company_address2 = (isset($setup_data['address2']) and $setup_data['address2'] != '') ? $setup_data['address2'] : $current_company->getAddress2();
     $t4as->company_city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity();
     $t4as->company_province = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince();
     $t4as->company_postal_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode();
     $t4as->l76 = $this->getUserObject()->getFullName();
     //Contact name.
     $t4as->l78 = $current_company->getWorkPhone();
     $total_row = Misc::ArrayAssocSum($this->form_data);
     $t4as->l88 = count($this->form_data);
     $t4as->l16 = $total_row['pension'];
     $t4as->l22 = $total_row['income_tax'];
     $t4as->l18 = $total_row['lump_sum_payment'];
     $t4as->l20 = $total_row['self_employed_commission'];
     $t4as->l24 = $total_row['annuities'];
     $t4as->l48 = $total_row['service_fees'];
     if (isset($setup_data['other_box'])) {
         foreach ($setup_data['other_box'] as $key => $other_box_data) {
             //Debug::Text('zFound other box total for T4A Sum: '. $key .' Code: '. $other_box_data['box'], __FILE__, __LINE__, __METHOD__,10);
             if (in_array((int) $other_box_data['box'], array(28, 30, 32, 34, 40, 42))) {
                 //Debug::Text('Found other box total for T4A Sum: '. $key .' Code: '. $other_box_data['box'], __FILE__, __LINE__, __METHOD__,10);
                 $object_var = 'l' . (int) $other_box_data['box'];
                 $t4as->{$object_var} = $total_row['other_box_' . $key];
                 unset($object_var);
             }
         }
     }
     unset($other_box_data, $key);
     $total_other_deductions = Misc::MoneyFormat(Misc::sumMultipleColumns($total_row, array('other_box_0', 'other_box_1', 'other_box_2', 'other_box_3', 'other_box_4')), FALSE);
     $t4as->l101 = $total_other_deductions;
     //$total_deductions = Misc::MoneyFormat( Misc::sumMultipleColumns( $total_row, array('pension','income_tax','lump_sum_payment', 'self_employed_commission', 'annuities','service_fees') ), FALSE );
     //$t4as->l82 = $total_deductions;
     $t4as->l82 = $total_row['income_tax'];
     $this->getFormObject()->addForm($t4as);
     if ($format == 'efile_xml') {
         $output_format = 'XML';
         $file_name = 't4a_efile_' . date('Y_m_d') . '.xml';
         $mime_type = 'applications/octet-stream';
         //Force file to download.
     } else {
         $output_format = 'PDF';
         $file_name = $this->file_name;
         $mime_type = $this->file_mime_type;
     }
     $output = $this->getFormObject()->output($output_format);
     return array('file_name' => $file_name, 'mime_type' => $mime_type, 'data' => $output);
 }
예제 #6
0
         if (in_array($user_id, $tax_deduction_arr['user_ids'])) {
             Debug::Text('Found user in Tax Deduction ID: ' . $tax_deduction_arr['id'] . ' Pay Stub Entry Account ID: ' . $tax_deduction_arr['pay_stub_entry_account_id'], __FILE__, __LINE__, __METHOD__, 10);
             if ($tax_deduction_arr['province'] != '' and $tax_deduction_arr['district'] == '') {
                 //State Wages/Taxes
                 //Handle two states here, just check if $tmp_rows[$x]['state_1'] isset,
                 //if it is, move on to state 2.
                 $lines_arr['state'][] = array('state' => $tax_deduction_arr['province'], 'wage' => Misc::MoneyFormat(Misc::sumMultipleColumns($raw_row, $tax_deduction_arr['include']), FALSE), 'tax' => Misc::MoneyFormat(Misc::sumMultipleColumns($raw_row, array($tax_deduction_arr['pay_stub_entry_account_id'])), FALSE));
             }
         } else {
             Debug::Text('DID NOT Find user in Tax Deduction ID: ' . $tax_deduction_arr['id'], __FILE__, __LINE__, __METHOD__, 10);
         }
     }
 }
 $lines_arr['4'] = Misc::sumMultipleColumns($raw_row, $column_ps_entry_name_map['4']);
 $lines_arr['6'] = Misc::sumMultipleColumns($raw_row, $column_ps_entry_name_map['6']);
 $lines_arr['7'] = Misc::sumMultipleColumns($raw_row, $column_ps_entry_name_map['7']);
 //print_r($lines_arr);
 $pdf->setMargins(0, 0, 0, 0);
 $pdf->SetAutoPageBreak(FALSE);
 $pdf->SetFont('freeserif', '', 10);
 $pages = array(1, 2, 4, 5);
 foreach ($pages as $page) {
     $pdf->AddPage();
     if (isset($tplidx[$page])) {
         $pdf->useTemplate($tplidx[$page], 0, 0);
     }
     if ($show_background == TRUE) {
         $pdf->SetFont('freeserif', 'B', 24);
         $pdf->setFillColor(255, 255, 255);
         if ($page == 1) {
             $pdf->setXY(Misc::AdjustXY(152, $adjust_x), Misc::AdjustXY(28, $adjust_y));
예제 #7
0
         $user_quarter_ps_entries[$quarter_id][$user_id][$pay_stub_entry_name_id] = $pse_obj->getColumn('amount');
     }
     if (isset($user_total_ps_entries[$user_id][$pay_stub_entry_name_id])) {
         $user_total_ps_entries[$user_id][$pay_stub_entry_name_id] = bcadd($user_total_ps_entries[$user_id][$pay_stub_entry_name_id], $pse_obj->getColumn('amount'), 2);
     } else {
         $user_total_ps_entries[$user_id][$pay_stub_entry_name_id] = $pse_obj->getColumn('amount');
     }
 }
 $lines_arr[$quarter_id]['p2_3'] = Misc::sumMultipleColumns($ps_entries, $column_ps_entry_name_map['p2_3']);
 $lines_arr[$quarter_id]['p2_4'] = Misc::sumMultipleColumns($ps_entries, $column_ps_entry_name_map['p2_4']);
 $lines_arr[$quarter_id]['p2_5'] = 0;
 //Get over cutoff amounts for each user.
 $i = 0;
 foreach ($user_quarter_ps_entries[$quarter_id] as $user_id => $user_quarter_ps_entry_arr) {
     $user_quarter_lines_arr[$user_id]['p2_3'] = Misc::sumMultipleColumns($user_quarter_ps_entry_arr, $column_ps_entry_name_map['p2_3']);
     $user_quarter_lines_arr[$user_id]['p2_4'] = Misc::sumMultipleColumns($user_quarter_ps_entry_arr, $column_ps_entry_name_map['p2_4']);
     $tmp_quarter_user_payment = $user_quarter_lines_arr[$user_id]['p2_3'] - $user_quarter_lines_arr[$user_id]['p2_4'];
     if (!isset($user_total_lines_arr[$user_id]['p2_3'])) {
         $user_total_lines_arr[$user_id]['p2_3'] = 0;
     }
     if (!isset($user_total_lines_arr[$user_id]['p2_4'])) {
         $user_total_lines_arr[$user_id]['p2_4'] = 0;
     }
     if (!isset($user_total_lines_arr[$user_id]['p2_5'])) {
         $user_total_lines_arr[$user_id]['p2_5'] = 0;
     }
     if (!isset($user_total_lines_arr[$user_id]['total_payment'])) {
         $user_total_lines_arr[$user_id]['total_payment'] = 0;
     }
     $user_total_lines_arr[$user_id]['p2_3'] += $user_quarter_lines_arr[$user_id]['p2_3'];
     $user_total_lines_arr[$user_id]['p2_4'] += $user_quarter_lines_arr[$user_id]['p2_4'];
예제 #8
0
             if (isset($ps_entries)) {
                 $pp_lines_arr[$month_id][$pay_period_id]['2'] = Misc::sumMultipleColumns($ps_entries, $column_ps_entry_name_map['2']);
                 $pp_lines_arr[$month_id][$pay_period_id]['3'] = Misc::sumMultipleColumns($ps_entries, $column_ps_entry_name_map['3']);
                 $pp_lines_arr[$month_id][$pay_period_id]['5a'] = Misc::sumMultipleColumns($ps_entries, $column_ps_entry_name_map['5a']);
                 $pp_lines_arr[$month_id][$pay_period_id]['5a2'] = bcmul($pp_lines_arr[$month_id][$pay_period_id]['5a'], $f941->social_security_rate);
                 $pp_lines_arr[$month_id][$pay_period_id]['5b'] = Misc::sumMultipleColumns($ps_entries, $column_ps_entry_name_map['5b']);
                 $pp_lines_arr[$month_id][$pay_period_id]['5b2'] = bcmul($pp_lines_arr[$month_id][$pay_period_id]['5b'], $f941->social_security_rate);
                 $pp_lines_arr[$month_id][$pay_period_id]['5c'] = Misc::sumMultipleColumns($ps_entries, $column_ps_entry_name_map['5c']);
                 $pp_lines_arr[$month_id][$pay_period_id]['5c2'] = bcmul($pp_lines_arr[$month_id][$pay_period_id]['5c'], $f941->medicare_rate);
                 $pp_lines_arr[$month_id][$pay_period_id]['5d'] = bcadd(bcadd($pp_lines_arr[$month_id][$pay_period_id]['5a2'], $pp_lines_arr[$month_id][$pay_period_id]['5b2']), $pp_lines_arr[$month_id][$pay_period_id]['5c2']);
                 $pp_lines_arr[$month_id][$pay_period_id]['6'] = bcadd($pp_lines_arr[$month_id][$pay_period_id]['3'], $pp_lines_arr[$month_id][$pay_period_id]['5d']);
                 $pp_lines_arr[$month_id][$pay_period_id]['7a'] = bcsub(Misc::MoneyFormat($pp_lines_arr[$month_id][$pay_period_id]['5d'], FALSE), bcadd(bcadd($pp_lines_arr[$month_id][$pay_period_id]['5a2'], $pp_lines_arr[$month_id][$pay_period_id]['5b2']), $pp_lines_arr[$month_id][$pay_period_id]['5c2']));
                 $pp_lines_arr[$month_id][$pay_period_id]['7b'] = Misc::sumMultipleColumns($ps_entries, $column_ps_entry_name_map['7b']);
                 $pp_lines_arr[$month_id][$pay_period_id]['7d'] = bcadd($pp_lines_arr[$month_id][$pay_period_id]['7a'], $pp_lines_arr[$month_id][$pay_period_id]['7b']);
                 $pp_lines_arr[$month_id][$pay_period_id]['8'] = bcadd($pp_lines_arr[$month_id][$pay_period_id]['6'], $pp_lines_arr[$month_id][$pay_period_id]['7d']);
                 $pp_lines_arr[$month_id][$pay_period_id]['9'] = abs(Misc::sumMultipleColumns($ps_entries, $column_ps_entry_name_map['9']));
                 $pp_lines_arr[$month_id][$pay_period_id]['10'] = bcsub($pp_lines_arr[$month_id][$pay_period_id]['8'], $pp_lines_arr[$month_id][$pay_period_id]['9']);
             }
             unset($ps_entries);
         }
         //Total all pay periods by month_id
         if (isset($pp_lines_arr)) {
             foreach ($pp_lines_arr as $month_id => $pp_data) {
                 $lines_arr[$month_id] = Misc::ArrayAssocSum($pp_data, NULL, 8);
             }
         }
     }
     unset($pay_period_ids, $ps_entries);
 }
 if (isset($lines_arr)) {
     $lines_arr['total'] = Misc::ArrayAssocSum($lines_arr, NULL, 6);
예제 #9
0
 $x = 0;
 foreach ($raw_rows as $user_id => $raw_row) {
     $user_obj = $ulf->getById($user_id)->getCurrent();
     //Handle state/district data here
     //FIXME: Loop through each raw_row pay stub account IDs, and match them to tax deductions
     //that way if a user is removed from a tax deduction half way through the year it will
     //still match up, assuming it isn't deleted.
     if (isset($tax_deductions) and isset($tax_deductions['user_ids'])) {
         foreach ($tax_deductions as $tax_deduction_arr) {
             if (in_array($user_id, $tax_deduction_arr['user_ids'])) {
                 Debug::Text('Found user in Tax Deduction ID: ' . $tax_deduction_arr['id'] . ' Pay Stub Entry Account ID: ' . $tax_deduction_arr['pay_stub_entry_account_id'], __FILE__, __LINE__, __METHOD__, 10);
                 if ($tax_deduction_arr['province'] != '' and $tax_deduction_arr['district'] == '') {
                     //State Wages/Taxes
                     //Handle two states here, just check if $tmp_rows[$x]['state_1'] isset,
                     //if it is, move on to state 2.
                     $lines_arr['state'][] = array('state' => $tax_deduction_arr['province'], 'wage' => Misc::MoneyFormat(Misc::sumMultipleColumns($raw_row, $tax_deduction_arr['include']), FALSE), 'tax' => Misc::MoneyFormat(Misc::sumMultipleColumns($raw_row, array($tax_deduction_arr['pay_stub_entry_account_id'])), FALSE));
                 }
             } else {
                 Debug::Text('DID NOT Find user in Tax Deduction ID: ' . $tax_deduction_arr['id'], __FILE__, __LINE__, __METHOD__, 10);
             }
         }
     }
     $lines_arr['4'] = Misc::calculateMultipleColumns($raw_row, $column_ps_entry_name_map['4'][0], $column_ps_entry_name_map['4'][1]);
     $lines_arr['6'] = Misc::calculateMultipleColumns($raw_row, $column_ps_entry_name_map['6'][0], $column_ps_entry_name_map['6'][1]);
     $lines_arr['7'] = Misc::calculateMultipleColumns($raw_row, $column_ps_entry_name_map['7'][0], $column_ps_entry_name_map['7'][1]);
     //print_r($lines_arr);
     $pdf->setMargins(0, 0, 0, 0);
     $pdf->SetAutoPageBreak(FALSE);
     $pdf->SetFont('freeserif', '', 10);
     $pages = array(1, 2, 4, 5);
     foreach ($pages as $page) {