From e260eaa535ea8f21180b439b234072aad2a5527d Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 10 Sep 2024 18:15:29 +0200 Subject: [PATCH] Added test for remainder --- .../fints/transactions/Mt940ParserTest.kt | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/fints4k/src/commonTest/kotlin/net/codinux/banking/fints/transactions/Mt940ParserTest.kt b/fints4k/src/commonTest/kotlin/net/codinux/banking/fints/transactions/Mt940ParserTest.kt index ac2aa871..12049472 100644 --- a/fints4k/src/commonTest/kotlin/net/codinux/banking/fints/transactions/Mt940ParserTest.kt +++ b/fints4k/src/commonTest/kotlin/net/codinux/banking/fints/transactions/Mt940ParserTest.kt @@ -106,13 +106,15 @@ class Mt940ParserTest : FinTsTestBase() { fun accountStatementWithTwoTransactions() { // when - val result = underTest.parseMt940String(AccountStatementWithTwoTransactions) + val (statements, remainder) = underTest.parseMt940Chunk(AccountStatementWithTwoTransactions) // then - assertSize(1, result) + assertEmpty(remainder) - val statement = result.first() + assertSize(1, statements) + + val statement = statements.first() assertEquals(BankCode, statement.bankCodeBicOrIban) assertEquals(CustomerId, statement.accountIdentifier) @@ -132,6 +134,33 @@ class Mt940ParserTest : FinTsTestBase() { AccountStatement1Transaction2OtherPartyBankId, AccountStatement1Transaction2OtherPartyAccountId) } + @Test + fun accountStatementWithPartialNextStatement() { + + // when + val (statements, remainder) = underTest.parseMt940Chunk(AccountStatementWithSingleTransaction + "\r\n" + ":20:STARTUMSE") + + + // then + assertEquals(":20:STARTUMSE", remainder) + + assertSize(1, statements) + + val statement = statements.first() + + assertEquals(BankCode, statement.bankCodeBicOrIban) + assertEquals(CustomerId, statement.accountIdentifier) + assertBalance(statement.openingBalance, true, AccountStatement1PreviousStatementBookingDate, AccountStatement1OpeningBalanceAmount) + assertBalance(statement.closingBalance, true, AccountStatement1BookingDate, AccountStatement1ClosingBalanceAmount) + + assertSize(1, statement.transactions) + + val transaction = statement.transactions.first() + assertTurnover(transaction.statementLine, AccountStatement1BookingDate, AccountStatement1Transaction1Amount) + assertTransactionDetails(transaction.information, AccountStatement1Transaction1OtherPartyName, + AccountStatement1Transaction1OtherPartyBankId, AccountStatement1Transaction1OtherPartyAccountId) + } + @Test fun fixAnnualJumpFromBookingDateToValueDate() {