Made remainder nullable to signal there is no remainder
This commit is contained in:
parent
e260eaa535
commit
2031cb9e9f
|
@ -217,7 +217,7 @@ open class FinTsJobExecutor(
|
|||
context.bank, parameter.account)
|
||||
|
||||
bookedTransactions.addAll(chunkTransaction)
|
||||
remainingMt940String = remainder
|
||||
remainingMt940String = remainder ?: ""
|
||||
|
||||
parameter.retrievedChunkListener?.invoke(bookedTransactions)
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ interface IAccountTransactionsParser {
|
|||
|
||||
fun parseTransactions(transactionsString: String, bank: BankData, account: AccountData): List<AccountTransaction>
|
||||
|
||||
fun parseTransactionsChunk(transactionsChunk: String, bank: BankData, account: AccountData): Pair<List<AccountTransaction>, String>
|
||||
fun parseTransactionsChunk(transactionsChunk: String, bank: BankData, account: AccountData): Pair<List<AccountTransaction>, String?>
|
||||
|
||||
}
|
|
@ -25,7 +25,7 @@ open class Mt940AccountTransactionsParser(
|
|||
return accountStatements.flatMap { mapToAccountTransactions(it, bank, account) }
|
||||
}
|
||||
|
||||
override fun parseTransactionsChunk(transactionsChunk: String, bank: BankData, account: AccountData): Pair<List<AccountTransaction>, String> {
|
||||
override fun parseTransactionsChunk(transactionsChunk: String, bank: BankData, account: AccountData): Pair<List<AccountTransaction>, String?> {
|
||||
val (accountStatements, remainder) = mt940Parser.parseMt940Chunk(transactionsChunk)
|
||||
|
||||
return Pair(accountStatements.flatMap { mapToAccountTransactions(it, bank, account) }, remainder)
|
||||
|
|
|
@ -25,6 +25,6 @@ interface IMt940Parser {
|
|||
* be displayed immediately to user and the remainder then be passed together with next partial
|
||||
* HKKAZ response to this method till this whole MT 940 statement is parsed.
|
||||
*/
|
||||
fun parseMt940Chunk(mt940Chunk: String): Pair<List<AccountStatement>, String>
|
||||
fun parseMt940Chunk(mt940Chunk: String): Pair<List<AccountStatement>, String?>
|
||||
|
||||
}
|
|
@ -95,11 +95,11 @@ open class Mt940Parser(
|
|||
* be displayed immediately to user and the remainder then be passed together with next partial
|
||||
* HKKAZ response to this method till this whole MT 940 statement is parsed.
|
||||
*/
|
||||
override fun parseMt940Chunk(mt940Chunk: String): Pair<List<AccountStatement>, String> {
|
||||
override fun parseMt940Chunk(mt940Chunk: String): Pair<List<AccountStatement>, String?> {
|
||||
try {
|
||||
val singleAccountStatementsStrings = splitIntoSingleAccountStatements(mt940Chunk).toMutableList()
|
||||
|
||||
var remainder = ""
|
||||
var remainder: String? = null
|
||||
if (singleAccountStatementsStrings.isNotEmpty() && singleAccountStatementsStrings.last().isEmpty() == false) {
|
||||
remainder = singleAccountStatementsStrings.removeAt(singleAccountStatementsStrings.lastIndex)
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ class Mt940ParserTest : FinTsTestBase() {
|
|||
|
||||
|
||||
// then
|
||||
assertEmpty(remainder)
|
||||
assertNull(remainder)
|
||||
|
||||
assertSize(1, statements)
|
||||
|
||||
|
|
Loading…
Reference in New Issue