Skip to content

Commit

Permalink
v0.5.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Dec 2, 2024
1 parent 9bf5855 commit 63a9f79
Show file tree
Hide file tree
Showing 24 changed files with 482 additions and 227 deletions.
3 changes: 2 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
__DIR__.'/.php-cs-fixer.dist.php',
])
->in('src')
->in('tests');
->in('tests')
->in('Examples');

$config->setCacheFile(__DIR__.'/.build/php-cs-fixer/.php-cs-fixer.cache');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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

\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], __DIR__.'/.env');
\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], \dirname(__DIR__).'/.env');

if (\Ease\Shared::cfg('EASE_LOGGER', false) === false) {
\define('EASE_LOGGER', 'console');
Expand Down
8 changes: 7 additions & 1 deletion tests/insert-address.php → Examples/insert-address.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

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

\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], \dirname(__DIR__).'/.env');

$addressBookRecord = [
'GPS' => '', // GPS souřadnice.
'ICQ' => '', // ICQ adresa.
Expand Down Expand Up @@ -84,5 +86,9 @@
'web' => 'https://www.vitexsoftware.cz', // Adresa www stránek.
];

$addresser = new Adressbook($addressBookRecord, \Ease\Shared::instanced()->loadConfig(__DIR__.'/.env'));
$addresser = new Adressbook($addressBookRecord);
$addresser->addToPohoda();

if ($addresser->commit()) {
print_r($addresser->response->producedDetails);
}
7 changes: 4 additions & 3 deletions tests/insert-bank.php → Examples/insert-bank.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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

\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], __DIR__.'/.env');
\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], \dirname(__DIR__).'/.env');

$bankRecord = [
// "MOSS" => ['ids' => '213'],
Expand Down Expand Up @@ -62,6 +62,7 @@

$banker = new Bank($bankRecord);
$banker->addToPohoda();
$result = $banker->commit();

print_r($result);
if ($banker->commit()) {
print_r($banker->response->producedDetails);
}
8 changes: 6 additions & 2 deletions tests/insert-invoice.php → Examples/insert-invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@
// "symVar",
];

$invoicer = new Invoice($invoiceRecord, \Ease\Shared::instanced()->loadConfig(__DIR__.'/.env'));
\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], \dirname(__DIR__).'/.env');

$invoicer = new Invoice($invoiceRecord);

$itemRecord = [
'text' => 'Židle Z220',
Expand All @@ -104,4 +106,6 @@

$invoicer->addToPohoda();

$invoicer->getIDS();
if ($invoicer->commit()) {
print_r($invoicer->response->producedDetails);
}
4 changes: 2 additions & 2 deletions tests/read-address.php → Examples/read-address.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/

require_once '../vendor/autoload.php';
\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], __DIR__.'/.env');
$addresser = new \mServer\Adressbook();
\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], \dirname(__DIR__).'/.env');
$addresser = new \mServer\Addressbook();
print_r($addresser->getColumnsFromPohoda(['id', 'jmeno', 'email', 'web']));
// print_r($addresser->getColumnsFromPohoda(['id', 'jmeno', 'email', 'web'], ['city' => 'Prague']));

Expand Down
19 changes: 19 additions & 0 deletions Examples/read-bank.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

