Create accounting document


post https://api.trivi.com/v2/accountingdocuments

The accounting document will be set to a state based on your organization settings.

Currently we support these two workflows:

  • Direct processing - it will be processed in the standard period (approx. 15 minutes)
  • Approval - it will be set to "Waiting For Approval" state and someone has to approve it manually or you can move it to the final state via API

Calculations

Trivi Public API provides calculations on some fields. We can calculate total, totalVatExcl and vatRecap from lineItems or we can do partial calculations on some conditions:

VAT payer total filled totalVatExcl filled VAT recap filled calculations
Yes Yes Yes Yes None
Yes No No No vatRecap, total, totalVatExcl
No Yes Yes Yes None
No No No No vatRecap, total, totalVatExcl
No Yes Yes No vatRecap

VAT payer means that contact.taxId is filled

You don't have to use calculations. You can provide us whole information, i.e. vatRecap, total and totalVatExcl. In this case, we skip calculations.

Line Items Calculations

There is 5 fields that we can calculate. unitPrice, unitPriceVatExcl, total, totalVatExcl and vatValue. You can provide us all values or one of them (excep vatValue). In this case, other fields are calculated.

Accounting document types and required fields

If type is CashRegister or SimplifiedInvoice, cashRegisterId is required but contact is optional.

VAT Rates

VAT rates can be assigned to line items. Check GET /vatrates endpoint for available VAT rates. They are assigned either by vatRateId or by a unique combination of vatRate and vatRateType properties. If vatRate and vatRateType combination is not unique among GET /vatrates use the vatRateId property.

Body
AccountingDocument
id
integer   optional

Only in GET

Format int64
sequenceId
integer   optional

An accounting document number sequence ID.

Format int64
accountingDocumentNo
string   optional

Only in GET

The number of the account document.

cashRegisterId
integer   optional

If set, the accounting document is placed in a given cash register. This is required for CashReceipt, SimplifiedInvoice, EmployeeAdvance, CashTransfer and CashUncategorized types

Format int64
type
integer   optional

Possible values: Invoice = 0, Advance = 1, TaxAdvance = 2, CreditNote = 3, CashReceipt = 7, SimplifiedInvoice = 8, EmployeeAdvance = 10, CashTransfer = 11, CashUncategorized = 12

issueDate
string   optional
Format date
dueDate
string   optional
Format date
bookingDate
string   optional
Format date
taxDate
string   optional
Format date
taxReturnDate
string   optional
Format date
direction
integer   optional

Possible values: 0 - Received, 1 - Issued

externalNo
string   optional
exchRate
number   optional

Set automatically tu null when accounting document currency and organization currency are the same.

Format double
vatExchRate
number   optional
Format double
sadExchRate
number   optional
Format double
specificSymbol
string   optional
variableSymbol
string   optional
constSymbol
string   optional
currency
string   required

ISO 4217

payments
AccountingDocumentPaymentInfo   optional
orderNo
string   optional

Order number, can be any string

contact
AccountingDocumentContact   optional
paymentType
integer   optional

Possible values:

BankTransfer = 1, Cash = 2, CashOnDelivery = 3, PaymentCard = 4, SetOff = 5, Loan = 6

CashReceipt accepts correctly Cash = 2 only. Behavior is undefined for other values.

Bank accounts assigned to this accounting document

processingState
number   optional

Only in GET If Trivi processed this accounting document, values: 0 - Not Processed, 1 - Processed, 2 - Waiting For Processing 3 - Processing Error

processingMessage
string   optional

Only in GET

countryVariantSpecific
object   optional

Contains properties which are specific only to some countries

total
number   optional

In POST or PUT If not set, it is calculated from line items.

Format double
totalVatExcl
number   optional

In POST or PUT If not set, it is calculated from line items.

Format double
description
string   optional

A description of this accounting document

explicitNo
string   optional

