1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kingsquare\Parser\Banking\Mt940\Engine; |
4
|
|
|
|
5
|
|
|
use Kingsquare\Parser\Banking\Mt940\Engine; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @author Timotheus Pokorra ([email protected]) |
9
|
|
|
* @license http://opensource.org/licenses/MIT MIT |
10
|
|
|
* |
11
|
|
|
* This is for german banks, for example Sparkasse |
12
|
|
|
*/ |
13
|
|
|
class Spk extends Engine |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* returns the name of the bank. |
17
|
|
|
* |
18
|
|
|
* @return string |
19
|
|
|
*/ |
20
|
|
|
protected function parseStatementBank() |
21
|
|
|
{ |
22
|
|
|
return 'Spk'; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Overloaded: Sparkasse uses 60M and 60F. |
27
|
|
|
* |
28
|
|
|
* {@inheritdoc} |
29
|
|
|
*/ |
30
|
|
|
protected function parseStatementStartPrice() |
31
|
|
|
{ |
32
|
|
|
return parent::parseStatementPrice('60[FM]'); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Overloaded: Sparkasse uses 60M and 60F. |
37
|
|
|
* |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
protected function parseStatementStartTimestamp() |
41
|
|
|
{ |
42
|
|
|
return parent::parseTimestampFromStatement('60[FM]'); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Overloaded: Sparkasse uses 60M and 60F. |
47
|
|
|
* |
48
|
|
|
* {@inheritdoc} |
49
|
|
|
*/ |
50
|
|
|
protected function parseStatementEndTimestamp() |
51
|
|
|
{ |
52
|
|
|
return parent::parseTimestampFromStatement('60[FM]'); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Overloaded: Sparkasse uses 62M and 62F. |
57
|
|
|
* |
58
|
|
|
* {@inheritdoc} |
59
|
|
|
*/ |
60
|
|
|
protected function parseStatementEndPrice() |
61
|
|
|
{ |
62
|
|
|
return parent::parseStatementPrice('62[FM]'); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Overloaded: Sparkasse can have the 3rd character of the currencyname after the C/D |
67
|
|
|
* currency codes last letter is always a letter http://www.xe.com/iso4217.php. |
68
|
|
|
* |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
|
View Code Duplication |
protected function parseTransactionPrice() |
|
|
|
|
72
|
|
|
{ |
73
|
|
|
$results = []; |
74
|
|
|
if (preg_match('/^:61:.*[CD][a-zA-Z]?([\d,\.]+)N/i', $this->getCurrentTransactionData(), $results) |
75
|
|
|
&& !empty($results[1]) |
76
|
|
|
) { |
77
|
|
|
return $this->sanitizePrice($results[1]); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
return 0; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Overloaded: Sparkasse can have the 3rd character of the currencyname after the C/D and an "R" for cancellation befor the C/D. |
85
|
|
|
* |
86
|
|
|
* {@inheritdoc} |
87
|
|
|
*/ |
88
|
|
View Code Duplication |
protected function parseTransactionDebitCredit() |
|
|
|
|
89
|
|
|
{ |
90
|
|
|
$results = []; |
91
|
|
|
if (preg_match('/^:61:\d+R?([CD]).?\d+/', $this->getCurrentTransactionData(), $results) |
92
|
|
|
&& !empty($results[1]) |
93
|
|
|
) { |
94
|
|
|
return $this->sanitizeDebitCredit($results[1]); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
return ''; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Overloaded: Sparkasse use the Field 61 for cancellations |
102
|
|
|
* |
103
|
|
|
* {@inheritdoc} |
104
|
|
|
*/ |
105
|
|
|
protected function parseTransactionCancellation() |
106
|
|
|
{ |
107
|
|
|
$results = []; |
108
|
|
|
if (preg_match('/^:61:\d+(R)?[CD].?\d+/', $this->getCurrentTransactionData(), $results) |
109
|
|
|
&& !empty($results[1]) |
110
|
|
|
) { |
111
|
|
|
return true; |
112
|
|
|
} |
113
|
|
|
return false; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Overloaded: Sparkasse does not have a header line. |
118
|
|
|
* |
119
|
|
|
* {@inheritdoc} |
120
|
|
|
*/ |
121
|
|
|
protected function parseStatementData() |
122
|
|
|
{ |
123
|
|
|
return preg_split( |
124
|
|
|
'/(^:20:|^-X{,3}$|\Z)/sm', |
125
|
|
|
$this->getRawData(), |
126
|
|
|
-1, |
127
|
|
|
PREG_SPLIT_NO_EMPTY |
128
|
|
|
); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Overloaded: Is applicable if first or second line has :20:STARTUMS or first line has -. |
133
|
|
|
* |
134
|
|
|
* {@inheritdoc} |
135
|
|
|
*/ |
136
|
|
|
public static function isApplicable($string) |
137
|
|
|
{ |
138
|
|
|
$firstline = strtok($string, "\r\n\t"); |
139
|
|
|
$secondline = strtok("\r\n\t"); |
140
|
|
|
|
141
|
|
|
return strpos($firstline, ':20:STARTUMS') !== false || $firstline === '-' && $secondline === ':20:STARTUMS'; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.