Skip to content

Commit 8e7070e

Browse files
authored
Merge pull request #168 from fluffis/master
Add support for Related party identification structure
2 parents 809a968 + e2490b8 commit 8e7070e

28 files changed

+860
-0
lines changed

src/DTO/Creditor.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class Creditor implements RelatedPartyTypeInterface
88
{
99
private ?Address $address = null;
1010

11+
private ?Identification $identification = null;
12+
1113
public function __construct(private ?string $name)
1214
{
1315
}
@@ -17,6 +19,11 @@ public function setAddress(Address $address): void
1719
$this->address = $address;
1820
}
1921

22+
public function setIdentification(Identification $identification): void
23+
{
24+
$this->identification = $identification;
25+
}
26+
2027
public function getAddress(): ?Address
2128
{
2229
return $this->address;
@@ -26,4 +33,9 @@ public function getName(): ?string
2633
{
2734
return $this->name;
2835
}
36+
37+
public function getIdentification(): ?Identification
38+
{
39+
return $this->identification;
40+
}
2941
}

src/DTO/Debtor.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class Debtor implements RelatedPartyTypeInterface
88
{
99
private ?Address $address = null;
1010

11+
private ?Identification $identification = null;
12+
1113
public function __construct(private ?string $name)
1214
{
1315
}
@@ -17,6 +19,11 @@ public function setAddress(Address $address): void
1719
$this->address = $address;
1820
}
1921

22+
public function setIdentification(Identification $identification): void
23+
{
24+
$this->identification = $identification;
25+
}
26+
2027
public function getAddress(): ?Address
2128
{
2229
return $this->address;
@@ -26,4 +33,9 @@ public function getName(): ?string
2633
{
2734
return $this->name;
2835
}
36+
37+
public function getIdentification(): ?Identification
38+
{
39+
return $this->identification;
40+
}
2941
}

src/DTO/PrivateIdentification.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Genkgo\Camt\DTO;
6+
7+
use DateTimeImmutable;
8+
9+
class PrivateIdentification extends Identification
10+
{
11+
private ?DateTimeImmutable $birthDate = null;
12+
13+
private ?string $provinceOfBirth = null;
14+
15+
private ?string $cityOfBirth = null;
16+
17+
private ?string $countryOfBirth = null;
18+
19+
private ?string $otherId = null;
20+
21+
private ?string $otherIssuer = null;
22+
23+
private ?string $otherSchemeName = null;
24+
25+
public function getBirthDate(): ?DateTimeImmutable
26+
{
27+
return $this->birthDate;
28+
}
29+
30+
public function setBirthDate(?DateTimeImmutable $birthDate): void
31+
{
32+
$this->birthDate = $birthDate;
33+
}
34+
35+
public function getProvinceOfBirth(): ?string
36+
{
37+
return $this->provinceOfBirth;
38+
}
39+
40+
public function setProvinceOfBirth(?string $provinceOfBirth): void
41+
{
42+
$this->provinceOfBirth = $provinceOfBirth;
43+
}
44+
45+
public function getCityOfBirth(): ?string
46+
{
47+
return $this->cityOfBirth;
48+
}
49+
50+
public function setCityOfBirth(?string $cityOfBirth): void
51+
{
52+
$this->cityOfBirth = $cityOfBirth;
53+
}
54+
55+
public function getCountryOfBirth(): ?string
56+
{
57+
return $this->countryOfBirth;
58+
}
59+
60+
public function setCountryOfBirth(?string $countryOfBirth): void
61+
{
62+
$this->countryOfBirth = $countryOfBirth;
63+
}
64+
65+
public function getOtherId(): ?string
66+
{
67+
return $this->otherId;
68+
}
69+
70+
public function setOtherId(?string $otherId): void
71+
{
72+
$this->otherId = $otherId;
73+
}
74+
75+
public function getOtherIssuer(): ?string
76+
{
77+
return $this->otherIssuer;
78+
}
79+
80+
public function setOtherIssuer(?string $otherIssuer): void
81+
{
82+
$this->otherIssuer = $otherIssuer;
83+
}
84+
85+
public function getOtherSchemeName(): ?string
86+
{
87+
return $this->otherSchemeName;
88+
}
89+
90+
public function setOtherSchemeName(?string $otherSchemeName): void
91+
{
92+
$this->otherSchemeName = $otherSchemeName;
93+
}
94+
}

src/DTO/RelatedPartyTypeInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ public function setAddress(Address $address): void;
1616
public function getAddress(): ?Address;
1717

