From e955bc5bb9af90f6e9750bc8243d478c2499de52 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Sat, 8 Dec 2012 18:15:37 -0800 Subject: [PATCH] JS: Fixes for add and subtract. --- src/js/amount.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/js/amount.js b/src/js/amount.js index e02a0c72f3..9c407dbda4 100644 --- a/src/js/amount.js +++ b/src/js/amount.js @@ -383,7 +383,7 @@ Amount.prototype.add = function(v) { var result; if (!this.is_comparable(v)) { - result = Amount.NaN(); + result = Amount.NaN(); } else if (this._is_native) { result = new Amount(); @@ -411,9 +411,13 @@ Amount.prototype.add = function(v) { result._is_negative = result._value.compareTo(BigInteger.ZERO) < 0; if (result._is_negative) { - result._value = result._value.negate(); + result._value = result._value.negate(); + result._is_negative = false; } + result._currency = this._currency.clone(); + result._issuer = this._issuer.clone(); + // XXX Do we need to worry about overflow? Maybe only in to_json. result.canonicalize(); }