diff --git a/client/js/common/format.js b/client/js/common/format.js index 80544e2c..dc4fe828 100644 --- a/client/js/common/format.js +++ b/client/js/common/format.js @@ -17,6 +17,10 @@ format.camelToWords = function(str, os) { format.dollarsToCents = function(dollars) { dollars = dollars.toString().replace(/[$,]/g, '') + if(!isNaN(dollars) && dollars.match(/^-?\d+\.\d$/)) { + // could we use toFixed instead? Probably but this is straightforward. + dollars = dollars + "0" + } if(isNaN(dollars) || !dollars.match(/^-?\d+(\.\d\d)?$/)) throw "Invalid dollar amount: " + dollars return Math.round(Number(dollars) * 100) } diff --git a/client/js/nonprofits/donate/amount-step.js b/client/js/nonprofits/donate/amount-step.js index a5f42a45..26d0d2d9 100644 --- a/client/js/nonprofits/donate/amount-step.js +++ b/client/js/nonprofits/donate/amount-step.js @@ -187,7 +187,7 @@ function showSingleAmount(isRecurring, state) { var desig = state.params$().designation return h('section.u-centered', [ h('p.singleAmount-message', [ - h('strong', app.currency_symbol + state.params$().single_amount) + h('strong', app.currency_symbol + format.centsToDollars(format.dollarsToCents(state.params$().single_amount))) , h('span.u-padding--0', { class: {'u-hide': !isRecurring} }, ' monthly') , h('span', {class: {'u-hide': !state.params$().designation && !gift.id}}, [ ' for ' + (desig || gift.name) ]) ])