1818
public function getName(): ?string;
19+
20+
public function getIdentification(): ?Identification;
21+
22+
public function setIdentification(Identification $identification): void;
1923
}

src/Decoder/EntryTransactionDetail.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ protected function addRelatedParty(DTO\EntryTransactionDetail $detail, SimpleXML
120120
$relatedPartyType->setAddress(DTOFactory\Address::createFromXml($xmlPartyDetail->PstlAdr));
121121
}
122122

123+
if (isset($xmlPartyDetail->Id)) {
124+
if (isset($xmlPartyDetail->Id->PrvtId)) {
125+
$relatedPartyType->setIdentification(DTOFactory\PrivateIdentification::createFromXml($xmlPartyDetail->Id->PrvtId));
126+
} elseif (isset($xmlPartyDetail->Id->OrgId)) {
127+
$relatedPartyType->setIdentification(DTOFactory\OrganisationIdentification::createFromXml($xmlPartyDetail->Id->OrgId));
128+
}
129+
}
130+
123131
$relatedParty = new RelatedParty($relatedPartyType, $this->getRelatedPartyAccount($xmlRelatedPartyTypeAccount));
124132

125133
$detail->addRelatedParty($relatedParty);
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Genkgo\Camt\Decoder\Factory\DTO;
6+
7+
use Genkgo\Camt\Decoder\Date;
8+
use Genkgo\Camt\DTO;
9+
use SimpleXMLElement;
10+
11+
class PrivateIdentification
12+
{
13+
public static function createFromXml(SimpleXMLElement $xmlPrivateIdentification): DTO\PrivateIdentification
14+
{
15+
$privateIdentification = new DTO\PrivateIdentification();
16+
if (isset($xmlPrivateIdentification->DtAndPlcOfBirth)) {
17+
if (isset($xmlPrivateIdentification->DtAndPlcOfBirth->BirthDt)) {
18+
$dateDecoder = new Date();
19+
$privateIdentification->setBirthDate($dateDecoder->decode((string) $xmlPrivateIdentification->DtAndPlcOfBirth->BirthDt));
20+
}
21+
if (isset($xmlPrivateIdentification->DtAndPlcOfBirth->PrvcOfBirth)) {
22+
$privateIdentification->setProvinceOfBirth((string) $xmlPrivateIdentification->DtAndPlcOfBirth->PrvcOfBirth);
23+
}
24+
if (isset($xmlPrivateIdentification->DtAndPlcOfBirth->CityOfBirth)) {
25+
$privateIdentification->setCityOfBirth((string) $xmlPrivateIdentification->DtAndPlcOfBirth->CityOfBirth);
26+
}
27+
if (isset($xmlPrivateIdentification->DtAndPlcOfBirth->CtryOfBirth)) {
28+
$privateIdentification->setCountryOfBirth((string) $xmlPrivateIdentification->DtAndPlcOfBirth->CtryOfBirth);
29+
}
30+
}
31+
if (isset($xmlPrivateIdentification->Othr)) {
32+
if (isset($xmlPrivateIdentification->Othr->Id)) {
33+
$privateIdentification->setOtherId((string) $xmlPrivateIdentification->Othr->Id);
34+
}
35+
36+
if (isset($xmlPrivateIdentification->Othr->SchmeNm)) {
37+
if (isset($xmlPrivateIdentification->Othr->SchmeNm->Cd)) {
38+
$privateIdentification->setOtherSchemeName((string) $xmlPrivateIdentification->Othr->SchmeNm->Cd);
39+
}
40+
if (isset($xmlPrivateIdentification->Othr->SchmeNm->Prtry)) {
41+
$privateIdentification->setOtherSchemeName((string) $xmlPrivateIdentification->Othr->SchmeNm->Prtry);
42+
}
43+
}
44+
if (isset($xmlPrivateIdentification->Othr->Issr)) {
45+
$privateIdentification->setOtherIssuer((string) $xmlPrivateIdentification->Othr->Issr);
46+
}
47+
}
48+
49+
return $privateIdentification;
50+
}
51+
}

