> ## Documentation Index
> Fetch the complete documentation index at: https://developers.pleo.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Accounts Mapping

export const NoteCallout = ({title, children, icon = "💡"}) => <div style={{
  backgroundColor: 'var(--recommended-bg)',
  borderLeft: '4px solid #3beaf6',
  borderRadius: '10px',
  padding: '18px 22px',
  marginBottom: '20px',
  boxShadow: '1px 1px 3px rgba(0,0,0,0.06)'
}}>
    <div style={{
  display: 'flex',
  alignItems: 'flex-start',
  gap: '14px'
}}>
      <span style={{
  fontSize: '22px',
  lineHeight: '1',
  flexShrink: 0
}}>
        {icon}
      </span>
      <div>
        {title && <div style={{
  fontSize: '16px',
  fontWeight: 600,
  color: 'var(--recommended-title)',
  marginBottom: '6px'
}}>
            {title}
          </div>}
        <div style={{
  fontSize: '14px',
  lineHeight: 1.65
}}>
          {children}
        </div>
      </div>
    </div>
  </div>;

export const RememberCallout = ({title, children, icon = "🪢"}) => <div style={{
  backgroundColor: 'var(--recommended-bg)',
  borderLeft: '4px solid #f63b92',
  borderRadius: '10px',
  padding: '18px 22px',
  marginBottom: '20px',
  boxShadow: '1px 1px 3px rgba(0,0,0,0.06)'
}}>
    <div style={{
  display: 'flex',
  alignItems: 'flex-start',
  gap: '14px'
}}>
      <span style={{
  fontSize: '22px',
  lineHeight: '1',
  flexShrink: 0
}}>
        {icon}
      </span>
      <div>
        {title && <div style={{
  fontSize: '16px',
  fontWeight: 600,
  color: 'var(--recommended-title)',
  marginBottom: '6px'
}}>
            {title}
          </div>}
        <div style={{
  fontSize: '14px',
  lineHeight: 1.65
}}>
          {children}
        </div>
      </div>
    </div>
  </div>;

Accounts Mapping determines which **General Ledger (GL) accounts** are used to record debit and credit entries for each Export Item.

All exported expenses follow **double-entry bookkeeping**, meaning every transaction must have both:

* a debit account
* a credit (counter) account

Accounts Mapping occurs **after**:

* Export Items are fetched
* [Bookkeeping method](/docs/current/integration-design/exports/integration-design-exports-bookkeeping-method-resolution) has been resolved

## Implementation

See the corresponding how-to article for API usage and step-by-step instructions:

* [How to Apply Accounts Mapping for Export Items](/docs/current/how-tos/accounting-integrations/how-to-determine-accounts-mapping-for-as-erp-processing)

## Mapping Inputs

Accounts Mapping depends on:

* `data[].type` and `data[].subType` (e.g., `card_purchase`, `invoice`, `wallet_topup`)
* Expense category (Expense GL Account)
* Bookkeeping method:
  * `journal`
  * `accounts_payable`

## Required Account Configuration

The integration must obtain the following GL accounts from user configuration in the Accounting System:

* Pleo Wallet Account
* Pleo Out-of-Pocket Account
* Pleo Contra Account
* Accounts Payable Account (fallback)

These accounts define the base posting structure used across all Export Items.

## Vendor-Specific Accounts Payable

### When Accounts Payable Applies

If:

```json theme={null}
data[].bookkeeping.method = accounts_payable
```

the counter account is determined using vendor resolution logic.

### Vendor Resolution Logic

1. If `data[].vendor` exists:

* Match vendor in the Accounting System using:
  * `vendor.code` (preferred)
  * or `supplier.code` (legacy support)

2. If a match is found:

* Use vendor-specific Accounts Payable account

3. If no match or vendor is missing:

* Use fallback Accounts Payable account from configuration

#### Example

* Vendor = `ACME Ltd` → matched → `2901-AP-ACME`
* Vendor not found → `2000-AP-Default`

