Fixed getting remainder without that an exception gets thrown
This commit is contained in:
parent
e749a88c83
commit
4a890a0ba7
|
@ -75,13 +75,15 @@ open class Mt940Parser : IMt940Parser {
|
|||
|
||||
override fun parseTransactionsChunk(mt940Chunk: String): Pair<List<AccountStatement>, String> {
|
||||
try {
|
||||
val singleAccountStatementsStrings = splitIntoSingleAccountStatements(mt940Chunk)
|
||||
val singleAccountStatementsStrings = splitIntoSingleAccountStatements(mt940Chunk).toMutableList()
|
||||
|
||||
var remainder = ""
|
||||
if (singleAccountStatementsStrings.isNotEmpty() && singleAccountStatementsStrings.last().isEmpty() == false) {
|
||||
remainder = singleAccountStatementsStrings.removeAt(singleAccountStatementsStrings.lastIndex)
|
||||
}
|
||||
|
||||
val transactions = singleAccountStatementsStrings.mapNotNull { parseAccountStatement(it) }
|
||||
|
||||
val remainder = if (singleAccountStatementsStrings.size == transactions.size + 1) singleAccountStatementsStrings.last()
|
||||
else ""
|
||||
|
||||
return Pair(transactions, remainder)
|
||||
} catch (e: Exception) {
|
||||
log.error("Could not parse account statements from MT940 string:\n$mt940Chunk", e)
|
||||
|
|
Loading…
Reference in New Issue