Skip to content

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 the ledgerNoteAccountingsSync query (refer to ledgerNoteAccounting Query below) with the lastLocalId parameter set to the value of a locally stored variable lastLedgerNoteAccountingsLocalId (use 0 for the initial retrieval).

    • For each ledgerNoteAccounting where changeType.id equals created and ledger.type.id does not equal invoice or invoiceCredit:

      • Create an invoice in the target system.
    • For each ledgerNoteAccounting where changeType.id equals reversed and ledger.type.id does not equal invoice or invoiceCredit:

      • 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).
    • Save the highest returned ledgerNoteAccounting.localId to a locally stored variable lastLedgerNoteAccountingsLocalId for future retrievals.

  • Sync Ledger Note (Faktura)

    • Retrieve a list of ledgerNoteAccounting using the ledgerNoteAccountingsSync query (refer to ledgerNoteAccounting Query below) with the lastLocalId parameter set to the value of a locally stored variable lastLedgerNoteAccountingsLocalId (use 0 for the initial retrieval).

    • For each ledgerNoteAccounting where ledger.type.id equals invoice

      • Create an invoice in the target system.
    • For each ledgerNoteAccounting where ledger.type.id equals invoiceCredit

      • 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 variable lastLedgerNoteAccountingsLocalId for future retrievals.

  • Sync Ledgers without Ledger Notes (E.g. "Outhyrd Reskontra" or "Egen Reskontra")

    • Retrieve a list of ledgerAccounting using the ledgerAccountingsSync query (refer to ledgerAccounting Query below) with the lastLocalId parameter set to the value of a locally stored variable lastLedgerAccountingsLocalId (use 0 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 variable lastLedgerAccountingsLocalId for future retrievals.

🛈 Note

We do not recommend that you alter or filter the ledgerNoteAccounting and the ledgerAccounting 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 field identityOfficialNumber are only used when the type is einvoice.

  • The fields globalLocationNumber, ordererReference1, and ordererReference2 are only used when the type is sweinvoice.

  • In the case where you use egen kund or simular types of custumers with an E connected to the Reskontra in the GUI, the ledger - type - id -> objectOwn can be used to filter if a Reskontra 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).