From 7dd0ee6ed9ba21cd4e27458938030449cd32c78f Mon Sep 17 00:00:00 2001 From: Stefan Thomas Date: Wed, 13 Feb 2013 18:32:14 +0100 Subject: [PATCH] JS: Allow an integer factor in Amount#product_human. --- src/js/amount.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/js/amount.js b/src/js/amount.js index a690616d..bbaea1bb 100644 --- a/src/js/amount.js +++ b/src/js/amount.js @@ -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) { - factor = Amount.from_json(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); @@ -436,7 +441,7 @@ Amount.prototype.issuer = function () { Amount.prototype.multiply = function (v) { var result; - if (this.is_zero()) { + if (this.is_zero()) { result = this.clone(); } else if (v.is_zero()) {