> For the complete documentation index, see [llms.txt](https://docs.younium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.younium.com/erp-and-accounting-integrations/saf-t.md).

# SAF-T

## Overview

The SAF-T integration exports Norwegian SAF-T Financial XML (schema version 1.30) for a selected period. Younium builds an `AuditFile` with company header, master files (GL accounts, customers, tax table), and general ledger entries from postings, validates against the bundled XSD, and returns serialised XML (JSON-wrapped inner XML string in the API response path).

## Authentication

No external system. Export is generated on demand from Younium ledger and master data.

## Settings

| Setting                  | Description    | Validation                        |
| ------------------------ | -------------- | --------------------------------- |
| `ContactPersonEmail`     | Header contact | Required with first/last name     |
| `ContactPersonFirstName` | Header contact | Required                          |
| `ContactPersonLastName`  | Header contact | Required                          |
| `SelectionStartDate`     | Period start   | Must be before `SelectionEndDate` |
| `SelectionEndDate`       | Period end     | Must be after start               |

`SaveSettings` and export both call `ValidateSettings`.

## Export workflow

1. Load current legal entity; fail if missing.
2. `CreateSaftFile` for date range.
3. `ValidateSaftXml` against Norwegian SAF-T Financial Schema v1.30.
4. Serialize to `XmlDocument`; log integration success `Create Saft Xml`.
5. Return JSON-serialised inner XML.

Failures log integration failure and throw `ApiException`.

## Header mapping

| Younium Field                                         | SAF-T `Header` element                                                                                        |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `ApplicationLegalEntity.Address.Country.TwoAlphaCode` | `AuditFileCountry`                                                                                            |
| UTC date                                              | `AuditFileDateCreated`                                                                                        |
| Fixed                                                 | `AuditFileVersion` `1.0`, `SoftwareCompanyName` `Younium AB`, `SoftwareID` `Younium`, `SoftwareVersion` `1.3` |
| Legal entity base currency (repository may update)    | `DefaultCurrencyCode`                                                                                         |
| Fixed                                                 | `TaxAccountingBasis` `A`                                                                                      |
| `ApplicationLegalEntity.OrganizationNumber`           | `Company/RegistrationNumber`                                                                                  |
| `ApplicationLegalEntity.Name`                         | `Company/Name`                                                                                                |
| Legal entity address street, city, zip, country       | `Company/Address`                                                                                             |
| Settings contact names + email                        | `Company/Contact`                                                                                             |
| `ApplicationLegalEntity.TaxRegistrationNumber`        | `Company/TaxRegistration`                                                                                     |
| `SelectionStartDate`, `SelectionEndDate`              | `SelectionCriteria` items                                                                                     |

## Master files — general ledger accounts

Financial accounts with activity in the period are mapped from repository queries (account codes and descriptions per SAF-T repository logic).

## Master files — customers

| Younium Field                       | SAF-T `Customer`                               |
| ----------------------------------- | ---------------------------------------------- |
| `Account.AccountNumber`             | `CustomerID`                                   |
| `Account.Name`                      | `Name`                                         |
| `Account.OrganizationNumber`        | `RegistrationNumber`                           |
| `Account.TaxRegistrationNumber`     | `TaxRegistration` (optional)                   |
| `Account.DefaultPaymentTerm.Days`   | `PartyInfo/PaymentTerms/Days`                  |
| `Account.Currency.Code`             | `PartyInfo/CurrencyCode`                       |
| Default delivery or invoice address | `Address` (street or billing type)             |
| Opening/closing balance in period   | Balance fields from `GetAccountInvoiceBalance` |

Accounts missing default payment term or both addresses are skipped with integration log failure for that account.

## Master files — tax table

| Younium Field                  | SAF-T tax table                                                   |
| ------------------------------ | ----------------------------------------------------------------- |
| `TaxTemplateDetails.Tax1`      | Tax percentage item                                               |
| `TaxCategoryType.Description`  | Description                                                       |
| `Country.TwoAlphaCode`         | Country                                                           |
| `TaxCategoryType.ExternalCode` | `TaxCode`, `StandardTaxCode` (required — export fails if missing) |
| `TaxTemplate.EffectiveFrom`    | `EffectiveDate`                                                   |
| Fixed description/type         | `Merverdiavgift` / `MVA`                                          |

> **Note on external tax codes:** Every tax category used must have **External code** set under Accounts receivable tax categories; otherwise export throws naming the tax template.

## General ledger entries

Postings in the date range are grouped by journal number, then by transaction number.

| Younium `PostingData`           | SAF-T `Transaction` / `Line`                               |
| ------------------------------- | ---------------------------------------------------------- |
| `JournalNumber`                 | `Journal/JournalID`                                        |
| `JournalType` + journal number  | `Description`                                              |
| Fixed                           | `Type` `GL`                                                |
| `TransactionDate`               | `TransactionDate`, `GLPostingDate`, `Period`, `PeriodYear` |
| `TransactionNumber`             | `TransactionID`                                            |
| `InvoiceNumber`                 | `Description`                                              |
| `CustomerId`                    | `CustomerID`                                               |
| `AccountCode`                   | `Line/AccountID`                                           |
| `Debit` / `Credit` base amounts | `DebitAmount` or `CreditAmount` with currency              |
| Zero debit and credit lines     | Skipped                                                    |

Journal totals: `NumberOfEntries`, `TotalDebit`, `TotalCredit` summed in base currency rounded.

## Eligibility

Requires complete legal entity address with country. Tax templates must have external codes. Posting data must exist for the selected window.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.younium.com/erp-and-accounting-integrations/saf-t.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
