Merge pull request #1091 from lnbits/fix/tpos_valueDisplay

Small fix for TPoS amount display
This commit is contained in:
Vlad Stan
2022-11-18 13:27:45 +02:00
committed by GitHub

View File

@@ -13,7 +13,7 @@
<q-page-sticky v-if="exchangeRate" expand position="top"> <q-page-sticky v-if="exchangeRate" expand position="top">
<div class="row justify-center full-width"> <div class="row justify-center full-width">
<div class="col-12 col-sm-8 col-md-6 col-lg-4 text-center"> <div class="col-12 col-sm-8 col-md-6 col-lg-4 text-center">
<h3 class="q-mb-md">{% raw %}{{ famount }}{% endraw %}</h3> <h3 class="q-mb-md">{% raw %}{{ amountFormatted }}{% endraw %}</h3>
<h5 class="q-mt-none q-mb-sm"> <h5 class="q-mt-none q-mb-sm">
{% raw %}{{ fsat }}{% endraw %} <small>sat</small> {% raw %}{{ fsat }}{% endraw %} <small>sat</small>
</h5> </h5>
@@ -173,12 +173,14 @@
></qrcode> ></qrcode>
</q-responsive> </q-responsive>
<div class="text-center"> <div class="text-center">
<h3 class="q-my-md">{% raw %}{{ famount }}{% endraw %}</h3> <h3 class="q-my-md">
{% raw %}{{ amountWithTipFormatted }}{% endraw %}
</h3>
<h5 class="q-mt-none"> <h5 class="q-mt-none">
{% raw %}{{ fsat }} {% raw %}{{ fsat }}
<small>sat</small> <small>sat</small>
<span v-show="tip_options" style="font-size: 0.75rem" <span v-show="tip_options" style="font-size: 0.75rem"
>( + {{ tipAmountSat }} tip)</span >( + {{ tipAmountFormatted }} tip)</span
> >
{% endraw %} {% endraw %}
</h5> </h5>
@@ -360,21 +362,31 @@
computed: { computed: {
amount: function () { amount: function () {
if (!this.stack.length) return 0.0 if (!this.stack.length) return 0.0
return (Number(this.stack.join('')) / 100).toFixed(2) return Number(this.stack.join('') / 100)
}, },
famount: function () { amountFormatted: function () {
return LNbits.utils.formatCurrency(this.amount, this.currency) 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 () { sat: function () {
if (!this.exchangeRate) return 0 if (!this.exchangeRate) return 0
return Math.ceil( return Math.ceil((this.amount / this.exchangeRate) * 100000000)
((this.amount - this.tipAmount) / this.exchangeRate) * 100000000
)
}, },
tipAmountSat: function () { tipAmountSat: function () {
if (!this.exchangeRate) return 0 if (!this.exchangeRate) return 0
return Math.ceil((this.tipAmount / this.exchangeRate) * 100000000) return Math.ceil((this.tipAmount / this.exchangeRate) * 100000000)
}, },
tipAmountFormatted: function () {
return LNbits.utils.formatSat(this.tipAmountSat)
},
fsat: function () { fsat: function () {
return LNbits.utils.formatSat(this.sat) return LNbits.utils.formatSat(this.sat)
} }
@@ -392,26 +404,12 @@
processTipSelection: function (selectedTipOption) { processTipSelection: function (selectedTipOption) {
this.tipDialog.show = false this.tipDialog.show = false
if (selectedTipOption) { if (!selectedTipOption) {
const tipAmount = parseFloat( this.tipAmount = 0.0
parseFloat((selectedTipOption / 100) * this.amount) return this.showInvoice()
)
const subtotal = parseFloat(this.amount)
const grandTotal = parseFloat((tipAmount + subtotal).toFixed(2))
const totalString = grandTotal.toFixed(2).toString()
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 = (selectedTipOption / 100) * this.amount
this.showInvoice() this.showInvoice()
}, },
submitForm: function () { submitForm: function () {