fix restart timesheet with meta-fields (#1993)

This commit is contained in:
Kevin Papst
2020-09-24 16:55:23 +02:00
committed by GitHub
parent 4cfa7347e9
commit 23f484a14d

View File

@@ -660,7 +660,6 @@ class TimesheetController extends BaseApiController
->setActivity($timesheet->getActivity())
->setProject($timesheet->getProject())
;
$this->service->prepareNewTimesheet($copyTimesheet);
if (null !== ($copy = $paramFetcher->get('copy'))) {
if (\in_array($copy, ['rates', 'all'])) {
@@ -686,6 +685,12 @@ class TimesheetController extends BaseApiController
}
}
// needs to be executed AFTER copying the values!
// the event triggered in prepareNewTimesheet() will add meta fields first. Afterwards
// setMetaField() will merge meta fields and if we merge in the existing ones from the copied record,
// it will fail, because they do not have a type assigned
$this->service->prepareNewTimesheet($copyTimesheet);
$this->service->restartTimesheet($copyTimesheet, $timesheet);
$view = new View($copyTimesheet, 200);