-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit de54f29
Showing
15 changed files
with
865 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[email protected] | ||
EASE_LOGGER=syslog|console | ||
LANG=cs_CZ | ||
|
||
CERT_FILE=vendor/vitexsoftware/rbczpremiumapi/examples/test_cert.p12 | ||
CERT_PASS=test12345678 | ||
XIBMCLIENTID=FbboLD2r1WHDRcuKS4wWUbSRHxlDloWL | ||
API_DEBUG=True | ||
STATEMENT_LINE=MAIN | ||
|
||
ACCOUNT_NUMBER=640805006 | ||
ACCOUNT_CURRENCY=CZK | ||
|
||
|
||
POHODA_ICO=12345678 | ||
POHODA_URL=http://77.87.240.111:10010 | ||
POHODA_USERNAME=Admin | ||
POHODA_PASSWORD=xxxxxxxx | ||
POHODA_TIMEOUT=60 | ||
POHODA_COMPRESS=false | ||
POHODA_DEBUG=true | ||
POHODA_BANK_IDS=KB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.DS_Store | ||
config.php | ||
import.csv | ||
output.xml | ||
/nbproject/private/ | ||
/nbproject/ | ||
.phpdoc | ||
/.phpunit.result.cache | ||
.env | ||
/RAIFF_MULTIFLEXI.p12 | ||
/debian/debhelper-build-stamp | ||
/debian/abraflexi-raiffeisenbank.debhelper.log | ||
/debian/abraflexi-raiffeisenbank/ | ||
/debian/.debhelper/ | ||
/debian/abraflexi-raiffeisenbank.substvars | ||
/debian/files | ||
/statement.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Massimo Filippi, s.r.o. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
php -f /usr/lib/pohoda-raiffeisenbank/setup.php $@ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
php -f /usr/lib/pohoda-raiffeisenbank/statements.php $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
php -f /usr/lib/pohoda-raiffeisenbank/transactions.php $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
php -f /usr/lib/pohoda-raiffeisenbank/balance.php $@ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "vitexsoftware/pohoda-raiffeisenbank", | ||
"description": "raiffeisenbank bank statement downloader for Stormware Pohoda", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Vítězslav Dvořák", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"require": { | ||
"vitexsoftware/pohoda-connector": "dev-main", | ||
"vitexsoftware/rbczpremiumapi": "dev-main" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Pohoda\\RaiffeisenBank\\": "src/Pohoda/RaiffeisenBank/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Test\\Pohoda\\": "vendor/spojenet/abraflexi/testing/src/Pohoda/", | ||
"Test\\Pohoda\\RaiffeisenBank\\": "tests/Pohoda/RaiffeisenBank/" | ||
} | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
<?php | ||
|
||
/** | ||
* RaiffeisenBank - BankClient class | ||
* | ||
* @author Vítězslav Dvořák <[email protected]> | ||
* @copyright (C) 2023 Spoje.Net | ||
*/ | ||
|
||
namespace Pohoda\RaiffeisenBank; | ||
|
||
/** | ||
* Description of ApiClient | ||
* | ||
* @author vitex | ||
*/ | ||
abstract class PohodaBankClient extends \mServer\Bank | ||
{ | ||
protected $constantor; | ||
|
||
protected $constSymbols; | ||
|
||
/** | ||
* | ||
* @var \DateTime | ||
*/ | ||
protected $since; | ||
|
||
/** | ||
* | ||
* @var \DateTime | ||
*/ | ||
protected $until; | ||
|
||
/** | ||
* DateTime Formating eg. 2021-08-01T10:00:00.0Z | ||
* @var string | ||
*/ | ||
public static $dateTimeFormat = 'Y-m-d\\TH:i:s.0\\Z'; | ||
|
||
/** | ||
* DateTime Formating eg. 2021-08-01T10:00:00.0Z | ||
* @var string | ||
*/ | ||
public static $dateFormat = 'Y-m-d'; | ||
|
||
/** | ||
* | ||
* @var | ||
*/ | ||
protected $bank; | ||
|
||
/** | ||
* Transaction Handler | ||
* | ||
* @param string $bankAccount Account Number | ||
* @param array $options | ||
*/ | ||
public function __construct($bankAccount, $options = []) | ||
{ | ||
parent::__construct(); | ||
$this->setDataValue('account', $bankAccount); | ||
// $this->constantor = new \Pohoda\RW(null, ['evidence' => 'konst-symbol']); | ||
// $this->constSymbols = $this->constantor->getColumnsFromPohoda(['kod'], ['limit' => 0], 'kod'); | ||
} | ||
|
||
/** | ||
* Source Identifier | ||
* | ||
* @return string | ||
*/ | ||
public function sourceString() | ||
{ | ||
return substr(__FILE__ . '@' . gethostname(), -50); | ||
} | ||
|
||
/** | ||
* Try to check certificate readibilty | ||
* | ||
* @param string $certFile path to certificate | ||
*/ | ||
public static function checkCertificatePresence($certFile) | ||
{ | ||
if ((file_exists($certFile) === false) || (is_readable($certFile) === false)) { | ||
fwrite(STDERR, 'Cannot read specified certificate file: ' . $certFile . PHP_EOL); | ||
exit; | ||
} | ||
} | ||
|
||
/** | ||
* Prepare processing interval | ||
* | ||
* @param string $scope | ||
* | ||
* @throws \Exception | ||
*/ | ||
function setScope($scope) | ||
{ | ||
switch ($scope) { | ||
case 'today': | ||
$this->since = (new \DateTime())->setTime(0, 0); | ||
$this->until = (new \DateTime())->setTime(23, 59); | ||
break; | ||
case 'yesterday': | ||
$this->since = (new \DateTime('yesterday'))->setTime(0, 0); | ||
$this->until = (new \DateTime('yesterday'))->setTime(23, 59); | ||
break; | ||
case 'current_month': | ||
$this->since = new \DateTime("first day of this month"); | ||
$this->until = new \DateTime(); | ||
break; | ||
case 'last_month': | ||
$this->since = new \DateTime("first day of last month"); | ||
$this->until = new \DateTime("last day of last month"); | ||
break; | ||
case 'last_two_months': | ||
$this->since = (new \DateTime("first day of last month"))->modify('-1 month'); | ||
$this->until = (new \DateTime("last day of last month")); | ||
break; | ||
case 'previous_month': | ||
$this->since = new \DateTime("first day of -2 month"); | ||
$this->until = new \DateTime("last day of -2 month"); | ||
break; | ||
case 'two_months_ago': | ||
$this->since = new \DateTime("first day of -3 month"); | ||
$this->until = new \DateTime("last day of -3 month"); | ||
break; | ||
case 'this_year': | ||
$this->since = new \DateTime('first day of January ' . date('Y')); | ||
$this->until = new \DateTime("last day of December" . date('Y')); | ||
break; | ||
case 'January': //1 | ||
case 'February': //2 | ||
case 'March': //3 | ||
case 'April': //4 | ||
case 'May': //5 | ||
case 'June': //6 | ||
case 'July': //7 | ||
case 'August': //8 | ||
case 'September'://9 | ||
case 'October': //10 | ||
case 'November': //11 | ||
case 'December': //12 | ||
$this->since = new \DateTime('first day of ' . $scope . ' ' . date('Y')); | ||
$this->until = new \DateTime('last day of ' . $scope . ' ' . date('Y')); | ||
break; | ||
case 'auto': | ||
$latestRecord = $this->getColumnsFromPohoda(['id', 'lastUpdate'], ['limit' => 1, 'order' => 'lastUpdate@A', 'source' => $this->sourceString(), 'banka' => $this->bank]); | ||
if (array_key_exists(0, $latestRecord) && array_key_exists('lastUpdate', $latestRecord[0])) { | ||
$this->since = $latestRecord[0]['lastUpdate']; | ||
} else { | ||
$this->addStatusMessage('Previous record for "auto since" not found. Defaulting to today\'s 00:00', 'warning'); | ||
$this->since = (new \DateTime())->setTime(0, 0); | ||
} | ||
$this->until = new \DateTime(); //Now | ||
break; | ||
default: | ||
throw new \Exception('Unknown scope ' . $scope); | ||
break; | ||
} | ||
if ($scope != 'auto' && $scope != 'today' && $scope != 'yesterday') { | ||
$this->since = $this->since->setTime(0, 0); | ||
$this->until = $this->until->setTime(0, 0); | ||
} | ||
} | ||
|
||
/** | ||
* Request Identifier | ||
* | ||
* @return string | ||
*/ | ||
public function getxRequestId() | ||
{ | ||
return $this->getDataValue('account') . time(); | ||
} | ||
|
||
/** | ||
* Obtain Current Currency | ||
* | ||
* @return string | ||
*/ | ||
public function getCurrencyCode() | ||
{ | ||
return \Ease\Shared::cfg('ACCOUNT_CURRENCY', 'CZK'); | ||
} | ||
|
||
/** | ||
* Is Record with current remoteNumber already present in Pohoda ? | ||
* | ||
* @return bool | ||
*/ | ||
public function checkForTransactionPresence() | ||
{ | ||
return false; //!empty($this->getColumnsFromPohoda('id', ['cisDosle' => $this->getDataValue('cisDosle')])); | ||
} | ||
|
||
/** | ||
* | ||
* @param string $conSym | ||
*/ | ||
public function ensureKSExists($conSym) | ||
{ | ||
if (!array_key_exists($conSym, $this->constSymbols)) { | ||
$this->constantor->insertToPohoda(['kod' => $conSym, 'poznam' => 'Created by Raiffeisen Bank importer', 'nazev' => '?!?!? ' . $conSym]); | ||
$this->constantor->addStatusMessage('New constant ' . $conSym . ' created in flexibee', 'warning'); | ||
$this->constSymbols[$conSym] = $conSym; | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param int $success | ||
* | ||
* @return int | ||
*/ | ||
public function insertTransactionToPohoda($success) | ||
{ | ||
if ($this->checkForTransactionPresence() === false) { | ||
try { | ||
$cache = $this->getData(); | ||
$this->reset(); | ||
//TODO: $result = $this->sync(); | ||
$result = $this->addToPohoda($cache); | ||
$this->commit(); | ||
} catch (\Pohoda\Exception $exc) { | ||
} | ||
$this->addStatusMessage('New entry ', $result ? 'success' : 'error'); | ||
$success++; | ||
} else { | ||
$this->addStatusMessage('Record with remoteNumber ' . 'TODO' . ' already present in Pohoda', 'warning'); | ||
} | ||
return $success; | ||
} | ||
} |
Oops, something went wrong.