|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Kasifi\PdfParserBundle\Processor; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class SgProProcessor. |
|
9
|
|
|
*/ |
|
10
|
|
|
class SgProProcessor extends Processor implements ProcessorInterface |
|
11
|
|
|
{ |
|
12
|
|
|
protected $configuration = [ |
|
13
|
|
|
'id' => 'sg_pro', |
|
14
|
|
|
'name' => 'Société Générale - Compte courant professionnel', |
|
15
|
|
|
'startConditions' => ['/Date\s+Valeur\s+Nature de l\'opération/'], |
|
16
|
|
|
'endConditions' => [ |
|
17
|
|
|
'/1 Depuis l\'étranger/', '/N° d\'adhérent JAZZ Pro/', '/Société Générale\s+552 120 222 RCS Paris/', |
|
18
|
|
|
], |
|
19
|
|
|
'rowMergeColumnTokens' => [0], |
|
20
|
|
|
'rowSkipConditions' => ['SOLDE PRÉCÉDENT AU', 'TOTAUX DES MOUVEMENTS', 'RA4-01K', 'NOUVEAU SOLDE AU'], |
|
21
|
|
|
'rowsToSkip' => [0], |
|
22
|
|
|
]; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param ArrayCollection $data |
|
26
|
|
|
* |
|
27
|
|
|
* @return ArrayCollection |
|
28
|
|
|
*/ |
|
29
|
|
|
public function format(ArrayCollection $data) |
|
30
|
|
|
{ |
|
31
|
|
|
$data = $data->map(function ($item) { |
|
32
|
|
|
// Date |
|
33
|
|
|
$dateRaw = $item[0]; |
|
34
|
|
|
$date = new \DateTime(); |
|
35
|
|
|
$date->setDate((int) substr($dateRaw, 6, 4), (int) substr($dateRaw, 3, 2), (int) substr($dateRaw, 0, 2)); |
|
36
|
|
|
$date->setTime(12, 0, 0); |
|
37
|
|
|
|
|
38
|
|
|
// Value Date |
|
39
|
|
|
$dateRaw = $item[1]; |
|
40
|
|
|
$valueDate = new \DateTime(); |
|
41
|
|
|
$valueDate->setDate((int) substr($dateRaw, 6, 4), (int) substr($dateRaw, 3, 2), (int) substr($dateRaw, 0, 2)); |
|
42
|
|
|
$valueDate->setTime(12, 0, 0); |
|
43
|
|
|
|
|
44
|
|
|
// Transaction |
|
45
|
|
|
$transaction = $this->frenchTransactionFormatter($item[3], isset($item[4]) ? $item[4] : null); |
|
46
|
|
|
|
|
47
|
|
|
return [ |
|
48
|
|
|
'date' => $date, |
|
49
|
|
|
'value_date' => $valueDate, |
|
50
|
|
|
'label' => $item[2], |
|
51
|
|
|
'value' => $transaction['value'], |
|
52
|
|
|
'debit' => $transaction['debit'], |
|
53
|
|
|
]; |
|
54
|
|
|
}); |
|
55
|
|
|
|
|
56
|
|
|
return $data; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|