copy the billable status when restarting timesheet (#2778)
This commit is contained in:
@@ -590,7 +590,7 @@ class TimesheetController extends BaseApiController
|
|||||||
* required=true,
|
* required=true,
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
* @Rest\RequestParam(name="copy", requirements="all|tags|rates|meta|description", strict=true, nullable=true, description="Whether data should be copied to the new entry. Allowed values: all, tags, rates, description, meta (default: nothing is copied)")
|
* @Rest\RequestParam(name="copy", requirements="all|tags|rates|meta|description", strict=true, nullable=true, description="Whether data should be copied to the new entry. Allowed values: all, tags (deprecated), rates (deprecated), description (deprecated), meta (deprecated) (default: nothing is copied)")
|
||||||
* @Rest\RequestParam(name="begin", requirements=@Constraints\DateTime(format="Y-m-d\TH:i:s"), strict=true, nullable=true, description="Changes the restart date to the given one (default: now)")
|
* @Rest\RequestParam(name="begin", requirements=@Constraints\DateTime(format="Y-m-d\TH:i:s"), strict=true, nullable=true, description="Changes the restart date to the given one (default: now)")
|
||||||
*
|
*
|
||||||
* @ApiSecurity(name="apiUser")
|
* @ApiSecurity(name="apiUser")
|
||||||
@@ -620,28 +620,26 @@ class TimesheetController extends BaseApiController
|
|||||||
;
|
;
|
||||||
|
|
||||||
if (null !== ($copy = $paramFetcher->get('copy'))) {
|
if (null !== ($copy = $paramFetcher->get('copy'))) {
|
||||||
if (\in_array($copy, ['rates', 'all'])) {
|
if ($copy !== 'all') {
|
||||||
$copyTimesheet->setHourlyRate($timesheet->getHourlyRate());
|
@trigger_error('Setting the "copy" attribute in "restart timesheet" API to something else then "all" is deprecated', E_USER_DEPRECATED);
|
||||||
$copyTimesheet->setFixedRate($timesheet->getFixedRate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\in_array($copy, ['description', 'all'])) {
|
$copyTimesheet
|
||||||
$copyTimesheet->setDescription($timesheet->getDescription());
|
->setHourlyRate($timesheet->getHourlyRate())
|
||||||
}
|
->setFixedRate($timesheet->getFixedRate())
|
||||||
|
->setDescription($timesheet->getDescription())
|
||||||
|
->setBillable($timesheet->isBillable())
|
||||||
|
;
|
||||||
|
|
||||||
if (\in_array($copy, ['tags', 'all'])) {
|
|
||||||
foreach ($timesheet->getTags() as $tag) {
|
foreach ($timesheet->getTags() as $tag) {
|
||||||
$copyTimesheet->addTag($tag);
|
$copyTimesheet->addTag($tag);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (\in_array($copy, ['meta', 'all'])) {
|
|
||||||
foreach ($timesheet->getMetaFields() as $metaField) {
|
foreach ($timesheet->getMetaFields() as $metaField) {
|
||||||
$metaNew = clone $metaField;
|
$metaNew = clone $metaField;
|
||||||
$copyTimesheet->setMetaField($metaNew);
|
$copyTimesheet->setMetaField($metaNew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// needs to be executed AFTER copying the values!
|
// needs to be executed AFTER copying the values!
|
||||||
// the event triggered in prepareNewTimesheet() will add meta fields first. Afterwards
|
// the event triggered in prepareNewTimesheet() will add meta fields first. Afterwards
|
||||||
|
|||||||
Reference in New Issue
Block a user