test/Unit/Camt053/EndToEndTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ public function testEntries(): void
264264
self::assertEquals('NL', $party->getRelatedPartyType()->getAddress()->getCountry());
265265
self::assertEquals([], $party->getRelatedPartyType()->getAddress()->getAddressLines());
266266
self::assertEquals('NL56AGDH9619008421', (string) $party->getAccount()->getIdentification());
267+
self::assertEquals('455454654', $party->getRelatedPartyType()->getIdentification()->getOtherId());
268+
self::assertEquals('KBO-BCE', $party->getRelatedPartyType()->getIdentification()->getOtherIssuer());
267269
}
268270
} elseif ($party->getRelatedPartyType() instanceof DTO\Debtor) {
269271
if ($party->getRelatedPartyType() instanceof DTO\UltimateDebtor) {

test/data/camt052.v2.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,23 @@
135135
"getSubDepartment": null,
136136
"getTownName": null
137137
},
138+
"getIdentification": {
139+
"__CLASS__": "Genkgo\\Camt\\DTO\\OrganisationIdentification",
140+
"getBankPartyId": null,
141+
"getBei": null,
142+
"getBic": null,
143+
"getChipsUniversalId": null,
144+
"getDuns": null,
145+
"getEangln": null,
146+
"getIbei": null,
147+
"getIdentification": "455454654",
148+
"getIssuer": null,
149+
"getOtherId": "455454654",
150+
"getOtherIssuer": "KBO-BCE",
151+
"getOtherSchemeName": null,
152+
"getOtherType": null,
153+
"getTaxId": null
154+
},
138155
"getName": "Company Name"
139156
}
140157
},
@@ -166,6 +183,7 @@
166183
"getSubDepartment": null,
167184
"getTownName": null
168185
},
186+
"getIdentification": null,
169187
"getName": "NAME NAME"
170188
}
171189
}

test/data/camt052.v2.other-account.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,23 @@
132132
"getSubDepartment": null,
133133
"getTownName": null
134134
},
135+
"getIdentification": {
136+
"__CLASS__": "Genkgo\\Camt\\DTO\\OrganisationIdentification",
137+
"getBankPartyId": null,
138+
"getBei": null,
139+
"getBic": null,
140+
"getChipsUniversalId": null,
141+
"getDuns": null,
142+
"getEangln": null,
143+
"getIbei": null,
144+
"getIdentification": "455454654",
145+
"getIssuer": null,
146+
"getOtherId": "455454654",
147+
"getOtherIssuer": "KBO-BCE",
148+
"getOtherSchemeName": null,
149+
"getOtherType": null,
150+
"getTaxId": null
151+
},
135152
"getName": "Company Name"
136153
}
137154
},
@@ -160,6 +177,7 @@
160177
"getSubDepartment": null,
161178
"getTownName": null
162179
},
180+
"getIdentification": null,
163181
"getName": "NAME NAME"
164182
}
165183
}

test/data/camt052.v2.with-account-name.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"getRelatedPartyType": {
8686
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
8787
"getAddress": null,
88+
"getIdentification": null,
8889
"getName": "Company Name"
8990
}
9091
},
@@ -102,6 +103,7 @@
102103
"getRelatedPartyType": {
103104
"__CLASS__": "Genkgo\\Camt\\DTO\\Debtor",
104105
"getAddress": null,
106+
"getIdentification": null,
105107
"getName": "NAME NAME"
106108
}
107109
}

test/data/camt052.v4.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
"getRelatedPartyType": {
213213
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
214214
"getAddress": null,
215+
"getIdentification": null,
215216
"getName": "UNIFITS GmbH"
216217
}
217218
},
@@ -240,6 +241,7 @@
240241
"getSubDepartment": null,
241242
"getTownName": "Example Creditor Town 4 - V1"
242243
},
244+
"getIdentification": null,
243245
"getName": "Example Creditor 4 - V1"
244246
}
245247
}

test/data/camt052.v6.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
"getRelatedPartyType": {
213213
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
214214
"getAddress": null,
215+
"getIdentification": null,
215216
"getName": "UNIFITS GmbH"
216217
}
217218
},
@@ -240,6 +241,7 @@
240241
"getSubDepartment": null,
241242
"getTownName": "Example Creditor Town 6 - V1"
242243
},
244+
"getIdentification": null,
243245
"getName": "Example Creditor 6 - V1"
244246
}
245247
}

test/data/camt053.v2.all-balance-types.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
"getSubDepartment": null,
283283
"getTownName": null
284284
},
285+
"getIdentification": null,
285286
"getName": "Company Name"
286287
}
287288
}

test/data/camt053.v2.five.decimals.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"getSubDepartment": null,
158158
"getTownName": null
159159
},
160+
"getIdentification": null,
160161
"getName": "Company Name"
161162
}
162163
}

0 commit comments

Comments
 (0)