source: trunk/Modules/FinanceBankAPI/GPC.php

Last change on this file was 887, checked in by chronos, 4 years ago
  • Added: Static types added to almost all classes, methods and function. Supported by PHP 7.4.
  • Fixed: Various found code issues.
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(string $Line): array
9 {
10 $Line = ' '.$Line;
11 $Type = mb_substr($Line, 1, 3);
12
13 if ($Type == GPC_TYPE_REPORT)
14 {
15 $GPCLine = array
16 (
17 'Type' => GPC_TYPE_REPORT,
18 'AccountNumber' => mb_substr($Line, 4, 16),
19 'AccountName' => trim(mb_substr($Line, 20, 20)),
20 'OldBalanceDate' => mktime(0, 0, 0, mb_substr($Line, 42, 2), mb_substr($Line, 40, 2), '20'.mb_substr($Line, 44, 2)),
21 'OldBalanceValue' => (mb_substr($Line, 60, 1).mb_substr($Line, 46, 14)) / 100,
22 'NewBalanceValue' => (mb_substr($Line, 75, 1).mb_substr($Line, 61, 14)) / 100,
23 'DebitValue' => (mb_substr($Line, 90, 1).mb_substr($Line, 76, 14)) / 100,
24 'CreditValue' => (mb_substr($Line, 105, 1).mb_substr($Line, 91, 14)) / 100,
25 'SequenceNumber' => intval(mb_substr($Line, 106, 3)),
26 'Date' => mktime(0, 0, 0, mb_substr($Line, 111, 2), mb_substr($Line, 109, 2), '20'.mb_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' => mb_substr($Line, 4, 16),
37 'OffsetAccount' => mb_substr($Line, 20, 16),
38 'RecordNumber' => mb_substr($Line, 36, 13),
39 'Value' => mb_substr($Line, 49, 12) / 100,
40 'Code' => mb_substr($Line, 61, 1),
41 'VariableSymbol' => intval(mb_substr($Line, 62, 10)),
42 'BankCode' => mb_substr($Line, 74, 4),
43 'ConstantSymbol' => intval(mb_substr($Line, 78, 4)),
44 'SpecificSymbol' => intval(mb_substr($Line, 82, 10)),
45 'Valut' => mb_substr($Line, 92, 6),
46 'ClientName' => mb_substr($Line, 98, 20),
47 //'Zero' => substr($Line, 118, 1),
48 'CurrencyCode' => mb_substr($Line, 119, 4),
49 'DueDate' => mktime(0, 0, 0, mb_substr($Line, 125, 2), mb_substr($Line, 123, 2), mb_substr($Line, 127, 2)),
50 'CheckSum' => sha1(md5($Line).$Line),
51 );
52 } else
53 $GPCLine = NULL;
54
55 return $GPCLine;
56 }
57}
Note: See TracBrowser for help on using the repository browser.