Created
May 3, 2017 17:15
-
-
Save ryanmasondavies/72c8ace496f27f64da6835e412023539 to your computer and use it in GitHub Desktop.
On the 'new invoice' page, run this JS to round hours.
This file contains 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
var nodes = document.getElementsByName("qty[]"); | |
var index; | |
for (index = 0; index < nodes.length; ++index) { | |
var node = nodes[index]; | |
if (node.getAttribute("title") == "Task hours") { | |
var nonRoundedValueAsString = node.getAttribute("value"); | |
var nonRoundedValue = Number(nonRoundedValueAsString); | |
var roundedValue = (Math.round(nonRoundedValue * 4) / 4).toFixed(2); | |
console.log(nonRoundedValue + " => " + roundedValue); | |
node.value = roundedValue.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment