Skip to content

Commit

Permalink
Merge origin/main into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Dec 14, 2024
2 parents 7ebc9df + 51abede commit 6213fcc
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 15 deletions.
11 changes: 9 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
pohoda-raiffeisenbank (1.1.3) UNRELEASED; urgency=medium
pohoda-raiffeisenbank (1.2.0) UNRELEASED; urgency=medium

* ACCOUNT_CURRENCY support added

-- <vitezslav.dvorak@spojenet.cz> Thu, 12 Dec 2024 19:46:43 +0100

pohoda-raiffeisenbank (1.1.3) jammy; urgency=medium

[ vitezslav.dvorak@spojenet.cz ]
* bankIDS processed now
* Fail with correct exitpode

-- <vitezslav.dvorak@spojenet.cz> Mon, 09 Dec 2024 11:37:42 +0100
-- <vitezslav.dvorak@spojenet.cz> Thu, 12 Dec 2024 19:46:38 +0100

pohoda-raiffeisenbank (1.1.1) jammy; urgency=medium

Expand Down
6 changes: 3 additions & 3 deletions multiflexi/2461feac-a694-4171-a37e-069fe3f56cef.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion multiflexi/pohoda_raiffeisenbank_statements.multiflexi.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,24 @@
"defval": "",
"required": true
},
"STATEMENT_IMPORT_SCOPE": {
"IMPORT_SCOPE": {
"type": "text",
"description": "Time scope of transactions downloaded",
"defval": "auto",
"required": true
},
"STATEMENT_LINE": {
"type": "text",
"description": "Statement line can be MAIN or ADDITIONAL",
"defval": "MAIN",
"required": false
},
"ACCOUNT_CURRENCY": {
"type": "text",
"description": "for multicurrency accounts please specify one",
"defval": "CZK",
"required": false
},
"XIBMCLIENTID": {
"type": "text",
"description": "ClientID",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
"defval": "auto",
"required": true
},
"ACCOUNT_CURRENCY": {
"type": "text",
"description": "for multicurrency accounts please specify one",
"defval": "CZK",
"required": false
},
"XIBMCLIENTID": {
"type": "text",
"description": "ClientID",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
"defval": "auto",
"required": true
},
"ACCOUNT_CURRENCY": {
"type": "text",
"description": "for multicurrency accounts please specify one",
"defval": "CZK",
"required": false
},
"XIBMCLIENTID": {
"type": "text",
"description": "ClientID",
Expand Down
2 changes: 1 addition & 1 deletion src/Pohoda/RaiffeisenBank/PohodaBankClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function getxRequestId()
*/
public function getCurrencyCode()
{
return Shared::cfg('ACCOUNT_CURRENCY', 'CZK');
return $this->currency;
}

/**
Expand Down
44 changes: 42 additions & 2 deletions src/Pohoda/RaiffeisenBank/Statementor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Statementor extends PohodaBankClient
public string $scope = '';
private \VitexSoftware\Raiffeisenbank\Statementor $obtainer;
private string $statementsDir;
private string $currency = '';
private string $statementLine = 'MAIN';

/**
* Downloaded XML statements.
Expand Down Expand Up @@ -93,7 +95,7 @@ public function getStatementFilenames(string $format): array

public function getStatements()
{
return $this->obtainer->getStatements();
return $this->obtainer->getStatements($this->currency, $this->statementLine);
}

public function download($format)
Expand Down Expand Up @@ -179,6 +181,17 @@ public function import(string $bankIds = ''): array
return $inserted;
}

public static function simpleXmlAttributes(\SimpleXMLElement $item): array
{
$attributes = [];

foreach ($item->attributes() as $key => $value) {
$attributes[$key] = (string) $value;
}

return $attributes;
}

/**
* Parse Ntry element and convert into \Pohoda\Banka data.
*
Expand All @@ -198,7 +211,15 @@ public function entryToPohoda(\SimpleXMLElement $entry): array
$data['bankType'] = $moveTrans[trim((string) $entry->CdtDbtInd)];
// $data['cisDosle', strval($entry->NtryRef));
// $data['datVyst', new \DateTime($entry->BookgDt->DtTm));
$data['homeCurrency'] = ['priceNone' => abs((float) $entry->Amt)]; // "price3", "price3Sum", "price3VAT", "priceHigh", "priceHighSum", "priceHighVAT", "priceLow", "priceLowSum", "priceLowVAT", "priceNone", "round"

$amountAttributes = self::simpleXmlAttributes($entry->Amt);

if (\array_key_exists('Ccy', $amountAttributes) && $amountAttributes['Ccy'] !== 'CZK') {
$data['foreignCurrency'] = ['priceSum' => abs((float) $entry->Amt)]; // "price3", "price3Sum", "price3VAT", "priceHigh", "priceHighSum", "priceHighVAT", "priceLow", "priceLowSum", "priceLowVAT", "priceNone", "round"
$data['foreignCurrency']['currency'] = $amountAttributes['Ccy'];
} else {
$data['homeCurrency'] = ['priceNone' => abs((float) $entry->Amt)]; // "price3", "price3Sum", "price3VAT", "priceHigh", "priceHighSum", "priceHighVAT", "priceLow", "priceLowSum", "priceLowVAT", "priceNone", "round"
}

// TODO $data['foreignCurrency', abs(floatval($entry->Amt)));
// $data['account', $this->bank);
Expand Down Expand Up @@ -426,4 +447,23 @@ public function takeXmlStatementFile(string $xmlFilePath): void
{
$this->statementsXML[basename($xmlFilePath)] = $xmlFilePath;
}

public function setCurrency(string $currency): void
{
$this->currency = $currency;
}

public function setStatementLine(string $line): void
{
switch ($line) {
case 'MAIN':
case 'ADDITIONAL':
$this->statementLine = $line;

break;

default:
throw new \InvalidArgumentException('Wrong statement line: '.$line);
}
}
}
6 changes: 3 additions & 3 deletions src/pohoda-raiffeisenbank-offline-statement-importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

\define('APP_NAME', 'Pohoda RaiffeisenBank Offline Statements');

$statementFile = 'statement.xml'; // TODO: specify by commandline

$options = getopt('i::e::', ['input::environment::']);
$statementFile = \array_key_exists('output', $options) ? $options['output'] : \Ease\Shared::cfg('STATEMENT_FILE', 'php://stdin');
/**
* Get today's Statements list.
*/
\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD', 'POHODA_ICO', 'POHODA_BANK_IDS', 'ACCOUNT_NUMBER'], $argv[1] ?? '../.env');
\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD', 'POHODA_ICO', 'POHODA_BANK_IDS', 'ACCOUNT_NUMBER'], \array_key_exists('environment', $options) ? $options['environment'] : '../.env');
$engine = new Statementor(\Ease\Shared::cfg('ACCOUNT_NUMBER'));
$engine->logBanner('', 'Importing file: '.$statementFile);

Expand Down
2 changes: 2 additions & 0 deletions src/pohoda-raiffeisenbank-statements.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

namespace Pohoda\RaiffeisenBank;

use Ease\Shared;

require_once '../vendor/autoload.php';

\define('APP_NAME', 'Pohoda RaiffeisenBank Statements');
Expand Down
14 changes: 12 additions & 2 deletions src/pohodaSQL-raiffeisenbank-statements-sharepoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
$options = getopt('o::e::', ['output::environment::']);
Shared::init(
[
'OFFICE365_TENANT', 'OFFICE365_PATH', 'OFFICE365_SITE',
'POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD', 'POHODA_ICO',
'CERT_FILE', 'CERT_PASS', 'XIBMCLIENTID', 'ACCOUNT_NUMBER',
'DB_CONNECTION', 'DB_HOST', 'DB_PORT', 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD',
Expand All @@ -41,7 +42,16 @@
PohodaBankClient::checkCertificatePresence(Shared::cfg('CERT_FILE'));
$engine = new Statementor(Shared::cfg('ACCOUNT_NUMBER'));
$engine->setScope(Shared::cfg('IMPORT_SCOPE', 'last_month'));
$engine->logBanner('', 'Scope: '.$engine->scope);

if (Shared::cfg('STATEMENT_LINE')) {
$engine->setStatementLine(Shared::cfg('STATEMENT_LINE'));
}

if (Shared::cfg('ACCOUNT_CURRENCY')) {
$engine->setCurrency(Shared::cfg('ACCOUNT_CURRENCY'));
}

$engine->logBanner(Shared::cfg('ACCOUNT_CURRENCY'), 'Scope: '.$engine->scope);
$exitcode = 0;
$fileUrls = [];
$report = [
Expand All @@ -54,7 +64,7 @@
$pdfStatements = $engine->downloadPDF();
} catch (\VitexSoftware\Raiffeisenbank\ApiException $exc) {
$report['mesage'] = $exc->getMessage();

$pdfStatements = [];
$exitcode = $exc->getCode();

if (!$exitcode) {
Expand Down
2 changes: 1 addition & 1 deletion src/raiffeisenbank-statements-sharepoint-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
$options = getopt('o::e::', ['output::environment::']);
Shared::init(
[
'OFFICE365_TENANT', 'OFFICE365_PATH', 'OFFICE365_SITE',
'CERT_FILE', 'CERT_PASS', 'XIBMCLIENTID', 'ACCOUNT_NUMBER',
'DB_CONNECTION', 'DB_HOST', 'DB_PORT', 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD',
],
\array_key_exists('environment', $options) ? $options['environment'] : '../.env',
);
Expand Down

0 comments on commit 6213fcc

Please sign in to comment.