<NoteCallout title="Legacy Support">
  Some older integrations may still provide `supplier.code` for vendor matching. Use only when [applicable](/docs/current/integration-design/exports/integration-design-exports-bookkeeping-method-accounts-payable#legacy-support).
</NoteCallout>

## Expense Booking Logic

### Scope

This section defines how debit and credit accounts are assigned once:

* bookkeeping method is resolved
* (for Accounts Payable) vendor resolution is completed

### Line-Level Expense Account

Each Export Item line provides the expense (debit) account:

```json theme={null}
data[].accountingEntryLines[].account
```

### Fields

* **id** – internal Pleo account ID
* **name** – category name
* **code** – ERP-facing GL account code
* **identifier** – ERP-facing identifier

### Counter Account Sources

The counter account is determined as follows:

#### Journal Entries

If:

```pseudo theme={null}
data[].bookkeeping.method = journal
```

Counter account is determined using:

* `data[].type` + `data[].subType`
* Expense Type Mapping rules
* `data[].contraAccount` (when provided)
* configured accounts:
  * Wallet account
  * Out-of-pocket account
  * Contra account

#### Accounts Payable Entries

If:

```pseudo theme={null}
data[].bookkeeping.method = accounts_payable
```

Counter account is:

* vendor-specific AP account (if resolved)
* otherwise fallback AP account

## Mapping Rule Summary

1. Identify bookkeeping method

2. Set expense (debit) account from:
   * `data[].accountingEntryLines[].account`

3. Determine counter account:
   * journal
     * Based on Expense Type Mapping rules
     * `data[].type` + `data[].subType`
     * `data[].contraAccount` (if applicable)
     * configured wallet / out-of-pocket / contra accounts
   * Accounts Payable
     * Vendor-specific Accounts Payable account if matched
     * Otherwise fallback Accounts Payable account

### Example Mapping Table

| Export Item Type | Bookkeeping Method | Debit Account (Expense)                 | Credit Account (Counter)                   |
| ---------------- | ------------------ | --------------------------------------- | ------------------------------------------ |
| `card_purchase`  | `journal`          | `data[].accountingEntryLines[].account` | `data[].contraAccount` (wallet/bank)       |
| `invoice`        | `accounts_payable` | `data[].accountingEntryLines[].account` | Vendor AP account or fallback              |
| `wallet_topup`   | `journal`          | Wallet account                          | Contra account (direction depends on flow) |

<RememberCallout title="Counter Account Rule">
  * Each transaction always has one expense (debit) account and one counter (credit) account
  * Direction may invert for refunds or reversals as defined by mapping rules
</RememberCallout>

### Expense Type Mapping Dependency

Accounts Mapping relies on Expense Type Mapping, which defines:

* how `type` and `subType` determine accounting treatment
* how counter accounts are selected for journal entries

```mermaid theme={null}
    %%{init: {"themeVariables": {"fontSize": "12px"}}}%%
flowchart TD
    A[Fetch Export Item] --> B[Resolve bookkeeping method + vendor context]

    %% Journal path
    B -->|journal| C[Process each data#91;#93;.accountingEntryLines#91;#93; line]

    C --> C1[Expense #40;debit#41; account → data#91;#93;.accountingEntryLines#91;#93; .account]

    C --> C2[Counter account determined via type + subtype, mapping rules, contraAccount, and configured accounts]

    C1 --> G[Create journal entry line]
    C2 --> G

    %% Accounts Payable path
    B -->|accounts_payable| D[Resolve vendor]

    D -->|Matched| E[Use vendor-specific AP account]

    D -->|Not matched| F[Use fallback AP account #40;configuration#41;]

    E --> H[Create AP entry]
    F --> H

    %% Styling
    style A white-space:normal
    style B white-space:normal
    style C white-space:normal
    style C1 white-space:normal
    style C2 white-space:normal
    style D white-space:normal
    style E white-space:normal
    style F white-space:normal
    style G white-space:normal
    style H white-space:normal
```

## Upstream Dependencies

* Export Job has been started (status = in\_progress)
* Fetch Export Item Data (data layer)
* Bookkeeping method resolved

## Downstream Dependencies

* **Data Mapping** – ensures amounts, dates, dimensions, identifiers, and VAT/tax information are recorded correctly
* **Attachment Handling** – links receipts and supporting documentation
* **Accounting Periods** – assigns entries to the correct accounting period
* **Posting Behaviour** – determines whether entries are created as drafts or finalised
* **Export Item status update** – updates outcome of Export Item (`successful` or `failed`)
* **Export Job status update** – updates outcome of Export Job (`completed`, `completed_with_errors` or `failed`)

***

## What Comes Next?

* [Data Mapping](/docs/current/integration-design/exports/integration-design-exports-data-mapping)

***

## Related Reading

* [How to Apply Accounts Mapping for Export Items](/docs/current/how-tos/accounting-integrations/how-to-determine-accounts-mapping-for-as-erp-processing)
* [Export Integration Workflow Guide](/docs/current/guides/export-integration-workflow-guide)
* [AS/ERP Processing Workflow Guide](/docs/current/guides/accounting-system-processing-workflow-guide)

***
