Create Sales Invoice

V2 should be used when willow dimensions ase used.

Endpoints v1

Estonia:    https://aktiva.merit.ee/api/v1/sendinvoice
Poland:     https://program.360ksiegowosc.pl/api/v1/sendinvoice

Query Payload

Example payload 1: payload only

Example payload 2: PHP example with sending

FieldTypeComment 
CustomerCustomerObject
AccountingDocInt 1Values: 1 faktura, 2 rachunek, 3 paragon, 4 nodoc, 5 credit, 6 prepinvoice, 7 fincchrg, 8 delivorder, 9 grpinv
ProcCodesArray of StringsPoland only. Values:
SW, EE, TP, TT_WNT, TT_D, MR_T, MR_UZ, I_42, I_63, B_SPV, B_SPV_DOSTAWA, B_MRV_PROWIZJA, MPP, WSTO_EE, IED
PolDocTypeIntPoland only. Values: 1-RO, 2 - WEW, 3 - FP, 4 - OJPK
DocDateDate
DueDateDate
TransactionDateDate
InvoiceNoStr 35Required
RefNoStr 36If not specified, generated automatically.
Please validate this number yourself.
CurrencyCodeStr 4
DepartmentCodeStr 20If used then must be found in the company database.
ProjectCodeStr 20If used then must be found in the company database.
InvoiceRowArray of InvoiceRow objects
TaxAmountArray of VAT objectsRequired
RoundingAmountDecimal 18.2Use it for getting PDF invoice to round number. Does not affect TotalAmount.
TotalAmountDecimal 18.2Amount without VAT
PaymentPayment object
HcommentString 4KIf not specified, API will get it from client record, if it is written there.
FcommentString 4KIf not specified, API will get it from client record, if it is written there.
ContractNoString 35Contract number with operator
PDFString 4KPdf file in Base64 format

CustomerObject

3 use cases:

  1. new customer – you will create new client record when this name was not found
  2. existing customer by name – if this name exists in our system, Merit will take info from client record instead of reading it from the payload.
  3. customer by ID – every time you add new customer, the CustomerId is returned, you can use this ID instead of name, the object = { CustomerId: <guid-of-the-customer }.
ParameterTypeComment
IdGuidIf filled and customer is found in the database then following fields are not important. If not found, the customer is added using the following fields.
Name Str 150Required when customer is added
RegNoStr 30
NotTDCustomerBoolRequired when customer is added. EE True for physical persons and foreign companies. PL True for physical persons. Allowed “true” or “false” (lowercase).
VatRegNoStr 30
CurrencyCodeStr 30
PaymentDeadLineIntIf missing then taken from default settings.
OverDueChargeDecimal 5.2If missing then taken from default settings.
AddressStr 100
CityStr 30
CountyStr 100
PostalCodeStr 15
CountryCodeStr 2Required when adding
PhoneNoStr 50
PhoneNo2Str 50
HomePageStr 80
EmailStr 80
SalesInvLangStr 8Invoice language for this specific customer.(ET, EN, RU,FI,PL,SV)
RefNoBaseStr 36
EInvPaymIdStr 20
EInvOperatorInt1 - Not exist, 2 - E-invoices to the bank through Omniva, 3 - Bank ( full extent E-invoice), 4- Bank (limited extent E-invoice)
BankAccountStr 50
ContactStr 35
ApixEinvStr 20
GroupInvBool

InvoiceRowObject

Every invoice has its rows. Row has its quantity and price, it also has its general ledger record and that’s why it has its own tax calculation.

FieldTypeComment 
ItemItemObjectSometimes the volume of transactions in the sales software is very high and there is no need to duplicate all the data in accounting. In those cases, you could consider using the same item code for the items with the same VAT rate.

Items with different VAT rates must have a different item codes.

Also, for the VAT declarations to work, goods and services may not be summed up and must have different item codes.
QuantityDecimal 18.3
PriceDecimal 18.7If there is no price field, the price is searched from the sales price table
DiscountPctDecimal 18.2
DiscountAmountDecimal 18.2Amount * Price * (DiscountPCt / 100). This is not rounded. Will be substracted from row amount before row roundings.
TaxIdGuidRequired. Use gettaxes endpoint to detect the guid needed
LocationCodeStr 20Used for stock items and multiple stocks. If used then must be found in the company database.
DepartmentCodeStr 20If used then must be found in the company database.
ItemCostAmountDecimal 18.2Required for credit invoices when crediting stock items.
GLAccountCodeString 10If used, must be found in the company database.
ProjectCodeString 20If used, must be found in the company database.
CostCenterCodeString 20If used, must be found in the company database.
VatDateDate StringYYYYMMDD type date. In some countries where you have to specify VatDate.