If not given and sequenceId is filled by a valid sequence ID, it will be generated. If given, sequenceId has to be empty and this number will be used as accountingDocumentNo

creditNoteDescription
string   optional

A reason of the credit note, this is used only if type is Credit Note

state
string   optional

User-defined state defined in a workflow

vatRecapCalculationMode
number   optional

0 - StartFromVatExcluded, 1 - StartFromVatIncluded, 2 - Manually If AccountingDocument.type is CashReceipt, CashUncategorized, EmployeeAdvance or CashTransfer, this field have to be set to Manually

Default 0
categoryName
string   optional

Only in GET

categoryId
integer   optional
Format int64
preferredBranch
string   optional
preferredProject
string   optional
roundingType
integer   optional

1 - None, 2 - RoundNearest, 3 - Round Up, 4 - Round Down

Default 1
relatedAccountingDocumentId
integer   optional

Indicates that the accounting document is related to another. It is used when there is a cash payment on an accounting document. The CashReceipt accounting document is created and relatedAccountingDocumentId is set to the paid accounting document.

Format int64
relatedAccountingDocumentNo
string   optional

Only in GET

exchRateDefault
number   optional

Only in GET

Format double
authorName
string   optional

Only in GET

totalVatAmount
number   optional

Only in GET

Format double

Only in GET List of attached scans

vatCountryType
integer   required

Enum: 1 - Domestic, 2 - EU, 3 - Foreign

creditNoteDelayedVat
boolean   optional
Default False
signatureId
integer   optional

In general, only non-deleted signature is allowed.

If the request doesn't change current value it can be even the deleted one.

Format int64
connectableAmount
number   optional

Only in GET

Returned only if scope=CA is queried.

Format double
roundingAmount
number   optional

Only in GET

Format double
language
AccountingDocumentLanguage   optional
amountPaid
number   optional

Only in GET

Sum of all payments paired with the Accounting Document.

amountDrawn
number   optional

Only in GET

Sum of amount drawn from the Accounting Document via connections.

vatPaymentMode
VatPaymentMode   optional
accountingDocumentNoPreview
string   optional

Only in GET

variableSymbolPreview
string   optional

Only in GET

VatPaymentMode
AccountingDocumentNote
uniqueId
string   optional

UUID

authorUniqueId
string   required

UUID

Only in GET

authorName
string   optional

Only in GET

createdTime
string   optional

Only in GET

Format date-time
updatedTime
string   optional

Only in GET

Format date-time
type
integer   optional

1 - Default

text
string   optional
AccountingDocumentPrintingInfo
lineItemsHeader
string   optional
lineItemsFooter
string   optional
headerNote
string   optional
footerNote
string   optional
language
AccountingDocumentLanguage   optional
AccountingDocumentBankAccount
number
string   optional
bankCode
string   optional
iban
string   optional
swift
string   optional
bankAccountId
integer   optional

Issued Accounting Document Required, other properties will be ignored

Received Accounting Document This is not allowed

Format int64
localId
string   optional

Only in GET GUID

AccountingDocumentPaymentInfo

Only in GET

paidConfirmed
boolean   optional

Only in GET

paid
boolean   optional
Default False
AccountingDocumentPayment
id
integer   optional
Format int64
amount
number   optional
Format double
currency
string   optional
domesticAmount
number   optional
Format double
domesticCurrency
string   optional
cashRegisterId
integer   optional
Format int64
direction
integer   optional

0 - Received, 1 - Issued

date
string   optional
Format date
type
number   optional

BankTransfer = 1, Cash = 2, CashOnDelivery = 3, PaymentCard = 4, SetOff = 5, Loan = 6

AccountingDocumentLineItem
id
string   optional

Only in GET Guid

description
string   optional
finAccount
string   optional
unitPrice
number   optional

Unit Price VAT incl.

Format double
unitName
string   optional
qt
number   optional
Format double
total
number   optional

Total VAT incl.

Format double
totalVatExcl
number   optional

