{"action":"created","comment":{"url":"https://api.github.com/repos/agriculture-capstone/agricore/pulls/comments/165786982","pull_request_review_id":93787516,"id":165786982,"diff_hunk":"@@ -55,14 +88,34 @@ export async function createProdTransactionsInDb(apiReq: api.ProdTransactionReq)\n     lastmodified: new Date().toISOString(),\n   };\n \n+  // create database request for attribute entry\n   const attributes: db.ProdTransactionAttrDb[] = [];\n \n-  if (apiReq.milkQuality) {\n-    attributes.push({\n-      attrname: 'milkQuality',\n-      attrvalue: apiReq.milkQuality,\n+  if (apiReq.productType === 'milk') {\n+    if (!apiReq.milkQuality) {\n+      invalidFields.push('milkQuality');\n+    } else {\n+      attributes.push({\n+        attrname: 'milkQuality',\n+        attrvalue: apiReq.milkQuality,\n+      });\n+    }\n+  }\n+\n+  // throw error for any invalid fields\n+  if (invalidFields.length !== 0) {\n+    let errorMsg = 'The following fields are invalid or missing';\n+    invalidFields.forEach(function (invalidField) {\n+      errorMsg += ', ' + invalidField;\n     });\n+    throw new Error(errorMsg);\n   }\n \n-  return db.insertProdTransaction(dbInsertReq, attributes);\n+  let newUuid: string;\n+  try {\n+    newUuid = await db.insertProdTransaction(dbInsertReq, attributes);\n+  } catch (e) {\n+    throw new Error(unhandledErrorMsg);","path":"src/services/ProductTransactions.ts","position":118,"original_position":91,"commit_id":"cce514b17956af9fc73841434c05b199d79f14ff","original_commit_id":"cce514b17956af9fc73841434c05b199d79f14ff","user":{"login":"enochtsang","id":9893396,"avatar_url":"https://avatars3.githubusercontent.com/u/9893396?v=4","gravatar_id":"","url":"https://api.github.com/users/enochtsang","html_url":"https://github.com/enochtsang","followers_url":"https://api.github.com/users/enochtsang/followers","following_url":"https://api.github.com/users/enochtsang/following{/other_user}","gists_url":"https://api.github.com/users/enochtsang/gists{/gist_id}","starred_url":"https://api.github.com/users/enochtsang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enochtsang/subscriptions","organizations_url":"https://api.github.com/users/enochtsang/orgs","repos_url":"https://api.github.com/users/enochtsang/repos","events_url":"https://api.github.com/users/enochtsang/events{/privacy}","received_events_url":"https://api.github.com/users/enochtsang/received_events","type":"User","site_admin":false},"body":"I'll log it, but it shouldn't be thrown up, because the clients can see it.","created_at":"2018-02-02T23:30:08Z","updated_at":"2018-02-02T23:30:08Z","html_url":"https://github.com/agriculture-capstone/agricore/pull/71#discussion_r165786982","pull_request_url":"https://api.github.com/repos/agriculture-capstone/agricore/pulls/71","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/agriculture-capstone/agricore/pulls/comments/165786982"},"html":{"href":"https://github.com/agriculture-capstone/agricore/pull/71#discussion_r165786982"},"pull_request":{"href":"https://api.github.com/repos/agriculture-capstone/agricore/pulls/71"}},"in_reply_to_id":165762302},"pull_request":{"url":"https://api.github.com/repos/agriculture-capstone/agricore/pulls/71","id":166722886,"html_url":"https://github.com/agriculture-capstone/agricore/pull/71","diff_url":"https://github.com/agriculture-capstone/agricore/pull/71.diff","patch_url":"https://github.com/agriculture-capstone/agricore/pull/71.patch","issue_url":"https://api.github.com/repos/agriculture-capstone/agricore/issues/71","number":71,"state":"open","locked":false,"title":"Enoch/ac 65 post product transaction","user":{"login":"enochtsang","id":9893396,"avatar_url":"https://avatars3.githubusercontent.com/u/9893396?v=4","gravatar_id":"","url":"https://api.github.com/users/enochtsang","html_url":"https://github.com/enochtsang","followers_url":"https://api.github.com/users/enochtsang/followers","following_url":"https://api.github.com/users/enochtsang/following{/other_user}","gists_url":"https://api.github.com/users/enochtsang/gists{/gist_id}","starred_url":"https://api.github.com/users/enochtsang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enochtsang/subscriptions","organizations_url":"https://api.github.com/users/enochtsang/orgs","repos_url":"https://api.github.com/users/enochtsang/repos","events_url":"https://api.github.com/users/enochtsang/events{/privacy}","received_events_url":"https://api.github.com/users/enochtsang/received_events","type":"User","site_admin":false},"body":"APIs have their own interface types, database has their own, service in the middle to translate between the two types.\r\n\r\nExample CURL request\r\n```JSON\r\ncurl -d '{\r\n\t\"datetime\": \"2000-01-01 12:12:12Z\",\r\n\t\"toPersonUuid\": \"a2b121fd-1a1f-4425-97db-876af3c5bd2f\",\r\n\t\"fromPersonUuid\": \"2fc0977d-c49b-47e8-9a03-090c5c65792d\",\r\n\t\"amountOfProduct\": 99.99,\r\n\t\"costPerUnit\": 99.99,\r\n\t\"currency\": \"UGX\",\r\n\t\"milkQuality\": \"9999\"\r\n}' -H \"Content-Type: application/json\" -X POST http://localhost:9090/transactions/products/milk\r\n\r\n```","created_at":"2018-02-02T05:48:36Z","updated_at":"2018-02-02T23:30:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1ac76150713af2440b75454007094a26ad5a3729","assignee":{"login":"beaesguerra","id":14334617,"avatar_url":"https://avatars2.githubusercontent.com/u/14334617?v=4","gravatar_id":"","url":"https://api.github.com/users/beaesguerra","html_url":"https://github.com/beaesguerra","followers_url":"https://api.github.com/users/beaesguerra/followers","following_url":"https://api.github.com/users/beaesguerra/following{/other_user}","gists_url":"https://api.github.com/users/beaesguerra/gists{/gist_id}","starred_url":"https://api.github.com/users/beaesguerra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beaesguerra/subscriptions","organizations_url":"https://api.github.com/users/beaesguerra/orgs","repos_url":"https://api.github.com/users/beaesguerra/repos","events_url":"https://api.github.com/users/beaesguerra/events{/privacy}","received_events_url":"https://api.github.com/users/beaesguerra/received_events","type":"User","site_admin":false},"assignees":[{"login":"beaesguerra","id":14334617,"avatar_url":"https://avatars2.githubusercontent.com/u/14334617?v=4","gravatar_id":"","url":"https://api.github.com/users/beaesguerra","html_url":"https://github.com/beaesguerra","followers_url":"https://api.github.com/users/beaesguerra/followers","following_url":"https://api.github.com/users/beaesguerra/following{/other_user}","gists_url":"https://api.github.com/users/beaesguerra/gists{/gist_id}","starred_url":"https://api.github.com/users/beaesguerra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beaesguerra/subscriptions","organizations_url":"https://api.github.com/users/beaesguerra/orgs","repos_url":"https://api.github.com/users/beaesguerra/repos","events_url":"https://api.github.com/users/beaesguerra/events{/privacy}","received_events_url":"https://api.github.com/users/beaesguerra/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/agriculture-capstone/agricore/pulls/71/commits","review_comments_url":"https://api.github.com/repos/agriculture-capstone/agricore/pulls/71/comments","review_comment_url":"https://api.github.com/repos/agriculture-capstone/agricore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/agriculture-capstone/agricore/issues/71/comments","statuses_url":"https://api.github.com/repos/agriculture-capstone/agricore/statuses/cce514b17956af9fc73841434c05b199d79f14ff","head":{"label":"agriculture-capstone:enoch/ac-65-post-product-transaction","ref":"enoch/ac-65-post-product-transaction","sha":"cce514b17956af9fc73841434c05b199d79f14ff","user":{"login":"agriculture-capstone","id":32144790,"avatar_url":"https://avatars3.githubusercontent.com/u/32144790?v=4","gravatar_id":"","url":"https://api.github.com/users/agriculture-capstone","html_url":"https://github.com/agriculture-capstone","followers_url":"https://api.github.com/users/agriculture-capstone/followers","following_url":"https://api.github.com/users/agriculture-capstone/following{/other_user}","gists_url":"https://api.github.com/users/agriculture-capstone/gists{/gist_id}","starred_url":"https://api.github.com/users/agriculture-capstone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agriculture-capstone/subscriptions","organizations_url":"https://api.github.com/users/agriculture-capstone/orgs","repos_url":"https://api.github.com/users/agriculture-capstone/repos","events_url":"https://api.github.com/users/agriculture-capstone/events{/privacy}","received_events_url":"https://api.github.com/users/agriculture-capstone/received_events","type":"Organization","site_admin":false},"repo":{"id":106718315,"name":"agricore","full_name":"agriculture-capstone/agricore","owner":{"login":"agriculture-capstone","id":32144790,"avatar_url":"https://avatars3.githubusercontent.com/u/32144790?v=4","gravatar_id":"","url":"https://api.github.com/users/agriculture-capstone","html_url":"https://github.com/agriculture-capstone","followers_url":"https://api.github.com/users/agriculture-capstone/followers","following_url":"https://api.github.com/users/agriculture-capstone/following{/other_user}","gists_url":"https://api.github.com/users/agriculture-capstone/gists{/gist_id}","starred_url":"https://api.github.com/users/agriculture-capstone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agriculture-capstone/subscriptions","organizations_url":"https://api.github.com/users/agriculture-capstone/orgs","repos_url":"https://api.github.com/users/agriculture-capstone/repos","events_url":"https://api.github.com/users/agriculture-capstone/events{/privacy}","received_events_url":"https://api.github.com/users/agriculture-capstone/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/agriculture-capstone/agricore","description":"The Agriculture Core","fork":false,"url":"https://api.github.com/repos/agriculture-capstone/agricore","forks_url":"https://api.github.com/repos/agriculture-capstone/agricore/forks","keys_url":"https://api.github.com/repos/agriculture-capstone/agricore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/agriculture-capstone/agricore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/agriculture-capstone/agricore/teams","hooks_url":"https://api.github.com/repos/agriculture-capstone/agricore/hooks","issue_events_url":"https://api.github.com/repos/agriculture-capstone/agricore/issues/events{/number}","events_url":"https://api.github.com/repos/agriculture-capstone/agricore/events","assignees_url":"https://api.github.com/repos/agriculture-capstone/agricore/assignees{/user}","branches_url":"https://api.github.com/repos/agriculture-capstone/agricore/branches{/branch}","tags_url":"https://api.github.com/repos/agriculture-capstone/agricore/tags","blobs_url":"https://api.github.com/repos/agriculture-capstone/agricore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/agriculture-capstone/agricore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/agriculture-capstone/agricore/git/refs{/sha}","trees_url":"https://api.github.com/repos/agriculture-capstone/agricore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/agriculture-capstone/agricore/statuses/{sha}","languages_url":"https://api.github.com/repos/agriculture-capstone/agricore/languages","stargazers_url":"https://api.github.com/repos/agriculture-capstone/agricore/stargazers","contributors_url":"https://api.github.com/repos/agriculture-capstone/agricore/contributors","subscribers_url":"https://api.github.com/repos/agriculture-capstone/agricore/subscribers","subscription_url":"https://api.github.com/repos/agriculture-capstone/agricore/subscription","commits_url":"https://api.github.com/repos/agriculture-capstone/agricore/commits{/sha}","git_commits_url":"https://api.github.com/repos/agriculture-capstone/agricore/git/commits{/sha}","comments_url":"https://api.github.com/repos/agriculture-capstone/agricore/comments{/number}","issue_comment_url":"https://api.github.com/repos/agriculture-capstone/agricore/issues/comments{/number}","contents_url":"https://api.github.com/repos/agriculture-capstone/agricore/contents/{+path}","compare_url":"https://api.github.com/repos/agriculture-capstone/agricore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/agriculture-capstone/agricore/merges","archive_url":"https://api.github.com/repos/agriculture-capstone/agricore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/agriculture-capstone/agricore/downloads","issues_url":"https://api.github.com/repos/agriculture-capstone/agricore/issues{/number}","pulls_url":"https://api.github.com/repos/agriculture-capstone/agricore/pulls{/number}","milestones_url":"https://api.github.com/repos/agriculture-capstone/agricore/milestones{/number}","notifications_url":"https://api.github.com/repos/agriculture-capstone/agricore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/agriculture-capstone/agricore/labels{/name}","releases_url":"https://api.github.com/repos/agriculture-capstone/agricore/releases{/id}","deployments_url":"https://api.github.com/repos/agriculture-capstone/agricore/deployments","created_at":"2017-10-12T16:30:56Z","updated_at":"2018-01-19T08:38:17Z","pushed_at":"2018-02-02T21:40:46Z","git_url":"git://github.com/agriculture-capstone/agricore.git","ssh_url":"git@github.com:agriculture-capstone/agricore.git","clone_url":"https://github.com/agriculture-capstone/agricore.git","svn_url":"https://github.com/agriculture-capstone/agricore","homepage":null,"size":416,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":11,"watchers":0,"default_branch":"master"}},"base":{"label":"agriculture-capstone:master","ref":"master","sha":"4d3a437e91d4bbdfb08a6cb64960cd2bece50836","user":{"login":"agriculture-capstone","id":32144790,"avatar_url":"https://avatars3.githubusercontent.com/u/32144790?v=4","gravatar_id":"","url":"https://api.github.com/users/agriculture-capstone","html_url":"https://github.com/agriculture-capstone","followers_url":"https://api.github.com/users/agriculture-capstone/followers","following_url":"https://api.github.com/users/agriculture-capstone/following{/other_user}","gists_url":"https://api.github.com/users/agriculture-capstone/gists{/gist_id}","starred_url":"https://api.github.com/users/agriculture-capstone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agriculture-capstone/subscriptions","organizations_url":"https://api.github.com/users/agriculture-capstone/orgs","repos_url":"https://api.github.com/users/agriculture-capstone/repos","events_url":"https://api.github.com/users/agriculture-capstone/events{/privacy}","received_events_url":"https://api.github.com/users/agriculture-capstone/received_events","type":"Organization","site_admin":false},"repo":{"id":106718315,"name":"agricore","full_name":"agriculture-capstone/agricore","owner":{"login":"agriculture-capstone","id":32144790,"avatar_url":"https://avatars3.githubusercontent.com/u/32144790?v=4","gravatar_id":"","url":"https://api.github.com/users/agriculture-capstone","html_url":"https://github.com/agriculture-capstone","followers_url":"https://api.github.com/users/agriculture-capstone/followers","following_url":"https://api.github.com/users/agriculture-capstone/following{/other_user}","gists_url":"https://api.github.com/users/agriculture-capstone/gists{/gist_id}","starred_url":"https://api.github.com/users/agriculture-capstone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agriculture-capstone/subscriptions","organizations_url":"https://api.github.com/users/agriculture-capstone/orgs","repos_url":"https://api.github.com/users/agriculture-capstone/repos","events_url":"https://api.github.com/users/agriculture-capstone/events{/privacy}","received_events_url":"https://api.github.com/users/agriculture-capstone/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/agriculture-capstone/agricore","description":"The Agriculture Core","fork":false,"url":"https://api.github.com/repos/agriculture-capstone/agricore","forks_url":"https://api.github.com/repos/agriculture-capstone/agricore/forks","keys_url":"https://api.github.com/repos/agriculture-capstone/agricore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/agriculture-capstone/agricore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/agriculture-capstone/agricore/teams","hooks_url":"https://api.github.com/repos/agriculture-capstone/agricore/hooks","issue_events_url":"https://api.github.com/repos/agriculture-capstone/agricore/issues/events{/number}","events_url":"https://api.github.com/repos/agriculture-capstone/agricore/events","assignees_url":"https://api.github.com/repos/agriculture-capstone/agricore/assignees{/user}","branches_url":"https://api.github.com/repos/agriculture-capstone/agricore/branches{/branch}","tags_url":"https://api.github.com/repos/agriculture-capstone/agricore/tags","blobs_url":"https://api.github.com/repos/agriculture-capstone/agricore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/agriculture-capstone/agricore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/agriculture-capstone/agricore/git/refs{/sha}","trees_url":"https://api.github.com/repos/agriculture-capstone/agricore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/agriculture-capstone/agricore/statuses/{sha}","languages_url":"https://api.github.com/repos/agriculture-capstone/agricore/languages","stargazers_url":"https://api.github.com/repos/agriculture-capstone/agricore/stargazers","contributors_url":"https://api.github.com/repos/agriculture-capstone/agricore/contributors","subscribers_url":"https://api.github.com/repos/agriculture-capstone/agricore/subscribers","subscription_url":"https://api.github.com/repos/agriculture-capstone/agricore/subscription","commits_url":"https://api.github.com/repos/agriculture-capstone/agricore/commits{/sha}","git_commits_url":"https://api.github.com/repos/agriculture-capstone/agricore/git/commits{/sha}","comments_url":"https://api.github.com/repos/agriculture-capstone/agricore/comments{/number}","issue_comment_url":"https://api.github.com/repos/agriculture-capstone/agricore/issues/comments{/number}","contents_url":"https://api.github.com/repos/agriculture-capstone/agricore/contents/{+path}","compare_url":"https://api.github.com/repos/agriculture-capstone/agricore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/agriculture-capstone/agricore/merges","archive_url":"https://api.github.com/repos/agriculture-capstone/agricore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/agriculture-capstone/agricore/downloads","issues_url":"https://api.github.com/repos/agriculture-capstone/agricore/issues{/number}","pulls_url":"https://api.github.com/repos/agriculture-capstone/agricore/pulls{/number}","milestones_url":"https://api.github.com/repos/agriculture-capstone/agricore/milestones{/number}","notifications_url":"https://api.github.com/repos/agriculture-capstone/agricore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/agriculture-capstone/agricore/labels{/name}","releases_url":"https://api.github.com/repos/agriculture-capstone/agricore/releases{/id}","deployments_url":"https://api.github.com/repos/agriculture-capstone/agricore/deployments","created_at":"2017-10-12T16:30:56Z","updated_at":"2018-01-19T08:38:17Z","pushed_at":"2018-02-02T21:40:46Z","git_url":"git://github.com/agriculture-capstone/agricore.git","ssh_url":"git@github.com:agriculture-capstone/agricore.git","clone_url":"https://github.com/agriculture-capstone/agricore.git","svn_url":"https://github.com/agriculture-capstone/agricore","homepage":null,"size":416,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":11,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/agriculture-capstone/agricore/pulls/71"},"html":{"href":"https://github.com/agriculture-capstone/agricore/pull/71"},"issue":{"href":"https://api.github.com/repos/agriculture-capstone/agricore/issues/71"},"comments":{"href":"https://api.github.com/repos/agriculture-capstone/agricore/issues/71/comments"},"review_comments":{"href":"https://api.github.com/repos/agriculture-capstone/agricore/pulls/71/comments"},"review_comment":{"href":"https://api.github.com/repos/agriculture-capstone/agricore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/agriculture-capstone/agricore/pulls/71/commits"},"statuses":{"href":"https://api.github.com/repos/agriculture-capstone/agricore/statuses/cce514b17956af9fc73841434c05b199d79f14ff"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"enochtsang"}}