Accounting Sync
Overview
The Accounting Sync feature provides a centralized notification system for syncing invoices, ledger notes, and accounting entries with an external accounting system. It includes the ability to disable payment handling in properties. The sync operates incrementally and supports two levels: invoice and ledger notes for unrented ledger entries.
Prerequisites
Ensure the following prerequisites are met:
- Ledger management (Reskontrahantering) is inactive.
- The accounting (Bokföringskörningen) run must be executed and approved.
- The settings for all accounting coding parts needs to have
Utfyllnadspecified.
How to sync
- The sync example 'Sync Ledger Notes' could contain both 'AVI' and 'Faktura'-objects.
- The AVI-invoice, we use 'changeType' to determine if a change has accured.
-
The Faktura-invoice, we use 'ledger.type.id' to detmine if it is a Faktura-invoice or a Faktura-creditinvoice.
-
Sync Ledger Notes (AVI)
-
Retrieve a list of
ledgerNoteAccountingusing theledgerNoteAccountingsSyncquery (refer to ledgerNoteAccounting Query below) with thelastLocalIdparameter set to the value of a locally stored variablelastLedgerNoteAccountingsLocalId(use0for the initial retrieval). -
For each
ledgerNoteAccountingwherechangeType.idequalscreatedandledger.type.iddoes not equalinvoiceorinvoiceCredit:- Create an invoice in the target system.
-
For each ledgerNoteAccounting where
changeType.idequalsreversedandledger.type.iddoes not equalinvoiceorinvoiceCredit:- Create a credit invoice in the target system.
-
This sync-example does contain 3 different stages:
- orginal AVI is created (
created). - orginal AVI is changed (
reversed), and no longer valid. - a new AVI is created (
created).
- orginal AVI is created (
-
Save the highest returned
ledgerNoteAccounting.localIdto a locally stored variablelastLedgerNoteAccountingsLocalIdfor future retrievals.
-
-
Sync Ledger Note (Faktura)
-
Retrieve a list of
ledgerNoteAccountingusing theledgerNoteAccountingsSyncquery (refer to ledgerNoteAccounting Query below) with thelastLocalIdparameter set to the value of a locally stored variablelastLedgerNoteAccountingsLocalId(use0for the initial retrieval). -
For each
ledgerNoteAccountingwhereledger.type.idequalsinvoice- Create an invoice in the target system.
-
For each
ledgerNoteAccountingwhereledger.type.idequalsinvoiceCredit- Create an credit invoice in the target system.
-
In the object of the credit invoice, you can find the specific invoice that is being credited (
ledgerNote.invoice.creditInvoice).- NOTE! You could have multiple credit invoices that credits the same invoice, because you can credit an invoice in parts. Not the entire credited sum has to be in the same credit invoice.
-
Save the highest returned
ledgerNoteAccounting.localIdto a locally stored variablelastLedgerNoteAccountingsLocalIdfor future retrievals.
-
-
Sync Ledgers without Ledger Notes (E.g. "Outhyrd Reskontra" or "Egen Reskontra")
-
Retrieve a list of
ledgerAccountingusing theledgerAccountingsSyncquery (refer to ledgerAccounting Query below) with thelastLocalIdparameter set to the value of a locally stored variablelastLedgerAccountingsLocalId(use0for the initial retrieval). -
Follow the same steps as in the "Sync Ledger Notes" section.
-
Save the highest returned
ledgerAccounting.localIdto a locally stored variablelastLedgerAccountingsLocalIdfor future retrievals.
-
🛈 Note
We do not recommend that you alter or filter the
ledgerNoteAccountingand theledgerAccountingQuery.
LedgerNoteAccounting Query
{
ledgerNoteAccountingsSync(lastLocalId: 0) {
nodes {
id
localId
changeType {
id
displayName
}
distributions {
bankCode {
bankCode
displayName
}
identityOfficialNumber
globalLocationNumber
ordererReference1
ordererReference2
address {
attention
careOf
streetAddress1
streetAddress2
country {
displayName
shortDisplayName
}
address
postCode
city
}
postalAddress {
attention
careOf
streetAddress1
streetAddress2
country {
displayName
shortDisplayName
}
address
postCode
city
}
type {
displayName
}
}
company {
displayName
organisationNumber
ledgerNoteHeader
ledgerNoteMessage
actor {
vatRegistrationNumber
postalAddress
postalAddressPostCode
postalAddressCity
}
}
ledgerNote {
type {
displayName
}
invoice {
number
creditInvoice {
number
ledgerPrimary {
ledgerNotes {
ledgerNote {
id
number
toPay
}
}
}
}
}
id
refersToPeriodDisplayName
number
referenceNumber
payToTypeDisplayName
payToNumber
due
toPay
contract {
id
number
}
customer {
nodeClass {
displayName
id
}
identityOfficialNumber
number
displayName
}
}
ledgers {
id
changeType {
id
displayName
}
ledger {
type {
id
}
statusStart
statusEnd
object {
number
displayName
}
}
rows {
id
changeType {
id
displayName
}
ledgerRow {
id
text {
text
textDetailed
}
pricing {
messages {
text
statusStart
statusEnd
}
id
}
vatAmount
netAmount
vatType {
id
displayName
}
}
records {
accountingDate
debit
amount
accountDistributionCoding
}
}
}
}
}
}
LedgerAccounting Query
{
ledgerAccountingsSync(lastLocalId: 0) {
nodes {
localId
changeType {
id
displayName
}
company {
displayName
organisationNumber
ledgerNoteHeader
ledgerNoteMessage
actor {
vatRegistrationNumber
postalAddress
postalAddressPostCode
postalAddressCity
}
}
ledger {
statusStart
statusEnd
object {
number
displayName
}
}
rows {
id
changeType {
id
displayName
}
ledgerRow {
id
text {
text
textDetailed
}
pricing {
id
}
vatAmount
netAmount
vatType
{
id
displayName
}
}
records {
accountingDate
debit
amount
accountDistributionCoding
}
}
}
}
}
Distribution
The distribution object under ledgerNoteAccountings contains information regarding how the ledger note can be distributed.
Address
postalAddress is always the postal address while address can be an e-mail address if one is available, otherwise it will be identical to the postalAddress.
Type dependant fields/objects
Some fields are only used depending on the type of distribution.
-
The object
bankCodeand the fieldidentityOfficialNumberare only used when thetypeiseinvoice. -
The fields
globalLocationNumber,ordererReference1, andordererReference2are only used when thetypeissweinvoice. -
In the case where you use
egen kundor simular types of custumers with anEconnected to theReskontrain the GUI, theledger - type - id->objectOwncan be used to filter if aReskontrashould be made into a invoice or not.
Accounting Records
Each row in records the accountDistributionCoding holds the raw coding.
⚠ You need to keep track of the different parts in the accounting strings (konterinssträngar).
👉 Make sure you have some form of completion (utfyllnad) set up, otherwise it difficult to keep track (1510 00 102 0000 00).