1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kingsquare\Parser\Banking\Mt940\Engine; |
4
|
|
|
|
5
|
|
|
use Kingsquare\Parser\Banking\Mt940\Engine; |
6
|
|
|
|
7
|
|
|
class Wise extends Engine |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* |
11
|
|
|
* {@inheritdoc} |
12
|
|
|
* @see \Kingsquare\Parser\Banking\Mt940\Engine::parseStatementBank() |
13
|
|
|
*/ |
14
|
|
|
protected function parseStatementBank() |
15
|
|
|
{ |
16
|
|
|
return 'WISE'; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* uses field 25 to gather accoutnumber. |
21
|
|
|
* |
22
|
|
|
* @return string accountnumber |
23
|
|
|
*/ |
24
|
|
|
protected function parseStatementAccount() |
25
|
|
|
{ |
26
|
|
|
$results = []; |
27
|
|
|
if (preg_match('/:25:([\d\.]+)*/', $this->getCurrentStatementData(), $results) |
28
|
|
|
&& !empty($results[1]) |
29
|
|
|
) { |
30
|
|
|
return $this->sanitizeAccount($results[1]); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
// SEPA / IBAN |
34
|
|
|
if (preg_match('/:25:([A-Z0-9]{8}[\d\.]+)*/', $this->getCurrentStatementData(), $results) |
35
|
|
|
&& !empty($results[1]) |
36
|
|
|
) { |
37
|
|
|
return $this->sanitizeAccount($results[1]); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
return 'WISE'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* uses the 61 field to determine amount/value of the transaction. |
46
|
|
|
* |
47
|
|
|
* @return float |
48
|
|
|
*/ |
49
|
|
|
protected function parseTransactionPrice() |
50
|
|
|
{ |
51
|
|
|
$results = []; |
52
|
|
|
if (preg_match('/^:61:.*?[CD]([\d,\.]+)F/i', $this->getCurrentTransactionData(), $results) |
53
|
|
|
&& !empty($results[1]) |
54
|
|
|
) { |
55
|
|
|
return $this->sanitizePrice($results[1]); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
return 0; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* uses the 61 field to get the bank specific transaction code. |
63
|
|
|
* |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
protected function parseTransactionCode() |
67
|
|
|
{ |
68
|
|
|
$results = []; |
69
|
|
|
if (preg_match('/^:61:.*?F(.{3}).*/', $this->getCurrentTransactionData(), $results) |
70
|
|
|
&& !empty($results[1]) |
71
|
|
|
) { |
72
|
|
|
return trim($results[1]); |
73
|
|
|
} |
74
|
|
|
return ''; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @TODO WIP get this into the transaction somehow.. (possibly as a decorator over the transactions?) |
79
|
|
|
* @return int |
80
|
|
|
*/ |
81
|
|
|
protected function parseTransactionType() |
82
|
|
|
{ |
83
|
|
|
static $map = [ |
84
|
|
|
'FEX' => Type::BANK_TRANSFER, |
|
|
|
|
85
|
|
|
'CHG' => Type::BANK_COSTS, |
86
|
|
|
'MSC' => Type::BANK_INTEREST, |
87
|
|
|
'TRF' => Type::UNKNOWN, |
88
|
|
|
]; |
89
|
|
|
|
90
|
|
|
$code = $this->parseTransactionCode(); |
91
|
|
|
if (array_key_exists($code, $map)) { |
92
|
|
|
return $map[$code]; |
93
|
|
|
} |
94
|
|
|
throw new \RuntimeException("Don't know code $code for this bank"); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* |
99
|
|
|
* {@inheritdoc} |
100
|
|
|
* @see \Kingsquare\Parser\Banking\Mt940\Engine::isApplicable() |
101
|
|
|
*/ |
102
|
|
|
public static function isApplicable($string) |
103
|
|
|
{ |
104
|
|
|
$firstline = strtok($string, "\r\n\t"); |
105
|
|
|
|
106
|
|
|
return strpos($firstline, 'F01TRWIGB2LAXXX0000000000') !== false; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
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