JS: Allow an integer factor in Amount#product_human.

This commit is contained in:
Stefan Thomas
2013-02-13 18:32:14 +01:00
parent cd0a70565a
commit 7dd0ee6ed9

View File

@@ -380,7 +380,12 @@ Amount.prototype.ratio_human = function (denominator) {
* @return {Amount} The product. Unit will be the same as the first factor.
*/
Amount.prototype.product_human = function (factor) {
if ("number" === typeof factor && parseInt(factor) === factor) {
// Special handling of integer arguments
factor = Amount.from_json("" + factor + ".0");
} else {
factor = Amount.from_json(factor);
}
var product = this.multiply(factor);