function calcAnnualPayPeriods() { switch ($this->getType()) { case 5: //We need the annual number of pay periods calculated for manual pay period schedules if we //are to have any hope of calculating taxes correctly. //Get all the pay periods, take the first day, last day, and the total number to figure out an average //number of days per period. //Alternatively have them manually specify the number, but this required adding a field to the table. $retval = FALSE; if ($this->getId() > 0) { $pplf = new PayPeriodListFactory(); $retarr = $pplf->getFirstStartDateAndLastEndDateByPayPeriodScheduleId($this->getId()); if (is_array($retarr) and isset($retarr['first_start_date']) and isset($retarr['last_end_date'])) { $retarr['first_start_date'] = TTDate::strtotime($retarr['first_start_date']); $retarr['last_end_date'] = TTDate::strtotime($retarr['last_end_date']); $days_per_period = ($retarr['last_end_date'] - $retarr['first_start_date']) / $retarr['total'] / 86400; $retval = floor(365 / round($days_per_period)); Debug::text('First Start Date: ' . TTDate::getDate('DATE+TIME', $retarr['first_start_date']) . ' Last End Date: ' . TTDate::getDate('DATE+TIME', $retarr['last_end_date']) . ' Total PP: ' . $retarr['total'] . ' Average Days/Period: ' . $days_per_period . '(' . round($days_per_period) . ') Annual Pay Periods: ' . $retval, __FILE__, __LINE__, __METHOD__, 10); } unset($pplf, $retarr); } break; case 10: $retval = 52; break; case 20: $retval = 26; break; case 30: $retval = 24; //Semi-monthly break; case 40: $retval = 12; //Monthly + advance, deductions only once per month break; case 50: $retval = 12; break; default: return FALSE; break; } return $retval; }