Skip to content

Commit 3a5d74d

Browse files
committed
[info] frissites: PHPApiAgent-2.10.23-50fe9a95e69bd665e2cb079c9a72bad0.zip
1 parent 86956da commit 3a5d74d

File tree

8 files changed

+63
-17
lines changed

8 files changed

+63
-17
lines changed

szamlaagent/changelog.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,26 @@
22
All notable changes to this project will be documented in this file.
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
44

5-
## [2.10.22] - 2025.11.13
5+
## [2.10.23] - 2025.11.26
6+
7+
### Added
8+
9+
- added function: singleton mode can be disabled
10+
- src/szamlaagent/SzamlaAgentAPI.php
11+
- SzamlaAgentAPI::create last parameter, default is true (singleton mode is enabled)
12+
- when disabled, the SzamlaAgentAPI create method always returns a new instance
13+
- when Singleton mode is disabled, the names of XML files change; hash of the SzamlaAgent instance is added to the file name
14+
````
15+
SzamlaAgentAPI::create("AGENT KEY", true, Log::LOG_LEVEL_DEBUG, SzamlaAgentResponse::RESULT_AS_TEXT, "PHP API teszt", false);
16+
````
17+
- added function: invoice XML data download by external ID
18+
- src/szamlaagent/SzamlaAgentSetting.php
19+
- src/szamlaagent/SzamlaAgent.php
20+
````
21+
$agent->getInvoiceData("EXTERNAL_ID", Invoice::FROM_INVOICE_EXTERNAL_ID);
22+
````
23+
24+
## [2.10.22] - 2025.10.13
625

726
### Added
827

