Last active
August 16, 2016 22:01
-
-
Save alexandremaeda/f9ae2a44e87b48ed476fa8f2c38b7b48 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// repository | |
const repository = { | |
findByUserID: (userID) => Simulator.findOne({ user: userID }).exec() | |
}; | |
// controller | |
const getModulesAmount = (req, res) => { | |
var valueMonth = req.param('valueMonth'); | |
var modules = 5; // create a flag | |
repository.findByUserID(req.decoded._doc._id).then( (doc) => { | |
if (valueMonth > 126.96) { // create a flag | |
modules = Math.ceil(((valueMonth - doc.taxaDisponibilidade * doc.tarifaImpostos) * 1000) / (30 * doc.hsp * doc.tarifaImpostos * doc.potenciaModulo)); | |
} | |
res.status(200).json({modules: modules}).end(); | |
}) | |
.catch( err => { | |
res.status(500).json({error: err}).end(); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment