kigkonsult/sie5sdk

Sie5 SDK, based on Sie5 XSD schema

Fund package maintenance!
Other

v1.4 2021-11-24 16:22 UTC

This package is auto-updated.

Last update: 2024-10-24 22:21:09 UTC


README

  • the PHP SDK for the Sie5 export/import formats
  • manages accounting, book-keeping, ledger, asset, inventory data etc
  • based on the Sie5 XSD schema

and provide

Usage, parse XML

Sie5Sdk uses XMLReader parsing input and accepts Sie and SieEntry root elements.

To parse an export Sie XML file :

<?php
namespace Kigkonsult\Sie5Sdk;
use Kigkonsult\Sie5Sdk\XMLParse\Sie5Parser;

$sie = Sie5Parser::factory()->parse( 
    file_get_contents( 'SieExportFile.xml' )
);

foreach( $sie->getAccounts()->getAccount() as $account ) {
    $id = $account->getId();
    //...
}
//...

To parse an import SieEntry XML file :

<?php
namespace Kigkonsult\Sie5Sdk;
use Kigkonsult\Sie5Sdk\XMLParse\Sie5Parser;

$sieEntry = Sie5Parser::factory()->parse( 
    file_get_contents( 'SieImportFile.xml' )
);

foreach( $sieEntry->getAccounts()->getAccount() as $account ) {
    $id = $account->getId();
    //...
}
//...

The XML parser save the XMLreader node properties (baseURI, localName, name, namespaceURI, prefix) for each XML (Dto) element as 'XMLattributes' as well as XML attributes (xmlns, xmlns:*, schemaLocation), if set.

Usage, build up structure

To build up import SieEntry structure:

<?php
namespace Kigkonsult\Sie5Sdk;
use Kigkonsult\Sie5Sdk\XMLWrite\Sie5Writer;
use Kigkonsult\Sie5Sdk\Dto\SieEntry;
use Kigkonsult\Sie5Sdk\Dto\AccountsTypeEntry;
use Kigkonsult\Sie5Sdk\Dto\AccountTypeEntry;

$sieEntry = sieEntry::factory()
    ->setXMLattribute( SieEntry::XMLNS_XSI,          SieEntry::XMLSCHEMAINSTANCE )
    ->setXMLattribute( SieEntry::XMLNS_XSD,          SieEntry::XMLSCHEMA )
    ->setXMLattribute( SieEntry::XSI_SCHEMALOCATION, SieEntry::SIE5SCHEMALOCATION )
    ->setXMLattribute( SieEntry::XMLNS,              SieEntry::SIE5URI );

    ->setAccounts( 
        AccountsTypeEntry::factory()
            ->setAccount(
                [
                    AccountTypeEntry::factory()
                        ->setId( '1910' )
                        ->setName( 'Kassa' )
                        ->setType( AccountTypeEntry::ASSET ),
                    AccountTypeEntry::factory()
                        ->setId( '1930' )
                        ->setName( 'Bank' )
                        ->setType( AccountTypeEntry::ASSET )
                ]
            )
    )
    ->set...
    
$XMLstring = Sie5Writer::factory()->write( $sieEntry );
...
XML attributes

You may also set XMLattribute(s) (explicitly, NOT required if rewriting a parsed sie xml file) using

$sieEntry->setXMLAttribut( <key>, <value> );

To set (ex. prefix) and 'propagate' down in hierarchy:

$sieEntry->setXMLAttribut( SieEntry::PREFIX, <value>, true );

You can remove (single 'element') XMLattribute using

$dsig->unsetXMLAttribut( <key> );

To unset (ex. prefix) and 'propagate' down in hierarchy:

$sieEntry->unsetXMLAttribut( SignatureType::PREFIX, true );

To fetch and iterate over XMLAttributes

foreach( $sieEntry->getXMLAttributes() as $key => $value {
    ...
}

Usage, output as XML

Sie5Sdk uses XMLWriter creating output.

$XMLstring = Sie5Writer::factory()->write( $sieEntry );

The XMLwriter adds for (each) element

  • element name with prefix, is exists
  • XMLattribute xmlns, xmlns:* and schemaLocation, if exists.

Usage, output as DomNode

$domNode = Sie5Writer::factory()->write( $sieEntry, true );

Info

Sie5Sdk require PHP7+.

For class structure, architecture and usage, please examine

You may find convenient constants in

Sie5Sdk uses

Sie5Sdk support attribute extensions in the elements

  • Account, Company, CustomerInvoice, Customer, FileInfo, FixedAsset, GeneralObject, JournalEntry, LedgerEntry, Supplier

Installation

Composer, from the Command Line:

composer require kigkonsult/sie5sdk

Composer, in your composer.json:

{
    "require": {
        "kigkonsult/sie5sdk": "dev-master"
    }
}

Version 1.4 supports PHP 8.0, 1.2 7.4, 1.1 7.0.

Acquire access

namespace Kigkonsult\Sie5Sdk;
...
include 'vendor/autoload.php';

Otherwise , download and acquire..

namespace Kigkonsult\Sie5Sdk;
...
include 'pathToSource/sie5sdk/autoload.php';

Sponsorship

Donation using paypal.me/kigkonsult are appreciated. For invoice, please e-mail.

Support

For support, please use Github/issues.

For Sie XSD issues, go to Sie homepage.

License

This project is licensed under the LGPLv3 License