Skip to content

Commit

Permalink
Merge branch 'main' of github.com:VitexSoftware/PHP-Pohoda-Connector
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Nov 19, 2024
2 parents 266fdc1 + 255155f commit bc01b11
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 44 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PHP Composer

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

# - name: Run test suite
# run: composer run-script test
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -941,17 +941,17 @@
"require": {
"ext-curl": "*",
"ext-iconv": "*",
"goetas-webservices/xsd2php-runtime": "^0.2.16",
"lightools/xml": "v2.0.0",
"riesenia/pohoda": ">=1.5 || dev-master",
"vitexsoftware/ease-core": "dev-main",
"goetas-webservices/xsd2php-runtime": "0.2.17",
"lightools/xml": "^3.0",
"riesenia/pohoda": "^1.21",
"vitexsoftware/ease-core": "^1.44",
"jms/serializer": "^3.28"
},
"require-dev": {
"goetas-webservices/xsd2php": "^0.4.11",
"phpunit/phpunit": "*",
"phpstan/phpstan": "*",
"friendsofphp/php-cs-fixer": "^3.61",
"friendsofphp/php-cs-fixer": "3.64.0",
"ergebnis/composer-normalize": "^2.43",
"ergebnis/php-cs-fixer-config": "^6.34"
},
Expand Down
10 changes: 3 additions & 7 deletions src/mServer/Adressbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,19 @@ class Adressbook extends Client
/**
* Request XML helper.
*/
public \Riesenia\Pohoda\Addressbook $requestXml = null;
public ?\Riesenia\Pohoda\Addressbook $requestXml = null;

/**
* AddressBook records name column.
*/
public string $nameColumn = 'address:company';

/**
* AddressBook records name column.
*/
public string $nameColumn = 'address:company';
public ?string $nameColumn = 'address:company';

/**
* Create Agenda document using given data.
*
* @param array $data
*/
#[\Override]
public function create($data): void
{
$this->requestXml = $this->pohoda->createAddressbook($data);
Expand Down
5 changes: 4 additions & 1 deletion src/mServer/Bank.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Bank extends Client
*
* @param array $data
*/
#[\Override]
public function create($data): void
{
$this->requestXml = $this->pohoda->createBank($data);
Expand All @@ -62,13 +63,15 @@ public function takeData($data)
\Ease\Functions::divDataArray($data, $summaryData, 'homeCurrency');
\Ease\Functions::divDataArray($data, $summaryData, 'foreignCurrency');
$taken = parent::takeData($data);
$this->addSummary($summaryData);

return $taken + $this->addSummary($summaryData);
return $taken;
}

/**
* {@inheritDoc}
*/
#[\Override]
public function setObjectName($forceName = '')
{
return parent::setObjectName($forceName ?: $this->getDataValue('account').'@'.$this->getObjectName());
Expand Down
4 changes: 2 additions & 2 deletions src/mServer/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,9 @@ public function takeData($data)
*
* @param array $data
*/
public function create($data)
public function create(string $data)
{
$this->requestXml = $this->pohoda->create($data);
$this->requestXml = $this->pohoda->create($this->agenda, $data);

return empty($this->requestXml) ? 0 : 1;
}
Expand Down
3 changes: 2 additions & 1 deletion src/mServer/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Invoice extends Client
/**
* Request XML helper.
*/
public \Riesenia\Pohoda\Invoice $requestXml = null;
public ?\Riesenia\Pohoda\Invoice $requestXml = null;

/*
public function getElementMap($extra = []) {
Expand Down Expand Up @@ -76,6 +76,7 @@ static function xmlDeserialize(\Sabre\Xml\Reader $reader) {
*
* @param array $data
*/
#[\Override]
public function create($data): void
{
if (\array_key_exists('invoiceSummary', $data)) {
Expand Down
12 changes: 7 additions & 5 deletions src/mServer/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function processResponseData($responseData): void
foreach ($responseData as $key => $value) {
switch ($key) {
case 'lAdb:addressbook':
$this->parsed = $this->processListAddressBook(array_key_exists(0, $value) ? $value : [$value]);
$this->parsed = $this->processListAddressBook(\array_key_exists(0, $value) ? $value : [$value]);

break;
case 'rdc:producedDetails':
Expand All @@ -160,7 +160,7 @@ public function processResponseData($responseData): void

break;
case 'lst:bank':
$this->parsed = $this->processBank(array_key_exists(0, $value) ? $value : [$value]);
$this->parsed = $this->processBank(\array_key_exists(0, $value) ? $value : [$value]);

break;
case '@version':
Expand Down Expand Up @@ -475,15 +475,17 @@ public function processBank(array $bank): array
foreach ($bank as $bankEntry) {
if (\is_array($bankEntry)) {
$striped = self::stripArrayNames('bnk', $bankEntry);
if (array_key_exists('bankHeader', $striped)) {

if (\array_key_exists('bankHeader', $striped)) {
$bankItems[$striped['bankHeader']['id']] = $striped;
} elseif (array_key_exists('bankItem', $striped)) {
} elseif (\array_key_exists('bankItem', $striped)) {
$bankItems[$striped['bankItem']['id']] = $striped;
} elseif(array_key_exists('id', $striped)) {
} elseif (\array_key_exists('id', $striped)) {
$bankItems[$striped['id']] = $striped;
}
}
}

return self::stripArrayNames('typ', $bankItems);
}
}
64 changes: 41 additions & 23 deletions tests/src/mServer/ResponseTest.php

Large diffs are not rendered by default.

0 comments on commit bc01b11

Please sign in to comment.