* SZEP card transaction log check bumped to last 7 days
* account_id and transation parameter form changes in KOIN
This commit is contained in:
parent
9d4062e724
commit
5d09d96cf2
@ -38,6 +38,11 @@ class KoinService
|
|||||||
*/
|
*/
|
||||||
private $httpClient;
|
private $httpClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $accountId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
@ -285,6 +290,7 @@ class KoinService
|
|||||||
$body = $httpResponse->getBody();
|
$body = $httpResponse->getBody();
|
||||||
|
|
||||||
$this->getCsrfToken($body);
|
$this->getCsrfToken($body);
|
||||||
|
$this->getAccountId($body);
|
||||||
|
|
||||||
$httpResponse = $this->httpClient
|
$httpResponse = $this->httpClient
|
||||||
->post(self::BASE_URI . "/site/login", [
|
->post(self::BASE_URI . "/site/login", [
|
||||||
@ -306,9 +312,9 @@ class KoinService
|
|||||||
$documentXpath = $this->getCsrfToken($htmlData);
|
$documentXpath = $this->getCsrfToken($htmlData);
|
||||||
|
|
||||||
/** @var \DOMNodeList $expenseOptionElements */
|
/** @var \DOMNodeList $expenseOptionElements */
|
||||||
$expenseOptionElements = $documentXpath->query('//select[@id="transactioncreate-category_id"]/optgroup[@label="Kiadás"]/option');
|
$expenseOptionElements = $documentXpath->query('//select[@id="transaction-category_id"]/optgroup[@label="Kiadás"]/option');
|
||||||
/** @var \DOMNodeList $incomeOptionElements */
|
/** @var \DOMNodeList $incomeOptionElements */
|
||||||
$incomeOptionElements = $documentXpath->query('//select[@id="transactioncreate-category_id"]/optgroup[@label="Bevétel"]/option');
|
$incomeOptionElements = $documentXpath->query('//select[@id="transaction-category_id"]/optgroup[@label="Bevétel"]/option');
|
||||||
|
|
||||||
/** @var \DOMElement $element */
|
/** @var \DOMElement $element */
|
||||||
foreach ($expenseOptionElements as $element) {
|
foreach ($expenseOptionElements as $element) {
|
||||||
@ -347,6 +353,29 @@ class KoinService
|
|||||||
return $documentXpath;
|
return $documentXpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse account:id from html
|
||||||
|
*
|
||||||
|
* @param $html
|
||||||
|
* @return \DOMXPath
|
||||||
|
*/
|
||||||
|
private function getAccountId($html): \DOMXPath
|
||||||
|
{
|
||||||
|
$xmlErrorHandling = libxml_use_internal_errors(TRUE);
|
||||||
|
$domDocument = new \DOMDocument();
|
||||||
|
$domDocument->loadHTML($html);
|
||||||
|
libxml_clear_errors();
|
||||||
|
libxml_use_internal_errors($xmlErrorHandling);
|
||||||
|
|
||||||
|
$documentXpath = new \DOMXPath($domDocument);
|
||||||
|
/** @var \DOMElement $accountIdElement */
|
||||||
|
$accountIdElement = $documentXpath->query('//input[@id="transaction-account_id"]')->item(0);
|
||||||
|
|
||||||
|
$this->csrfParam = $accountIdElement->getAttribute("value");
|
||||||
|
|
||||||
|
return $documentXpath;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $amount
|
* @param string $amount
|
||||||
* @param string $currency
|
* @param string $currency
|
||||||
@ -361,12 +390,13 @@ class KoinService
|
|||||||
->post(self::BASE_URI . "/main/save-transaction", [
|
->post(self::BASE_URI . "/main/save-transaction", [
|
||||||
'form_params' => [
|
'form_params' => [
|
||||||
$this->csrfParam => $this->csrfToken,
|
$this->csrfParam => $this->csrfToken,
|
||||||
'TransactionCreate[category_id]' => $category,
|
'Transaction[account_id]' => $this->accountId,
|
||||||
'TransactionCreate[value]' => $amount,
|
'Transaction[category_id]' => $category,
|
||||||
'TransactionCreate[currency]' => $currency,
|
'Transaction[value]' => $amount,
|
||||||
'TransactionCreate[imgKey]' => "",
|
'Transaction[currency]' => $currency,
|
||||||
'TransactionCreate[tagData]' => $tags,
|
'Transaction[imgKey]' => "",
|
||||||
'TransactionCreate[date]' => $date,
|
'Transaction[tagData]' => $tags,
|
||||||
|
'Transaction[date]' => $date,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@ -82,7 +82,7 @@ class SZEPManagerService
|
|||||||
openssl_public_encrypt($this->config['szep.key'], $cryptCardKey, $certificate, OPENSSL_PKCS1_PADDING);
|
openssl_public_encrypt($this->config['szep.key'], $cryptCardKey, $certificate, OPENSSL_PKCS1_PADDING);
|
||||||
|
|
||||||
$endDate = new \DateTimeImmutable();
|
$endDate = new \DateTimeImmutable();
|
||||||
$startDate = $endDate->sub(new \DateInterval('P4D'));
|
$startDate = $endDate->sub(new \DateInterval('P7D'));
|
||||||
|
|
||||||
$gueryTemplate = file_get_contents(self::TEMPLATE_QUERY_CARD);
|
$gueryTemplate = file_get_contents(self::TEMPLATE_QUERY_CARD);
|
||||||
$query = sprintf($gueryTemplate,
|
$query = sprintf($gueryTemplate,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user