diff --git a/src/API/ActivityController.php b/src/API/ActivityController.php index 1f311471..43120467 100644 --- a/src/API/ActivityController.php +++ b/src/API/ActivityController.php @@ -202,7 +202,9 @@ class ActivityController extends BaseApiController $event = new ActivityMetaDefinitionEvent($activity); $this->dispatcher->dispatch($event); - $form = $this->createForm(ActivityApiEditForm::class, $activity); + $form = $this->createForm(ActivityApiEditForm::class, $activity, [ + 'include_budget' => $this->isGranted('budget', $activity), + ]); $form->submit($request->request->all()); @@ -264,7 +266,9 @@ class ActivityController extends BaseApiController $event = new ActivityMetaDefinitionEvent($activity); $this->dispatcher->dispatch($event); - $form = $this->createForm(ActivityApiEditForm::class, $activity); + $form = $this->createForm(ActivityApiEditForm::class, $activity, [ + 'include_budget' => $this->isGranted('budget', $activity), + ]); $form->setData($activity); $form->submit($request->request->all(), false); diff --git a/src/API/CustomerController.php b/src/API/CustomerController.php index 98a99b3b..f9377953 100644 --- a/src/API/CustomerController.php +++ b/src/API/CustomerController.php @@ -175,7 +175,9 @@ class CustomerController extends BaseApiController $event = new CustomerMetaDefinitionEvent($customer); $this->dispatcher->dispatch($event); - $form = $this->createForm(CustomerApiEditForm::class, $customer); + $form = $this->createForm(CustomerApiEditForm::class, $customer, [ + 'include_budget' => $this->isGranted('budget', $customer), + ]); $form->submit($request->request->all()); @@ -237,7 +239,9 @@ class CustomerController extends BaseApiController $event = new CustomerMetaDefinitionEvent($customer); $this->dispatcher->dispatch($event); - $form = $this->createForm(CustomerApiEditForm::class, $customer); + $form = $this->createForm(CustomerApiEditForm::class, $customer, [ + 'include_budget' => $this->isGranted('budget', $customer), + ]); $form->setData($customer); $form->submit($request->request->all(), false); diff --git a/src/API/ProjectController.php b/src/API/ProjectController.php index 46b6d5c8..d691013e 100644 --- a/src/API/ProjectController.php +++ b/src/API/ProjectController.php @@ -224,6 +224,7 @@ class ProjectController extends BaseApiController $form = $this->createForm(ProjectApiEditForm::class, $project, [ 'date_format' => self::DATE_FORMAT, + 'include_budget' => $this->isGranted('budget', $project), ]); $form->submit($request->request->all()); @@ -288,6 +289,7 @@ class ProjectController extends BaseApiController $form = $this->createForm(ProjectApiEditForm::class, $project, [ 'date_format' => self::DATE_FORMAT, + 'include_budget' => $this->isGranted('budget', $project), ]); $form->setData($project); diff --git a/tests/API/ActivityControllerTest.php b/tests/API/ActivityControllerTest.php index 88565c2d..8fecfbfc 100644 --- a/tests/API/ActivityControllerTest.php +++ b/tests/API/ActivityControllerTest.php @@ -188,7 +188,9 @@ class ActivityControllerTest extends APIControllerBaseTest $data = [ 'name' => 'foo', 'project' => 1, - 'visible' => true + 'visible' => true, + 'budget' => '999', + 'timeBudget' => '7200', ]; $this->request($client, '/api/activities', 'POST', [], json_encode($data)); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -236,7 +238,9 @@ class ActivityControllerTest extends APIControllerBaseTest 'name' => 'foo', 'comment' => '', 'project' => 1, - 'visible' => true + 'visible' => true, + 'budget' => '999', + 'timeBudget' => '7200', ]; $this->request($client, '/api/activities/1', 'PATCH', [], json_encode($data)); $this->assertTrue($client->getResponse()->isSuccessful()); diff --git a/tests/API/CustomerControllerTest.php b/tests/API/CustomerControllerTest.php index c52bfd05..cba12602 100644 --- a/tests/API/CustomerControllerTest.php +++ b/tests/API/CustomerControllerTest.php @@ -124,6 +124,8 @@ class CustomerControllerTest extends APIControllerBaseTest 'country' => 'DE', 'currency' => 'EUR', 'timezone' => 'Europe/Berlin', + 'budget' => '999', + 'timeBudget' => '7200', ]; $this->request($client, '/api/customers', 'POST', [], json_encode($data)); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -178,6 +180,8 @@ class CustomerControllerTest extends APIControllerBaseTest 'country' => 'DE', 'currency' => 'EUR', 'timezone' => 'Europe/Berlin', + 'budget' => '999', + 'timeBudget' => '7200', ]; $this->request($client, '/api/customers/1', 'PATCH', [], json_encode($data)); $this->assertTrue($client->getResponse()->isSuccessful()); diff --git a/tests/API/ProjectControllerTest.php b/tests/API/ProjectControllerTest.php index b7d76601..2086b13b 100644 --- a/tests/API/ProjectControllerTest.php +++ b/tests/API/ProjectControllerTest.php @@ -187,6 +187,8 @@ class ProjectControllerTest extends APIControllerBaseTest 'orderDate' => '2018-02-08T13:02:54', 'start' => '2019-02-01T19:32:17', 'end' => '2020-02-08T21:11:42', + 'budget' => '999', + 'timeBudget' => '7200', ]; $this->request($client, '/api/projects', 'POST', [], json_encode($data)); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -237,7 +239,9 @@ class ProjectControllerTest extends APIControllerBaseTest 'name' => 'foo', 'comment' => '', 'customer' => 1, - 'visible' => true + 'visible' => true, + 'budget' => '999', + 'timeBudget' => '7200', ]; $this->request($client, '/api/projects/1', 'PATCH', [], json_encode($data)); $this->assertTrue($client->getResponse()->isSuccessful());