Changeset 887 for trunk/Modules/FinanceBankAPI
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- Location:
- trunk/Modules/FinanceBankAPI
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/FinanceBankAPI/FileImport.php
r884 r887 5 5 class BankImport 6 6 { 7 var$System;8 var$Database;9 var$BankAccount;10 11 function __construct( $System)7 public System $System; 8 public Database $Database; 9 public int $BankAccount; 10 11 function __construct(System $System) 12 12 { 13 13 $this->Database = &$System->Database; … … 15 15 } 16 16 17 function Import() 18 { 17 function Import(): string 18 { 19 return ''; 19 20 } 20 21 … … 23 24 } 24 25 25 function PairOperations() 26 { 26 function PairOperations(): void 27 { 28 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 27 29 $DbResult = $this->Database->select('FinanceBankImport', '*', 'FinanceOperation IS NULL'); 28 30 while ($DbRow = $DbResult->fetch_assoc()) … … 34 36 { 35 37 $DbRow2 = $DbResult2->fetch_assoc(); 36 if ($DbRow['Value'] >= 0) { 37 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup'); 38 } else { 39 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 38 if ($DbRow['Value'] >= 0) 39 { 40 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup'); 41 } else 42 { 43 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 40 44 } 41 45 $Year = date('Y', MysqlDateToTime($DbRow['Time'])); 42 $BillCode = $ this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);43 $ DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0,46 $BillCode = $Finance->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year); 47 $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 44 48 'ValueUser' => Abs($DbRow['Value']), 'Value' => 0, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1, 45 49 'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'Group' => $FinanceGroup['Id'])); … … 65 69 class PageImportAPI extends Page 66 70 { 67 var $FullTitle = 'Import plateb přes API'; 68 var $ShortTitle = 'Import plateb přes API'; 69 var $ParentClass = 'PageFinance'; 70 71 function Import($Id) 71 function __construct(System $System) 72 { 73 parent::__construct($System); 74 $this->FullTitle = 'Import plateb přes API'; 75 $this->ShortTitle = 'Import plateb přes API'; 76 $this->ParentClass = 'PageFinance'; 77 } 78 79 function Import(int $Id): string 72 80 { 73 81 $Output = ''; … … 92 100 } 93 101 94 function Show() 95 { 96 if (! $this->System->User->CheckPermission('Finance', 'SubjectList'))102 function Show(): string 103 { 104 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) 97 105 return 'Nemáte oprávnění'; 98 106 … … 104 112 class PageImportFile extends Page 105 113 { 106 var $FullTitle = 'Import plateb ze souboru'; 107 var $ShortTitle = 'Import plateb ze souboru'; 108 var $ParentClass = 'PageFinance'; 109 110 function Show() 114 function __construct(System $System) 115 { 116 parent::__construct($System); 117 $this->FullTitle = 'Import plateb ze souboru'; 118 $this->ShortTitle = 'Import plateb ze souboru'; 119 $this->ParentClass = 'PageFinance'; 120 } 121 122 function Show(): string 111 123 { 112 124 $Output = ''; 113 if (! $this->System->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';125 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění'; 114 126 if (array_key_exists('Operation', $_GET)) 115 127 { … … 121 133 } 122 134 123 function ShowForm() 135 function ShowForm(): string 124 136 { 125 137 $Form = new Form($this->System->FormManager); … … 156 168 } 157 169 158 function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group) 170 function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group): void 159 171 { 160 172 $Year = date('Y', $Time); 161 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId(173 $BillCode = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId( 162 174 $Group['DocumentLine'], $Year); 163 175 $this->Database->insert('FinanceOperation', array('Text' => $Text, … … 166 178 } 167 179 168 function Insert() 169 { 170 $Finance = $ this->System->Modules['Finance'];180 function Insert(): string 181 { 182 $Finance = $ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 171 183 $Output = ''; 172 184 173 185 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 174 186 { 175 if ($_POST['Money'.$I] >= 0) { 187 if ($_POST['Money'.$I] >= 0) 188 { 176 189 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 177 190 'FinanceOperationGroup'); 178 } else { 191 } else 192 { 179 193 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 180 194 'FinanceOperationGroup'); … … 185 199 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup); 186 200 $Output .= $I.', '; 187 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');201 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted'); 188 202 } 189 203 return $Output; -
trunk/Modules/FinanceBankAPI/FinanceBankAPI.php
r874 r887 8 8 class ModuleFinanceBankAPI extends AppModule 9 9 { 10 function __construct( $System)10 function __construct(System $System) 11 11 { 12 12 parent::__construct($System); … … 16 16 $this->License = 'GNU/GPLv3'; 17 17 $this->Description = 'Communication through API to various banks, manual file import'; 18 $this->Dependencies = array('Finance', 'Scheduler' );18 $this->Dependencies = array('Finance', 'Scheduler', 'IS'); 19 19 } 20 20 21 function DoInstall() 21 function DoInstall(): void 22 22 { 23 23 } 24 24 25 function DoUninstall() 25 function DoUninstall(): void 26 26 { 27 27 } 28 28 29 function DoStart() 29 function DoStart(): void 30 30 { 31 31 $this->System->FormManager->RegisterClass('ImportBankFile', array( … … 60 60 )); 61 61 62 $this->System->RegisterPage( array('finance', 'import-api'), 'PageImportAPI');63 $this->System->RegisterPage( array('finance', 'import-soubor'), 'PageImportFile');62 $this->System->RegisterPage(['finance', 'import-api'], 'PageImportAPI'); 63 $this->System->RegisterPage(['finance', 'import-soubor'], 'PageImportFile'); 64 64 65 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('FinanceBankAPI',66 array( 'ModuleFinanceBankAPI', 'ShowDashboardItem'));65 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('FinanceBankAPI', 66 array($this, 'ShowDashboardItem')); 67 67 } 68 68 69 function DoStop() 69 function DoStop(): void 70 70 { 71 71 } 72 72 73 function ShowDashboardItem() 73 function ShowDashboardItem(): string 74 74 { 75 75 $DbResult = $this->Database->select('FinanceBankImport', 'COUNT(*)', '`FinanceOperation` IS NULL'); … … 79 79 } 80 80 81 function PresetItem( $Item)81 function PresetItem(array $Item): array 82 82 { 83 83 $Preset = array(); 84 84 if ($Item['Value'] < 0) $OperationGroupId = OPERATION_GROUP_ACCOUNT_OUT; 85 85 else $OperationGroupId = OPERATION_GROUP_ACCOUNT_IN; 86 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($OperationGroupId, 'FinanceOperationGroup');86 $FinanceGroup = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetFinanceGroupById($OperationGroupId, 'FinanceOperationGroup'); 87 87 88 88 $Preset = array( … … 100 100 class ScheduleBankImport extends SchedulerTask 101 101 { 102 function Execute() 102 function Execute(): string 103 103 { 104 104 $Output = ''; -
trunk/Modules/FinanceBankAPI/Fio.php
r874 r887 5 5 class Fio 6 6 { 7 var$UserName;8 var$Password;9 var$Account;7 public string $UserName; 8 public string $Password; 9 public int $Account; 10 10 11 function Import( $TimeFrom, $TimeTo)11 function Import(int $TimeFrom, int $TimeTo): array 12 12 { 13 13 if ($this->UserName == '') throw new Exception('Missing value for UserName property.'); … … 59 59 } 60 60 61 function NoValidDataError( $Response)61 function NoValidDataError(array $Response): void 62 62 { 63 63 // Try to get error message 64 // If something go wrong fio show HTML login page and display error message65 $Response = implode('', $Response);64 // If something go wrong fio shows HTML login page and display error message 65 $Response = implode('', $Response); 66 66 $ErrorMessageStart = '<div id="oldform_warning">'; 67 67 if (strpos($Response, $ErrorMessageStart) !== false) 68 {69 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart));70 $ErrorMessage = trim(substr($Response, 0, strpos($Response, '</div>')));71 } else $ErrorMessage = '';72 throw new Exception('No valid GPC data: '.$ErrorMessage);68 { 69 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart)); 70 $ErrorMessage = trim(substr($Response, 0, strpos($Response, '</div>'))); 71 } else $ErrorMessage = ''; 72 throw new Exception('No valid GPC data: '.$ErrorMessage); 73 73 } 74 74 } -
trunk/Modules/FinanceBankAPI/FioAPI.php
r874 r887 23 23 } 24 24 25 function Import( $TimeFrom, $TimeTo)25 function Import(int $TimeFrom, int $TimeTo): array 26 26 { 27 27 if ($this->Token == '') throw new Exception('Missing value for Token property.'); … … 101 101 } 102 102 103 function NoValidDataError( $Response)103 function NoValidDataError(array $Response): void 104 104 { 105 105 // Try to get error message -
trunk/Modules/FinanceBankAPI/GPC.php
r874 r887 6 6 class GPC 7 7 { 8 function ParseLine( $Line)8 function ParseLine(string $Line): array 9 9 { 10 10 $Line = ' '.$Line; -
trunk/Modules/FinanceBankAPI/ImportFio.php
r884 r887 5 5 class ImportFio extends BankImport 6 6 { 7 function Import() 7 function Import(): string 8 8 { 9 9 $Fio = new FioAPI(); -
trunk/Modules/FinanceBankAPI/ImportPS.php
r873 r887 11 11 function ImportTxt($Content) 12 12 { 13 $Finance = &$this->System->Modules['Finance'];14 $Data = explode("\n", $Content);15 13 } 16 14 17 15 function ImportCVS($Content) 18 16 { 19 $Finance = &$this->System->Modules['Finance'];20 21 17 $Data = explode("\n", $Content); 22 18 foreach ($Data as $Key => $Value)
Note:
See TracChangeset
for help on using the changeset viewer.