{"action":"created","comment":{"url":"https://api.github.com/repos/civicrm/civihr/pulls/comments/91062646","pull_request_review_id":11572183,"id":91062646,"diff_hunk":"@@ -277,6 +287,177 @@ public function testGetReturnsOnlyPublicHolidayLeaveRequestsIfThePublicHolidayIs\n     $this->assertEquals($publicHoliday->date, $result['values'][0]['from_date']);\n   }\n \n+  public function testGetCanReturnALeaveRequestWhichOverlapsAContractWithoutEndDate() {\n+    $leaveRequestStatuses = array_flip(LeaveRequest::buildOptions('status_id'));\n+\n+    HRJobContractFabricator::fabricate([\n+      'contact_id' => 1\n+    ],\n+    [\n+      'period_start_date' => '2016-01-01'\n+    ]);\n+\n+    //This leave request is before the contract start date and will not be returned\n+    LeaveRequestFabricator::fabricate([\n+      'contact_id' => 1,\n+      'type_id' => 1,\n+      'from_date' => CRM_Utils_Date::processDate('2015-12-30'),\n+      'to_date' => CRM_Utils_Date::processDate('2015-12-31'),\n+      'status_id' => $leaveRequestStatuses['Waiting Approval']\n+    ], true);\n+\n+    //This will be returned as it is after the contract start date\n+    $leaveRequest2 = LeaveRequestFabricator::fabricate([\n+      'contact_id' => 1,\n+      'type_id' => 1,\n+      'from_date' => CRM_Utils_Date::processDate('2017-12-30'),\n+      'to_date' => CRM_Utils_Date::processDate('2017-12-31'),\n+      'status_id' => $leaveRequestStatuses['Waiting Approval']\n+    ], true);\n+\n+    $result = civicrm_api3('LeaveRequest', 'get');\n+    $this->assertCount(1, $result['values']);\n+    $this->assertNotEmpty($result['values'][$leaveRequest2->id]);\n+  }\n+\n+  public function testGetCanReturnALeaveRequestWhichOverlapsAContractWithEndDate() {","path":"uk.co.compucorp.civicrm.hrleaveandabsences/tests/phpunit/api/v3/LeaveRequestTest.php","position":null,"original_position":77,"commit_id":"edb8e06e7f2307d55dcd4294010be02d83bb86e0","original_commit_id":"9560e8a63304b2d86a7687c1c89be4041cb55437","user":{"login":"davialexandre","id":388373,"avatar_url":"https://avatars.githubusercontent.com/u/388373?v=3","gravatar_id":"","url":"https://api.github.com/users/davialexandre","html_url":"https://github.com/davialexandre","followers_url":"https://api.github.com/users/davialexandre/followers","following_url":"https://api.github.com/users/davialexandre/following{/other_user}","gists_url":"https://api.github.com/users/davialexandre/gists{/gist_id}","starred_url":"https://api.github.com/users/davialexandre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davialexandre/subscriptions","organizations_url":"https://api.github.com/users/davialexandre/orgs","repos_url":"https://api.github.com/users/davialexandre/repos","events_url":"https://api.github.com/users/davialexandre/events{/privacy}","received_events_url":"https://api.github.com/users/davialexandre/received_events","type":"User","site_admin":false},"body":"fixed","created_at":"2016-12-06T11:50:44Z","updated_at":"2016-12-06T11:50:44Z","html_url":"https://github.com/civicrm/civihr/pull/1268#discussion_r91062646","pull_request_url":"https://api.github.com/repos/civicrm/civihr/pulls/1268","_links":{"self":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/comments/91062646"},"html":{"href":"https://github.com/civicrm/civihr/pull/1268#discussion_r91062646"},"pull_request":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/1268"}}},"pull_request":{"url":"https://api.github.com/repos/civicrm/civihr/pulls/1268","id":96604521,"html_url":"https://github.com/civicrm/civihr/pull/1268","diff_url":"https://github.com/civicrm/civihr/pull/1268.diff","patch_url":"https://github.com/civicrm/civihr/pull/1268.patch","issue_url":"https://api.github.com/repos/civicrm/civihr/issues/1268","number":1268,"state":"open","locked":false,"title":"PCHR-1756: Filter out leave requests not overlapping contracts","user":{"login":"davialexandre","id":388373,"avatar_url":"https://avatars.githubusercontent.com/u/388373?v=3","gravatar_id":"","url":"https://api.github.com/users/davialexandre","html_url":"https://github.com/davialexandre","followers_url":"https://api.github.com/users/davialexandre/followers","following_url":"https://api.github.com/users/davialexandre/following{/other_user}","gists_url":"https://api.github.com/users/davialexandre/gists{/gist_id}","starred_url":"https://api.github.com/users/davialexandre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davialexandre/subscriptions","organizations_url":"https://api.github.com/users/davialexandre/orgs","repos_url":"https://api.github.com/users/davialexandre/repos","events_url":"https://api.github.com/users/davialexandre/events{/privacy}","received_events_url":"https://api.github.com/users/davialexandre/received_events","type":"User","site_admin":false},"body":"A Leave Request is not linked directly to a Contract. Instead it's linked to a Contact and we use the Leave Request dates in order to know with which contracts it overlaps. This means we can have \"stale\" requests, which don't overlap any existing contract (this can happen, for example, when a contract length is decreased).\r\n\r\nA call to the LeaveRequest.get API endpoint, even without any params, should no include those \"stale\" requests, so this PR updates the query used by the API to filter out any Leave Request not overlapping a contract. This was implemented by updating the query to join Leave Request with Contracts using the contact_id. Next, we join the Contract with its details, through the Contract Revision, in order to finally be able to add the conditions to return only the Leave Requests where the from_date and to_date overlaps the Contract's period_start_date and period_end_date.","created_at":"2016-12-05T20:37:44Z","updated_at":"2016-12-06T11:50:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b7d871da5508c5bf430bc961fb56dc1e2e5acc86","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/civicrm/civihr/pulls/1268/commits","review_comments_url":"https://api.github.com/repos/civicrm/civihr/pulls/1268/comments","review_comment_url":"https://api.github.com/repos/civicrm/civihr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/civicrm/civihr/issues/1268/comments","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/edb8e06e7f2307d55dcd4294010be02d83bb86e0","head":{"label":"civicrm:PCHR-1756-filter-out-leave-requests-not-overlapping-contracts","ref":"PCHR-1756-filter-out-leave-requests-not-overlapping-contracts","sha":"edb8e06e7f2307d55dcd4294010be02d83bb86e0","user":{"login":"civicrm","id":136373,"avatar_url":"https://avatars.githubusercontent.com/u/136373?v=3","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"repo":{"id":10086903,"name":"civihr","full_name":"civicrm/civihr","owner":{"login":"civicrm","id":136373,"avatar_url":"https://avatars.githubusercontent.com/u/136373?v=3","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/civicrm/civihr","description":"CiviHR","fork":false,"url":"https://api.github.com/repos/civicrm/civihr","forks_url":"https://api.github.com/repos/civicrm/civihr/forks","keys_url":"https://api.github.com/repos/civicrm/civihr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/civicrm/civihr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/civicrm/civihr/teams","hooks_url":"https://api.github.com/repos/civicrm/civihr/hooks","issue_events_url":"https://api.github.com/repos/civicrm/civihr/issues/events{/number}","events_url":"https://api.github.com/repos/civicrm/civihr/events","assignees_url":"https://api.github.com/repos/civicrm/civihr/assignees{/user}","branches_url":"https://api.github.com/repos/civicrm/civihr/branches{/branch}","tags_url":"https://api.github.com/repos/civicrm/civihr/tags","blobs_url":"https://api.github.com/repos/civicrm/civihr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/civicrm/civihr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/civicrm/civihr/git/refs{/sha}","trees_url":"https://api.github.com/repos/civicrm/civihr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/{sha}","languages_url":"https://api.github.com/repos/civicrm/civihr/languages","stargazers_url":"https://api.github.com/repos/civicrm/civihr/stargazers","contributors_url":"https://api.github.com/repos/civicrm/civihr/contributors","subscribers_url":"https://api.github.com/repos/civicrm/civihr/subscribers","subscription_url":"https://api.github.com/repos/civicrm/civihr/subscription","commits_url":"https://api.github.com/repos/civicrm/civihr/commits{/sha}","git_commits_url":"https://api.github.com/repos/civicrm/civihr/git/commits{/sha}","comments_url":"https://api.github.com/repos/civicrm/civihr/comments{/number}","issue_comment_url":"https://api.github.com/repos/civicrm/civihr/issues/comments{/number}","contents_url":"https://api.github.com/repos/civicrm/civihr/contents/{+path}","compare_url":"https://api.github.com/repos/civicrm/civihr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/civicrm/civihr/merges","archive_url":"https://api.github.com/repos/civicrm/civihr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/civicrm/civihr/downloads","issues_url":"https://api.github.com/repos/civicrm/civihr/issues{/number}","pulls_url":"https://api.github.com/repos/civicrm/civihr/pulls{/number}","milestones_url":"https://api.github.com/repos/civicrm/civihr/milestones{/number}","notifications_url":"https://api.github.com/repos/civicrm/civihr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/civicrm/civihr/labels{/name}","releases_url":"https://api.github.com/repos/civicrm/civihr/releases{/id}","deployments_url":"https://api.github.com/repos/civicrm/civihr/deployments","created_at":"2013-05-15T20:06:06Z","updated_at":"2016-10-25T11:36:09Z","pushed_at":"2016-12-06T11:50:32Z","git_url":"git://github.com/civicrm/civihr.git","ssh_url":"git@github.com:civicrm/civihr.git","clone_url":"https://github.com/civicrm/civihr.git","svn_url":"https://github.com/civicrm/civihr","homepage":null,"size":41241,"stargazers_count":4,"watchers_count":4,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":21,"forks":26,"open_issues":21,"watchers":4,"default_branch":"staging"}},"base":{"label":"civicrm:la-milestone-3","ref":"la-milestone-3","sha":"884ffcb239b5291aa7c9cd464efd83bc1d454158","user":{"login":"civicrm","id":136373,"avatar_url":"https://avatars.githubusercontent.com/u/136373?v=3","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"repo":{"id":10086903,"name":"civihr","full_name":"civicrm/civihr","owner":{"login":"civicrm","id":136373,"avatar_url":"https://avatars.githubusercontent.com/u/136373?v=3","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/civicrm/civihr","description":"CiviHR","fork":false,"url":"https://api.github.com/repos/civicrm/civihr","forks_url":"https://api.github.com/repos/civicrm/civihr/forks","keys_url":"https://api.github.com/repos/civicrm/civihr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/civicrm/civihr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/civicrm/civihr/teams","hooks_url":"https://api.github.com/repos/civicrm/civihr/hooks","issue_events_url":"https://api.github.com/repos/civicrm/civihr/issues/events{/number}","events_url":"https://api.github.com/repos/civicrm/civihr/events","assignees_url":"https://api.github.com/repos/civicrm/civihr/assignees{/user}","branches_url":"https://api.github.com/repos/civicrm/civihr/branches{/branch}","tags_url":"https://api.github.com/repos/civicrm/civihr/tags","blobs_url":"https://api.github.com/repos/civicrm/civihr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/civicrm/civihr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/civicrm/civihr/git/refs{/sha}","trees_url":"https://api.github.com/repos/civicrm/civihr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/{sha}","languages_url":"https://api.github.com/repos/civicrm/civihr/languages","stargazers_url":"https://api.github.com/repos/civicrm/civihr/stargazers","contributors_url":"https://api.github.com/repos/civicrm/civihr/contributors","subscribers_url":"https://api.github.com/repos/civicrm/civihr/subscribers","subscription_url":"https://api.github.com/repos/civicrm/civihr/subscription","commits_url":"https://api.github.com/repos/civicrm/civihr/commits{/sha}","git_commits_url":"https://api.github.com/repos/civicrm/civihr/git/commits{/sha}","comments_url":"https://api.github.com/repos/civicrm/civihr/comments{/number}","issue_comment_url":"https://api.github.com/repos/civicrm/civihr/issues/comments{/number}","contents_url":"https://api.github.com/repos/civicrm/civihr/contents/{+path}","compare_url":"https://api.github.com/repos/civicrm/civihr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/civicrm/civihr/merges","archive_url":"https://api.github.com/repos/civicrm/civihr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/civicrm/civihr/downloads","issues_url":"https://api.github.com/repos/civicrm/civihr/issues{/number}","pulls_url":"https://api.github.com/repos/civicrm/civihr/pulls{/number}","milestones_url":"https://api.github.com/repos/civicrm/civihr/milestones{/number}","notifications_url":"https://api.github.com/repos/civicrm/civihr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/civicrm/civihr/labels{/name}","releases_url":"https://api.github.com/repos/civicrm/civihr/releases{/id}","deployments_url":"https://api.github.com/repos/civicrm/civihr/deployments","created_at":"2013-05-15T20:06:06Z","updated_at":"2016-10-25T11:36:09Z","pushed_at":"2016-12-06T11:50:32Z","git_url":"git://github.com/civicrm/civihr.git","ssh_url":"git@github.com:civicrm/civihr.git","clone_url":"https://github.com/civicrm/civihr.git","svn_url":"https://github.com/civicrm/civihr","homepage":null,"size":41241,"stargazers_count":4,"watchers_count":4,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":21,"forks":26,"open_issues":21,"watchers":4,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/1268"},"html":{"href":"https://github.com/civicrm/civihr/pull/1268"},"issue":{"href":"https://api.github.com/repos/civicrm/civihr/issues/1268"},"comments":{"href":"https://api.github.com/repos/civicrm/civihr/issues/1268/comments"},"review_comments":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/1268/comments"},"review_comment":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/1268/commits"},"statuses":{"href":"https://api.github.com/repos/civicrm/civihr/statuses/edb8e06e7f2307d55dcd4294010be02d83bb86e0"}}}}
{"actor":{"display_login":"davialexandre"}}