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
Utfyllnad
specified.
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
ledgerNoteAccounting
using theledgerNoteAccountingsSync
query (refer to ledgerNoteAccounting Query below) with thelastLocalId
parameter set to the value of a locally stored variablelastLedgerNoteAccountingsLocalId
(use0
for the initial retrieval). -
For each
ledgerNoteAccounting
wherechangeType.id
equalscreated
andledger.type.id
does not equalinvoice
orinvoiceCredit
:- Create an invoice in the target system.
-
For each ledgerNoteAccounting where
changeType.id
equalsreversed
andledger.type.id
does not equalinvoice
orinvoiceCredit
:- 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
.localId
to a locally stored variablelastLedgerNoteAccountingsLocalId
for future retrievals.
-
-
Sync Ledger Note (Faktura)
-
Retrieve a list of
ledgerNoteAccounting
using theledgerNoteAccountingsSync
query (refer to ledgerNoteAccounting Query below) with thelastLocalId
parameter set to the value of a locally stored variablelastLedgerNoteAccountingsLocalId
(use0
for the initial retrieval). -
For each
ledgerNoteAccounting
whereledger.type.id
equalsinvoice
- Create an invoice in the target system.
-
For each
ledgerNoteAccounting
whereledger.type.id
equalsinvoiceCredit
- 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
.localId
to a locally stored variablelastLedgerNoteAccountingsLocalId
for future retrievals.
-
-
Sync Ledgers without Ledger Notes (E.g. "Outhyrd Reskontra" or "Egen Reskontra")
-
Retrieve a list of
ledgerAccounting
using theledgerAccountingsSync
query (refer to ledgerAccounting Query below) with thelastLocalId
parameter set to the value of a locally stored variablelastLedgerAccountingsLocalId
(use0
for the initial retrieval). -
Follow the same steps as in the "Sync Ledger Notes" section.
-
Save the highest returned
ledgerAccounting
.localId
to a locally stored variablelastLedgerAccountingsLocalId
for future retrievals.
-
🛈 Note
We do not recommend that you alter or filter the
ledgerNoteAccounting
and theledgerAccounting
Query.
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
bankCode
and the fieldidentityOfficialNumber
are only used when thetype
iseinvoice
. -
The fields
globalLocationNumber
,ordererReference1
, andordererReference2
are only used when thetype
issweinvoice
. -
In the case where you use
egen kund
or simular types of custumers with anE
connected to theReskontra
in the GUI, theledger - type - id
->objectOwn
can be used to filter if aReskontra
should 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).