{"action":"created","comment":{"url":"https://api.github.com/repos/danliris/dl-module/pulls/comments/103635787","pull_request_review_id":24426644,"id":103635787,"diff_hunk":"@@ -239,63 +240,92 @@ module.exports = class PurchaseOrderManager extends BaseManager {\n             .then((purchaseOrder) => {\n                 return this.purchaseRequestManager.getSingleById(purchaseOrder.purchaseRequestId)\n                     .then((purchaseRequest) => {\n-                        purchaseRequest.isUsed = true;\n+                        var purchaseOrderError = {};\n+                        if (purchaseRequest.isUsed) {\n+                            purchaseOrderError[\"purchaseRequestId\"] = i18n.__(\"purchaseRequest.isUsed:%s is already used\", i18n.__(\"purchaseRequest.isUsed._:Used\"));\n+                        }\n+                        if (purchaseRequest.purchaseOrderIds.length > 1) {\n+                            var poId = purchaseRequest.purchaseOrderIds.find((_poId) => _poId.toString() === id.toString());\n+                            if (poId) {\n+                                purchaseOrderError[\"purchaseRequestId\"] = i18n.__(\"purchaseRequest.purchaseOrderIds:%s is already used\", i18n.__(\"purchaseRequest.purchaseOrderIds._:Used\"));\n+                            }\n+                        }\n+                        if (Object.getOwnPropertyNames(purchaseOrderError).length > 0) {\n+                            var ValidationError = require(\"module-toolkit\").ValidationError;\n+                            return Promise.reject(new ValidationError(\"data does not pass validation\", purchaseOrderError));\n+                        }\n+\n+                        if (!purchaseRequest.stamp) {\n+                            purchaseRequest = new PurchaseRequest(purchaseRequest);\n+                        }\n+                        purchaseRequest.stamp(this.user.username, 'manager');\n+                        return Promise.resolve(purchaseRequest)\n+                    })\n+                    .then((purchaseRequest) => {\n                         purchaseRequest.purchaseOrderIds = purchaseRequest.purchaseOrderIds || [];\n-                        purchaseRequest.status = prStatusEnum.PROCESSING;\n                         purchaseRequest.purchaseOrderIds.push(id);\n-                        return this.purchaseRequestManager.update(purchaseRequest)\n-                            .then(() => {\n-                                purchaseOrder.purchaseRequest = purchaseRequest\n-                                return this.collection\n-                                    .updateOne({\n-                                        _id: purchaseOrder._id\n-                                    }, {\n-                                        $set: purchaseOrder\n-                                    })\n-                                    .then((result) => Promise.resolve(purchaseOrder._id));\n-                            });\n+                        return this.purchaseRequestManager.collection\n+                            .updateOne({\n+                                _id: purchaseRequest._id\n+                            }, {\n+                                $set: { \"isUsed\": true, \"status\": prStatusEnum.PROCESSING, \"purchaseOrderIds\": purchaseRequest.purchaseOrderIds }\n+                            })\n+                            .then((result) => { return this.purchaseRequestManager.getSingleById(purchaseRequest._id) })\n                     })\n+                    .then((purchaseRequest) => {\n+                        if (purchaseOrder.purchaseRequestId.toString() === purchaseRequest._id.toString()) {\n+                            purchaseOrder.purchaseRequest = purchaseRequest\n+                            return this.collection\n+                                .updateOne({\n+                                    _id: purchaseOrder._id\n+                                }, {\n+                                    $set: purchaseOrder\n+                                })\n+                                .then((result) => Promise.resolve(purchaseOrder._id));\n+                        }\n+                    });\n             })\n     }\n \n     delete(purchaseOrder) {\n-        return new Promise((resolve, reject) => {\n-            this._createIndexes()\n-                .then((createIndexResults) => {\n-                    this._validate(purchaseOrder)\n-                        .then(validData => {\n-                            validData._deleted = true;\n-                            this.collection.update(validData)\n-                                .then(id => {\n-                                    this.purchaseRequestManager.getSingleById(validData.purchaseRequest._id)\n-                                        .then(PR => {\n-                                            var poIndex = PR.purchaseOrderIds.indexOf(validData._id);\n-                                            PR.purchaseOrderIds.splice(poIndex, 1);\n-                                            if (PR.purchaseOrderIds.length === 0) {\n-                                                PR.isUsed = false;\n-                                                PR.status = prStatusEnum.POSTED;\n-                                            }\n-                                            this.purchaseRequestManager.update(PR)\n-                                                .then(results => {\n-                                                    resolve(id);\n-                                                })\n-                                                .catch(e => {\n-                                                    reject(e);\n-                                                });\n-                                        })\n-                                })\n-                                .catch(e => {\n-                                    reject(e);\n-                                });\n-                        })\n-                        .catch(e => {\n-                            reject(e);\n-                        });\n-                })\n-                .catch(e => {\n-                    reject(e);\n-                });\n-        });\n+        return this._createIndexes()\n+            .then((createIndexResults) => {\n+                return this._validate(purchaseOrder)\n+                    .then(validData => {","path":"src/managers/purchasing/purchase-order-manager.js","position":122,"original_position":122,"commit_id":"e8e4729908206b4e3adeff0d520dd0fb36098b68","original_commit_id":"e8e4729908206b4e3adeff0d520dd0fb36098b68","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars3.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').","created_at":"2017-03-01T08:55:38Z","updated_at":"2017-03-01T08:55:39Z","html_url":"https://github.com/danliris/dl-module/pull/490#discussion_r103635787","pull_request_url":"https://api.github.com/repos/danliris/dl-module/pulls/490","_links":{"self":{"href":"https://api.github.com/repos/danliris/dl-module/pulls/comments/103635787"},"html":{"href":"https://github.com/danliris/dl-module/pull/490#discussion_r103635787"},"pull_request":{"href":"https://api.github.com/repos/danliris/dl-module/pulls/490"}}},"pull_request":{"url":"https://api.github.com/repos/danliris/dl-module/pulls/490","id":108492787,"html_url":"https://github.com/danliris/dl-module/pull/490","diff_url":"https://github.com/danliris/dl-module/pull/490.diff","patch_url":"https://github.com/danliris/dl-module/pull/490.patch","issue_url":"https://api.github.com/repos/danliris/dl-module/issues/490","number":490,"state":"open","locked":false,"title":"add parseFloat for price and currencyRate ","user":{"login":"indriHutabalian","id":20896254,"avatar_url":"https://avatars2.githubusercontent.com/u/20896254?v=3","gravatar_id":"","url":"https://api.github.com/users/indriHutabalian","html_url":"https://github.com/indriHutabalian","followers_url":"https://api.github.com/users/indriHutabalian/followers","following_url":"https://api.github.com/users/indriHutabalian/following{/other_user}","gists_url":"https://api.github.com/users/indriHutabalian/gists{/gist_id}","starred_url":"https://api.github.com/users/indriHutabalian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/indriHutabalian/subscriptions","organizations_url":"https://api.github.com/users/indriHutabalian/orgs","repos_url":"https://api.github.com/users/indriHutabalian/repos","events_url":"https://api.github.com/users/indriHutabalian/events{/privacy}","received_events_url":"https://api.github.com/users/indriHutabalian/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-03-01T08:55:28Z","updated_at":"2017-03-01T08:55:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b9a87b6cff420ba034732a4204e40d54e3186a4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/danliris/dl-module/pulls/490/commits","review_comments_url":"https://api.github.com/repos/danliris/dl-module/pulls/490/comments","review_comment_url":"https://api.github.com/repos/danliris/dl-module/pulls/comments{/number}","comments_url":"https://api.github.com/repos/danliris/dl-module/issues/490/comments","statuses_url":"https://api.github.com/repos/danliris/dl-module/statuses/e8e4729908206b4e3adeff0d520dd0fb36098b68","head":{"label":"indriHutabalian:dev","ref":"dev","sha":"e8e4729908206b4e3adeff0d520dd0fb36098b68","user":{"login":"indriHutabalian","id":20896254,"avatar_url":"https://avatars2.githubusercontent.com/u/20896254?v=3","gravatar_id":"","url":"https://api.github.com/users/indriHutabalian","html_url":"https://github.com/indriHutabalian","followers_url":"https://api.github.com/users/indriHutabalian/followers","following_url":"https://api.github.com/users/indriHutabalian/following{/other_user}","gists_url":"https://api.github.com/users/indriHutabalian/gists{/gist_id}","starred_url":"https://api.github.com/users/indriHutabalian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/indriHutabalian/subscriptions","organizations_url":"https://api.github.com/users/indriHutabalian/orgs","repos_url":"https://api.github.com/users/indriHutabalian/repos","events_url":"https://api.github.com/users/indriHutabalian/events{/privacy}","received_events_url":"https://api.github.com/users/indriHutabalian/received_events","type":"User","site_admin":false},"repo":{"id":66045418,"name":"dl-module","full_name":"indriHutabalian/dl-module","owner":{"login":"indriHutabalian","id":20896254,"avatar_url":"https://avatars2.githubusercontent.com/u/20896254?v=3","gravatar_id":"","url":"https://api.github.com/users/indriHutabalian","html_url":"https://github.com/indriHutabalian","followers_url":"https://api.github.com/users/indriHutabalian/followers","following_url":"https://api.github.com/users/indriHutabalian/following{/other_user}","gists_url":"https://api.github.com/users/indriHutabalian/gists{/gist_id}","starred_url":"https://api.github.com/users/indriHutabalian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/indriHutabalian/subscriptions","organizations_url":"https://api.github.com/users/indriHutabalian/orgs","repos_url":"https://api.github.com/users/indriHutabalian/repos","events_url":"https://api.github.com/users/indriHutabalian/events{/privacy}","received_events_url":"https://api.github.com/users/indriHutabalian/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/indriHutabalian/dl-module","description":"Dan Liris Modules","fork":true,"url":"https://api.github.com/repos/indriHutabalian/dl-module","forks_url":"https://api.github.com/repos/indriHutabalian/dl-module/forks","keys_url":"https://api.github.com/repos/indriHutabalian/dl-module/keys{/key_id}","collaborators_url":"https://api.github.com/repos/indriHutabalian/dl-module/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/indriHutabalian/dl-module/teams","hooks_url":"https://api.github.com/repos/indriHutabalian/dl-module/hooks","issue_events_url":"https://api.github.com/repos/indriHutabalian/dl-module/issues/events{/number}","events_url":"https://api.github.com/repos/indriHutabalian/dl-module/events","assignees_url":"https://api.github.com/repos/indriHutabalian/dl-module/assignees{/user}","branches_url":"https://api.github.com/repos/indriHutabalian/dl-module/branches{/branch}","tags_url":"https://api.github.com/repos/indriHutabalian/dl-module/tags","blobs_url":"https://api.github.com/repos/indriHutabalian/dl-module/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/indriHutabalian/dl-module/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/indriHutabalian/dl-module/git/refs{/sha}","trees_url":"https://api.github.com/repos/indriHutabalian/dl-module/git/trees{/sha}","statuses_url":"https://api.github.com/repos/indriHutabalian/dl-module/statuses/{sha}","languages_url":"https://api.github.com/repos/indriHutabalian/dl-module/languages","stargazers_url":"https://api.github.com/repos/indriHutabalian/dl-module/stargazers","contributors_url":"https://api.github.com/repos/indriHutabalian/dl-module/contributors","subscribers_url":"https://api.github.com/repos/indriHutabalian/dl-module/subscribers","subscription_url":"https://api.github.com/repos/indriHutabalian/dl-module/subscription","commits_url":"https://api.github.com/repos/indriHutabalian/dl-module/commits{/sha}","git_commits_url":"https://api.github.com/repos/indriHutabalian/dl-module/git/commits{/sha}","comments_url":"https://api.github.com/repos/indriHutabalian/dl-module/comments{/number}","issue_comment_url":"https://api.github.com/repos/indriHutabalian/dl-module/issues/comments{/number}","contents_url":"https://api.github.com/repos/indriHutabalian/dl-module/contents/{+path}","compare_url":"https://api.github.com/repos/indriHutabalian/dl-module/compare/{base}...{head}","merges_url":"https://api.github.com/repos/indriHutabalian/dl-module/merges","archive_url":"https://api.github.com/repos/indriHutabalian/dl-module/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/indriHutabalian/dl-module/downloads","issues_url":"https://api.github.com/repos/indriHutabalian/dl-module/issues{/number}","pulls_url":"https://api.github.com/repos/indriHutabalian/dl-module/pulls{/number}","milestones_url":"https://api.github.com/repos/indriHutabalian/dl-module/milestones{/number}","notifications_url":"https://api.github.com/repos/indriHutabalian/dl-module/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/indriHutabalian/dl-module/labels{/name}","releases_url":"https://api.github.com/repos/indriHutabalian/dl-module/releases{/id}","deployments_url":"https://api.github.com/repos/indriHutabalian/dl-module/deployments","created_at":"2016-08-19T02:17:47Z","updated_at":"2016-08-19T02:17:48Z","pushed_at":"2017-03-01T07:44:07Z","git_url":"git://github.com/indriHutabalian/dl-module.git","ssh_url":"git@github.com:indriHutabalian/dl-module.git","clone_url":"https://github.com/indriHutabalian/dl-module.git","svn_url":"https://github.com/indriHutabalian/dl-module","homepage":null,"size":2610,"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":"danliris:dev","ref":"dev","sha":"74c3920c088dd4f8ff18fe34040f7e04246639ba","user":{"login":"danliris","id":20855729,"avatar_url":"https://avatars3.githubusercontent.com/u/20855729?v=3","gravatar_id":"","url":"https://api.github.com/users/danliris","html_url":"https://github.com/danliris","followers_url":"https://api.github.com/users/danliris/followers","following_url":"https://api.github.com/users/danliris/following{/other_user}","gists_url":"https://api.github.com/users/danliris/gists{/gist_id}","starred_url":"https://api.github.com/users/danliris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danliris/subscriptions","organizations_url":"https://api.github.com/users/danliris/orgs","repos_url":"https://api.github.com/users/danliris/repos","events_url":"https://api.github.com/users/danliris/events{/privacy}","received_events_url":"https://api.github.com/users/danliris/received_events","type":"User","site_admin":false},"repo":{"id":64628314,"name":"dl-module","full_name":"danliris/dl-module","owner":{"login":"danliris","id":20855729,"avatar_url":"https://avatars3.githubusercontent.com/u/20855729?v=3","gravatar_id":"","url":"https://api.github.com/users/danliris","html_url":"https://github.com/danliris","followers_url":"https://api.github.com/users/danliris/followers","following_url":"https://api.github.com/users/danliris/following{/other_user}","gists_url":"https://api.github.com/users/danliris/gists{/gist_id}","starred_url":"https://api.github.com/users/danliris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danliris/subscriptions","organizations_url":"https://api.github.com/users/danliris/orgs","repos_url":"https://api.github.com/users/danliris/repos","events_url":"https://api.github.com/users/danliris/events{/privacy}","received_events_url":"https://api.github.com/users/danliris/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danliris/dl-module","description":"Dan Liris Modules","fork":false,"url":"https://api.github.com/repos/danliris/dl-module","forks_url":"https://api.github.com/repos/danliris/dl-module/forks","keys_url":"https://api.github.com/repos/danliris/dl-module/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danliris/dl-module/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danliris/dl-module/teams","hooks_url":"https://api.github.com/repos/danliris/dl-module/hooks","issue_events_url":"https://api.github.com/repos/danliris/dl-module/issues/events{/number}","events_url":"https://api.github.com/repos/danliris/dl-module/events","assignees_url":"https://api.github.com/repos/danliris/dl-module/assignees{/user}","branches_url":"https://api.github.com/repos/danliris/dl-module/branches{/branch}","tags_url":"https://api.github.com/repos/danliris/dl-module/tags","blobs_url":"https://api.github.com/repos/danliris/dl-module/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danliris/dl-module/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danliris/dl-module/git/refs{/sha}","trees_url":"https://api.github.com/repos/danliris/dl-module/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danliris/dl-module/statuses/{sha}","languages_url":"https://api.github.com/repos/danliris/dl-module/languages","stargazers_url":"https://api.github.com/repos/danliris/dl-module/stargazers","contributors_url":"https://api.github.com/repos/danliris/dl-module/contributors","subscribers_url":"https://api.github.com/repos/danliris/dl-module/subscribers","subscription_url":"https://api.github.com/repos/danliris/dl-module/subscription","commits_url":"https://api.github.com/repos/danliris/dl-module/commits{/sha}","git_commits_url":"https://api.github.com/repos/danliris/dl-module/git/commits{/sha}","comments_url":"https://api.github.com/repos/danliris/dl-module/comments{/number}","issue_comment_url":"https://api.github.com/repos/danliris/dl-module/issues/comments{/number}","contents_url":"https://api.github.com/repos/danliris/dl-module/contents/{+path}","compare_url":"https://api.github.com/repos/danliris/dl-module/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danliris/dl-module/merges","archive_url":"https://api.github.com/repos/danliris/dl-module/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danliris/dl-module/downloads","issues_url":"https://api.github.com/repos/danliris/dl-module/issues{/number}","pulls_url":"https://api.github.com/repos/danliris/dl-module/pulls{/number}","milestones_url":"https://api.github.com/repos/danliris/dl-module/milestones{/number}","notifications_url":"https://api.github.com/repos/danliris/dl-module/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danliris/dl-module/labels{/name}","releases_url":"https://api.github.com/repos/danliris/dl-module/releases{/id}","deployments_url":"https://api.github.com/repos/danliris/dl-module/deployments","created_at":"2016-08-01T02:15:05Z","updated_at":"2016-08-08T03:27:08Z","pushed_at":"2017-03-01T08:55:29Z","git_url":"git://github.com/danliris/dl-module.git","ssh_url":"git@github.com:danliris/dl-module.git","clone_url":"https://github.com/danliris/dl-module.git","svn_url":"https://github.com/danliris/dl-module","homepage":null,"size":2605,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":2,"forks":14,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/danliris/dl-module/pulls/490"},"html":{"href":"https://github.com/danliris/dl-module/pull/490"},"issue":{"href":"https://api.github.com/repos/danliris/dl-module/issues/490"},"comments":{"href":"https://api.github.com/repos/danliris/dl-module/issues/490/comments"},"review_comments":{"href":"https://api.github.com/repos/danliris/dl-module/pulls/490/comments"},"review_comment":{"href":"https://api.github.com/repos/danliris/dl-module/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/danliris/dl-module/pulls/490/commits"},"statuses":{"href":"https://api.github.com/repos/danliris/dl-module/statuses/e8e4729908206b4e3adeff0d520dd0fb36098b68"}}}}
{"actor":{"display_login":"houndci-bot"}}