|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Genkgo\Camt\Decoder; |
|
4
|
|
|
|
|
5
|
|
|
use Genkgo\Camt\DTO; |
|
6
|
|
|
use \SimpleXMLElement; |
|
7
|
|
|
use Genkgo\Camt\Decoder\Factory\DTO as DTOFactory; |
|
8
|
|
|
use Money\Money; |
|
9
|
|
|
use Money\Currency; |
|
10
|
|
|
use Genkgo\Camt\Util\StringToUnits; |
|
11
|
|
|
|
|
12
|
|
|
abstract class EntryTransactionDetail |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @var DateDecoderInterface |
|
16
|
|
|
*/ |
|
17
|
|
|
private $dateDecoder; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* EntryTransactionDetail constructor. |
|
21
|
|
|
* @param DateDecoderInterface $dateDecoder |
|
22
|
|
|
*/ |
|
23
|
37 |
|
public function __construct(DateDecoderInterface $dateDecoder) |
|
24
|
|
|
{ |
|
25
|
37 |
|
$this->dateDecoder = $dateDecoder; |
|
26
|
37 |
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param DTO\EntryTransactionDetail $detail |
|
30
|
|
|
* @param SimpleXMLElement $xmlDetail |
|
31
|
|
|
*/ |
|
32
|
23 |
|
public function addReferences(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail) |
|
33
|
|
|
{ |
|
34
|
23 |
|
if (false === isset($xmlDetail->Refs)) { |
|
35
|
8 |
|
return; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
18 |
|
$refs = $xmlDetail->Refs; |
|
|
|
|
|
|
39
|
18 |
|
$reference = new DTO\Reference(); |
|
40
|
|
|
|
|
41
|
18 |
|
$reference->setMessageId(isset($refs->MsgId) ? (string) $refs->MsgId : null); |
|
42
|
18 |
|
$reference->setAccountServiceReference(isset($refs->AcctSvcrRef) ? (string) $refs->AcctSvcrRef : null); |
|
43
|
18 |
|
$reference->setPaymentInformationId(isset($refs->PmtInfId) ? (string) $refs->PmtInfId : null); |
|
44
|
18 |
|
$reference->setInstructionId(isset($refs->InstrId) ? (string) $refs->InstrId : null); |
|
45
|
18 |
|
$reference->setEndToEndId(isset($refs->EndToEndId) ? (string) $refs->EndToEndId : null); |
|
46
|
18 |
|
$reference->setTransactionId(isset($refs->TxId) ? (string) $refs->TxId : null); |
|
47
|
18 |
|
$reference->setMandateId(isset($refs->MndtId) ? (string) $refs->MndtId : null); |
|
48
|
18 |
|
$reference->setChequeNumber(isset($refs->ChqNb) ? (string) $refs->ChqNb : null); |
|
49
|
18 |
|
$reference->setClearingSystemReference(isset($refs->ClrSysRef) ? (string) $refs->ClrSysRef : null); |
|
50
|
18 |
|
$reference->setAccountOwnerTransactionId(isset($refs->AcctOwnrTxId) ? (string) $refs->AcctOwnrTxId : null); |
|
51
|
18 |
|
$reference->setAccountServicerTransactionId(isset($refs->AcctSvcrTxId) ? (string) $refs->AcctSvcrTxId : null); |
|
52
|
18 |
|
$reference->setMarketInfrastructureTransactionId(isset($refs->MktInfrstrctrTxId) ? (string) $refs->MktInfrstrctrTxId : null); |
|
53
|
18 |
|
$reference->setProcessingId(isset($refs->PrcgId) ? (string) $refs->PrcgId : null); |
|
54
|
|
|
|
|
55
|
18 |
|
foreach ($refs->Prtry as $xmlProprietary) { |
|
56
|
8 |
|
$type = isset($xmlProprietary->Tp) ? (string) $xmlProprietary->Tp : null; |
|
57
|
8 |
|
$subReference = isset($xmlProprietary->Ref) ? (string) $xmlProprietary->Ref : null; |
|
58
|
|
|
|
|
59
|
8 |
|
$reference->addProprietary(new DTO\ProprietaryReference($type, $subReference)); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
18 |
|
$detail->addReference($reference); |
|
63
|
18 |
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param DTO\EntryTransactionDetail $detail |
|
67
|
|
|
* @param SimpleXMLElement $xmlDetail |
|
68
|
|
|
*/ |
|
69
|
23 |
|
public function addRelatedParties(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail) |
|
70
|
|
|
{ |
|
71
|
23 |
|
if (false === isset($xmlDetail->RltdPties)) { |
|
72
|
1 |
|
return; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
22 |
|
foreach ($xmlDetail->RltdPties as $xmlRelatedParty) { |
|
76
|
22 |
|
if (isset($xmlRelatedParty->Cdtr)) { |
|
77
|
22 |
|
$xmlRelatedPartyType = $xmlRelatedParty->Cdtr; |
|
78
|
22 |
|
$xmlRelatedPartyTypeAccount = $xmlRelatedParty->CdtrAcct; |
|
79
|
22 |
|
$xmlRelatedPartyName = (isset($xmlRelatedPartyType->Nm)) ? (string) $xmlRelatedPartyType->Nm : '' ; |
|
80
|
22 |
|
$relatedPartyType = $creditor = new DTO\Creditor($xmlRelatedPartyName); |
|
|
|
|
|
|
81
|
|
|
|
|
82
|
22 |
|
$this->addRelatedParty($detail, $xmlRelatedPartyType, $relatedPartyType, $xmlRelatedPartyTypeAccount); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
22 |
|
if (isset($xmlRelatedParty->UltmtCdtr)) { |
|
86
|
5 |
|
$xmlRelatedPartyType = $xmlRelatedParty->UltmtCdtr; |
|
87
|
5 |
|
$xmlRelatedPartyName = (isset($xmlRelatedPartyType->Nm)) ? (string) $xmlRelatedPartyType->Nm : '' ; |
|
88
|
5 |
|
$relatedPartyType = $creditor = new DTO\UltimateCreditor($xmlRelatedPartyName); |
|
|
|
|
|
|
89
|
|
|
|
|
90
|
5 |
|
$this->addRelatedParty($detail, $xmlRelatedPartyType, $relatedPartyType); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
22 |
|
if (isset($xmlRelatedParty->Dbtr)) { |
|
94
|
19 |
|
$xmlRelatedPartyType = $xmlRelatedParty->Dbtr; |
|
95
|
19 |
|
$xmlRelatedPartyTypeAccount = $xmlRelatedParty->DbtrAcct; |
|
96
|
19 |
|
$xmlRelatedPartyName = (isset($xmlRelatedPartyType->Nm)) ? (string) $xmlRelatedPartyType->Nm : '' ; |
|
97
|
19 |
|
$relatedPartyType = $debtor = new DTO\Debtor($xmlRelatedPartyName); |
|
|
|
|
|
|
98
|
|
|
|
|
99
|
19 |
|
$this->addRelatedParty($detail, $xmlRelatedPartyType, $relatedPartyType, $xmlRelatedPartyTypeAccount); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
22 |
|
if (isset($xmlRelatedParty->UltmtDbtr)) { |
|
103
|
5 |
|
$xmlRelatedPartyType = $xmlRelatedParty->UltmtDbtr; |
|
104
|
5 |
|
$xmlRelatedPartyName = (isset($xmlRelatedPartyType->Nm)) ? (string) $xmlRelatedPartyType->Nm : '' ; |
|
105
|
5 |
|
$relatedPartyType = $creditor = new DTO\UltimateDebtor($xmlRelatedPartyName); |
|
|
|
|
|
|
106
|
|
|
|
|
107
|
22 |
|
$this->addRelatedParty($detail, $xmlRelatedPartyType, $relatedPartyType); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
22 |
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @param DTO\EntryTransactionDetail $detail |
|
114
|
|
|
* @param $xmlRelatedPartyType |
|
115
|
|
|
* @param $relatedPartyType |
|
116
|
|
|
* @param $xmlRelatedPartyTypeAccount |
|
117
|
|
|
* @return DTO\RelatedParty |
|
118
|
|
|
*/ |
|
119
|
22 |
|
protected function addRelatedParty(DTO\EntryTransactionDetail $detail, $xmlRelatedPartyType, DTO\RelatedPartyTypeInterface $relatedPartyType, $xmlRelatedPartyTypeAccount = null) |
|
120
|
|
|
{ |
|
121
|
22 |
|
if (isset($xmlRelatedPartyType->PstlAdr)) { |
|
122
|
22 |
|
$relatedPartyType->setAddress(DTOFactory\Address::createFromXml($xmlRelatedPartyType->PstlAdr)); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
22 |
|
$relatedParty = new DTO\RelatedParty($relatedPartyType, $this->getRelatedPartyAccount($xmlRelatedPartyTypeAccount)); |
|
126
|
|
|
|
|
127
|
22 |
|
$detail->addRelatedParty($relatedParty); |
|
128
|
|
|
|
|
129
|
22 |
|
return $relatedParty; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @param DTO\EntryTransactionDetail $detail |
|
134
|
|
|
* @param SimpleXMLElement $xmlDetail |
|
135
|
|
|
*/ |
|
136
|
21 |
|
public function addRelatedAgents(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail) |
|
137
|
|
|
{ |
|
138
|
21 |
|
if (false === isset($xmlDetail->RltdAgts)) { |
|
139
|
13 |
|
return; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
17 |
|
foreach ($xmlDetail->RltdAgts as $xmlRelatedAgent) { |
|
143
|
17 |
|
if (isset($xmlRelatedAgent->CdtrAgt)) { |
|
144
|
17 |
|
$agent = new DTO\CreditorAgent((string)$xmlRelatedAgent->CdtrAgt->FinInstnId->Nm, (string)$xmlRelatedAgent->CdtrAgt->FinInstnId->BIC); |
|
145
|
17 |
|
$relatedAgent = new DTO\RelatedAgent($agent); |
|
146
|
17 |
|
$detail->addRelatedAgent($relatedAgent); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
17 |
|
if (isset($xmlRelatedAgent->DbtrAgt)) { |
|
150
|
17 |
|
$agent = new DTO\DebtorAgent((string)$xmlRelatedAgent->DbtrAgt->FinInstnId->Nm, (string)$xmlRelatedAgent->DbtrAgt->FinInstnId->BIC); |
|
151
|
17 |
|
$relatedAgent = new DTO\RelatedAgent($agent); |
|
152
|
17 |
|
$detail->addRelatedAgent($relatedAgent); |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
17 |
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @param DTO\EntryTransactionDetail $detail |
|
159
|
|
|
* @param SimpleXMLElement $xmlDetail |
|
160
|
|
|
*/ |
|
161
|
24 |
|
public function addRemittanceInformation(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail) |
|
162
|
|
|
{ |
|
163
|
24 |
|
if (false === isset($xmlDetail->RmtInf)) { |
|
164
|
8 |
|
return; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
19 |
|
$remittanceInformation = new DTO\RemittanceInformation(); |
|
168
|
19 |
|
$unstructuredBlockExists = false; |
|
169
|
|
|
|
|
170
|
19 |
|
if (isset($xmlDetail->RmtInf->Ustrd)) { |
|
171
|
10 |
|
$unstructuredRemittanceInformation = new DTO\UnstructuredRemittanceInformation( |
|
172
|
10 |
|
(string)$xmlDetail->RmtInf->Ustrd |
|
173
|
|
|
); |
|
174
|
|
|
|
|
175
|
10 |
|
$remittanceInformation->setUnstructuredRemittanceInformation($unstructuredRemittanceInformation); |
|
176
|
|
|
|
|
177
|
|
|
// Legacy |
|
178
|
10 |
|
$unstructuredBlockExists = true; |
|
179
|
10 |
|
$remittanceInformation->setMessage( |
|
180
|
10 |
|
(string)$xmlDetail->RmtInf->Ustrd |
|
181
|
|
|
); |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
19 |
|
if (isset($xmlDetail->RmtInf->Strd)) { |
|
185
|
|
|
|
|
186
|
13 |
|
$structuredRemittanceInformation = new DTO\StructuredRemittanceInformation(); |
|
187
|
|
|
|
|
188
|
13 |
|
if(isset($xmlDetail->RmtInf->Strd->AddtlRmtInf)) { |
|
189
|
4 |
|
$structuredRemittanceInformation->setAdditionalRemittanceInformation( |
|
190
|
4 |
|
(string)$xmlDetail->RmtInf->Strd->AddtlRmtInf |
|
191
|
|
|
); |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
13 |
|
if(isset($xmlDetail->RmtInf->Strd->CdtrRefInf)) { |
|
195
|
|
|
|
|
196
|
13 |
|
$creditorReferenceInformation = new DTO\CreditorReferenceInformation(); |
|
197
|
|
|
|
|
198
|
13 |
|
if(isset($xmlDetail->RmtInf->Strd->CdtrRefInf->Ref)) { |
|
199
|
13 |
|
$creditorReferenceInformation->setRef( |
|
200
|
13 |
|
(string)$xmlDetail->RmtInf->Strd->CdtrRefInf->Ref |
|
201
|
|
|
); |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
13 |
|
if(isset($xmlDetail->RmtInf->Strd->CdtrRefInf->Tp) |
|
205
|
13 |
|
&& isset($xmlDetail->RmtInf->Strd->CdtrRefInf->Tp->CdOrPrtry) |
|
206
|
13 |
|
&& isset($xmlDetail->RmtInf->Strd->CdtrRefInf->Tp->CdOrPrtry->Prtry)) { |
|
207
|
4 |
|
$creditorReferenceInformation->setProprietary( |
|
208
|
4 |
|
(string)$xmlDetail->RmtInf->Strd->CdtrRefInf->Tp->CdOrPrtry->Prtry |
|
209
|
|
|
); |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
13 |
|
if(isset($xmlDetail->RmtInf->Strd->CdtrRefInf->Tp) |
|
213
|
13 |
|
&& isset($xmlDetail->RmtInf->Strd->CdtrRefInf->Tp->CdOrPrtry) |
|
214
|
13 |
|
&& isset($xmlDetail->RmtInf->Strd->CdtrRefInf->Tp->CdOrPrtry->Cd)) { |
|
215
|
8 |
|
$creditorReferenceInformation->setCode( |
|
216
|
8 |
|
(string)$xmlDetail->RmtInf->Strd->CdtrRefInf->Tp->CdOrPrtry->Cd |
|
217
|
|
|
); |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
13 |
|
$structuredRemittanceInformation->setCreditorReferenceInformation($creditorReferenceInformation); |
|
221
|
|
|
|
|
222
|
|
|
// Legacy : do not overwrite message if already defined above |
|
223
|
13 |
|
if(false === $unstructuredBlockExists) { |
|
224
|
13 |
|
$remittanceInformation->setCreditorReferenceInformation($creditorReferenceInformation); |
|
225
|
|
|
} |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
13 |
|
$remittanceInformation->setStructuredRemittanceInformation($structuredRemittanceInformation); |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
19 |
|
$detail->setRemittanceInformation($remittanceInformation); |
|
232
|
19 |
|
} |
|
233
|
|
|
|
|
234
|
|
|
/** |
|
235
|
|
|
* @param DTO\EntryTransactionDetail $detail |
|
236
|
|
|
* @param SimpleXMLElement $xmlDetail |
|
237
|
|
|
*/ |
|
238
|
23 |
|
public function addRelatedDates(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail) |
|
239
|
|
|
{ |
|
240
|
23 |
|
if (false === isset($xmlDetail->RltdDts)) { |
|
241
|
22 |
|
return; |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
1 |
|
if (isset($xmlDetail->RltdDts->AccptncDtTm)) { |
|
245
|
1 |
|
$RelatedDates = DTO\RelatedDates::fromUnstructured( |
|
246
|
1 |
|
$this->dateDecoder->decode((string) $xmlDetail->RltdDts->AccptncDtTm ) |
|
247
|
|
|
); |
|
248
|
1 |
|
$detail->setRelatedDates($RelatedDates); |
|
249
|
1 |
|
return; |
|
250
|
|
|
} |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
|
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* @param DTO\EntryTransactionDetail $detail |
|
257
|
|
|
* @param SimpleXMLElement $xmlDetail |
|
258
|
|
|
*/ |
|
259
|
23 |
|
public function addReturnInformation(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail) |
|
260
|
|
|
{ |
|
261
|
23 |
|
if (isset($xmlDetail->RtrInf) && isset($xmlDetail->RtrInf->Rsn->Cd)) { |
|
262
|
1 |
|
$remittanceInformation = DTO\ReturnInformation::fromUnstructured( |
|
263
|
1 |
|
(string)$xmlDetail->RtrInf->Rsn->Cd, |
|
264
|
1 |
|
(string)$xmlDetail->RtrInf->AddtlInf |
|
265
|
|
|
); |
|
266
|
1 |
|
$detail->setReturnInformation($remittanceInformation); |
|
267
|
|
|
} |
|
268
|
23 |
|
} |
|
269
|
|
|
|
|
270
|
|
|
/** |
|
271
|
|
|
* @param DTO\EntryTransactionDetail $detail |
|
272
|
|
|
* @param SimpleXMLElement $xmlDetail |
|
273
|
|
|
*/ |
|
274
|
23 |
|
public function addAdditionalTransactionInformation(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail) |
|
275
|
|
|
{ |
|
276
|
23 |
|
if (isset($xmlDetail->AddtlTxInf)) { |
|
277
|
1 |
|
$additionalInformation = new DTO\AdditionalTransactionInformation( |
|
278
|
1 |
|
(string) $xmlDetail->AddtlTxInf |
|
279
|
|
|
); |
|
280
|
1 |
|
$detail->setAdditionalTransactionInformation($additionalInformation); |
|
281
|
|
|
} |
|
282
|
23 |
|
} |
|
283
|
|
|
|
|
284
|
|
|
/** |
|
285
|
|
|
* @param DTO\EntryTransactionDetail $detail |
|
286
|
|
|
* @param SimpleXMLElement $xmlDetail |
|
287
|
|
|
*/ |
|
288
|
21 |
|
public function addBankTransactionCode(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail) |
|
289
|
|
|
{ |
|
290
|
21 |
|
$bankTransactionCode = new DTO\BankTransactionCode(); |
|
291
|
|
|
|
|
292
|
21 |
|
if (isset($xmlDetail->BkTxCd)) { |
|
293
|
19 |
|
$bankTransactionCode = new DTO\BankTransactionCode(); |
|
294
|
|
|
|
|
295
|
19 |
|
if (isset($xmlDetail->BkTxCd->Prtry)) { |
|
296
|
19 |
|
$proprietaryBankTransactionCode = new DTO\ProprietaryBankTransactionCode( |
|
297
|
19 |
|
(string)$xmlDetail->BkTxCd->Prtry->Cd, |
|
298
|
19 |
|
(string)$xmlDetail->BkTxCd->Prtry->Issr |
|
299
|
|
|
); |
|
300
|
|
|
|
|
301
|
19 |
|
$bankTransactionCode->setProprietary($proprietaryBankTransactionCode); |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
19 |
|
if (isset($xmlDetail->BkTxCd->Domn)) { |
|
305
|
7 |
|
$domainBankTransactionCode = new DTO\DomainBankTransactionCode( |
|
306
|
7 |
|
(string)$xmlDetail->BkTxCd->Domn->Cd |
|
307
|
|
|
); |
|
308
|
|
|
|
|
309
|
7 |
|
if (isset($xmlDetail->BkTxCd->Domn->Fmly)) { |
|
310
|
7 |
|
$domainFamilyBankTransactionCode = new DTO\DomainFamilyBankTransactionCode( |
|
311
|
7 |
|
(string)$xmlDetail->BkTxCd->Domn->Fmly->Cd, |
|
312
|
7 |
|
(string)$xmlDetail->BkTxCd->Domn->Fmly->SubFmlyCd |
|
313
|
|
|
); |
|
314
|
|
|
|
|
315
|
7 |
|
$domainBankTransactionCode->setFamily($domainFamilyBankTransactionCode); |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
7 |
|
$bankTransactionCode->setDomain($domainBankTransactionCode); |
|
319
|
|
|
} |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
21 |
|
$detail->setBankTransactionCode($bankTransactionCode); |
|
323
|
21 |
|
} |
|
324
|
|
|
|
|
325
|
|
|
/** |
|
326
|
|
|
* @param DTO\EntryTransactionDetail $detail |
|
327
|
|
|
* @param SimpleXMLElement $xmlDetail |
|
328
|
|
|
*/ |
|
329
|
23 |
|
public function addCharges(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail) |
|
330
|
|
|
{ |
|
331
|
23 |
|
if (isset($xmlDetail->Chrgs)) { |
|
332
|
4 |
|
$charges = new DTO\Charges(); |
|
333
|
|
|
|
|
334
|
4 |
|
if (isset($xmlDetail->Chrgs->TtlChrgsAndTaxAmt) && (string) $xmlDetail->Chrgs->TtlChrgsAndTaxAmt) { |
|
335
|
4 |
|
$amount = StringToUnits::convert((string) $xmlDetail->Chrgs->TtlChrgsAndTaxAmt); |
|
336
|
4 |
|
$currency = (string)$xmlDetail->Chrgs->TtlChrgsAndTaxAmt['Ccy']; |
|
337
|
|
|
|
|
338
|
4 |
|
$charges->setTotalChargesAndTaxAmount(new Money($amount, new Currency($currency))); |
|
339
|
|
|
} |
|
340
|
|
|
|
|
341
|
4 |
|
$chargesRecords = $xmlDetail->Chrgs->Rcrd; |
|
342
|
4 |
|
if ($chargesRecords) { |
|
343
|
4 |
|
foreach ($chargesRecords as $chargesRecord) { |
|
344
|
|
|
|
|
345
|
4 |
|
$chargesDetail = new DTO\ChargesRecord(); |
|
346
|
|
|
|
|
347
|
4 |
|
if(isset($chargesRecord->Amt) && (string) $chargesRecord->Amt) { |
|
348
|
4 |
|
$amount = StringToUnits::convert((string) $chargesRecord->Amt); |
|
349
|
4 |
|
$currency = (string)$chargesRecord->Amt['Ccy']; |
|
350
|
|
|
|
|
351
|
4 |
|
if ((string) $chargesRecord->CdtDbtInd === 'DBIT') { |
|
352
|
4 |
|
$amount = $amount * -1; |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
4 |
|
$chargesDetail->setAmount(new Money($amount, new Currency($currency))); |
|
356
|
|
|
} |
|
357
|
4 |
|
if (isset($chargesRecord->CdtDbtInd) && (string) $chargesRecord->CdtDbtInd === 'true') { |
|
358
|
|
|
$chargesDetail->setChargesIncludedIndicator(true); |
|
359
|
|
|
} |
|
360
|
4 |
|
if (isset($chargesRecord->Tp->Prtry->Id) && (string) $chargesRecord->Tp->Prtry->Id) { |
|
361
|
4 |
|
$chargesDetail->setIdentification((string) $chargesRecord->Tp->Prtry->Id); |
|
362
|
|
|
} |
|
363
|
4 |
|
$charges->addRecord($chargesDetail); |
|
364
|
|
|
} |
|
365
|
|
|
} |
|
366
|
4 |
|
$detail->setCharges($charges); |
|
367
|
|
|
} |
|
368
|
23 |
|
} |
|
369
|
|
|
|
|
370
|
|
|
/** |
|
371
|
|
|
* @param DTO\EntryTransactionDetail $detail |
|
372
|
|
|
* @param SimpleXMLElement $xmlDetail |
|
373
|
|
|
* @param SimpleXMLElement $CdtDbtInd |
|
374
|
|
|
*/ |
|
375
|
21 |
|
public function addAmountDetails(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail, $CdtDbtInd) |
|
376
|
|
|
{ |
|
377
|
21 |
|
if (isset($xmlDetail->AmtDtls)) { |
|
378
|
7 |
|
$amountDetails = new DTO\AmountDetails(); |
|
379
|
|
|
|
|
380
|
7 |
|
if (isset($xmlDetail->AmtDtls->TxAmt) && isset($xmlDetail->AmtDtls->TxAmt->Amt)) { |
|
381
|
7 |
|
$amount = StringToUnits::convert((string) $xmlDetail->AmtDtls->TxAmt->Amt); |
|
382
|
|
|
|
|
383
|
7 |
|
if ((string) $CdtDbtInd === 'DBIT') { |
|
384
|
7 |
|
$amount = $amount * -1; |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
7 |
|
$money = new Money( |
|
388
|
7 |
|
$amount, |
|
389
|
7 |
|
new Currency((string) $xmlDetail->AmtDtls->TxAmt->Amt['Ccy']) |
|
390
|
|
|
); |
|
391
|
7 |
|
$amountDetails->setAmount($money); |
|
392
|
|
|
} |
|
393
|
7 |
|
$detail->setAmountDetails($amountDetails); |
|
394
|
|
|
} |
|
395
|
21 |
|
} |
|
396
|
|
|
|
|
397
|
|
|
/** |
|
398
|
|
|
* @param DTO\EntryTransactionDetail $detail |
|
399
|
|
|
* @param SimpleXMLElement $xmlDetail |
|
400
|
|
|
* @param SimpleXMLElement $CdtDbtInd |
|
401
|
|
|
*/ |
|
402
|
21 |
|
public function addAmount(DTO\EntryTransactionDetail $detail, SimpleXMLElement $xmlDetail, $CdtDbtInd) |
|
403
|
|
|
{ |
|
404
|
21 |
|
if (isset($xmlDetail->Amt)) { |
|
405
|
14 |
|
$amountDetails = new DTO\Amount(); |
|
406
|
|
|
|
|
407
|
14 |
|
$amount = StringToUnits::convert((string) $xmlDetail->Amt); |
|
408
|
|
|
|
|
409
|
14 |
|
if ((string) $CdtDbtInd === 'DBIT') { |
|
410
|
7 |
|
$amount = $amount * -1; |
|
411
|
|
|
} |
|
412
|
|
|
|
|
413
|
14 |
|
$money = new Money( |
|
414
|
14 |
|
$amount, |
|
415
|
14 |
|
new Currency((string) $xmlDetail->Amt['Ccy']) |
|
416
|
|
|
); |
|
417
|
14 |
|
$amountDetails->setAmount($money); |
|
418
|
|
|
|
|
419
|
14 |
|
$detail->setAmount($amountDetails); |
|
420
|
|
|
} |
|
421
|
21 |
|
} |
|
422
|
|
|
|
|
423
|
|
|
/** |
|
424
|
|
|
* @param SimpleXMLElement $xmlDetail |
|
|
|
|
|
|
425
|
|
|
* |
|
426
|
|
|
* @return DTO\Account|null |
|
427
|
|
|
*/ |
|
428
|
|
|
abstract public function getRelatedPartyAccount(SimpleXMLElement $xmlRelatedPartyTypeAccount = null); |
|
429
|
|
|
} |
|
430
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.