Skip to content

Commit

Permalink
[TASK] Add support for 052.001.08 and 053.001.08
Browse files Browse the repository at this point in the history
* added xsd files to assets folder:

  - assets/camt.052.001.08.xsd
  - assets/camt.053.001.08.xsd

* added support for 052.001.08:

  - added message-format and decoder for 052.001.08
  - added camt052.v8.xml test file
  - added message v8 to EndToEnd tests
  - added 052.08 message to default config
    and adjusted default config test
  - added json file for regression test

* added support for 053.001.08:
  - added message-format for 053.001.08
  - added camt053.v8.xml test file
  - added 053.08 message to default config
    and adjusted default config test
  - added json file for regression test

* documented as supported in README.md

>> Same read capabilities are ensured like the versions
   before. Some new entities and attributes are missing
   and can be implemented in a dedicated change.

Resolves: #142
Related: #124
Related: #126
  • Loading branch information
sbuerk authored and PowerKiKi committed May 1, 2023
1 parent 08fd5f6 commit 15f3d03
Show file tree
Hide file tree
Showing 15 changed files with 5,028 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ Library to read CAMT files. Currently only CAMT.052, CAMT.053 and CAMT.054 are s

#### Camt 052

| Version | Supported |
|:---------------:| :----------------: |
| Version | Supported |
|:---------------:|:------------------:|
| camt.052.001.01 | :heavy_check_mark: |
| camt.052.001.02 | :heavy_check_mark: |
| camt.052.001.03 | |
| camt.052.001.04 | :heavy_check_mark: |
| camt.052.001.05 | |
| camt.052.001.06 | :heavy_check_mark: |
| camt.052.001.08 | |
| camt.052.001.08 | :heavy_check_mark: |
| camt.052.001.10 | |
| camt.052.001.11 | |

#### Camt 053

| Version | Supported |
|:---------------:| :----------------: |
| Version | Supported |
|:---------------:|:------------------:|
| camt.053.001.01 | |
| camt.053.001.02 | :heavy_check_mark: |
| camt.053.001.03 | :heavy_check_mark: |
| camt.053.001.04 | :heavy_check_mark: |
| camt.053.001.05 | |
| camt.053.001.06 | |
| camt.053.001.08 | |
| camt.053.001.08 | :heavy_check_mark: |
| camt.053.001.10 | |
| camt.053.001.11 | |

#### Camt 054

| Version | Supported |
|:---------------:| :----------------: |
| Version | Supported |
|:---------------:|:------------------:|
| camt.054.001.01 | |
| camt.054.001.02 | :heavy_check_mark: |
| camt.054.001.03 | |
Expand Down
2,070 changes: 2,070 additions & 0 deletions assets/camt.052.001.08.xsd

Large diffs are not rendered by default.

2,070 changes: 2,070 additions & 0 deletions assets/camt.053.001.08.xsd

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/Camt052/Decoder/V08/Message.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Genkgo\Camt\Camt052\Decoder\V08;

use Genkgo\Camt\Camt052\Decoder\Message as BaseMessageDecoder;
use SimpleXMLElement;

class Message extends BaseMessageDecoder
{
/**
* @inheritDoc
*/
public function getRootElement(SimpleXMLElement $document): SimpleXMLElement
{
return $document->BkToCstmrAcctRpt;
}
}
38 changes: 38 additions & 0 deletions src/Camt052/MessageFormat/V08.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Genkgo\Camt\Camt052\MessageFormat;

use Genkgo\Camt\Camt052;
use Genkgo\Camt\Decoder;
use Genkgo\Camt\DecoderInterface;
use Genkgo\Camt\MessageFormatInterface;