Total VAT excluded

Format double
reverseChargeCode
string   optional

If empty, reverse charge is not applied to this line item

storeItemId
integer   optional
Format int64
unitPriceVatExcl
number   optional

Unit price VAT excluded

Format double
vatValue
number   optional

VAT value in the accounting document currency

Format double
vatRate
number   optional

Ignored on input when vatRateId populated.

Same as VatRate.vatRate from GET /vatrates.

Format double
vatRateType
number   optional

Ignored on input when vatRateId populated.

Same as VatRate.vatRateType from GET /vatrates.

vatRateId
integer   optional

vatRate and vatRateType ignored if vatRateId populated.

Same as VatRate.vatRateId from GET /vatrates.

Format int64
branch
string   optional
project
string   optional
vatDeduction
boolean   optional

Valid for received Accounting Documents only.

greenboxFinancialAccountStatus
integer   optional

1 - NotClassified

2 - CheckNeeded

3 - Classified

countryVariantSpecific
cz
object   optional
cz
eet
object   optional
eet
use
boolean   optional

In POST or PUT, if this is true, leave fik, bkp and pkp empty.

fik
string   optional
bkp
string   optional
pkp
string   optional
operation
string   optional

Only in GET Last sent operation: send_eet, cancel_eet

AccountingDocumentVatRecapLine
vatRate
number   required
Format double
base
number   optional
Format double
vatAmount
number   optional
Format double
total
number   optional
Format double
vatRateType
number   optional

1 - Standard, 2 - Out of VAT (cz: Mimo DPH), 3 - DoNotApplyVat (cz: Neuplatnit DPH), 4 - Reverse Charge, 5 - ExemptFromVAT (cz: osvobozeno od DPH)

AccountingDocumentExpectedPayment
transactionId
string   required
expectedAmount
number   optional
Format double
expectedCurrency
string   optional
AccountingDocumentContact
contactId
integer   optional

If set, the accounting document will be paired to this contact. If other contact properties are empty, they will be loaded from contact, otherwise they will be used as posted. The contact will not be changed.

Format int64
firstname
string   optional
lastname
string   optional
companyRegNo
string   optional
companyName
string   optional
taxId
string   optional
city
string   optional
street
string   optional
country
string   optional
zipCode
string   optional
email
string   optional
externalId
string   optional

Can be used if a contact doesn't have companyRegNo

AccountingDocumentLanguage
CS
string   optional
EN
string   optional
DE
string   optional
AccountingDocumentScan
guid
string   optional

GUID

size
integer   optional

In bytes

fileId
integer   optional
Format int64
filename
string   optional

Only in GET

AccountingDocument
id
integer   optional

Only in GET

Format int64
sequenceId
integer   optional

An accounting document number sequence ID.

Format int64
accountingDocumentNo
string   optional

Only in GET

The number of the account document.

cashRegisterId
integer   optional

If set, the accounting document is placed in a given cash register. This is required for CashReceipt, SimplifiedInvoice, EmployeeAdvance, CashTransfer and CashUncategorized types

Format int64
type
integer   optional

Possible values: Invoice = 0, Advance = 1, TaxAdvance = 2, CreditNote = 3, CashReceipt = 7, SimplifiedInvoice = 8, EmployeeAdvance = 10, CashTransfer = 11, CashUncategorized = 12

issueDate
string   optional
Format date
dueDate
string   optional
Format date
bookingDate
string   optional
Format date
taxDate
string   optional
Format date
taxReturnDate
string   optional
Format date
direction
integer   optional

Possible values: 0 - Received, 1 - Issued

externalNo
string   optional
exchRate
number   optional

Set automatically tu null when accounting document currency and organization currency are the same.

Format double
vatExchRate
number   optional
Format double
sadExchRate
number   optional
Format double
specificSymbol
string   optional
variableSymbol
string   optional
constSymbol
string   optional
currency
string   required

