1 | <?php |
||
2 | /** |
||
3 | * Belfius.php |
||
4 | * Copyright (c) 2019 Sander Kleykens <[email protected]> |
||
5 | * |
||
6 | * This file is part of Firefly III (https://github.com/firefly-iii). |
||
7 | * |
||
8 | * This program is free software: you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU Affero General Public License as |
||
10 | * published by the Free Software Foundation, either version 3 of the |
||
11 | * License, or (at your option) any later version. |
||
12 | * |
||
13 | * This program is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU Affero General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU Affero General Public License |
||
19 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
20 | */ |
||
21 | declare(strict_types=1); |
||
22 | |||
23 | namespace FireflyIII\Import\Specifics; |
||
24 | |||
25 | /** |
||
26 | * Class Belfius. |
||
27 | * |
||
28 | * @deprecated |
||
29 | * @codeCoverageIgnore |
||
30 | * |
||
31 | * Fixes Belfius CSV files to: |
||
32 | * - Correct descriptions for recurring transactions so doubles can be detected when the equivalent incoming |
||
33 | * transaction is imported. |
||
34 | * |
||
35 | */ |
||
36 | class Belfius implements SpecificInterface |
||
0 ignored issues
–
show
|
|||
37 | { |
||
38 | /** |
||
39 | * Description of this specific fix. |
||
40 | * |
||
41 | * @return string |
||
42 | * @codeCoverageIgnore |
||
43 | */ |
||
44 | public static function getDescription(): string |
||
45 | { |
||
46 | return 'import.specific_belfius_descr'; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Name of specific fix. |
||
51 | * |
||
52 | * @return string |
||
53 | * @codeCoverageIgnore |
||
54 | */ |
||
55 | public static function getName(): string |
||
56 | { |
||
57 | return 'import.specific_belfius_name'; |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Fixes the description for outgoing recurring transactions so doubles can be detected when the equivalent incoming |
||
62 | * transaction is imported for another bank account. |
||
63 | * |
||
64 | * @return array the row containing the new description |
||
65 | */ |
||
66 | protected static function processRecurringTransactionDescription(array $row): array |
||
67 | { |
||
68 | if (!isset($row[5]) || !isset($row[14])) { |
||
69 | return $row; |
||
70 | } |
||
71 | |||
72 | $opposingAccountName = $row[5]; |
||
73 | $description = $row[14]; |
||
74 | |||
75 | preg_match('/DOORLOPENDE OPDRACHT.*\s+' . preg_quote($opposingAccountName, '/') . '\s+(.+)\s+REF.\s*:/', $description, $matches); |
||
76 | |||
77 | if (isset($matches[1])) { |
||
78 | $row[14] = $matches[1]; |
||
79 | } |
||
80 | |||
81 | return $row; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Run the fix. |
||
86 | * |
||
87 | * @param array $row |
||
88 | * |
||
89 | * @return array |
||
90 | * |
||
91 | */ |
||
92 | public function run(array $row): array |
||
93 | { |
||
94 | return Belfius::processRecurringTransactionDescription($row); |
||
95 | } |
||
96 | } |
||
97 |
This interface has been deprecated. The supplier of the interface has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the interface will be removed and what other interface to use instead.