fixed amount formatting

This commit is contained in:
Akinwale Ariwodola 2017-09-24 09:52:13 +01:00
parent 0c362345c7
commit 06bdd73d71

10
app.js
View file

@ -226,7 +226,7 @@ const sendTip = (sender, recipient, amount, tipdata, callback) => {
how_to_use_url: config.howToUseUrl, how_to_use_url: config.howToUseUrl,
recipient: `u/${recipient}`, recipient: `u/${recipient}`,
amount: amount, amount: amount,
amount_usd: ['$', tipdata.amountUsd.toFixed(2)].join(''), amount_usd: ['$', parseFloat(tipdata.amountUsd).toFixed(2)].join(''),
balance: senderBalance balance: senderBalance
}, 'Insufficient funds to send tip', tipdata.message.data.author, () => { }, 'Insufficient funds to send tip', tipdata.message.data.author, () => {
markMessageRead(tipdata.message.data.name, () => { markMessageRead(tipdata.message.data.name, () => {
@ -276,7 +276,7 @@ const sendTip = (sender, recipient, amount, tipdata, callback) => {
}, },
(res, fields, cb) => { (res, fields, cb) => {
// reply to the source message with message template after successful commit // reply to the source message with message template after successful commit
const amountUsdStr = tipdata.amountUsd.toFixed(2); const amountUsdStr = parseFloat(tipdata.amountUsd).toFixed(2);
replyMessageUsingTemplate('onsendtip', { recipient: `u/${recipient}`, tip: `${amount} LBC ($${amountUsdStr})`, how_to_use_url: config.howToUseUrl}, replyMessageUsingTemplate('onsendtip', { recipient: `u/${recipient}`, tip: `${amount} LBC ($${amountUsdStr})`, how_to_use_url: config.howToUseUrl},
tipdata.message.data.name, cb); tipdata.message.data.name, cb);
}, },
@ -524,7 +524,7 @@ const sendGild = (sender, recipient, amount, gilddata, callback) => {
how_to_use_url: config.howToUseUrl, how_to_use_url: config.howToUseUrl,
recipient: `u/${recipient}`, recipient: `u/${recipient}`,
amount: amount, amount: amount,
amount_usd: ['$', gilddata.amountUsd.toFixed(2)].join(''), amount_usd: ['$', parseFloat(gilddata.amountUsd).toFixed(2)].join(''),
balance: senderBalance balance: senderBalance
}, 'Insufficient funds', gilddata.message.data.author, () => { }, 'Insufficient funds', gilddata.message.data.author, () => {
markMessageRead(gilddata.message.data.name, () => { markMessageRead(gilddata.message.data.name, () => {
@ -565,7 +565,7 @@ const sendGild = (sender, recipient, amount, gilddata, callback) => {
data.recipientId, data.recipientId,
amount, amount,
gilddata.amountUsd, gilddata.amountUsd,
['$', config.gildPrice].join(''), ['$', config.gildPrice.toFixed(2)].join(''),
], cb); ], cb);
}, },
(res, fields, cb) => { (res, fields, cb) => {
@ -574,7 +574,7 @@ const sendGild = (sender, recipient, amount, gilddata, callback) => {
}, },
(success, cb) => { (success, cb) => {
// reply to the source message with message template after successful commit // reply to the source message with message template after successful commit
const amountUsdStr = gilddata.amountUsd; const amountUsdStr = parseFloat(gilddata.amountUsd).toFixed(2);
replyMessageUsingTemplate('ongild', { sender: `u/${sender}`, recipient: `u/${recipient}`, gild_amount: `${amount} LBC ($${amountUsdStr})`, how_to_use_url: config.howToUseUrl}, replyMessageUsingTemplate('ongild', { sender: `u/${sender}`, recipient: `u/${recipient}`, gild_amount: `${amount} LBC ($${amountUsdStr})`, how_to_use_url: config.howToUseUrl},
gilddata.message.data.name, cb); gilddata.message.data.name, cb);
}, },