Skip to content

Commit

Permalink
Merge pull request #1014 from OneCommunityGlobal/Shereen_EquipmentPur…
Browse files Browse the repository at this point in the history
…chase

Shereen_Purchase_Equipment
  • Loading branch information
one-community authored Jun 30, 2024
2 parents b350948 + 0c4c3b3 commit 5850ffa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
13 changes: 13 additions & 0 deletions src/controllers/bmdashboard/bmInventoryTypeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ function bmInventoryTypeController(InvType, MatType, ConsType, ReusType, ToolTyp
res.status(500).send(error);
}
}

async function fetchEquipmentTypes(req, res) {
try {
EquipType.find()
.exec()
.then((result) => res.status(200).send(result))
.catch((error) => res.status(500).send(error));
} catch (err) {
res.json(err);
}
}

const fetchSingleInventoryType = async (req, res) => {
const { invtypeId } = req.params;
try {
Expand Down Expand Up @@ -317,6 +329,7 @@ function bmInventoryTypeController(InvType, MatType, ConsType, ReusType, ToolTyp
fetchReusableTypes,
fetchToolTypes,
addEquipmentType,
fetchEquipmentTypes,
fetchSingleInventoryType,
updateNameAndUnit,
addMaterialType,
Expand Down
9 changes: 5 additions & 4 deletions src/models/bmdashboard/buildingInventoryItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const largeItemBaseSchema = mongoose.Schema({
responsibleUser: { type: mongoose.SchemaTypes.ObjectId, ref: 'userProfile' },
type: { type: String, enum: ['Check In', 'Check Out'] },
}],
userResponsible: { type: mongoose.SchemaTypes.ObjectId, ref: 'userProfile' }, //new field
userResponsible: { type: mongoose.SchemaTypes.ObjectId, ref: 'userProfile' }, // new field
});

const largeItemBase = mongoose.model('largeItemBase', largeItemBaseSchema, 'buildingInventoryItems');
Expand Down Expand Up @@ -130,7 +130,8 @@ const buildingTool = largeItemBase.discriminator('tool_item', new mongoose.Schem
code: { type: String, default: '001' },
purchaseStatus: {
type: String,
enum: ['Needed', 'Purchased'] // Override enum values
enum: ['Rental', 'Purchased'], // Override enum values
default: 'Rental',
}
}));

Expand All @@ -144,8 +145,8 @@ const buildingTool = largeItemBase.discriminator('tool_item', new mongoose.Schem
// ex: tractors, excavators, bulldozers

const buildingEquipment = largeItemBase.discriminator('equipment_item', new mongoose.Schema({
isTracked: { type: Boolean, required: true }, // has asset tracker
assetTracker: { type: String, required: () => this.isTracked }, // required if isTracked = true (syntax?)
// isTracked: { type: Boolean, required: true }, // has asset tracker
// assetTracker: { type: String, required: () => this.isTracked }, // required if isTracked = true (syntax?)
}));

module.exports = {
Expand Down
2 changes: 2 additions & 0 deletions src/routes/bmdashboard/bmInventoryTypeRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const routes = function (baseInvType, matType, consType, reusType, toolType, equ

inventoryTypeRouter.route('/invtypes/equipment').post(controller.addEquipmentType);

inventoryTypeRouter.route('/invtypes/equipments').get(controller.fetchEquipmentTypes);

inventoryTypeRouter.route('/invtypes/consumables').get(controller.fetchConsumableTypes);

// Route for fetching types by selected type
Expand Down

0 comments on commit 5850ffa

Please sign in to comment.