szamlaagent/src/SzamlaAgent/Item/InvoiceItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function buildXmlData() {
5050
$data['mennyiseg'] = SzamlaAgentUtil::doubleFormat($this->getQuantity());
5151
$data['mennyisegiEgyseg'] = $this->getQuantityUnit();
5252
$data['nettoEgysegar'] = SzamlaAgentUtil::doubleFormat($this->getNetUnitPrice());
53-
$data['afakulcs'] = $this->getVat();
53+
$data['afakulcs'] = SzamlaAgentUtil::dotCheck($this->getVat());
5454

5555
if (SzamlaAgentUtil::isNotNull($this->getPriceGapVatBase())) {
5656
$data['arresAfaAlap'] = SzamlaAgentUtil::doubleFormat($this->getPriceGapVatBase());

szamlaagent/src/SzamlaAgent/Response/SzamlaAgentResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ private function createXmlFile(\SimpleXMLElement $xml) {
270270
throw new SzamlaAgentException(SzamlaAgentException::RESPONSE_TYPE_NOT_EXISTS . " ($type)");
271271
}
272272

273-
$fileName = SzamlaAgentUtil::getXmlFileName('response', $name . $postfix, $agent->getRequest()->getEntity());
273+
$fileName = SzamlaAgentUtil::getXmlFileName('response', $name . $postfix, $agent, $agent->getRequest()->getEntity());
274274
$xmlSaved = $xml->save($fileName);
275275

276276
if (!$xmlSaved) {

szamlaagent/src/SzamlaAgent/SzamlaAgent.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ class SzamlaAgent {
177177
*/
178178
private $certificationFilePath;
179179

180+
private $singleton = true;
181+
180182
/**
181183
* Számla Agent létrehozása
182184
*
@@ -397,8 +399,10 @@ public function getInvoiceData($data, $type = Invoice::FROM_INVOICE_NUMBER, $dow
397399

398400
if ($type == Invoice::FROM_INVOICE_NUMBER) {
399401
$invoice->getHeader()->setInvoiceNumber($data);
400-
} else {
402+
} else if($type == Invoice::FROM_ORDER_NUMBER) {
401403
$invoice->getHeader()->setOrderNumber($data);
404+
} else {
405+
$this->setInvoiceExternalId($data);
402406
}
403407

404408
if ($this->getResponseType() !== SzamlaAgentResponse::RESULT_AS_XML) {
@@ -1256,4 +1260,21 @@ public function getRequestConnectTimeout() {
12561260
public function setRequestConnectTimeout($requestConnectTimeout) {
12571261
$this->requestConnectTimeout = max($requestConnectTimeout, 0);
12581262
}
1263+
1264+
/**
1265+
* @return mixed
1266+
*/
1267+
public function getSingleton()
1268+
{
1269+
return $this->singleton;
1270+
}
1271+
1272+
/**
1273+
* @param mixed $singleton
1274+
*/
1275+
protected function setSingleton($singleton)
1276+
{
1277+
$this->singleton = $singleton;
1278+
}
1279+
12591280
}

szamlaagent/src/SzamlaAgent/SzamlaAgentAPI.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,22 @@ class SzamlaAgentAPI extends SzamlaAgent {
2323
* @return SzamlaAgent
2424
* @throws SzamlaAgentException
2525
*/
26-
public static function create($apiKey, $downloadPdf = true, $logLevel = Log::LOG_LEVEL_DEBUG, $responseType = SzamlaAgentResponse::RESULT_AS_TEXT, $aggregator = '') {
27-
$index = self::getHash($apiKey);
26+
public static function create($apiKey, $downloadPdf = true, $logLevel = Log::LOG_LEVEL_DEBUG, $responseType = SzamlaAgentResponse::RESULT_AS_TEXT, $aggregator = '', $singleton = true) {
2827

2928
$agent = null;
30-
if (isset(self::$agents[$index])) {
31-
$agent = self::$agents[$index];
32-
}
3329

34-
if ($agent === null) {
35-
return self::$agents[$index] = new self(null, null, $apiKey, $downloadPdf, $logLevel, $responseType, $aggregator);
30+
if ($singleton) {
31+
$index = self::getHash($apiKey);
32+
if (isset(self::$agents[$index])) {
33+
$agent = self::$agents[$index];
34+
} else {
35+
$agent = new self(null, null, $apiKey, $downloadPdf, $logLevel, $responseType, $aggregator);
36+
self::$agents[$index] = $agent;
37+
}
3638
} else {
37-
return $agent;
39+
$agent = new self(null, null, $apiKey, $downloadPdf, $logLevel, $responseType, $aggregator);
40+
$agent->setSingleton($singleton);
3841
}
42+
return $agent;
3943
}
4044
}

szamlaagent/src/SzamlaAgent/SzamlaAgentRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ private function arrayToXML(array $xmlData, SimpleXMLExtended &$xmlFields) {
289289
* @throws \ReflectionException
290290
*/
291291
private function createXmlFile(\DOMDocument $xml) {
292-
$fileName = SzamlaAgentUtil::getXmlFileName('request', $this->getXmlName(), $this->getEntity());
292+
$fileName = SzamlaAgentUtil::getXmlFileName('request', $this->getXmlName(), $this->getAgent(), $this->getEntity());
293293
$xmlSaved = $xml->save($fileName);
294294

295295
if (!$xmlSaved) {
@@ -491,7 +491,7 @@ private function makeCurlCall() {
491491
$xmlFile = new \CURLFile($this->getXmlFilePath(), $mimeType, basename($this->getXmlFilePath()));
492492
} else {
493493
$xmlContent = 'data://application/octet-stream;base64,' . base64_encode($this->getXmlData());
494-
$fileName = SzamlaAgentUtil::getXmlFileName('request', $this->getXmlName(), $this->getEntity());
494+
$fileName = SzamlaAgentUtil::getXmlFileName('request', $this->getXmlName(), $this->getAgent(), $this->getEntity());
495495
$xmlFile = new \CURLFile($xmlContent, $mimeType, basename($fileName));
496496
}
497497

szamlaagent/src/SzamlaAgent/SzamlaAgentSetting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public function buildXmlData(SzamlaAgentRequest $request) {
349349
$data = $this->buildFieldsData($request, array_merge($settings, ['szamlaszam', 'adoszam', 'additiv', 'aggregator', 'valaszVerzio']));
350350
break;
351351
case $request::XML_SCHEMA_REQUEST_INVOICE_XML:
352-
$data = $this->buildFieldsData($request, array_merge($settings, ['szamlaszam', 'rendelesSzam', 'pdf']));
352+
$data = $this->buildFieldsData($request, array_merge($settings, ['szamlaszam', 'rendelesSzam', 'pdf', 'szamlaKulsoAzon']));
353353
break;
354354
case $request::XML_SCHEMA_REQUEST_INVOICE_PDF:
355355
$data = $this->buildFieldsData($request, array_merge($settings, ['szamlaszam', 'rendelesSzam', 'valaszVerzio', 'szamlaKulsoAzon']));

szamlaagent/src/SzamlaAgent/SzamlaAgentUtil.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,14 @@ public static function isNotValidDate($date) {
156156
* @return string|bool
157157
* @throws \ReflectionException
158158
*/
159-
public static function getXmlFileName($prefix, $name, $entity = null) {
159+
public static function getXmlFileName($prefix, $name, $agent, $entity = null) {
160160
if (!empty($name) && !empty($entity)) {
161161
$name .= '-' . (new \ReflectionClass($entity))->getShortName();
162162
}
163163

164-
$fileName = $prefix . '-' . strtolower($name) . '-' . self::getDateTimeWithMilliseconds() . '.xml';
164+
$hash = $agent->getSingleton() ? '' : spl_object_hash($agent);
165+
166+
$fileName = $prefix . '-' . strtolower($name) . '-' . $hash . '-' .self::getDateTimeWithMilliseconds() . '.xml';
165167
return self::getAbsPath(SzamlaAgent::XML_FILE_SAVE_PATH, $fileName);
166168
}
167169

0 commit comments

Comments
 (0)