* test contract dates on update dependent
* must not throw the HumanResources_Exception_ContractNotEditable exception
*/
-
public function testContractDates()
{
$employmentBegin = Tinebase_DateTime::now()->setDate(2014, 1, 2)->setTimezone(Tinebase_Core::getUserTimezone())->setTime(0,0,0);
/**
* test adding a contract with manually setting the end_date of the contract before
+ *
+ * @see 0011962: contract end_date can't be changed if vacation has been added
*/
public function testAddContract()
{
// no exception should be thrown
$employeeJson = $this->_json->saveEmployee($employeeJson);
$this->assertEquals(2, count($employeeJson['contracts']));
+
+ $endDate = '2013-05-30 00:00:00';
+ $employeeJson['contracts'][0]['end_date'] = $endDate;
+ $employeeJson['contracts'][0]['workingtime_json'] = '{"days": [8,8,8,8,8,0,0]}';
+ $recordData = $this->_json->saveEmployee($employeeJson);
+ $this->assertEquals($endDate, $recordData['contracts'][0]['end_date']);
- // an exception should be thrown
$employeeJson['contracts'][0]['vacation_days'] = 31;
- $this->setExpectedException('HumanResources_Exception_ContractNotEditable');
-
- $employeeJson = $this->_json->saveEmployee($employeeJson);
+ try {
+ $employeeJson = $this->_json->saveEmployee($employeeJson);
+ $this->fail('an exception should be thrown');
+ } catch (Exception $e) {
+ $this->assertTrue($e instanceof HumanResources_Exception_ContractNotEditable);
+ }
}
/**
-<<<<<<< HEAD
* @see: https://forge.tine20.org/mantisbt/view.php?id=10122
*/
public function testAlternatingContracts()
}
$diff = $_record->diff($_oldRecord, array(
- 'created_by', 'creation_time', 'last_modified_by', 'last_modified_time', 'notes', 'end_date', 'seq', 'tags'
+ 'created_by', 'creation_time', 'last_modified_by', 'last_modified_time', 'notes', 'end_date', 'seq', 'tags',
+ // see 0011962: contract end_date can't be changed if vacation has been added
+ // TODO fix json encoded field diff - this is only a workaround
+ // sadly, there is currently no test that breaks without this hotfix :(
+ 'workingtime_json'
))->diff;
if (! empty($diff)) {
+ if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(
+ __METHOD__ . '::' . __LINE__ . " Contract diff:" . print_r($diff, true));
+
if ($this->getFreeTimes($_record)->filter('type', 'vacation')->count() > 0) {
throw new HumanResources_Exception_ContractNotEditable();
}
$freeTimeFilter->addFilter(new Tinebase_Model_Filter_Text(
array('field' => 'employee_id', 'operator' => 'equals', 'value' => $contract->employee_id)
));
+
+ if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(
+ __METHOD__ . '::' . __LINE__ . " FreeTime filter:" . print_r($freeTimeFilter->toArray(), true));
$freeTimeController = HumanResources_Controller_FreeTime::getInstance();
$results = $freeTimeController->search($freeTimeFilter);
return $results;
}
-
-
+
/**
* checks the start_date and end_date
*
throw new HumanResources_Exception_ContractDates();
}
}
+
/**
* resolves the container array to the corresponding id
*
if (! empty($recordData['contracts'])) {
for ($i = 0; $i < count($recordData['contracts']); $i++) {
- if (is_array($recordData['contracts'][$i]['feast_calendar_id'])) {
+ if (isset($recordData['contracts'][$i]) && is_array($recordData['contracts'][$i]['feast_calendar_id'])) {
$recordData['contracts'][$i]['feast_calendar_id'] = $recordData['contracts'][$i]['feast_calendar_id']['id'];
}
}