|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Kingsquare\Parser\Banking\Mt940\Engine; |
|
4
|
|
|
|
|
5
|
|
|
use Kingsquare\Parser\Banking\Mt940\Engine; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @author Kingsquare ([email protected]) |
|
9
|
|
|
* @license http://opensource.org/licenses/MIT MIT |
|
10
|
|
|
*/ |
|
11
|
|
|
class Rabo extends Engine |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* returns the name of the bank. |
|
15
|
|
|
* |
|
16
|
|
|
* @return string |
|
17
|
|
|
*/ |
|
18
|
|
|
protected function parseStatementBank() |
|
19
|
|
|
{ |
|
20
|
|
|
return 'Rabo'; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Overloaded: Rabo has different way of storing account info. |
|
25
|
|
|
* |
|
26
|
|
|
* @inheritdoc |
|
27
|
|
|
*/ |
|
28
|
|
|
protected function parseTransactionAccount() |
|
29
|
|
|
{ |
|
30
|
|
|
$results = []; |
|
31
|
|
|
// SEPA MT940 Structured |
|
32
|
|
|
if (preg_match('/^:61:.*\n(.*?)(\n|\:8)/im', $this->getCurrentTransactionData(), $results) |
|
33
|
|
|
&& !empty($results[1]) |
|
34
|
|
|
) { |
|
35
|
|
|
return $this->sanitizeAccount($results[1]); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
if (preg_match('/^:61:.{26}(.{16})/m', $this->getCurrentTransactionData(), $results) |
|
39
|
|
|
&& !empty($results[1]) |
|
40
|
|
|
) { |
|
41
|
|
|
return $this->sanitizeAccount($results[1]); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
return ''; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Overloaded: Rabo has different way of storing account name. |
|
49
|
|
|
* |
|
50
|
|
|
* @inheritdoc |
|
51
|
|
|
*/ |
|
52
|
|
|
protected function parseTransactionAccountName() |
|
53
|
|
|
{ |
|
54
|
|
|
$results = []; |
|
55
|
|
|
// SEPA MT940 Structured |
|
56
|
|
|
if (preg_match('#/NAME/(.+?)\n?/(REMI|ADDR|ISDT|CSID)/#ms', $this->getCurrentTransactionData(), $results)) { |
|
57
|
|
|
$accountName = trim($results[1]); |
|
58
|
|
|
if (!empty($accountName)) { |
|
59
|
|
|
return $this->sanitizeAccountName($accountName); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
if (preg_match('/^:61:.*? (.+)/m', $this->getCurrentTransactionData(), $results)) { |
|
64
|
|
|
$accountName = trim($results[1]); |
|
65
|
|
|
if (!empty($accountName)) { |
|
66
|
|
|
return $this->sanitizeAccountName($accountName); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
if (preg_match('/(.*) Betaalautomaat/', $this->parseTransactionDescription(), $results)) { |
|
71
|
|
|
$accountName = trim($results[1]); |
|
72
|
|
|
if (!empty($accountName)) { |
|
73
|
|
|
return $this->sanitizeAccountName($accountName); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
return ''; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Overloaded: Rabo has different way of storing transaction value timestamps (ymd). |
|
81
|
|
|
* |
|
82
|
|
|
* @inheritdoc |
|
83
|
|
|
*/ |
|
84
|
|
|
protected function parseTransactionEntryTimestamp() |
|
85
|
|
|
{ |
|
86
|
|
|
$results = []; |
|
87
|
|
|
if (preg_match('/^:60F:[C|D]([\d]{6})/m', $this->getCurrentStatementData(), $results) && !empty($results[1])) { |
|
88
|
|
|
return $this->sanitizeTimestamp($results[1], 'ymd'); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
return 0; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Overloaded: Rabo has different way of storing transaction value timestamps (ymd). |
|
96
|
|
|
* |
|
97
|
|
|
* @inheritdoc |
|
98
|
|
|
*/ |
|
99
|
|
|
protected function parseTransactionValueTimestamp() |
|
100
|
|
|
{ |
|
101
|
|
|
$results = []; |
|
102
|
|
|
if (preg_match('/^:61:([\d]{6})[C|D]/', $this->getCurrentTransactionData(), $results) && !empty($results[1])) { |
|
103
|
|
|
return $this->sanitizeTimestamp($results[1], 'ymd'); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
return 0; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Overloaded: Rabo uses longer strings for accountnumbers. |
|
111
|
|
|
* |
|
112
|
|
|
* @inheritdoc |
|
113
|
|
|
*/ |
|
114
|
|
|
protected function sanitizeAccount($string) |
|
115
|
|
|
{ |
|
116
|
|
|
$account = parent::sanitizeAccount($string); |
|
117
|
|
|
if (strlen($account) > 20 && strpos($account, '80000') === 0) { |
|
118
|
|
|
$account = substr($account, 5); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
return $account; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Overloaded: Rabo encapsulates the description with /REMI/ for SEPA. |
|
126
|
|
|
* |
|
127
|
|
|
* @inheritdoc |
|
128
|
|
|
*/ |
|
129
|
|
|
protected function sanitizeDescription($string) |
|
130
|
|
|
{ |
|
131
|
|
|
$description = parent::sanitizeDescription($string); |
|
132
|
|
|
if (strpos($description, '/REMI/') !== false |
|
133
|
|
|
&& preg_match('#/REMI/(.*?)(/((PURP|ISDT|CSID|RTRN)/)|$)#s', $description, $results) && !empty($results[1]) |
|
134
|
|
|
) { |
|
135
|
|
|
return $results[1]; |
|
136
|
|
|
} |
|
137
|
|
|
if (strpos($description, '/EREF/') !== false |
|
138
|
|
|
&& preg_match('#/EREF/(.*?)/(ORDP)/#s', $description, $results) && !empty($results[1]) |
|
139
|
|
|
) { |
|
140
|
|
|
return $results[1]; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
if (strpos($description, '/PREF/') !== false |
|
144
|
|
|
&& preg_match('#/PREF/(.*)/?#s', $description, $results) && !empty($results[1]) |
|
145
|
|
|
) { |
|
146
|
|
|
return $results[1]; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
return $description; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Overloaded: Is applicable if first line has :940:. |
|
154
|
|
|
* |
|
155
|
|
|
* @inheritdoc |
|
156
|
|
|
*/ |
|
157
|
|
|
public static function isApplicable($string) |
|
158
|
|
|
{ |
|
159
|
|
|
return strpos(strtok($string, "\r\n\t"), ':940:') !== false; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
protected function parseTransactionType() |
|
163
|
|
|
{ |
|
164
|
|
|
$code = $this->parseTransactionCode(); |
|
165
|
|
|
switch ($code) { |
|
166
|
|
|
case 541: |
|
167
|
|
|
case 544: |
|
168
|
|
|
case 102: // "Betaalopdracht IDEAL" |
|
169
|
|
|
case 547: |
|
170
|
|
|
$result = TransactionType::get(TransactionType::SEPA_TRANSFER); |
|
|
|
|
|
|
171
|
|
|
break; |
|
172
|
|
|
|
|
173
|
|
|
case 504: |
|
174
|
|
|
case 691: |
|
175
|
|
|
$result = TransactionType::get(TransactionType::SAVINGS_TRANSFER); |
|
176
|
|
|
break; |
|
177
|
|
|
case 64: |
|
178
|
|
|
$result = TransactionType::get(TransactionType::SEPA_DIRECTDEBIT); |
|
179
|
|
|
break; |
|
180
|
|
|
case 93: |
|
181
|
|
|
$result = TransactionType::get(TransactionType::BANK_COSTS); |
|
182
|
|
|
break; |
|
183
|
|
|
case 13: |
|
184
|
|
|
case 12: |
|
185
|
|
|
case 30: |
|
186
|
|
|
$result = TransactionType::get(TransactionType::PAYMENT_TERMINAL); |
|
187
|
|
|
break; |
|
188
|
|
|
case 29: |
|
189
|
|
|
case 31: |
|
190
|
|
|
$result = TransactionType::get(TransactionType::ATM_WITHDRAWAL); |
|
191
|
|
|
break; |
|
192
|
|
|
case "MSC": |
|
193
|
|
|
$result = TransactionType::get(TransactionType::BANK_INTEREST); |
|
194
|
|
|
break; |
|
195
|
|
|
case 404: // "Buitenland transactie credit" |
|
196
|
|
|
if (stripos($this->getCurrentTransactionData(), 'eurobetaling') !== false) { |
|
197
|
|
|
$result = TransactionType::get(TransactionType::SEPA_TRANSFER); |
|
198
|
|
|
} else { |
|
199
|
|
|
$result = TransactionType::get(TransactionType::TRANSFER); |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
break; |
|
203
|
|
|
case 79: // "Acceptgiro Mobiel Bankieren" |
|
204
|
|
|
$result = TransactionType::get(TransactionType::UNKNOWN); |
|
205
|
|
|
break; |
|
206
|
|
|
|
|
207
|
|
|
default: |
|
208
|
|
|
var_dump($code); |
|
|
|
|
|
|
209
|
|
|
var_dump($this->getCurrentTransactionData()); die(); |
|
|
|
|
|
|
210
|
|
|
throw new \RuntimeException("Don't know code $code for RABOBANK"); |
|
|
|
|
|
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
return $result; |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
} |
|
217
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths