OSDN Git Service

add the decimal displayed for the transaction show
authorZhiting Lin <zlin035@uottawa.ca>
Fri, 20 Apr 2018 08:22:08 +0000 (16:22 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Fri, 20 Apr 2018 08:22:08 +0000 (16:22 +0800)
src/utility/buildInOutDisplay.js

index ccef483..89300e7 100644 (file)
@@ -123,10 +123,15 @@ const balanceFields = Object.keys(mappings)
 
 const buildDisplay = (item, fields, btmAmountUnit, lang) => {
   const details = []
+  const decimals = (item.assetDefinition && item.assetDefinition.decimals && item.assetId !== btmID)?
+    item.assetDefinition.decimals: null
   fields.forEach(key => {
     if (item.hasOwnProperty(key)) {
       if(key === 'amount'){
-        details.push({label: ( lang === 'zh'? mappings_ZH[key]: mappings[key] ), value: normalizeGlobalBTMAmount(item['assetId'], item[key], btmAmountUnit)})
+        details.push({
+          label: ( lang === 'zh'? mappings_ZH[key]: mappings[key] ),
+          value: decimals? formatIntNumToPosDecimal(item[key], decimals) :normalizeGlobalBTMAmount(item['assetId'], item[key], btmAmountUnit)
+        })
       }else{
         details.push({label: ( lang === 'zh'? mappings_ZH[key]: mappings[key] ), value: item[key]})
       }