0009854: Saving an employee fails
authorAlexander Stintzing <a.stintzing@metaways.de>
Tue, 22 Apr 2014 13:01:00 +0000 (15:01 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 22 Apr 2014 15:20:24 +0000 (17:20 +0200)
Even if there are no changes, the HumanResources_Exception_ContractNotEditable is thrown

https://forge.tine20.org/mantisbt/view.php?id=9854

Change-Id: I8667be0fb341367c502d35a377ab7eda1a2a82d5
Reviewed-on: http://gerrit.tine20.com/customers/546
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/HumanResources/JsonTests.php
tine20/HumanResources/Model/Contract.php

index 2a47847..055cc8f 100644 (file)
@@ -805,4 +805,37 @@ class HumanResources_JsonTests extends HumanResources_TestCase
             
             $this->_json->getFeastAndFreeDays($employee->getId(), "2013");
     }
+    
+    /**
+     * 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::get(Tinebase_Core::USERTIMEZONE))->setTime(0,0,0);
+        $employmentEnd   = clone $employmentBegin;
+        $employmentEnd->setDate(2014, 1, 30);
+        
+        $employee = $this->_getEmployee('unittest');
+        $employee->employment_begin = $employmentBegin;
+        $employee->employment_end = $employmentEnd;
+        
+        $contract1 = $this->_getContract();
+        $contract1->start_date = $employmentBegin;
+        $contract1->end_date = $employmentEnd;
+        $contract1->workingtime_json = '{"days": [8,8,8,8,8,0,0]}';
+        $contract1->vacation_days = 25;
+        
+        $recordData = $employee->toArray();
+        $recordData['contracts'] = array($contract1->toArray());
+        $recordData = $this->_json->saveEmployee($recordData);
+        
+        $recordData['bday'] = '2014-04-01 00:00:00';
+        
+        // no exception may be thrown
+        $recordData = $this->_json->saveEmployee($recordData);
+        
+        $this->assertEquals('2014-04-01 00:00:00', $recordData['bday']);
+    }
 }
index 26bd6fe..a59b314 100644 (file)
@@ -60,7 +60,7 @@ class HumanResources_Model_Contract extends Tinebase_Record_Abstract
             'start_date'        => array(
                 'label'      => 'Start Date',    // _('Start Date')
                 'validators' => array(Zend_Filter_Input::ALLOW_EMPTY => TRUE),
-                'type'       => 'date',
+                'type'       => 'datetime',
                 'sortable'   => FALSE,
                  'default'    => 'now',
                  'showInDetailsPanel' => TRUE
@@ -69,7 +69,7 @@ class HumanResources_Model_Contract extends Tinebase_Record_Abstract
                 'validators' => array(Zend_Filter_Input::ALLOW_EMPTY => TRUE),
                 'inputFilters' => array('Zend_Filter_Empty' => NULL),
                 'label'   => 'End Date',    // _('End Date')
-                'type'    => 'date',
+                'type'    => 'datetime',
                 'sortable'   => FALSE,
                 'showInDetailsPanel' => TRUE
             ),