ISO 4217

payments
AccountingDocumentPaymentInfo   optional
orderNo
string   optional

Order number, can be any string

contact
AccountingDocumentContact   optional
paymentType
integer   optional

Possible values:

BankTransfer = 1, Cash = 2, CashOnDelivery = 3, PaymentCard = 4, SetOff = 5, Loan = 6

CashReceipt accepts correctly Cash = 2 only. Behavior is undefined for other values.

Bank accounts assigned to this accounting document

processingState
number   optional

Only in GET If Trivi processed this accounting document, values: 0 - Not Processed, 1 - Processed, 2 - Waiting For Processing 3 - Processing Error

processingMessage
string   optional

Only in GET

countryVariantSpecific
object   optional

Contains properties which are specific only to some countries

total
number   optional

In POST or PUT If not set, it is calculated from line items.

Format double
totalVatExcl
number   optional

In POST or PUT If not set, it is calculated from line items.

Format double
description
string   optional

A description of this accounting document

explicitNo
string   optional

If not given and sequenceId is filled by a valid sequence ID, it will be generated. If given, sequenceId has to be empty and this number will be used as accountingDocumentNo

creditNoteDescription
string   optional

A reason of the credit note, this is used only if type is Credit Note

state
string   optional

User-defined state defined in a workflow

vatRecapCalculationMode
number   optional

0 - StartFromVatExcluded, 1 - StartFromVatIncluded, 2 - Manually If AccountingDocument.type is CashReceipt, CashUncategorized, EmployeeAdvance or CashTransfer, this field have to be set to Manually

Default 0
categoryName
string   optional

Only in GET

categoryId
integer   optional
Format int64
preferredBranch
string   optional
preferredProject
string   optional
roundingType
integer   optional

1 - None, 2 - RoundNearest, 3 - Round Up, 4 - Round Down

Default 1
relatedAccountingDocumentId
integer   optional

Indicates that the accounting document is related to another. It is used when there is a cash payment on an accounting document. The CashReceipt accounting document is created and relatedAccountingDocumentId is set to the paid accounting document.

Format int64
relatedAccountingDocumentNo
string   optional

Only in GET

exchRateDefault
number   optional

Only in GET

Format double
authorName
string   optional

Only in GET

totalVatAmount
number   optional

Only in GET

Format double

Only in GET List of attached scans

vatCountryType
integer   required

Enum: 1 - Domestic, 2 - EU, 3 - Foreign

creditNoteDelayedVat
boolean   optional
Default False
signatureId
integer   optional

In general, only non-deleted signature is allowed.

If the request doesn't change current value it can be even the deleted one.

Format int64
connectableAmount
number   optional

Only in GET

Returned only if scope=CA is queried.

Format double
roundingAmount
number   optional

Only in GET

Format double
language
AccountingDocumentLanguage   optional
amountPaid
number   optional

Only in GET

Sum of all payments paired with the Accounting Document.

amountDrawn
number   optional

Only in GET

Sum of amount drawn from the Accounting Document via connections.

vatPaymentMode
VatPaymentMode   optional
accountingDocumentNoPreview
string   optional

Only in GET

variableSymbolPreview
string   optional

Only in GET

VatPaymentMode
AccountingDocumentNote
uniqueId
string   optional

UUID

authorUniqueId
string   required

UUID

Only in GET

authorName
string   optional

Only in GET

createdTime
string   optional

Only in GET

Format date-time
updatedTime
string   optional

Only in GET

Format date-time
type
integer   optional

1 - Default

text
string   optional
AccountingDocumentPrintingInfo
lineItemsHeader
string   optional
lineItemsFooter
string   optional
headerNote
string   optional
footerNote
string   optional
language
AccountingDocumentLanguage   optional
AccountingDocumentBankAccount
number
string   optional
bankCode
string   optional
iban
string   optional
swift
string   optional
bankAccountId
integer   optional

