diff --git a/Tests/Unit/Segment/MinimaleVorlaufzeitSEPALastschriftTest.php b/Tests/Unit/Segment/MinimaleVorlaufzeitSEPALastschriftTest.php new file mode 100644 index 00000000..8e95e436 --- /dev/null +++ b/Tests/Unit/Segment/MinimaleVorlaufzeitSEPALastschriftTest.php @@ -0,0 +1,65 @@ +getParameter(); + + $recurring = $parameter->getMinimalLeadTime('RCUR'); + $this->assertInstanceOf(MinimaleVorlaufzeitSEPALastschrift::class, $recurring); + $this->assertEquals(1, $recurring->minimaleSEPAVorlaufzeit); + + // Version 1 states the lead time per sequence type and carries neither of the two codes + // that version 2 encodes, so they stay unset. + $this->assertNull($recurring->unterstuetzteSEPALastschriftartenCodiert); + $this->assertNull($recurring->sequenceTypeCodiert); + + $this->assertEquals(1, $parameter->getMinimalLeadTime('FRST')->minimaleSEPAVorlaufzeit); + } + + public function testGetMinimalLeadTimeFromVersion1B2B() + { + $parameter = HIBMESv1::parse(static::REAL_POSTBANK_HIBMES)->getParameter(); + + $this->assertEquals(1, $parameter->getMinimalLeadTime('RCUR')->minimaleSEPAVorlaufzeit); + $this->assertEquals(1, $parameter->getMinimalLeadTime('OOFF')->minimaleSEPAVorlaufzeit); + } + + /** + * The B2B variant of the coded format has no field for the direct debit type, so the parser + * passes none. + */ + public function testParseCodedB2B() + { + $parsed = MinimaleVorlaufzeitSEPALastschrift::parseCodedB2B('1;2;120000'); + + $this->assertEquals(2, $parsed['B2B']['RCUR']->minimaleSEPAVorlaufzeit); + $this->assertEquals('120000', $parsed['B2B']['FNAL']->cutOffZeit); + $this->assertNull($parsed['B2B']['RCUR']->unterstuetzteSEPALastschriftartenCodiert); + $this->assertEquals(1, $parsed['B2B']['RCUR']->sequenceTypeCodiert); + } + + public function testParseCoded() + { + $parsed = MinimaleVorlaufzeitSEPALastschrift::parseCoded('0;1;2;120000'); + + $this->assertEquals(2, $parsed['CORE']['RCUR']->minimaleSEPAVorlaufzeit); + $this->assertEquals(0, $parsed['CORE']['RCUR']->unterstuetzteSEPALastschriftartenCodiert); + $this->assertEquals(1, $parsed['CORE']['RCUR']->sequenceTypeCodiert); + } +} diff --git a/src/Segment/DSE/MinimaleVorlaufzeitSEPALastschrift.php b/src/Segment/DSE/MinimaleVorlaufzeitSEPALastschrift.php index f50330eb..25c2cca9 100644 --- a/src/Segment/DSE/MinimaleVorlaufzeitSEPALastschrift.php +++ b/src/Segment/DSE/MinimaleVorlaufzeitSEPALastschrift.php @@ -24,11 +24,11 @@ class MinimaleVorlaufzeitSEPALastschrift ['FRST', 'OOFF'], ]; - /** Must be 0,1,2 */ - public int $unterstuetzteSEPALastschriftartenCodiert; + /** Must be 0,1,2, or null when the segment does not state it (version 1, and B2B in general) */ + public ?int $unterstuetzteSEPALastschriftartenCodiert = null; - /** Must be 0,1,2 */ - public int $sequenceTypeCodiert; + /** Must be 0,1,2, or null when the segment does not state it (version 1) */ + public ?int $sequenceTypeCodiert = null; /** In Days */ public int $minimaleSEPAVorlaufzeit;