{"action":"created","comment":{"url":"https://api.github.com/repos/xtuple/xtuple/pulls/comments/50572317","id":50572317,"diff_hunk":"@@ -28,17 +29,25 @@ BEGIN\n                       EXTRACT(year FROM period_start + INTERVAL '1 year') || '-' || to_char((period_start + INTERVAL '1 year'), 'Mon'),\n                       _newYear, period_quarter, period_number\n     FROM period\n-    WHERE period_yearperiod_id = pYearPeriodid;\n+    WHERE (period_yearperiod_id = pYearPeriodid);\n+\n+--  Grab last period for reference\n+    SELECT max(period_id) into _periodid\n+    FROM period\n+    WHERE (period_yearperiod_id = _newYear);","path":"foundation-database/public/functions/copyaccountingyearperiod.sql","position":26,"original_position":26,"commit_id":"26349bc0b3deb803bd04cb2417af5d4c0b9758d3","original_commit_id":"26349bc0b3deb803bd04cb2417af5d4c0b9758d3","user":{"login":"andersdd","id":4682742,"avatar_url":"https://avatars.githubusercontent.com/u/4682742?v=3","gravatar_id":"","url":"https://api.github.com/users/andersdd","html_url":"https://github.com/andersdd","followers_url":"https://api.github.com/users/andersdd/followers","following_url":"https://api.github.com/users/andersdd/following{/other_user}","gists_url":"https://api.github.com/users/andersdd/gists{/gist_id}","starred_url":"https://api.github.com/users/andersdd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andersdd/subscriptions","organizations_url":"https://api.github.com/users/andersdd/orgs","repos_url":"https://api.github.com/users/andersdd/repos","events_url":"https://api.github.com/users/andersdd/events{/privacy}","received_events_url":"https://api.github.com/users/andersdd/received_events","type":"User","site_admin":false},"body":"Actually we only need to pick one period - I don't think it actually matters whether it is the latest - and given we have just inserted the periods for _newYear it most likely *will* be the max period anyway.","created_at":"2016-01-22T18:30:32Z","updated_at":"2016-01-22T18:30:32Z","html_url":"https://github.com/xtuple/xtuple/pull/2591#discussion_r50572317","pull_request_url":"https://api.github.com/repos/xtuple/xtuple/pulls/2591","_links":{"self":{"href":"https://api.github.com/repos/xtuple/xtuple/pulls/comments/50572317"},"html":{"href":"https://github.com/xtuple/xtuple/pull/2591#discussion_r50572317"},"pull_request":{"href":"https://api.github.com/repos/xtuple/xtuple/pulls/2591"}}},"pull_request":{"url":"https://api.github.com/repos/xtuple/xtuple/pulls/2591","id":56805906,"html_url":"https://github.com/xtuple/xtuple/pull/2591","diff_url":"https://github.com/xtuple/xtuple/pull/2591.diff","patch_url":"https://github.com/xtuple/xtuple/pull/2591.patch","issue_url":"https://api.github.com/repos/xtuple/xtuple/issues/2591","number":2591,"state":"open","locked":false,"title":"Issue #27205 Additional trial balance checks.  Resolve ordering issues","user":{"login":"andersdd","id":4682742,"avatar_url":"https://avatars.githubusercontent.com/u/4682742?v=3","gravatar_id":"","url":"https://api.github.com/users/andersdd","html_url":"https://github.com/andersdd","followers_url":"https://api.github.com/users/andersdd/followers","following_url":"https://api.github.com/users/andersdd/following{/other_user}","gists_url":"https://api.github.com/users/andersdd/gists{/gist_id}","starred_url":"https://api.github.com/users/andersdd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andersdd/subscriptions","organizations_url":"https://api.github.com/users/andersdd/orgs","repos_url":"https://api.github.com/users/andersdd/repos","events_url":"https://api.github.com/users/andersdd/events{/privacy}","received_events_url":"https://api.github.com/users/andersdd/received_events","type":"User","site_admin":false},"body":"If we are doing a 4.9.3 it would be nice to backport these fixes to that.","created_at":"2016-01-21T20:40:16Z","updated_at":"2016-01-22T18:30:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7cb0043bdbf85e3338e1733f946cacb7988043a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/xtuple/xtuple/pulls/2591/commits","review_comments_url":"https://api.github.com/repos/xtuple/xtuple/pulls/2591/comments","review_comment_url":"https://api.github.com/repos/xtuple/xtuple/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xtuple/xtuple/issues/2591/comments","statuses_url":"https://api.github.com/repos/xtuple/xtuple/statuses/26349bc0b3deb803bd04cb2417af5d4c0b9758d3","head":{"label":"andersdd:27205_trialbal_issues","ref":"27205_trialbal_issues","sha":"26349bc0b3deb803bd04cb2417af5d4c0b9758d3","user":{"login":"andersdd","id":4682742,"avatar_url":"https://avatars.githubusercontent.com/u/4682742?v=3","gravatar_id":"","url":"https://api.github.com/users/andersdd","html_url":"https://github.com/andersdd","followers_url":"https://api.github.com/users/andersdd/followers","following_url":"https://api.github.com/users/andersdd/following{/other_user}","gists_url":"https://api.github.com/users/andersdd/gists{/gist_id}","starred_url":"https://api.github.com/users/andersdd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andersdd/subscriptions","organizations_url":"https://api.github.com/users/andersdd/orgs","repos_url":"https://api.github.com/users/andersdd/repos","events_url":"https://api.github.com/users/andersdd/events{/privacy}","received_events_url":"https://api.github.com/users/andersdd/received_events","type":"User","site_admin":false},"repo":{"id":10651573,"name":"xtuple","full_name":"andersdd/xtuple","owner":{"login":"andersdd","id":4682742,"avatar_url":"https://avatars.githubusercontent.com/u/4682742?v=3","gravatar_id":"","url":"https://api.github.com/users/andersdd","html_url":"https://github.com/andersdd","followers_url":"https://api.github.com/users/andersdd/followers","following_url":"https://api.github.com/users/andersdd/following{/other_user}","gists_url":"https://api.github.com/users/andersdd/gists{/gist_id}","starred_url":"https://api.github.com/users/andersdd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andersdd/subscriptions","organizations_url":"https://api.github.com/users/andersdd/orgs","repos_url":"https://api.github.com/users/andersdd/repos","events_url":"https://api.github.com/users/andersdd/events{/privacy}","received_events_url":"https://api.github.com/users/andersdd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andersdd/xtuple","description":"xTuple Enterprise Resource Planning","fork":true,"url":"https://api.github.com/repos/andersdd/xtuple","forks_url":"https://api.github.com/repos/andersdd/xtuple/forks","keys_url":"https://api.github.com/repos/andersdd/xtuple/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andersdd/xtuple/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andersdd/xtuple/teams","hooks_url":"https://api.github.com/repos/andersdd/xtuple/hooks","issue_events_url":"https://api.github.com/repos/andersdd/xtuple/issues/events{/number}","events_url":"https://api.github.com/repos/andersdd/xtuple/events","assignees_url":"https://api.github.com/repos/andersdd/xtuple/assignees{/user}","branches_url":"https://api.github.com/repos/andersdd/xtuple/branches{/branch}","tags_url":"https://api.github.com/repos/andersdd/xtuple/tags","blobs_url":"https://api.github.com/repos/andersdd/xtuple/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andersdd/xtuple/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andersdd/xtuple/git/refs{/sha}","trees_url":"https://api.github.com/repos/andersdd/xtuple/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andersdd/xtuple/statuses/{sha}","languages_url":"https://api.github.com/repos/andersdd/xtuple/languages","stargazers_url":"https://api.github.com/repos/andersdd/xtuple/stargazers","contributors_url":"https://api.github.com/repos/andersdd/xtuple/contributors","subscribers_url":"https://api.github.com/repos/andersdd/xtuple/subscribers","subscription_url":"https://api.github.com/repos/andersdd/xtuple/subscription","commits_url":"https://api.github.com/repos/andersdd/xtuple/commits{/sha}","git_commits_url":"https://api.github.com/repos/andersdd/xtuple/git/commits{/sha}","comments_url":"https://api.github.com/repos/andersdd/xtuple/comments{/number}","issue_comment_url":"https://api.github.com/repos/andersdd/xtuple/issues/comments{/number}","contents_url":"https://api.github.com/repos/andersdd/xtuple/contents/{+path}","compare_url":"https://api.github.com/repos/andersdd/xtuple/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andersdd/xtuple/merges","archive_url":"https://api.github.com/repos/andersdd/xtuple/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andersdd/xtuple/downloads","issues_url":"https://api.github.com/repos/andersdd/xtuple/issues{/number}","pulls_url":"https://api.github.com/repos/andersdd/xtuple/pulls{/number}","milestones_url":"https://api.github.com/repos/andersdd/xtuple/milestones{/number}","notifications_url":"https://api.github.com/repos/andersdd/xtuple/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andersdd/xtuple/labels{/name}","releases_url":"https://api.github.com/repos/andersdd/xtuple/releases{/id}","deployments_url":"https://api.github.com/repos/andersdd/xtuple/deployments","created_at":"2013-06-12T20:36:45Z","updated_at":"2014-07-06T21:58:43Z","pushed_at":"2016-01-21T22:44:47Z","git_url":"git://github.com/andersdd/xtuple.git","ssh_url":"git@github.com:andersdd/xtuple.git","clone_url":"https://github.com/andersdd/xtuple.git","svn_url":"https://github.com/andersdd/xtuple","homepage":null,"size":69565,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"xtuple:4_10_x","ref":"4_10_x","sha":"173b0b924e76d8e14491b9b2fe5c09763b581e0d","user":{"login":"xtuple","id":703922,"avatar_url":"https://avatars.githubusercontent.com/u/703922?v=3","gravatar_id":"","url":"https://api.github.com/users/xtuple","html_url":"https://github.com/xtuple","followers_url":"https://api.github.com/users/xtuple/followers","following_url":"https://api.github.com/users/xtuple/following{/other_user}","gists_url":"https://api.github.com/users/xtuple/gists{/gist_id}","starred_url":"https://api.github.com/users/xtuple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xtuple/subscriptions","organizations_url":"https://api.github.com/users/xtuple/orgs","repos_url":"https://api.github.com/users/xtuple/repos","events_url":"https://api.github.com/users/xtuple/events{/privacy}","received_events_url":"https://api.github.com/users/xtuple/received_events","type":"Organization","site_admin":false},"repo":{"id":8138568,"name":"xtuple","full_name":"xtuple/xtuple","owner":{"login":"xtuple","id":703922,"avatar_url":"https://avatars.githubusercontent.com/u/703922?v=3","gravatar_id":"","url":"https://api.github.com/users/xtuple","html_url":"https://github.com/xtuple","followers_url":"https://api.github.com/users/xtuple/followers","following_url":"https://api.github.com/users/xtuple/following{/other_user}","gists_url":"https://api.github.com/users/xtuple/gists{/gist_id}","starred_url":"https://api.github.com/users/xtuple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xtuple/subscriptions","organizations_url":"https://api.github.com/users/xtuple/orgs","repos_url":"https://api.github.com/users/xtuple/repos","events_url":"https://api.github.com/users/xtuple/events{/privacy}","received_events_url":"https://api.github.com/users/xtuple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xtuple/xtuple","description":"This repository contains the source code for both the Mobile Web app core and the database schema for the PostBooks edition of xTuple ERP. The Mobile Web app core is written in JavaScript, using the Enyo framework for the client side and Node.js for the datasource layer. The database schema for PostBooks runs on PostgreSQL.","fork":false,"url":"https://api.github.com/repos/xtuple/xtuple","forks_url":"https://api.github.com/repos/xtuple/xtuple/forks","keys_url":"https://api.github.com/repos/xtuple/xtuple/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xtuple/xtuple/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xtuple/xtuple/teams","hooks_url":"https://api.github.com/repos/xtuple/xtuple/hooks","issue_events_url":"https://api.github.com/repos/xtuple/xtuple/issues/events{/number}","events_url":"https://api.github.com/repos/xtuple/xtuple/events","assignees_url":"https://api.github.com/repos/xtuple/xtuple/assignees{/user}","branches_url":"https://api.github.com/repos/xtuple/xtuple/branches{/branch}","tags_url":"https://api.github.com/repos/xtuple/xtuple/tags","blobs_url":"https://api.github.com/repos/xtuple/xtuple/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xtuple/xtuple/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xtuple/xtuple/git/refs{/sha}","trees_url":"https://api.github.com/repos/xtuple/xtuple/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xtuple/xtuple/statuses/{sha}","languages_url":"https://api.github.com/repos/xtuple/xtuple/languages","stargazers_url":"https://api.github.com/repos/xtuple/xtuple/stargazers","contributors_url":"https://api.github.com/repos/xtuple/xtuple/contributors","subscribers_url":"https://api.github.com/repos/xtuple/xtuple/subscribers","subscription_url":"https://api.github.com/repos/xtuple/xtuple/subscription","commits_url":"https://api.github.com/repos/xtuple/xtuple/commits{/sha}","git_commits_url":"https://api.github.com/repos/xtuple/xtuple/git/commits{/sha}","comments_url":"https://api.github.com/repos/xtuple/xtuple/comments{/number}","issue_comment_url":"https://api.github.com/repos/xtuple/xtuple/issues/comments{/number}","contents_url":"https://api.github.com/repos/xtuple/xtuple/contents/{+path}","compare_url":"https://api.github.com/repos/xtuple/xtuple/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xtuple/xtuple/merges","archive_url":"https://api.github.com/repos/xtuple/xtuple/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xtuple/xtuple/downloads","issues_url":"https://api.github.com/repos/xtuple/xtuple/issues{/number}","pulls_url":"https://api.github.com/repos/xtuple/xtuple/pulls{/number}","milestones_url":"https://api.github.com/repos/xtuple/xtuple/milestones{/number}","notifications_url":"https://api.github.com/repos/xtuple/xtuple/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xtuple/xtuple/labels{/name}","releases_url":"https://api.github.com/repos/xtuple/xtuple/releases{/id}","deployments_url":"https://api.github.com/repos/xtuple/xtuple/deployments","created_at":"2013-02-11T13:33:14Z","updated_at":"2016-01-14T21:58:20Z","pushed_at":"2016-01-22T17:38:13Z","git_url":"git://github.com/xtuple/xtuple.git","ssh_url":"git@github.com:xtuple/xtuple.git","clone_url":"https://github.com/xtuple/xtuple.git","svn_url":"https://github.com/xtuple/xtuple","homepage":"http://www.xtuple.com","size":72467,"stargazers_count":111,"watchers_count":111,"language":"PLpgSQL","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":252,"mirror_url":null,"open_issues_count":2,"forks":252,"open_issues":2,"watchers":111,"default_branch":"4_10_x"}},"_links":{"self":{"href":"https://api.github.com/repos/xtuple/xtuple/pulls/2591"},"html":{"href":"https://github.com/xtuple/xtuple/pull/2591"},"issue":{"href":"https://api.github.com/repos/xtuple/xtuple/issues/2591"},"comments":{"href":"https://api.github.com/repos/xtuple/xtuple/issues/2591/comments"},"review_comments":{"href":"https://api.github.com/repos/xtuple/xtuple/pulls/2591/comments"},"review_comment":{"href":"https://api.github.com/repos/xtuple/xtuple/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xtuple/xtuple/pulls/2591/commits"},"statuses":{"href":"https://api.github.com/repos/xtuple/xtuple/statuses/26349bc0b3deb803bd04cb2417af5d4c0b9758d3"}}}}