alex-kalanis/pohoda
最新稳定版本:v10.0.0
Composer 安装命令:
composer require alex-kalanis/pohoda
包简介
Pohoda XML communication
README 文档
README
Library for manipulation with data, which came as XML from Pohoda mServer.
Pohoda is an accounting software for Czech Republic, Slovakia and probably few other countries.
What is different:
Usage of phpunit, extended tests, phpstan 1.12, deeper type checking
Installation
Add to composer.json:
composer.phar require alex-kalanis/pohoda
Example of order imports
Examples of importing each type - more in spec folder.
use kalanis\Pohoda; $pohoda = new Pohoda('ICO'); // create file $pohoda->open($filename, 'i_obj1', 'Import orders'); $partnerIdentityAddress = new Pohoda\Type\Dtos\AddressTypeDto(); $partnerIdentityAddress->name = $billing_name; $partnerIdentityAddress->street => $billing_street; $partnerIdentityAddress->city => $billing_city; $partnerIdentityAddress->zip => $billing_zip; $partnerIdentityAddress->email => $email; $partnerIdentityAddress->phone => $phone; $partnerIdentityAddress = new Pohoda\Type\Dtos\ShipToAddressDto(); $partnerIdentityAddress->name = $shipping_name; $partnerIdentityAddress->street => $shipping_street; $partnerIdentityAddress->city => $shipping_city; $partnerIdentityAddress->zip => $shipping_zip; $partnerIdentityAddress->email => $email; $partnerIdentityAddress->phone => $phone; $partnerIdentity = new Pohoda\Type\Dtos\AddressDto(); $partnerIdentity->address = $partnerIdentityAddress; $partnerIdentity->shipToAddress = $partnerIdentityAddress; $orderHeaderDto = new Pohoda\Order\HeaderDto(); $orderHeaderDto->numberOrder = $order_number; $orderHeaderDto->isReserved = true; $orderHeaderDto->date = $created; $orderHeaderDto->text = '...'; $orderHeaderDto->partnerIdentity = $partnerIdentity; $orderDto = new Pohoda\Order\OrderDto(); $orderDto->header = $orderHeaderDto; // create order $order = $pohoda->createOrder($orderDto); // add items foreach ($items as $item) { $homeCurrency = new Pohoda\Type\Dtos\CurrencyItemDto(); $homeCurrency->unitPrice = $item->unit_price; $stockItem = new Pohoda\Type\Dtos\StockItemDto(); $stockItem->stockItem = [ 'id' => $item->pohoda_id ]; $itemDto = new Pohoda\Order\ItemDto(); $itemDto->code => $item->code; $itemDto->text => $item->text; $itemDto->quantity => $item->quantity; $itemDto->payVAT => false; $itemDto->rateVAT => $item->rate; $itemDto->homeCurrency = $homeCurrency; $itemDto->stockItem = $stockItem; $order->addItem($itemDto); } // add summary $summaryDto = new Riesenia\Pohoda\Order\SummaryDto(); $summaryDto->roundingDocument = 'none'; $order->addSummary($summaryDto); // add order to import (identified by $order_number) $pohoda->addItem($order_number, $order); // finish import file $pohoda->close();
Exporting stored goods
The creation of request to export goods is realized by creating ListRequest.
use kalanis\Pohoda; $pohoda = new Pohoda('ICO'); // create request for export $pohoda->open($filename, 'e_zas1', 'Export stock'); $requestDto = new Pohoda\ListRequest\ListRequestDto(); $requestDto->type = 'Stock'; $request = $pohoda->createListRequest($requestDto); // optional filter $request->addUserFilterName( Pohoda\ListRequest\UserFilterNameDto::init('MyFilter') ); $pohoda->addItem('Export 001', $request); $pohoda->close();
The rest of the processing itself is simple - just call next and got SimpleXMLElement with entity.
// load file $pohoda->loadStock($filename); while ($stock = $pohoda->next()) { // access header $header = $stock->children('stk', true)->stockHeader; // ... }
Example of deleting stock
When you delete stock you need to create an agenda with empty data and set them delete actionType.
use kalanis\Pohoda; $pohoda = new Pohoda('ICO'); // create request for deletion $pohoda->open($filename, 'd_zas1', 'Delete stock'); $stock = $pohoda->createStock(null); $stock->addActionType('delete', [ 'code' => $code ]); $pohoda->addItem($code, $stock); $pohoda->close();
Using ValueTransformer for value update
With interface ValueTransformer you can implement the transformation, which changes all the values. Example for change all values to uppercase:
use kalanis\Pohoda; class Capitalizer implements \Riesenia\Pohoda\ValueTransformer\ValueTransformerInterface { public function transform(string $value): string { return \strtoupper($value); } } $pohoda = new Pohoda('ICO'); // Register the capitalizer to be used to capitalize values $pohoda->getTransformerListing()->addTransformer(new Capitalizer()); ...
Sources
- XML Import
- XML Export
- Schemas
- Checker - Win 32bit
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-09