ItemObject

FieldTypeComment 
CodeStr 20Required
DescriptionStr 150Required
More than 150 characters will be cut off
TypeInt1 = stock item, 2 = service, 3 = item. Required.
UOMNameStr 64Name for the unit
DefLocationCodeStr 20If company has more than one (default) stock, stock code in this field is required for all stock items.
GTUCodeIntPoland only, values: 1...13

PaymentObject

You can mark the invoice already paid. This is useful when you create invoice only when internet bank payment is successful, or you have received cash.

FieldTypeComment 
PaymentMethodStr 150Name of the payment method. Must be found in the company database.
PaidAmountDecimal 18.2Amount with VAT (not more) or less if partial payment
PaymDateDateYYYYmmddHHii

TaxObject

Every invoice has section of taxes. Those taxes have to be calculated grouped and summed by TaxId. Every row has its own tax calculation, you have to group and sum them up.

This is because you can have different tax rates for different articles.

API always counts it as well to assure you have correct calculation.

FieldTypeComment 
TaxIdGuidRequired. Use gettaxes endpoint to detect the guid needed
AmountDecimal 18.2

Endpoints v2

Estonia: https://aktiva.merit.ee/api/v2/sendinvoice
Poland: https://program.360ksiegowosc.pl/api/v2/sendinvoice

Query Payload

FieldTypeComment 
CustomerCustomerObject
AccountingDocInt 1Values: 1 faktura, 2 rachunek, 3 paragon, 4 nodoc, 5 credit, 6 prepinvoice, 7 fincchrg, 8 delivorder, 9 grpinv
DocDateDate
DueDateDate
TransactionDateDate
InvoiceNoStr 35Required
CurrencyCodeStr 4
CurrencyRateDecimal 18.7If the exchange rate is not included, we will take it from the EU central bank's request for the respective date
DepartmentCodeStr 20If used then must be found in the company database.
DimensionsArray of Dimensions objects
InvoiceRowArray of InvoiceRow objects
TaxAmountArray of VAT objectsRequired
RoundingAmountDecimal 18.2Use it for getting PDF invoice to round number. Does not affect TotalAmount.
TotalAmountDecimal 18.2Amount without VAT
PaymentPayment object
RefNoString 36If not specified, generated automatically.
Please validate this number yourself.
HcommentString 4KIf not specified, API will get it from client record, if it is written there.
FcommentString 4KIf not specified, API will get it from client record, if it is written there.
ReserveItemsBool
ContractNoString 35Contract number with operator
PDFString 4KPdf file in Base64 format
FileNameString 100Name of PDF file
PayerPayerObject
DeliveryTypeBool

CustomerObject

3 use cases:

  • new customer – you will create new client record when this name was not found
  • existing customer by name – if this name exists in our system, Merit will take info from client record instead of reading it from the payload
  • customer by ID – every time you add new customer, the CustomerId is returned, you can use this ID instead of name, the object = { CustomerId: <guid-of-the-customer }
FieldTypeComment
IdGuidIf filled and customer is found in the database then following fields are not important. If not found, the customer is added using the following fields.
Name Str 150Required when customer is added
RegNoStr 30
NotTDCustomerBoolRequired when customer is added. EE True for physical persons and foreign companies. PL True for physical persons. Allowed “true” or “false” (lowercase).
VatRegNoStr 30
CurrencyCodeStr 30
PaymentDeadLineIntIf missing then taken from default settings.
OverDueChargeDecimal 5.2If missing then taken from default settings.
RefNoBaseStr 36
AddressStr 100
CountryCodeStr 2Required when adding
CountyStr 100
CityStr 30
PostalCodeStr 15
PhoneNoStr 50
PhoneNo2Str 50
HomePageStr 80
EmailStr 80
SalesInvLangStr 8Invoice language for this specific customer.(ET,EN,RU,FI,PL,SV)
ContactStr 35
GLNCodeStr 10
PartyCodeStr 20
EInvOperatorInt1 - Not exist, 2 - E-invoices to the bank through Omniva, 3 - Bank ( full extent E-invoice), 4- Bank (limited extent E-invoice)
EInvPaymIdStr 20
BankAccountStr 50
DimensionsArray of DimensionsObjects
CustGrCodeStr 20
ShowBalanceBool
ApixEinvStr 20
GroupInvBool

