The accounting system can be easily connected to various systems, and one of the most common integrations is with e-commerce stores. This guide will show you how to do it.
This guide is intended for developers implementing the integration and assumes familiarity with the basics of APIs (at minimum, a PHP example).
In general, the integration consists of the following parts:
Catalog export
Order creation
Pricing
Additional product catalog information
Other code lists
VAT considerations
Catalog export from Flexi
Catalog integration can be implemented in two ways:
Online – a query is made to Flexi on every client visit and the request is fulfilled (often combined with caching)
Synchronization-based – the e-shop has its own database into which the catalog is regularly synchronized
This guide covers the first approach. It can sometimes be implemented by having the e-shop download the entire catalog once overnight and then serve requests from its local copy.
Catalog export
First, we retrieve the list of products:
curl -u winstrom:winstrom -f -L "http://demo.flexibee.eu:5434/c/demo/cenik/(exportNaEshop=true).xml?detail=custom:nazev,kod,skupZboz,sumStavMj,cenaBezna,mj1,cenaZaklBezDph,cenaZaklVcDph,zaruka,mjZarukyK,popis,cenJednotka,eanKod,kratkyPopis,klicSlova,techParam,dodaciLhuta,mjDodaciLhuta&relations=poplatky,prilohy,prislustenstvi,atributy,podobne-zbozi&limit=0"
If you want to display only items that are in stock (or non-stocked items), use the following:
curl -u winstrom:winstrom -f -L "http://demo.flexibee.eu:5434/c/demo/cenik/(exportNaEshop=true and (sumStavMj gt 0 or skladove=false)).xml?detail=custom:nazev,kod,skupZboz,mj1,cenaZaklBezDph,cenaZaklVcDph,szbDph,zaruka,mjZarukyK,kratkyPopis,klicSlova,techParam,dodaciLhuta,mjDodaciLhuta&relations=poplatky,prilohy,prislustenstvi,atributy,podobne-zbozi&limit=0"
Note: this view includes items from all warehouses; it can also be restricted to specific warehouses via the stock card.
This also loads related objects such as fees, attachments, accessories, attributes, and similar products. Only publish attachments that are marked as exportNaEshop=true. You can also load all attachments as follows:
curl -u winstrom:winstrom -f -L "http://demo.flexibee.eu:5434/c/demo/prilohy/(exportNaEshop=true and cenik is not empty).xml?detail=full&limit=0"
If you want to work with the tree structure of the price list, first retrieve the tree nodes:
curl -u winstrom:winstrom -f -L "http://demo.flexibee.eu:5434/c/demo/strom/(strom='code:STR_CEN').xml?limit=0&detail=full"
and then the placement of price list items within the tree:
curl -u winstrom:winstrom -f -L "http://demo.flexibee.eu:5434/c/demo/strom-cenik.xml?limit=0&detail=full"
Order creation
Once a client places an order, a document must be created in Flexi. The key question is whether to create an order, a payment request (non-tax document), or an invoice (tax document). E-commerce stores always use the term "order." However, incoming payments in Flexi cannot be matched directly to an order, which is why orders in Flexi are generally not used for e-commerce stores.
Typically, an invoice is not created immediately — only a payment request is issued. The reason is that with an invoice, you are required to remit VAT even if payment has not been received. Additionally, in double-entry bookkeeping, unpaid invoices must also be recognized as revenue and taxed.
In the case of prepayment or cash on delivery, an invoice is typically created; for bank transfer payments, a payment request is created.
When importing data for a payment request, advance tax document, credit note, debit note, or invoice, these are always handled as an issued invoice.
What distinguishes them is the document type, which determines the type of document.
When a new company (database) is created, several default document types are set up. The document type determines whether the document is an accounting or non-accounting document, as well as the number series
into which the document will be placed (overview of document type options).
Document posting is controlled by the posting template (which can also be specified in the document type; however, a payment request does not require posting).
Setting up the "payment request" document type
To configure a payment request, you must set the following:
Select the type "proforma"
Uncheck "Document is an accounting document"
Select or create a new document series
Abbreviation: will be used when creating the document type
Name: will be used as the document heading
Additional settings such as account, payment method, due date, etc. can also be configured
When creating an invoice, you need to clarify a few things:
Price list item or custom price and quantity? When creating a document, you can use an item from the price list, optionally dispatch it from stock, apply the default price (including various partner discounts), or create a custom line item.
Currency: will it be in CZK or a foreign currency?
Recipient: will you use a recipient from the address book, or specify the details directly on this invoice only?
Customer identification
Flexi includes a customer address book. Some e-commerce stores make use of it; others do not. A created document can be linked to the address book, or all details can be entered directly on the document without any link. The decision depends on the preferences of the e-shop owner. Sales analysis relies on address book links, and without them, analysis by company or company group will not be possible.
Creating an address book entry if it does not already exist
<?xml version="1.0" encoding="utf-8"?><winstrom version="1.0"> <!-- pokud položka adresáře existuje, doplníme naše ID z eshopu. Pokud klient nemá IČO a DIČ, záznam je zbytečný. Pokud záznam existuje, neměníme jej. --> <adresar create="ignore"> <id>ext:ESHOP:1</id> <id>in:123</id> <id>vatId:CZ123</id> </adresar> <!-- pokud položka adresáře neexistuje, založíme ji a vyplníme další hodnoty --> <adresar update="ignore"> <id>ext:ESHOP:1</id> <id>in:123</id> <id>vatId:CZ123</id> <ic>123</ic> <dic>CZ123</dic> <nazev>Moje Firma s.r.o.</nazev> <ulice>Lochotínská 18</ulice> <tel>123/456 789</tel> <email>123/456 789</email> <stat>code:CZ</stat> <platceDph>true</platceDph> </adresar></winstrom>
For identification, you can use the ID (primary key), company registration number (IČO), or code (more about identifiers).
XML example
Now we will create a new document:
<?xml version="1.0" encoding="utf-8"?><winstrom version="1.0"> <faktura-vydana> <!-- ID, které jednoznačně identifikuje výzvu k platbě. Slouží při opakovaném importu --> <id>ext:ESHOP:1</id> <typDokl>code:FAKTURA</typDokl> <!-- identifikátor firmy, které posíláme výzvu k platbě --> <firma>[ext:ESHOP:1][in:123][vatId:CZ123]</firma> <!-- přímo uvedené kontaktní údaje. Není nutné vyplnit, pokud se mají použít hodnoty z adresáře --> <kontaktJmeno>Jan Novák</kontaktJmeno> <kontaktEmail>jan.novak@seznam.cz</kontaktEmail> <kontaktTel>123/456 789</kontaktTel> <nazFirmy>Moje Firma s.r.o.</nazFirmy> <ulice>Moje Firma s.r.o.</ulice> <stat>code:CZ</stat> <polozkyFaktury> <PolFak> <cenik>code:ZBOZI</cenik> <typPolozkyK>typPolozky.katalog</typPolozkyK> <mnozMj>1</mnozMj> </PolFak> </polozkyFaktury> </faktura-vydana></winstrom>
The invoice is then submitted as follows (more about command-line calls):
curl -u winstrom:winstrom -f -L http://demo.flexibee.eu:5434/c/demo/faktura-vydana.xml -T faktura.xml
The resulting document must be sent to the customer (either manually or via Flexi).
Additional contact details
Sometimes you need to include additional contact details on a document. The following document fields are available for this purpose:
kontaktJmenokontaktEmailkontaktTelkontaktOsoba– a link to the list of contact persons. Not required. When used, the other fields will be populated automatically.
Pricing
Each price list item has a defined price excluding VAT and including VAT. If you specify a price when creating an order/invoice, Flexi will honor it. If you do not specify a price, Flexi will automatically calculate it based on the advanced pricing rules. In most cases, the price displayed to the customer must also be reflected on the invoice.
Individual pricing for B2B
If you use advanced pricing and want the e-shop to apply it (typically in the case of wholesale sales, i.e., B2B), we have created an individual price list for this purpose.
curl -u winstrom:winstrom -f -L "http://demo.flexibee.eu:5434/c/demo/individualni-cenik.xml?limit=0&detail=full"
Additional product catalog information
Key attributes relevant to e-commerce stores:
Attributes
Attributes enable parametric product information (e.g., screen diagonal in inches), which can then be used for product comparisons.
Similar products
A list of products that serve as alternatives to the current item (e.g., from a different manufacturer).
Accessories
A list of products that complement the current item (e.g., consumables, add-on accessories).
Sets and bundles
In some cases, an entire set is sold at a discounted price (e.g., a bicycle + pump). When a set is added to an order, the individual components are dispatched from stock.
Price list item statuses
Sometimes you want to mark a product as new, on promotion, or on clearance. A single product can therefore have multiple statuses, each of which you can assign a meaning.
Other code lists
Shipping method
curl -u winstrom:winstrom -f -L "http://demo.flexibee.eu:5434/c/demo/forma-dopravy.xml?limit=0&detail=full"
Payment method
curl -u winstrom:winstrom -f -L "http://demo.flexibee.eu:5434/c/demo/forma-uhrady.xml?limit=0&detail=full"
VAT considerations
Flexi includes built-in VAT rates, and each item indicates whether it falls under the reduced or standard rate. When issuing a document to a foreign recipient, the applicable VAT treatment is automatically determined based on the recipient's country (e.g., EU VAT-registered entities are invoiced without VAT, EU non-VAT-registered entities are invoiced with VAT, etc.).
If your company is VAT-registered in multiple countries, please contact Flexi technical support.
