From e5677436b1a0dcd451dbfa0af9f02a6ff5db1922 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Thu, 7 Feb 2019 13:40:26 -0600 Subject: [PATCH] Add the equivalent value to both PDF and CSV export options. --- .../bitsybitshareswallet/utils/CSVGenerationTask.kt | 11 +++++++++-- .../bitsybitshareswallet/utils/PDFGeneratorTask.kt | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/CSVGenerationTask.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/CSVGenerationTask.kt index 50afdd7..a46e28f 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/CSVGenerationTask.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/CSVGenerationTask.kt @@ -71,8 +71,15 @@ class CSVGenerationTask(context: Context) : AsyncTask, Int, val assetAmount = transferDetail.assetAmount.toDouble() / Math.pow(10.0, assetPrecision.toDouble()) row[5] = String.format("%.${assetPrecision}f %s", assetAmount, transferDetail.assetSymbol) - // Fiat Equivalent TODO add once Nelson finishes - row[6] = "" + // Fiat Equivalent + row[6] = if (transferDetail.fiatAmount != null && transferDetail.fiatSymbol != null) { + val currency = Currency.getInstance(transferDetail.fiatSymbol) + val fiatAmount = transferDetail.fiatAmount.toDouble() / + Math.pow(10.0, currency.defaultFractionDigits.toDouble()) + String.format("%.${currency.defaultFractionDigits}f %s", fiatAmount, currency.currencyCode) + } else { + "" + } csvWriter.writeNext(row) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/PDFGeneratorTask.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/PDFGeneratorTask.kt index 8567693..d216180 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/PDFGeneratorTask.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/PDFGeneratorTask.kt @@ -84,7 +84,14 @@ class PDFGeneratorTask(context: Context) : AsyncTask, Int, val assetAmount = transferDetail.assetAmount.toDouble() / Math.pow(10.0, assetPrecision.toDouble()) table.addCell(makeCell(String.format("%.${assetPrecision}f %s", assetAmount, transferDetail.assetSymbol))) - // Fiat Equivalent TODO add once Nelson finishes + // Fiat Equivalent + if (transferDetail.fiatAmount != null && transferDetail.fiatSymbol != null) { + val currency = Currency.getInstance(transferDetail.fiatSymbol) + val fiatAmount = transferDetail.fiatAmount.toDouble() / + Math.pow(10.0, currency.defaultFractionDigits.toDouble()) + table.addCell(makeCell(String.format("%.${currency.defaultFractionDigits}f %s", + fiatAmount, currency.currencyCode))) + } table.completeRow()