/**
* This file is part of the PHP-Pohoda-Connector package
*
* https://github.com/VitexSoftware/PHP-Pohoda-Connector
*
* (c) VitexSoftware. <https://vitexsoftware.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

require_once '../vendor/autoload.php';
\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], \dirname(__DIR__).'/.env');
$addresser = new \mServer\Bank();
print_r($addresser->getColumnsFromPohoda(['id', 'number', 'symVar']));
19 changes: 19 additions & 0 deletions Examples/read-invoice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

/**
* This file is part of the PHP-Pohoda-Connector package
*
* https://github.com/VitexSoftware/PHP-Pohoda-Connector
*
* (c) VitexSoftware. <https://vitexsoftware.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

require_once '../vendor/autoload.php';
\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], \dirname(__DIR__).'/.env');
$invoicer = new \mServer\Invoice();
print_r($invoicer->getColumnsFromPohoda(['id', 'number', 'symVar']));
8 changes: 7 additions & 1 deletion tests/update-address.php → Examples/update-address.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

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

\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], \dirname(__DIR__).'/.env');

$extID = 234;

$addressBookRecord = [
Expand Down Expand Up @@ -86,5 +88,9 @@
'web' => 'https://www.vitexsoftware.cz', // Adresa www stránek.
];

$addresser = new Adressbook($addressBookRecord, \Ease\Shared::instanced()->loadConfig(__DIR__.'/.env'));
$addresser = new Adressbook($addressBookRecord);
$addresser->updateInPohoda(null, ['extId' => ['exSystemName' => \Ease\Shared::cfg('APP_NAME'), 'ids' => (string) $extID]]);

if ($addresser->commit()) {
print_r($addresser->response->producedDetails);
}
29 changes: 0 additions & 29 deletions Examples/userList.php

This file was deleted.

134 changes: 132 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
![Project Logo](phpmserver.svg?raw=true)

# PHPmServer

client library for Stormware's [mPohoda mServer](https://www.stormware.cz/pohoda/xml/mserver/)

![Project Logo](phpmserver.svg?raw=true)

The PHP-Pohoda-Connector library provides a set of features to interact with the Pohoda accounting software. Below are some of the key features along with code examples:

Features:

* Check connection
* Create/Update/Delete AddressBook record
* Create/Update/Delete Invoice record
* Create/Update/Delete Bank movement record

![PHP from Packagist](https://img.shields.io/packagist/php-v/vitexsoftware/pohoda-connector)
![Packagist Version](https://img.shields.io/packagist/v/vitexsoftware/pohoda-connector)
Expand Down Expand Up @@ -39,6 +42,133 @@ Classess check at startup for this constants or environment variables:

## Usage

1. Check Connection
This feature allows you to check if the connection to the Pohoda server is successful.

```php
<?php

namespace mServer;

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

\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], \dirname(__DIR__).'/.env');

$client = new \mServer\Client();

if (\Ease\Shared::cfg('APP_DEBUG')) {
$client->logBanner();
}

echo $client->isOnline() ? 'Online' : 'Offline';
```

1. Add Addressbook record
This feature allows you to add a new addressbook record.

```php
<?php

namespace mServer;

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

\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], \dirname(__DIR__).'/.env');

$addressBookRecord = [
'identity' => [
'address' => [
'company' => 'Vitex Software',
'name' => 'Vítězslav Dvořák',
'city' => 'Prague',
'street' => 'Long',
'zip' => '15800',
'ico' => '69438676',
'dic' => 'CZ7808072811',
],
],
'mobil' => '739 778 202',
'web' => 'https://www.vitexsoftware.cz',
];

$addresser = new Adressbook($addressBookRecord);
$addresser->addToPohoda();

if ($addresser->commit()) {
print_r($addresser->response->producedDetails);
}
```

1. Create Invoice

This feature allows you to create a new invoice.

```php
<?php

namespace mServer;

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

$invoiceRecord = [
'invoiceType' => 'issuedInvoice',
'date' => date('Y-m-d'),
'accounting' => ['ids' => '3Fv'],
'text' => 'Faktura za zboží bez adresy',
'paymentType' => 'draft',
'note' => 'Import XML.',
'intNote' => 'Tento doklad byl vytvořen importem přes XML z PHP.',
'invoiceSummary' => [
'roundingDocument' => 'math2one',
'homeCurrency' => [
'priceNone' => 3018,
'priceLow' => 60000,
'priceHighSum' => 557,
],
],
];

\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], \dirname(__DIR__).'/.env');

$invoicer = new Invoice($invoiceRecord);

$itemRecord = [
'text' => 'Židle Z220',
'quantity' => 1.0,
'unit' => 'ks',
'payVAT' => false,
'rateVAT' => 'high',
'homeCurrency' => [
'unitPrice' => 1968,
'price' => 1968,
'priceVAT' => 413.28,
'priceSum' => 2381.28,
],
'code' => 'Z220',
'stockItemIDS' => 'Z220',
];

$invoicer->addItem($itemRecord);
$invoicer->addToPohoda();

if ($invoicer->commit()) {
print_r($invoicer->response->producedDetails);
}
```

1. Addressbook reading

This feature allows you to read an addressbook record.

```php
<?php

require_once '../vendor/autoload.php';
\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD'], \dirname(__DIR__).'/.env');
$addresser = new \mServer\Addressbook();
print_r($addresser->getColumnsFromPohoda(['id', 'jmeno', 'email', 'web']));
```

See usage examples in [tests](tests) directory

* [Check Connection](tests/check-connection.php)
Expand Down
10 changes: 8 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
php-vitexsoftware-pohoda-connector (0.4.2) UNRELEASED; urgency=medium
php-vitexsoftware-pohoda-connector (0.5.0) UNRELEASED; urgency=medium

* Bank added

-- vitex <info@vitexsoftware.cz> Mon, 02 Dec 2024 13:31:13 +0100

php-vitexsoftware-pohoda-connector (0.4.2) unstable; urgency=medium

* Better Bank parser

-- vitex <info@vitexsoftware.cz> Sat, 09 Nov 2024 00:27:54 +0100
-- vitex <info@vitexsoftware.cz> Mon, 02 Dec 2024 13:31:10 +0100

php-vitexsoftware-pohoda-connector (0.4.1) unstable; urgency=low

Expand Down
46 changes: 46 additions & 0 deletions src/mServer/Addressbook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

/**
* This file is part of the PHP-Pohoda-Connector package
*
* https://github.com/VitexSoftware/PHP-Pohoda-Connector
*
* (c) VitexSoftware. <https://vitexsoftware.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace mServer;

/**
* Address handler.
*
* @author vitex
*/
class Addressbook extends Client
{
/**
* Current Object's agenda.
*/
public ?string $agenda = 'addressBook';

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

/**
* Create Agenda document using given data.
*
* @param array<string, array<string, string>|string> $data
*/
public function create(array $data): int
{
$this->requestXml = $this->pohoda->createAddressbook($data);

return 1;
}
}
Loading

0 comments on commit 63a9f79

Please sign in to comment.