final class V08 implements MessageFormatInterface
{
public function getXmlNs(): string
{
return 'urn:iso:std:iso:20022:tech:xsd:camt.052.001.08';
}

public function getMsgId(): string
{
return 'camt.052.001.08';
}

public function getName(): string
{
return 'BankToCustomerAccountReportV08';
}

public function getDecoder(): DecoderInterface
{
$entryTransactionDetailDecoder = new Camt052\Decoder\EntryTransactionDetail(new Decoder\Date());
$entryDecoder = new Decoder\Entry($entryTransactionDetailDecoder);
$recordDecoder = new Decoder\Record($entryDecoder, new Decoder\Date());
$messageDecoder = new Camt052\Decoder\V08\Message($recordDecoder, new Decoder\Date());

return new Decoder($messageDecoder, sprintf('/assets/%s.xsd', $this->getMsgId()));
}
}
38 changes: 38 additions & 0 deletions src/Camt053/MessageFormat/V08.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Genkgo\Camt\Camt053\MessageFormat;

use Genkgo\Camt\Camt053;
use Genkgo\Camt\Decoder;
use Genkgo\Camt\DecoderInterface;
use Genkgo\Camt\MessageFormatInterface;

final class V08 implements MessageFormatInterface
{
public function getXmlNs(): string
{
return 'urn:iso:std:iso:20022:tech:xsd:camt.053.001.08';
}

public function getMsgId(): string
{
return 'camt.053.001.08';
}

public function getName(): string
{
return 'BankToCustomerStatementV08';
}

public function getDecoder(): DecoderInterface
{
$entryTransactionDetailDecoder = new Camt053\Decoder\EntryTransactionDetail(new Decoder\Date());
$entryDecoder = new Decoder\Entry($entryTransactionDetailDecoder);
$recordDecoder = new Decoder\Record($entryDecoder, new Decoder\Date());
$messageDecoder = new Camt053\Decoder\Message($recordDecoder, new Decoder\Date());

return new Decoder($messageDecoder, sprintf('/assets/%s.xsd', $this->getMsgId()));
}
}
2 changes: 2 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ public static function getDefault(): self
$config->addMessageFormat(new Camt052\MessageFormat\V02());
$config->addMessageFormat(new Camt052\MessageFormat\V04());
$config->addMessageFormat(new Camt052\MessageFormat\V06());
$config->addMessageFormat(new Camt052\MessageFormat\V08());
$config->addMessageFormat(new Camt053\MessageFormat\V02());
$config->addMessageFormat(new Camt053\MessageFormat\V03());
$config->addMessageFormat(new Camt053\MessageFormat\V04());
$config->addMessageFormat(new Camt053\MessageFormat\V08());
$config->addMessageFormat(new Camt054\MessageFormat\V02());
$config->addMessageFormat(new Camt054\MessageFormat\V04());
$config->addMessageFormat(new Camt054\MessageFormat\V08());
Expand Down
12 changes: 12 additions & 0 deletions test/Unit/Camt052/EndToEndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,22 @@ protected function getV6Message(): Message
return (new MessageFormat\V06())->getDecoder()->decode($dom);
}

protected function getV8Message(): Message
{
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->load('test/data/camt052.v8.xml');

return (new MessageFormat\V08())->getDecoder()->decode($dom);
}

public function testGroupHeader(): void
{
$messages = [
$this->getV1Message(),
$this->getV2Message(),
$this->getV4Message(),
$this->getV6Message(),
$this->getV8Message(),
];

/** @var Message $message */
Expand Down Expand Up @@ -96,6 +105,7 @@ public function testReports(): void
$this->getV1Message(),
$this->getV2Message(),
$this->getV4Message(),
$this->getV8Message(),
];

foreach ($messages as $message) {
Expand Down Expand Up @@ -123,6 +133,7 @@ public function testEntries(): void
$this->getV1Message(),
$this->getV2Message(),
$this->getV4Message(),
$this->getV8Message(),
];

