Convert fiat totals to BTC and add to total amount

This commit is contained in:
2020-09-30 16:46:35 +02:00
parent 87bc8f5cb5
commit 63675a1e13
5 changed files with 37 additions and 19 deletions
@@ -67,6 +67,19 @@ export default class AddReimbursementComponent extends Component {
anchor.scrollIntoView();
}
updateTotalAmountFromFiat() {
let btcAmount = parseFloat(this.total);
if (this.exchangeRates.btceur > 0 && this.totalEUR > 0) {
btcAmount += (this.totalEUR / this.exchangeRates.btceur);
}
if (this.exchangeRates.btcusd > 0 && this.totalUSD > 0) {
btcAmount += (this.totalUSD / this.exchangeRates.btcusd);
}
this.total = btcAmount.toFixed(8);
}
@action
showExpenseForm () {
this.expenseFormVisible = true;
@@ -76,12 +89,14 @@ export default class AddReimbursementComponent extends Component {
@action
addExpenseItem (expenseItem) {
this.expenses.pushObject(expenseItem);
this.updateTotalAmountFromFiat();
this.expenseFormVisible = false;
}
@action
removeExpenseItem (expenseItem) {
this.expenses.removeObject(expenseItem);
this.updateTotalAmountFromFiat();
if (this.expenses.length === 0) {
this.expenseFormVisible = true;