Issued Accounting Document Required, other properties will be ignored

Received Accounting Document This is not allowed

Format int64
localId
string   optional

Only in GET GUID

AccountingDocumentPaymentInfo

Only in GET

paidConfirmed
boolean   optional

Only in GET

paid
boolean   optional
Default False
AccountingDocumentPayment
id
integer   optional
Format int64
amount
number   optional
Format double
currency
string   optional
domesticAmount
number   optional
Format double
domesticCurrency
string   optional
cashRegisterId
integer   optional
Format int64
direction
integer   optional

0 - Received, 1 - Issued

date
string   optional
Format date
type
number   optional

BankTransfer = 1, Cash = 2, CashOnDelivery = 3, PaymentCard = 4, SetOff = 5, Loan = 6

AccountingDocumentLineItem
id
string   optional

Only in GET Guid

description
string   optional
finAccount
string   optional
unitPrice
number   optional

Unit Price VAT incl.

Format double
unitName
string   optional
qt
number   optional
Format double
total
number   optional

Total VAT incl.

Format double
totalVatExcl
number   optional

Total VAT excluded

Format double
reverseChargeCode
string   optional

If empty, reverse charge is not applied to this line item

storeItemId
integer   optional
Format int64
unitPriceVatExcl
number   optional

Unit price VAT excluded

Format double
vatValue
number   optional

VAT value in the accounting document currency

Format double
vatRate
number   optional

Ignored on input when vatRateId populated.

Same as VatRate.vatRate from GET /vatrates.

Format double
vatRateType
number   optional

Ignored on input when vatRateId populated.

Same as VatRate.vatRateType from GET /vatrates.

vatRateId
integer   optional

vatRate and vatRateType ignored if vatRateId populated.

Same as VatRate.vatRateId from GET /vatrates.

Format int64
branch
string   optional
project
string   optional
vatDeduction
boolean   optional

Valid for received Accounting Documents only.

greenboxFinancialAccountStatus
integer   optional

1 - NotClassified

2 - CheckNeeded

3 - Classified

countryVariantSpecific
cz
object   optional
cz
eet
object   optional
eet
use
boolean   optional

In POST or PUT, if this is true, leave fik, bkp and pkp empty.

fik
string   optional
bkp
string   optional
pkp
string   optional
operation
string   optional

Only in GET Last sent operation: send_eet, cancel_eet

AccountingDocumentVatRecapLine
vatRate
number   required
Format double
base
number   optional
Format double
vatAmount
number   optional
Format double
total
number   optional
Format double
vatRateType
number   optional

1 - Standard, 2 - Out of VAT (cz: Mimo DPH), 3 - DoNotApplyVat (cz: Neuplatnit DPH), 4 - Reverse Charge, 5 - ExemptFromVAT (cz: osvobozeno od DPH)

AccountingDocumentExpectedPayment
transactionId
string   required
expectedAmount
number   optional
Format double
expectedCurrency
string   optional
AccountingDocumentContact
contactId
integer   optional

If set, the accounting document will be paired to this contact. If other contact properties are empty, they will be loaded from contact, otherwise they will be used as posted. The contact will not be changed.

Format int64
firstname
string   optional
lastname
string   optional
companyRegNo
string   optional
companyName
string   optional
taxId
string   optional
city
string   optional
street
string   optional
country
string   optional
zipCode
string   optional
email
string   optional
externalId
string   optional

Can be used if a contact doesn't have companyRegNo

AccountingDocumentLanguage
CS
string   optional
EN
string   optional
DE
string   optional
AccountingDocumentScan
guid
string   optional

GUID

size
integer   optional

In bytes

fileId
integer   optional
Format int64
filename
string   optional

Only in GET

ValidationError
code
string   optional
message
string   optional
params
object   optional
fieldsAffected
Array of ValidationFieldError   optional
ValidationFieldError
name
string   optional
message
string   optional
code
string   optional
params
object   optional