Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
- added custom amount csv formatting depending on localDecimalSeparat…
Browse files Browse the repository at this point in the history
…or (#2517)

Co-authored-by: tihi <[email protected]>
  • Loading branch information
Tiihi and tihi authored Aug 31, 2023
1 parent 9cf7c50 commit 99afd8e
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.ivy.wallet.io.persistence.dao.TransactionDao
import com.ivy.wallet.utils.format
import com.ivy.wallet.utils.formatLocal
import com.ivy.wallet.utils.ioThread
import com.ivy.wallet.utils.localDecimalSeparator
import com.ivy.wallet.utils.writeToFile
import org.apache.commons.text.StringEscapeUtils
import java.util.*
Expand Down Expand Up @@ -220,9 +221,24 @@ class ExportCSVLogic(
}

private fun Double.formatAmountCSV(currency: String): String {
return this.format(currency)
.replace(",", "")
.escapeCSVString()

val ivyAmountFormat = this.format(currency)

// string result example: 1078.38
return when(localDecimalSeparator()) {
"." -> {
// source string example: 1,078.38
ivyAmountFormat
.replace(",", "")
}
"," -> {
// source string example: 1.078,39
ivyAmountFormat
.replace(".", "")
.replace(",", ".")
}
else -> ivyAmountFormat
}.escapeCSVString()
}

private fun String.escapeCSVString(): String {
Expand Down

0 comments on commit 99afd8e

Please sign in to comment.