From 0039a48e730565c308d2e5bef02e97de823207bc Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Fri, 18 Nov 2022 12:02:51 +0200 Subject: [PATCH] fix: total amount (amount + tip) --- .../extensions/tpos/templates/tpos/tpos.html | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lnbits/extensions/tpos/templates/tpos/tpos.html b/lnbits/extensions/tpos/templates/tpos/tpos.html index 0dd105b9b..0f9620a96 100644 --- a/lnbits/extensions/tpos/templates/tpos/tpos.html +++ b/lnbits/extensions/tpos/templates/tpos/tpos.html @@ -13,7 +13,7 @@
-

{% raw %}{{ famount }}{% endraw %}

+

{% raw %}{{ amountFormatted }}{% endraw %}

{% raw %}{{ fsat }}{% endraw %} sat
@@ -173,12 +173,14 @@ >
-

{% raw %}{{ famount }}{% endraw %}

+

+ {% raw %}{{ amountWithTipFormatted }}{% endraw %} +

{% raw %}{{ fsat }} sat ( + {{ tipAmountSat }} tip)( + {{ tipAmountFormatted }} tip) {% endraw %}
@@ -362,12 +364,18 @@ if (!this.stack.length) return 0.0 return Number(this.stack.join('') / 100) }, - famount: function () { + amountFormatted: function () { return LNbits.utils.formatCurrency( this.amount.toFixed(2), this.currency ) }, + amountWithTipFormatted: function () { + return LNbits.utils.formatCurrency( + (this.amount + this.tipAmount).toFixed(2), + this.currency + ) + }, sat: function () { if (!this.exchangeRate) return 0 return Math.ceil((this.amount / this.exchangeRate) * 100000000) @@ -376,6 +384,9 @@ if (!this.exchangeRate) return 0 return Math.ceil((this.tipAmount / this.exchangeRate) * 100000000) }, + tipAmountFormatted: function () { + return LNbits.utils.formatSat(this.tipAmountSat) + }, fsat: function () { return LNbits.utils.formatSat(this.sat) } @@ -393,7 +404,10 @@ processTipSelection: function (selectedTipOption) { this.tipDialog.show = false - if (!selectedTipOption) return this.showInvoice() + if (!selectedTipOption) { + this.tipAmount = 0.0 + return this.showInvoice() + } this.tipAmount = (selectedTipOption / 100) * this.amount this.showInvoice()