Skip to content

Commit c3eea10

Browse files
author
Marko Petrovic
committed
Add parsing for orgId in related parties and add proprietary amount support
1 parent 211c757 commit c3eea10

17 files changed

+99
-38
lines changed

src/DTO/Creditor.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
class Creditor implements RelatedPartyTypeInterface
88
{
99
private ?Address $address = null;
10+
private ?string $orgId;
1011

1112
public function __construct(private ?string $name)
1213
{
@@ -26,4 +27,14 @@ public function getName(): ?string
2627
{
2728
return $this->name;
2829
}
30+
31+
public function setOrgId(?string $orgId): void
32+
{
33+
$this->orgId = $orgId;
34+
}
35+
36+
public function getOrgId(): ?string
37+
{
38+
return $this->orgId;
39+
}
2940
}

src/DTO/Debtor.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
class Debtor implements RelatedPartyTypeInterface
88
{
99
private ?Address $address = null;
10+
private ?string $orgId;
1011

1112
public function __construct(private ?string $name)
1213
{
@@ -26,4 +27,14 @@ public function getName(): ?string
2627
{
2728
return $this->name;
2829
}
30+
31+
public function setOrgId(?string $orgId): void
32+
{
33+
$this->orgId = $orgId;
34+
}
35+
36+
public function getOrgId(): ?string
37+
{
38+
return $this->orgId;
39+
}
2940
}

src/Decoder/EntryTransactionDetail.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ protected function addRelatedParty(DTO\EntryTransactionDetail $detail, SimpleXML
106106

107107
$xmlRelatedPartyName = (isset($xmlPartyDetail->Nm)) ? (string) $xmlPartyDetail->Nm : null;
108108
$relatedPartyType = new $relatedPartyTypeClass($xmlRelatedPartyName);
109+
$orgId = $xmlRelatedPartyType?->Id?->OrgId?->Othr?->Id;
109110

111+
$relatedPartyType->setOrgId((string) $orgId);
110112
if (isset($xmlPartyDetail->PstlAdr)) {
111113
$relatedPartyType->setAddress(DTOFactory\Address::createFromXml($xmlPartyDetail->PstlAdr));
112114
}
@@ -330,10 +332,13 @@ public function addCharges(DTO\EntryTransactionDetail $detail, SimpleXMLElement
330332

331333
public function addAmountDetails(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail, SimpleXMLElement $CdtDbtInd): void
332334
{
333-
if (isset($xmlDetail->AmtDtls, $xmlDetail->AmtDtls->TxAmt, $xmlDetail->AmtDtls->TxAmt->Amt)) {
334-
$money = $this->moneyFactory->create($xmlDetail->AmtDtls->TxAmt->Amt, $CdtDbtInd);
335-
$detail->setAmountDetails($money);
336-
}
335+
if (isset($xmlDetail->AmtDtls, $xmlDetail->AmtDtls->TxAmt, $xmlDetail->AmtDtls->TxAmt->Amt)) {
336+
$money = $this->moneyFactory->create($xmlDetail->AmtDtls->TxAmt->Amt, $CdtDbtInd);
337+
$detail->setAmountDetails($money);
338+
} elseif(isset($xmlDetail->AmtDtls->PrtryAmt, $xmlDetail->AmtDtls->PrtryAmt->Amt, $xmlDetail->AmtDtls->PrtryAmt->Tp)) {
339+
$money = $this->moneyFactory->create($xmlDetail->AmtDtls->PrtryAmt->Amt, $xmlDetail->AmtDtls->PrtryAmt->Tp);
340+
$detail->setAmountDetails($money);
341+
}
337342
}
338343

339344
public function addAmount(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail, SimpleXMLElement $CdtDbtInd): void

test/data/camt052.v2.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@
132132
"getSubDepartment": null,
133133
"getTownName": null
134134
},
135-
"getName": "Company Name"
135+
"getName": "Company Name",
136+
"getOrgId": "455454654"
136137
}
137138
},
138139
{
@@ -162,7 +163,8 @@
162163
"getSubDepartment": null,
163164
"getTownName": null
164165
},
165-
"getName": "NAME NAME"
166+
"getName": "NAME NAME",
167+
"getOrgId": ""
166168
}
167169
}
168170
],

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@
130130
"getSubDepartment": null,
131131
"getTownName": null
132132
},
133-
"getName": "Company Name"
133+
"getName": "Company Name",
134+
"getOrgId": "455454654"
134135
}
135136
},
136137
{
@@ -158,7 +159,8 @@
158159
"getSubDepartment": null,
159160
"getTownName": null
160161
},
161-
"getName": "NAME NAME"
162+
"getName": "NAME NAME",
163+
"getOrgId": ""
162164
}
163165
}
164166
],

test/data/camt052.v4.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@
191191
"getRelatedPartyType": {
192192
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
193193
"getAddress": null,
194-
"getName": "UNIFITS GmbH"
194+
"getName": "UNIFITS GmbH",
195+
"getOrgId": ""
195196
}
196197
},
197198
{
@@ -218,7 +219,8 @@
218219
"getSubDepartment": null,
219220
"getTownName": "Example Creditor Town 4 - V1"
220221
},
221-
"getName": "Example Creditor 4 - V1"
222+
"getName": "Example Creditor 4 - V1",
223+
"getOrgId": ""
222224
}
223225
}
224226
],

test/data/camt052.v6.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@
191191
"getRelatedPartyType": {
192192
"__CLASS__": "Genkgo\\Camt\\DTO\\Creditor",
193193
"getAddress": null,
194-
"getName": "UNIFITS GmbH"
194+
"getName": "UNIFITS GmbH",
195+
"getOrgId": ""
195196
}
196197
},
197198
{
@@ -218,7 +219,8 @@
218219
"getSubDepartment": null,
219220
"getTownName": "Example Creditor Town 6 - V1"
220221
},
221-
"getName": "Example Creditor 6 - V1"
222+
"getName": "Example Creditor 6 - V1",
223+
"getOrgId": ""
222224
}
223225
}
224226
],

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@
153153
"getSubDepartment": null,
154154
"getTownName": null
155155
},
156-
"getName": "Company Name"
156+
"getName": "Company Name",
157+
"getOrgId": ""
157158
}
158159
}
159160
],

test/data/camt053.v2.minimal.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@
197197
"getSubDepartment": null,
198198
"getTownName": null
199199
},
200-
"getName": "Company Name"
200+
"getName": "Company Name",
201+
"getOrgId": "455454654"
201202
}
202203
},
203204
{
@@ -227,7 +228,8 @@
227228
"getSubDepartment": null,
228229
"getTownName": null
229230
},
230-
"getName": "NAME NAME"
231+
"getName": "NAME NAME",
232+
"getOrgId": ""
231233
}
232234
}
233235
],

test/data/camt053.v2.minimal.ultimate.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@
193193
"getSubDepartment": null,
194194
"getTownName": null
195195
},
196-
"getName": "CREDITOR NAME NM"
196+
"getName": "CREDITOR NAME NM",
197+
"getOrgId": ""
197198
}
198199
},
199200
{
@@ -216,7 +217,8 @@
216217
"getSubDepartment": null,
217218
"getTownName": null
218219
},
219-
"getName": "DEBTOR NAME NM"
220+
"getName": "DEBTOR NAME NM",
221+
"getOrgId": ""
220222
}
221223
}
222224
],

0 commit comments

Comments
 (0)