fix bugs in accompanying periods

ref #11
This commit is contained in:
2016-05-17 10:02:45 +02:00
parent 8b98e8a4b6
commit ce7c149c35
12 changed files with 355 additions and 77 deletions

View File

@@ -186,11 +186,36 @@ class AccompanyingPeriod
return $this->closingMotive;
}
public function setClosingMotive(AccompanyingPeriod\ClosingMotive $closingMotive)
public function setClosingMotive(AccompanyingPeriod\ClosingMotive $closingMotive = null)
{
$this->closingMotive = $closingMotive;
return $this;
}
/**
* If the period can be reopened.
*
* This function test if the period is closed and if the period is the last
* for the associated person
*
* @return boolean
*/
public function canBeReOpened()
{
if ($this->isOpen() === true) {
return false;
}
$periods = $this->getPerson()->getAccompanyingPeriodsOrdered();
return end($periods) === $this;
}
public function reOpen()
{
$this->setClosingDate(null);
$this->setClosingMotive(null);
}
/// VALIDATION function
public function isDateConsistent(ExecutionContextInterface $context) {