Skip to content

Commit

Permalink
Merge pull request #1072 from OneCommunityGlobal/abi-hotfix-be
Browse files Browse the repository at this point in the history
ambika restoring git state to a working environment and manually merged PRs
  • Loading branch information
kabraambika authored Aug 16, 2024
2 parents 2a5d9fc + 3345a1e commit 717a862
Show file tree
Hide file tree
Showing 16 changed files with 492 additions and 632 deletions.
17 changes: 17 additions & 0 deletions requirements/inventoryController/getAllInvInProject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Check mark: ✅
Cross Mark: ❌

# Post Badge

> ## Positive case
1. ❌ Receives a POST request in the **/api/userProfile** route
2. ❌ Returns 200 if successfully fetch inventory data

> ## Negative case
3. ❌ Returns error 404 if the API does not exist
4. ❌ Returns error code 403 if the user is not authorized to view the inventory data
5. ❌ Returns error code 404 if an error occurs when populating or saving.

> ## Edge case
17 changes: 17 additions & 0 deletions requirements/inventoryController/getAllInvInProjectWBS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Check mark: ✅
Cross Mark: ❌

# Post Badge

> ## Positive case
1. ❌ Receives a POST request in the **/api/userProfile** route
2. ✅ Returns 200 if successfully found data

> ## Negative case
1. ❌ Returns error 404 if the API does not exist
2. ✅ Returns 403 if user is not authorized to view inventory data
3. ✅ Returns 404 if an error occurs while fetching data

> ## Edge case
19 changes: 19 additions & 0 deletions requirements/inventoryController/postInvInProjectWBS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Check mark: ✅
Cross Mark: ❌

# Post Badge

> ## Positive case
1. ❌ Receives a POST request in the **/api/userProfile** route
2. ✅ Returns status code 201, if the inventory was successfully created and saved
3. ✅ Returns status code 201, if the inventory item was succesfully updated and saved.

> ## Negative case
1. ❌ Returns error 404 if the API does not exist
2. ✅ Returns error 403 if the user is not authorized to view data
3. ✅ Returns error 500 if an error occurs when saving
4. ✅ Returns error 400 if a valid project was found but quantity and type id were missing

> ## Edge case
8 changes: 4 additions & 4 deletions src/controllers/inventoryController.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const inventoryController = function (Item, ItemType) {
// use req.params.projectId and wbsId
// Run a mongo query on the Item model to find all items with both the project and wbs
// sort the mongo query so that the Wasted false items are listed first
return Item.find({
await Item.find({
project: mongoose.Types.ObjectId(req.params.projectId),
wbs:
req.params.wbsId && req.params.wbsId !== 'Unassigned'
Expand Down Expand Up @@ -283,9 +283,9 @@ const inventoryController = function (Item, ItemType) {
}

// update the original item by decreasing by the quantity and adding a note
if (req.body.quantity && req.params.invId && projectExists && wbsExists) {
if (req.body.quantity && req.param.invId && projectExists && wbsExists) {
return Item.findByIdAndUpdate(
req.params.invId,
req.param.invId,
{
$decr: { quantity: req.body.quantity },
$push: {
Expand Down Expand Up @@ -797,4 +797,4 @@ const inventoryController = function (Item, ItemType) {
};
};

module.exports = inventoryController;
module.exports = inventoryController;
Loading

0 comments on commit 717a862

Please sign in to comment.