source: tools/fio/gpc.php

Last change on this file was 2, checked in by chronos, 12 years ago
  • Přidáno: Skript pro import GPC exportu z Fio banky.
File size: 2.1 KB
Line 
1<?php
2
3define('GPC_TYPE_REPORT', '074');
4define('GPC_TYPE_ITEM', '075');
5
6class GPC
7{
8 function ParseLine($Line)
9 {
10 $Line = ' '.$Line;
11 $Type = substr($Line, 1, 3);
12
13 if($Type == GPC_TYPE_REPORT)
14 {
15 $GPCLine = array
16 (
17 'Type' => GPC_TYPE_REPORT,
18 'AccountNumber' => substr($Line, 4, 16),
19 'AccountName' => trim(substr($Line, 20, 20)),
20 'OldBalanceDate' => mktime(0, 0, 0, substr($Line, 42, 2), substr($Line, 40, 2), '20'.substr($Line, 44, 2)),
21 'OldBalanceValue' => (substr($Line, 60, 1).substr($Line, 46, 14)) / 100,
22 'NewBalanceValue' => (substr($Line, 75, 1).substr($Line, 61, 14)) / 100,
23 'DebitValue' => (substr($Line, 90, 1).substr($Line, 76, 14)) / 100,
24 'CreditValue' => (substr($Line, 105, 1).substr($Line, 91, 14)) / 100,
25 'SequenceNumber' => intval(substr($Line, 106, 3)),
26 'Date' => mktime(0, 0, 0, substr($Line, 111, 2), substr($Line, 109, 2), '20'.substr($Line, 113, 2)),
27 //'DataAlignment' => substr($Line, 115, 14),
28 'CheckSum' => sha1(md5($Line).$Line),
29 );
30 } else
31 if($Type == GPC_TYPE_ITEM)
32 {
33 $GPCLine = array
34 (
35 'Type' => GPC_TYPE_ITEM,
36 'AccountNumber' => substr($Line, 4, 16),
37 'OffsetAccount' => substr($Line, 20, 16),
38 'RecordNumber' => substr($Line, 36, 13),
39 'Value' => substr($Line, 49, 12) / 100,
40 'Code' => substr($Line, 61, 1),
41 'VariableSymbol' => intval(substr($Line, 62, 10)),
42 'BankCode' => substr($Line, 74, 4),
43 'ConstantSymbol' => intval(substr($Line, 78, 4)),
44 'SpecificSymbol' => intval(substr($Line, 82, 10)),
45 'Valut' => substr($Line, 92, 6),
46 'ClientName' => substr($Line, 98, 20),
47 //'Zero' => substr($Line, 118, 1),
48 'CurrencyCode' => substr($Line, 119, 4),
49 'DueDate' => mktime(0, 0, 0, substr($Line, 125, 2), substr($Line, 123, 2), substr($Line, 127, 2)),
50 'CheckSum' => sha1(md5($Line).$Line),
51 );
52 } else
53 $GPCLine = NULL;
54
55 return($GPCLine);
56 }
57}
58
59?>
Note: See TracBrowser for help on using the repository browser.