InvoiceRowObject

Every invoice has its rows. Row has its quantity and price, it also has its general ledger record and that’s why it has its own tax calculation.

FieldTypeComment 
ItemItemObjectSometimes the volume of transactions in the sales software is very high and there is no need to duplicate all the data in accounting. In those cases, you could consider using the same item code for the items with the same VAT rate.

Items with different VAT rates must have a different item codes.

Also, for the VAT declarations to work, goods and services may not be summed up and must have different item codes.
QuantityDecimal 18.3
PriceDecimal 18.7If there is no price field, the price is searched from the sales price table
DiscountPctDecimal 18.2
DiscountAmountDecimal 18.2Amount * Price * (DiscountPCt / 100). This is not rounded. Will be substracted from row amount before row roundings.
TaxIdGuidRequired. Use gettaxes endpoint to detect the guid needed
LocationCodeStr 20Used for stock items and multiple stocks. If used then must be found in the company database.
DepartmentCodeStr 20If used then must be found in the company database.
GLAccountCodeString 10If used, must be found in the company database.
DimensionsArray of DimensionsObjects
ItemCostAmountDecimal 18.2Required for credit invoices when crediting stock items.
VatDateDate StringYYYYMMDD type date. In some countries where you have to specify VatDate.

ItemObject

FieldTypeComment
CodeStr 20Required
DescriptionStr 150Required
More than 150 characters will be cut off
TypeInt1 = stock item, 2 = service, 3 = item. Required.
UOMNameStr 64Name for the unit
DefLocationCodeStr 20If company has more than one (default) stock, stock code in this field is required for all stock items.
GTUCodeIntPoland only, values: 1...13
SalesAccCodeStr 10Can only be used when creating new stock items
PuchaseAccCodeStr 10Can only be used when creating new stock items
InventoryAccCodeStr 10Can only be used when creating new stock items
CostAccCodeStr 10Can only be used when creating new stock items

PaymentObject

You can mark the invoice already paid. This is useful when you create invoice only when internet bank payment is successful, or you have received cash.

FieldTypeComment 
PaymentMethodStr 150Name of the payment method. Must be found in the company database.
PaidAmountDecimal 18.2Amount with VAT (not more) or less if partial payment
PaymDateDateYYYYmmddHHii

TaxObject

Every invoice has section of taxes. Those taxes have to be calculated grouped and summed by TaxId. Every row has its own tax calculation, you have to group and sum them up.

This is because you can have different tax rates for different articles.

API always counts it as well to assure you have correct calculation.

FieldTypeComment 
TaxIdGuidRequired. Use gettaxes endpoint to detect the guid needed
AmountDecimal 18.2

DimensionsObject

FieldTypeComment
DimIdInt
DimValueIdGuid
DimCodeStr

PayerObject

FieldTypeComment
IdGuidIf filled and payer (customer) is found in the database then following fields are not important. If not found, the payer is added using the following fields.
Name Str 150Required when payer is added
RegNoStr 30
NotTDCustomerBoolRequired when payer is added. True for physical persons and foreign companies. Allowed “true” or “false” (lowercase).
VatRegNoStr 30
CurrencyCodeStr 30
PaymentDeadLineIntIf missing then taken from default settings.
OverDueChargeDecimal 5.2If missing then taken from default settings.
RefNoBaseStr 36
AddressStr 100
CountryCodeStr 2Required when adding
CountyStr 100
CityStr 30
PostalCodeStr 15
PhoneNoStr 50
PhoneNo2Str 50
HomePageStr 80
EmailStr 80
SalesInvLangStr 8Invoice language for this specific payer.(ET,EN,RU,FI,PL,SV)
ContactStr 35
GLNCodeStr 10
PartyCodeStr 20
EInvOperatorInt1 - Not exist, 2 - E-invoices to the bank through Omniva, 3 - Bank ( full extent E-invoice), 4- Bank (limited extent E-invoice)
EInvPaymIdStr 20
BankAccountStr 50
DimensionsArray of DimensionsObjects
CustGrCodeStr 20
ShowBalanceBool

Successful Result

  • CustomerId
  • InvoiceId
  • InvoiceNo
  • RefNo
  • NewCustomer