foreach ($messages as $message) {
Expand Down Expand Up @@ -154,6 +165,7 @@ public function testStatuses(): void
$messages = [
$this->getV1Message(),
$this->getV4Message(),
$this->getV8Message(),
];

self::assertEquals('BOOK', $messages[0]->getRecords()[0]->getEntries()[0]->getStatus());
Expand Down
20 changes: 20 additions & 0 deletions test/Unit/Camt053/EndToEndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ protected function getV4Message(): Message
return (new MessageFormat\V04())->getDecoder()->decode($dom);
}

protected function getV8Message(): Message
{
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->load('test/data/camt053.v8.xml');

return (new MessageFormat\V08())->getDecoder()->decode($dom);
}

public function testWrongDocument(): Message
{
$this->expectException(InvalidMessageException::class);
Expand Down Expand Up @@ -80,12 +88,20 @@ public function testV4Document(): void
self::assertInstanceOf(Message::class, (new MessageFormat\V04())->getDecoder()->decode($dom));
}

public function testV8Document(): void
{
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->load('test/data/camt053.v8.xml');
self::assertInstanceOf(Message::class, (new MessageFormat\V08())->getDecoder()->decode($dom));
}

public function testGroupHeader(): void
{
$messages = [
$this->getV2Message(),
$this->getV3Message(),
$this->getV4Message(),
$this->getV8Message(),
$this->getV2UltimateMessage(),
];

Expand Down Expand Up @@ -120,6 +136,7 @@ public function testStatements(): void
$this->getV2Message(),
$this->getV3Message(),
$this->getV4Message(),
$this->getV8Message(),
$this->getV2UltimateMessage(),
];

Expand Down Expand Up @@ -154,6 +171,7 @@ public function testBalance(): void
$this->getV2Message(),
$this->getV3Message(),
$this->getV4Message(),
$this->getV8Message(),
$this->getV2UltimateMessage(),
];

Expand Down Expand Up @@ -212,6 +230,7 @@ public function testEntries(): void
$this->getV2Message(),
$this->getV3Message(),
$this->getV4Message(),
$this->getV8Message(),
$this->getV2UltimateMessage(),
];

Expand Down Expand Up @@ -278,6 +297,7 @@ public function testStructuredMessage(): void
$this->getV2Message(),
$this->getV3Message(),
$this->getV4Message(),
$this->getV8Message(),
$this->getV2UltimateMessage(),
];

Expand Down
2 changes: 2 additions & 0 deletions test/Unit/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ public function testDefaultConfigHasMessageFormats(): void
Camt052\MessageFormat\V02::class,
Camt052\MessageFormat\V04::class,
Camt052\MessageFormat\V06::class,
Camt052\MessageFormat\V08::class,
Camt053\MessageFormat\V02::class,
Camt053\MessageFormat\V03::class,
Camt053\MessageFormat\V04::class,
Camt053\MessageFormat\V08::class,
Camt054\MessageFormat\V02::class,
Camt054\MessageFormat\V04::class,
Camt054\MessageFormat\V08::class,
Expand Down
2 changes: 2 additions & 0 deletions test/Unit/RegressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ public static function providerRegression(): iterable
yield ['test/data/camt052.v2.xml'];
yield ['test/data/camt052.v4.xml'];
yield ['test/data/camt052.v6.xml'];
yield ['test/data/camt052.v8.xml'];
yield ['test/data/camt053.v2.five.decimals.xml'];
yield ['test/data/camt053.v2.minimal.ultimate.xml'];
yield ['test/data/camt053.v2.minimal.xml'];
yield ['test/data/camt053.v2.multi.statement.xml'];
yield ['test/data/camt053.v3.xml'];
yield ['test/data/camt053.v4.xml'];
yield ['test/data/camt053.v8.xml'];
yield ['test/data/camt054.v2.xml'];
yield ['test/data/camt054.v4.xml'];
yield ['test/data/camt054.v8-with-UETR.xml'];
Expand Down
Loading

0 comments on commit 15f3d03

Please sign in to comment.