Prva stranica 
Natrag 
Naprijed 
Novosti 
 Kopiraj URL stranice 
 
Natisni stranNatisni stran  
e-računi upute za uporabu  >  Internetske usluge i in...  >  API Reference  >  SalesInvoice API

SalesInvoice API

Please check API reference documentation for the SalesInvoiceAPI here https://e-racuni.hr/rhr/ApiDocumentation https://e-racuni.hr/rhr/ApiDocumentation.

SalesInvoiceAPI exposes the functionality of the invoicing GUI to developer. Most of invoice editing features are available via API methods in this category. The API user account needs to own the same privileges as the regular GUI to get access to features via the API.

Below you will find examples on how to use the invoicing API.

Creating a simple invoice

Here is a simple example on how to create an invoice with two items using JSON API request. The item price is given as net price excluding VAT which will be added automatically using the general VAT rate.

POST https://e-racuni.com/WebServicesHR/API
Content-Type: application/json

{
       "username": "IVAN",
       "md5pass": "1234567890a1c85dc0c1234218acb900",
       "token": "1234562ADC3A123001234D00B0C71E0EC",
       "method": "SalesInvoiceCreate",
       "parameters": {
               "SalesInvoice": {
                       "dateOfSupplyFrom": "2022-10-13",
                       "buyerName": "Ivan Novak",
                       "buyerStreet": "Ilica 123",
                       "buyerPostalCode": "10000",
                       "buyerCity": "Zagreb",
                       "buyerEMail": "ivan.novak@gmail.com",
                       "buyerPhone": "01/1234567",
                       "Items": [
                               {
                                   "description": "Usluga jedan",
                                   "quantity": 5.0,
                                   "unit": "sat",
                                   "netPrice": 100.0
                               },
                               {
                                   "description": "Usluga dva",
                                   "quantity": 3,
                                   "unit": "sat",
                                   "netPrice": 50.0
                               }
                       ]
               }
       }
}


Creating a fiscalized invoice

In order to issue a fiscalized invoice you need to ensure that you have previously correctly setup and activated a fiscalized business unit and the master settings of the application. Also check the list of payment methods available for invoicing.

Example below shows how to make a fiscalized invoice for a received Stripe payment. The invoice is of type Retail  which means that price is meant to be the final price paid by the customer (price including all taxes).

POST https://e-racuni.com/WebServicesHR/API
Content-Type: application/json

{
       "username": "IVAN",
       "md5pass": "1234567890a1c85dc0c1234218acb900",
       "token": "1234562ADC3A123001234D00B0C71E0EC",
       "method": "SalesInvoiceCreate",
       "parameters": {
               "SalesInvoice": {
                       "dateOfSupplyFrom": "2022-10-13",
                       "buyerName": "Ivan Novak",
                       "buyerEMail": "ivan.novak@gmail.com",
                       "type": "Retail",
                       "methodOfPayment": "Stripe",
                       "businessUnit": "0000",
                       "Items": [
                               {
                                       "description": "Test item for purchase, general VAT rate",
                                       "quantity": 1.0,
                                       "unit": "kom",
                                       "price": 100.0
                               },
                               {
                                       "description": "Test item for purchase, lower VAT rate",
                                       "quantity": 1.0,
                                       "unit": "kom",
                                       "price": 250.0,
                                       "vatPercentage": 13
                               },
                               {
                                       "description": "Test item for zero rated services to EU (VAT reverse charge)",
                                       "quantity": 1.0,
                                       "unit": "kom",
                                       "price": 100.0,
                                       "vatTransactionType": "16"
                               }
                       ]
               }
       }
}


Fiscalization of invoices is completely automatic and is outside of control of the user or the API. Based on tax regulations the application will automatically fiscalize and report all invoices that need fiscalization to the tax office

Creating an invoice for selling products

If you have defined a master list of products and pricing for the products, then you can create invoice simply by specifying product code (SKU) and quantity. See example below:

POST https://e-racuni.com/WebServicesHR/API
Content-Type: application/json

{
       "username": "IVAN",
       "md5pass": "1234567890a1c85dc0c1234218acb900",
       "token": "1234562ADC3A123001234D00B0C71E0EC",
       "method": "SalesInvoiceCreate",
       "parameters": {
               "SalesInvoice": {
                       "dateOfSupplyFrom": "2022-10-13",
                       "buyerName": "Ivan Novak",
                       "buyerEMail": "ivan.novak@gmail.com",
                       "Items": [
                               {
                                   "productCode": "0000100",
                                   "quantity": 1.0
                               },
                               {
                                   "productCode": "0000240",
                                   "quantity": 1.0
                               }
                       ]
               }
       }
}


Be aware that issuing of invoice might fail if the products are not on stock and company settings are set to deny negative stock quantities on the warehouse. Issuing an invoice with stock tracking item will also trigger automatic issuing of delivery note on a warehouse associated with the invoice.

Printing invoices/Downloading of invoice PDF

Once the invoice is issued you can get the PDF of the invoice by specifying the invoice date and number or by specifying the invoice document ID which is returned in response of the SalesInvoiceCreate API call. Example:

POST https://e-racuni.com/WebServicesHR/API
Content-Type: application/json

{
       "username": "IVAN",
       "md5pass": "1234567890a1c85dc0c1234218acb900",
       "token": "1234562ADC3A123001234D00B0C71E0EC",
       "method": "SalesInvoiceGetPDF",
       "parameters": {
               "documentID": "60:3913326"
       }
}


In the example above, the PDF of the invoice will be returned as part of the JSON response with BASE64 encoding. If you want to download PDF more efficiently then you should directly download PDF by setting the method parameter downloadFile  to true. Example of API call using curl to directly download PDF from command line:

curl -OJ https://e-racuni.com/WebServicesHR/API-CLI/SalesInvoiceGetPDF \
 -u IVAN:12345678C3A70D0012312312312312_12312312312312312312312 \
 -d documentID='"60:3913326"' \
 -d downloadFile=true


Notes on API invoicing context

In order to create an invoice you need to either pre-set the user account with the context of the invoice or specify the context via the API call.

The invoicing context is defined by:

fiscal yearyou need to specify fiscal year if you are issuing invoices outside of the current fiscal year
business unitif multiple business units are defined, then the BU of the account will be used, or you need to specify the BU with your API call
cost center/cost positionif cost centers are used the default cost center will be set if not specified by the API call
warehouseif multiple warehouses are available the default WH of the BU/CC will be used if not specified by the API call. The warehouse determines the type of the invoice regarding pricing, either Retail (B2C) where VAT is included in the price, or Gross (B2B) with pricing excluding VAT.
currencydefault FY currency will be used as invoicing currency if not specified by the API call

Reference na stran

---
Zadnja sprememba 10.10.2023 11:34:57
© E-RAČUNI d.o.o. 2003-2024