Fixed that sheet number may is omitted

This commit is contained in:
dankito 2020-05-13 19:52:34 +02:00
parent 407b05be80
commit de91056094
2 changed files with 46 additions and 1 deletions

View File

@ -184,7 +184,7 @@ open class Mt940Parser : IMt940Parser {
protected open fun parseSheetNumber(statementAndMaySheetNumber: String): Int? { protected open fun parseSheetNumber(statementAndMaySheetNumber: String): Int? {
val parts = statementAndMaySheetNumber.split('/') val parts = statementAndMaySheetNumber.split('/')
if (parts.size > 0) { if (parts.size > 1) {
return parts[1].toInt() return parts[1].toInt()
} }

View File

@ -68,6 +68,38 @@ class Mt940ParserTest : FinTsTestBase() {
AccountStatement1Transaction1OtherPartyBankCode, AccountStatement1Transaction1OtherPartyAccountId) AccountStatement1Transaction1OtherPartyBankCode, AccountStatement1Transaction1OtherPartyAccountId)
} }
@Test
fun accountStatementWithSingleTransaction_SheetNumberOmitted() {
// given
val amount = BigDecimal("15.00")
val isCredit = false
val bookingDate = Date(120, 4, 11)
// when
val result = underTest.parseMt940String(AccountStatementWithSingleTransaction_SheetNumberOmitted)
// then
assertThat(result).hasSize(1)
val statement = result.first()
assertThat(statement.bankCodeBicOrIban).isEqualTo(BankCode)
assertThat(statement.accountIdentifier).isEqualTo(CustomerId)
assertThat(statement.statementNumber).isEqualTo(0)
assertThat(statement.sequenceNumber).isNull()
assertBalance(statement.openingBalance, true, bookingDate, BigDecimal("0.00"))
assertBalance(statement.closingBalance, isCredit, bookingDate, amount)
assertThat(statement.transactions).hasSize(1)
val transaction = statement.transactions.first()
assertTurnover(transaction.turnover, bookingDate, amount, isCredit, null)
assertTransactionDetails(transaction.details, "Ausgabe einer Debitkarte", BankCode, CustomerId)
}
@Test @Test
fun accountStatementWithTwoTransactions() { fun accountStatementWithTwoTransactions() {
@ -173,6 +205,19 @@ class Mt940ParserTest : FinTsTestBase() {
- -
""".trimIndent() """.trimIndent()
private val AccountStatementWithSingleTransaction_SheetNumberOmitted = """
:20:STARTUMS
:25:$BankCode/$CustomerId
:28C:0
:60F:C200511EUR0,00
:61:200511D15,00NMSCNONREF
:86:808?00Entgelt/Auslagen?10907?20Preis bezahlt bis 12.2020
?21Jahrespreis?22$AccountHolderName?23Folge-Nr. 0 Verfall 12.23
?30$BankCode?31$CustomerId?32Ausgabe einer Debitkarte
:62F:D200511EUR15,00
-
""".trimIndent()
private fun convertMt940Date(date: Date): String { private fun convertMt940Date(date: Date): String {
return Mt940Parser.DateFormat.format(date) return Mt940Parser.DateFormat.format(date)