From b0b14464835a9b460407d1c8fe4d142b43bbf3a2 Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Thu, 27 Oct 2022 19:14:26 +0100 Subject: [PATCH] fixed display amount --- .../extensions/tpos/templates/tpos/tpos.html | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lnbits/extensions/tpos/templates/tpos/tpos.html b/lnbits/extensions/tpos/templates/tpos/tpos.html index c66238f76..9e462abaf 100644 --- a/lnbits/extensions/tpos/templates/tpos/tpos.html +++ b/lnbits/extensions/tpos/templates/tpos/tpos.html @@ -360,15 +360,15 @@ computed: { amount: function () { if (!this.stack.length) return 0.0 - return (Number(this.stack.join('')) / 100).toFixed(2) + return Number(this.stack.join('') / 100) }, famount: function () { - return LNbits.utils.formatCurrency(this.amount, this.currency) + return LNbits.utils.formatCurrency(this.amount.toFixed(2), this.currency) }, sat: function () { if (!this.exchangeRate) return 0 return Math.ceil( - ((this.amount - this.tipAmount) / this.exchangeRate) * 100000000 + (this.amount / this.exchangeRate) * 100000000 ) }, tipAmountSat: function () { @@ -392,26 +392,25 @@ processTipSelection: function (selectedTipOption) { this.tipDialog.show = false - if (selectedTipOption) { - const tipAmount = parseFloat( - parseFloat((selectedTipOption / 100) * this.amount) - ) - const subtotal = parseFloat(this.amount) - const grandTotal = parseFloat((tipAmount + subtotal).toFixed(2)) - const totalString = grandTotal.toFixed(2).toString() + if(!selectedTipOption) return this.showInvoice() - this.stack = [] - for (var i = 0; i < totalString.length; i++) { - const char = totalString[i] + const tipAmount = (selectedTipOption / 100) * this.amount + const subtotal = this.amount + const grandTotal = (tipAmount + subtotal) + const totalString = grandTotal.toFixed(2) - if (char !== '.') { - this.stack.push(char) - } + this.stack = [] + for (var i = 0; i < totalString.length; i++) { + const char = totalString[i] + + if (char !== '.') { + this.stack.push(char) } - - this.tipAmount = tipAmount } + + this.tipAmount = tipAmount + this.showInvoice() }, submitForm: function () {