Fixed that Sparkasse returns 30th of February or 29th of February also in non leap years
This commit is contained in:
parent
c5432883ef
commit
32defa20f7
|
@ -463,6 +463,10 @@ open class Mt940Parser(
|
|||
year -= 100
|
||||
}
|
||||
|
||||
if (month == 2 && (day > 29 || (day > 28 && year % 4 != 0))) {
|
||||
return LocalDate(year, 3, 1)
|
||||
}
|
||||
|
||||
return LocalDate(year , month, day)
|
||||
} catch (e: Exception) {
|
||||
logError("Could not parse dateString '$dateString'", e)
|
||||
|
|
|
@ -330,6 +330,20 @@ class Mt940ParserTest : FinTsTestBase() {
|
|||
assertEquals(LocalDate(1999, 5, 7), result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseDate_FixSparkasse29thOFFebruaryInNonLeapYearBug() {
|
||||
val result = underTest.parseMt940Date("230229")
|
||||
|
||||
assertEquals(LocalDate(2023, 3, 1), result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseDate_FixSparkasse30thOfFebruaryBug() {
|
||||
val result = underTest.parseMt940Date("230229")
|
||||
|
||||
assertEquals(LocalDate(2023, 3, 1), result)
|
||||
}
|
||||
|
||||
|
||||
private fun assertBalance(balance: Balance, isCredit: Boolean, bookingDate: LocalDate, amount: Amount) {
|
||||
assertEquals(isCredit, balance.isCredit)
|
||||
|
|
Loading…
Reference in New Issue