diff options
-rw-r--r-- | js/backoffice.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/js/backoffice.js b/js/backoffice.js index 205a3bd..8ce913c 100644 --- a/js/backoffice.js +++ b/js/backoffice.js @@ -39,6 +39,15 @@ var LAST = 0; * it wrong. */ function amount_to_string(amount){ + if (typeof amount === 'string' || amount instanceof String) + { + var split = amount.match(/([A-Z]+):([0-9]+)\.?([0-9]+)?/); + if (!split) + return "Bad amount given: " + amount; + if (split[3]) + return `${split[2]}.${split[3]} ${split[1]}`; + return `${split[2]}.00 ${split[1]}`; + } var number = Number(amount.value) + (Number(amount.fraction)/FRACTION); return `${number.toFixed(2)} ${amount.currency}`; @@ -387,7 +396,7 @@ function fill_table(scroll, data, execution_time, wtid_marker){ ${entry.order_id}</a>`; td_summary.className = "summary"; td_summary.innerHTML = entry.summary; - td_amount.innerHTML = entry.amount; + td_amount.innerHTML = amount_to_string(entry.amount); td_date.innerHTML = parse_date (entry.timestamp || execution_time); row.appendChild(td_order_id); |