Ejemplo n.º 1
0
 public static function fetchPersonalHspSummary($year, $empId)
 {
     parent::updateAccrued($year);
     // Update 'total_accrued' for $year
     //parent::updateUsed($year); // Update 'total_used' for $year
     self::_broughtForwardHspBalance();
     $selectTable = parent::DB_TABLE_HSP_SUMMARY;
     $selectFields[0] = "*";
     $selectConditions[0] = "`" . parent::DB_FIELD_HSP_PLAN_YEAR . "` = " . $year;
     $hspPlanId = Config::getHspCurrentPlan();
     $selectConditions[1] = parent::_twoHspPlansCondition($hspPlanId);
     $selectConditions[2] = "`" . parent::DB_FIELD_EMPLOYEE_ID . "` = " . $empId;
     $selectOrderBy = "`" . parent::DB_FIELD_HSP_PLAN_ID . "`";
     $selectOrder = "ASC";
     $sqlBuilder = new SQLQBuilder();
     $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions, $selectOrderBy, $selectOrder);
     $dbConnection = new DMLFunctions();
     $result = $dbConnection->executeQuery($query);
     $hsbObjArr = self::_buildSummaryObjects($result);
     return $hsbObjArr;
 }
Ejemplo n.º 2
0
 public function testUpdateAccruedForTwoPlans()
 {
     $this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_pay_period`"));
     $this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_hsp_summary`"));
     // Here 'check dates' don't mach with pay periods. They have been added to get three past check dates from current day.
     $this->assertTrue(mysql_query("INSERT INTO hs_hr_pay_period VALUES(1, '" . date('Y') . "-01-01', '" . date('Y') . "-01-31', '" . date('Y') . "-01-31', '" . date('Y-m-d', time() - 3600 * 24 * 3) . "', '" . date('Y') . "-01-20')"));
     $this->assertTrue(mysql_query("INSERT INTO hs_hr_pay_period VALUES(2, '" . date('Y') . "-02-01', '" . date('Y') . "-02-29', '" . date('Y') . "-02-29', '" . date('Y-m-d', time() - 3600 * 24 * 2) . "', '" . date('Y') . "-02-20')"));
     $this->assertTrue(mysql_query("INSERT INTO hs_hr_pay_period VALUES(3, '" . date('Y') . "-03-01', '" . date('Y') . "-03-31', '" . date('Y') . "-03-31', '" . date('Y-m-d', time() - 3600 * 24 * 1) . "', '" . date('Y') . "-03-20')"));
     // Summary Insert
     $this->assertTrue(mysql_query("INSERT INTO hs_hr_hsp_summary VALUES(1, 1, 1, '" . date('Y') . "', 1, 1500, 50, 50, 0, 0)"), mysql_error());
     $this->assertTrue(mysql_query("INSERT INTO hs_hr_hsp_summary VALUES(2, 1, 3, '" . date('Y') . "', 1, 2500, 75, 75, 0, 0)"), mysql_error());
     $this->assertTrue(mysql_query("UPDATE `hs_hr_config` SET `value` = '" . (date('Y') - 1) . "-12-31' WHERE `key` = 'hsp_accrued_last_updated'"));
     $result = mysql_query("SELECT COUNT(*) FROM `hs_hr_pay_period` WHERE `check_date` < '" . date('Y-m-d') . "'");
     $resultArray = mysql_fetch_array($result);
     $expectedAccrued1 = 100 * $resultArray[0];
     // 100 comes from Summary Insert (50+50)
     $expectedAccrued2 = 150 * $resultArray[0];
     $this->assertTrue(mysql_query("UPDATE `hs_hr_config` SET `value` = '4' WHERE `key` = 'hsp_current_plan'"));
     Hsp::updateAccrued(date('Y'));
     // total_accrued is calculated by function and should be equal to $expectedAccrued
     $result = mysql_query("SELECT `total_accrued` FROM `hs_hr_hsp_summary` WHERE `summary_id` = 1");
     $resultArray = mysql_fetch_array($result);
     $this->assertEquals($expectedAccrued1, $resultArray[0]);
     $result = mysql_query("SELECT `total_accrued` FROM `hs_hr_hsp_summary` WHERE `summary_id` = 2");
     $resultArray = mysql_fetch_array($result);
     $this->assertEquals($expectedAccrued2, $resultArray[0]);
 }