> For the complete documentation index, see [llms.txt](https://adrasis.gitbook.io/console/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://adrasis.gitbook.io/console/payments/accounting-export.md).

# Accounting export

The accounting export hands your accounting program every sale you make through Adrasis as a sale record: who sold to whom, the sale and purchase amounts, commission, tax lines, currency and service dates. Your accounting program pulls new and changed records with an API key, or you open the same records as a CSV or Excel file. Adrasis does not issue invoices; your accounting program or e-invoice provider issues, numbers and books them.

For example, *Blue Coast Travel Ltd.* sells a two-night stay at *Hotel Sunrise* for *1,000 TRY*. Its accounting program receives one sale record with the buyer's accounting code *120.01.0042*, the *KDV* and lodging tax lines, and the service dates *1-3 December*. When the guest cancels, the program receives a new version of the same record marked cancelled, with the cancellation penalty.

{% hint style="info" %}
**A sale record is never edited.** Every change adds a new version: the sale, a change, a cancellation, a refund, and the end of the service. Your accounting program turns a cancellation or refund version into a credit note or return invoice when your rules require one.
{% endhint %}

## What a sale record holds

One record describes one booked service (a hotel stay, a tour, a transfer) for your Organization's books. When a sub-agency sells your supply, you and the sub-agency each receive your own record, and neither record shows the other's private figures.

| Group                | What you receive                                                                                                                                                                     |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **References**       | Booking reference and booking number, the service's reference, your agency reference, the channel's and the supplier's confirmation numbers.                                         |
| **Parties**          | Seller (your own billing details), buyer and supplier, each with company title, tax number and type, tax office, address and your accounting code for them.                          |
| **Commercial model** | *Net rate*: you sell in your own name and the full price is invoiced. *Commissionable*: you sell for the supplier and your commission is invoiced. Also who collects from the guest. |
| **Amounts**          | Sale amount, supplier net, margin, commission with its rate and base, and in your own record the cost you paid for the sale.                                                         |
| **Tax lines**        | One line per tax and rate, with its taxable base, amount, inclusion mode and the e-invoice tax type code, such as *0015* for KDV and *0059* for lodging tax.                         |
| **Service**          | Start and end dates, and when the service was completed.                                                                                                                             |
| **Cancellation**     | Whether the service was cancelled, and the penalty once it is known.                                                                                                                 |

Every amount is in the booking currency and keeps four decimal places exactly as stored, such as *870.1234*. Nothing is rounded or converted to a floating-point number on the way out.

### Tax detail on bookings received from a channel

If the channel provides a tax breakdown, the booking retains it. If it sends nightly prices without a breakdown, Adrasis uses the property's tax setup to split those amounts. For example, the taxes included in a 1,000 TRY night are separated within that amount; they are not added again to the guest's price.

When the required detail is missing or the split cannot be calculated, the booking can still be recorded without a tax breakdown. An empty breakdown does not establish that the sale is tax-free. Review the source booking and the property's tax setup before using the record for invoicing. Earlier bookings are not automatically recalculated by this change.

## Field mapping to the e-invoice format

The record's fields follow the Turkish e-invoice format UBL-TR 1.2.1, with the European standard EN 16931 beside it, so an e-invoice provider maps them without guessing.

| Record field                     | UBL-TR 1.2.1                                            | EN 16931      |
| -------------------------------- | ------------------------------------------------------- | ------------- |
| Seller identity and address      | `cac:AccountingSupplierParty`                           | BG-4          |
| Buyer identity and address       | `cac:AccountingCustomerParty`                           | BG-7          |
| Buyer accounting code            | buyer party identification, scheme `MUSTERINO`          | BT-46         |
| Booking number, agency reference | `cac:OrderReference`, `cac:AdditionalDocumentReference` | BT-13, BT-122 |
| Service period                   | `cac:InvoicePeriod`                                     | BG-14         |
| Currency                         | `cbc:DocumentCurrencyCode`                              | BT-5          |
| Tax line base, amount, rate      | `cac:TaxSubtotal`                                       | BG-23         |

{% hint style="warning" %}
**The exchange rate for a non-TRY invoice is not in the record.** The e-invoice format asks for the rate of the invoice date on every invoice that is not in TRY. Your accounting program applies the rate of the day it issues the invoice.
{% endhint %}

## Which buyer appears on a direct booking?

The invoice details chosen at booking identify the buyer. A corporate buyer card supplies the company's billing details and your accounting code. A person or company entered only for that booking supplies those details without creating a reusable card. If neither is provided, the booking contact is the buyer; this need not be the traveller.

For example, an employee stays at *Hotel Sunrise*, while *North Star Engineering Ltd.* is selected as the corporate buyer. The sale record names that company with accounting code *120.01.0042*. It does not report that the company has paid. Match collections separately using the booking reference.

On API partner and sub-agency sales, the buyer follows that trading relationship. A missing API partner billing card is not replaced with the guest's identity. See [Billing details and accounting codes](/console/payments/billing-details.md).

## Invoice-ready records

A record is **invoice-ready** when it names both a seller and a buyer. A record that misses one of them is exported as not invoice-ready, with the reason: *parties.seller* when your own billing details are missing, *parties.buyer* when the buyer has no billing details.

For example, a sale to an API partner made before you entered the partner's billing details exports as not invoice-ready with the reason *parties.buyer*. It is never exported as a sale without a buyer. Add the partner's billing details; the next version of that record carries them.

{% hint style="info" %}
**Keep earlier versions for comparison.** Existing sale record versions remain unchanged. New events create additional versions. Record your own billing details under **Organization settings** and your partners' under their **Billing details** cards, as described in [Billing details and accounting codes](/console/payments/billing-details.md).
{% endhint %}

## Margin, revenue and cost

| Column      | Meaning                                                                                                                                                                                                                                                                                                                                              |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Margin**  | Sale amount minus what you paid for it, in the booking currency. In your own record that is the cost: a room you sell at *1,000 TRY* with a *150 TRY* markup on its *850 TRY* net has a *150 TRY* margin. In the record of a sub-agency selling your rooms it is the supplier net it owes you. When your cost is not known, the margin is empty too. |
| **Revenue** | On a commissionable sale in your own record, your commission. Otherwise your margin. The revenue basis column says which one applies.                                                                                                                                                                                                                |
| **Cost**    | What you pay your supplier for the sale, frozen at booking and shown only in your own record. On a stay it is the price the room was sold at less your markup, or less the commission on a commissionable rate. When it is not known, the column is empty and the reason is given. An unknown cost is never shown as *0*.                            |

## How your accounting program pulls changes

{% stepper %}
{% step %}

### Create an API key

Open **Financials**, then **Accounting export**, and choose **New key**. Name it and pick what it may read: the sale records, the money movements export, or both. The key is shown once; copy it into your accounting program's settings. The key works only for your Organization and has a request limit per minute and per day. An Organization admin creates and revokes keys; revoke a key there when the program is retired or the key leaks, and the program using it stops on its next request.
{% endstep %}

{% step %}

### Pull from a start time

The program asks for every change recorded since a start time, such as *1 October 00:00 UTC*. Each answer covers at most 31 days and ends one minute before the current time, so a change still being written is never skipped.
{% endstep %}

{% step %}

### Follow the pages to the end

A long answer comes in pages. The program follows the page link until there are no more pages. Each change arrives once and in the order it was recorded.
{% endstep %}

{% step %}

### Continue from where it stopped

The answer states where it ends. The program keeps that time and starts the next pull from it. When the answer says to try again later, the program waits the given number of seconds.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
**For your accounting program's provider.** The request is `GET /api/console/v1/accounting/sale-records` with the key in the `X-API-Key` header and the start time in `updated_since`. Amounts are text, such as `"870.1234"`; identifiers are booking references and booking numbers.
{% endhint %}

## Export files

The same records are available as files for a window of up to 31 days, such as *1-31 October*. Open **Financials**, then **Accounting export**, pick the first and last day, and choose the file.

| File             | What it contains                                                                                                                                                                   |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **CSV**          | Ten lines with your billing details and the window covered, an empty line, then one table: either the sale records, or their tax lines keyed by the service reference and version. |
| **Excel (XLSX)** | A *seller* sheet with your billing details and the window, a *sale\_records* sheet and a *tax\_lines* sheet. Amounts are stored as text so they keep every decimal.                |

A window ending near the present is shortened to cover completed records, and the file states its actual end. Repeating the requested window later can include more records if the earlier export stopped sooner. Use the stated boundaries when comparing exports. The file header uses your current billing details. A window with more than 50,000 changes is refused; export a shorter window.

## Match sales and collections

The money movements export of [Cash position](/console/payments/cash-position.md) names each payment by the same booking reference and booking number as the sale record. Your accounting program matches a sale to its collections by that reference. The program pulls that file with the same API key from `GET /api/console/v1/accounting/movements/export`, for a window given in `from` and `to`.

For example, a sale record of *1,000 TRY* on booking *2841308894* and a received bank transfer of *600 TRY* on the same booking leave *400 TRY* open.

## What this does not do

* **It does not issue invoices.** No invoice number is assigned and nothing is sent to the tax authority or an e-invoice network.
* **It does not keep accounts.** There is no chart of accounts or ledger; your accounting program books the records.
* **It does not change bookings or payments.** The export only reads what was sold and collected.

## Where to next

* [Billing details and accounting codes](/console/payments/billing-details.md)
* [Cash position](/console/payments/cash-position.md)
* [Settlement & reconciliation](/console/payments/settlement-and-reconciliation.md)
