> ## 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.

# AS/ERP Processing Workflow Guide

export const PostingBehaviourDiagramNoClick = () => {
  const diagram = `
%%{init: {"themeVariables": {"fontSize": "18px"}}}%%
flowchart LR
    S1["1. Read Posting Configuration"] --> S2["2. Apply Posting Behaviour"]
    S2 -->|configured| S3["3. Map to AS Status"] --> S5["5. Create Entry & Capture Result"]
    S2 -->|not configured| S4["4. Apply Default Behaviour"] --> S5

style S1 white-space:normal
style S2 white-space:normal
style S3 white-space:normal
style S4 white-space:normal
style S5 white-space:normal
`;
  return <Mermaid chart={diagram} />;
};

export const AssignAccountingPeriodsDiagramNoClick = () => {
  const diagram = `
%%{init: {"themeVariables": {"fontSize": "22px"}}}%%
flowchart LR
    S1["1. Determine Posting Date"] --> S2["2. Attempt Posting"]
    S2 -->|success| S5["5. Resolve Accounting Period"]
    S2 -->|rejected| S3["3. Handle Closed Period Rejection"] --> S4["4. Apply Closed Period Strategy"]
    S4 -->|retry| S2
    S4 -->|fail item| FAIL["Item Failed"]

style S1 white-space:normal
style S2 white-space:normal
style S3 white-space:normal
style S4 white-space:normal
style S5 white-space:normal
style FAIL white-space:normal
`;
  return <Mermaid chart={diagram} />;
};

export const TransferAttachmentsDiagramNoClick = () => {
  const diagram = `
%%{init: {"themeVariables": {"fontSize": "28px"}}}%%
flowchart LR
    S1["1. Check for Attachments"] -->|has attachments| S2["2. Download Attachments"] --> S3["3. Handle Multiple Attachments"] --> S4["4. Upload & Associate"]
    S4 -->|success| S6["6. Ensure Idempotency"]
    S4 -->|fails| S5["5. Handle Failures"] --> S6
    S1 -->|no attachments| SKIP["Skip"]

style S1 white-space:normal
style S2 white-space:normal
style S3 white-space:normal
style S4 white-space:normal
style S5 white-space:normal
style S6 white-space:normal
style SKIP white-space:normal
`;
  return <Mermaid chart={diagram} />;
};

export const DataMappingDiagramNoClick = () => {
  const diagram = `
%%{init: {"themeVariables": {"fontSize": "22px"}}}%%
flowchart LR
    S1["1. Map Mandatory Datapoints"] --> S2["2. Map Invoice Datapoints"] --> S3["3. Map Optional Datapoints"] --> S4["4. Apply VAT Handling Rules"] --> S5["5. Build Final Entry Structure"]

style S1 white-space:normal
style S2 white-space:normal
style S3 white-space:normal
style S4 white-space:normal
style S5 white-space:normal
`;
  return <Mermaid chart={diagram} />;
};

export const AccountsMappingDiagramNoClick = () => {
  const diagram = `
%%{init: {"themeVariables": {"fontSize": "28px"}}}%%
flowchart LR
    S1["1. Determine Mapping Strategy"] --> S2["2. Apply Expense Account Mapping"] --> S3["3. Select Counter Account"]
    S3 -->|Case A| S3a["Journal Counter Account"]
    S3 -->|Case B| S3b["AP Counter Account"]
    S3a --> S4["4. Apply Expense Type Rules"]
    S3b --> S4
    S4 --> S5["5. Validate Mapping"]

style S1 white-space:normal
style S2 white-space:normal
style S3 white-space:normal
style S3a white-space:normal
style S3b white-space:normal
style S4 white-space:normal
style S5 white-space:normal
`;
  return <Mermaid chart={diagram} />;
};

export const DetermineBookkeepingMethodDiagramNoClick = () => {
  const diagram = `
%%{init: {"themeVariables": {"fontSize": "22px"}}}%%
flowchart LR
    S1["1. Read Bookkeeping Method"] --> S2["2. Determine Workflow"] --> S3["3. Route Export Item"]
    S3 -->|journal entry| S4["Accounting Entry Processing"]
    S3 -->|accounts payable| S4

style S1 white-space:normal
style S2 white-space:normal
style S3 white-space:normal
style S4 white-space:normal
`;
  return <Mermaid chart={diagram} />;
};

export const WhatComesNext = ({children, href}) => <div className="mt-4">
    <a href={href} className="
        inline-flex items-center justify-center
        rounded-full
        bg-black text-white dark:bg-[#1f262b]
        px-5 py-2.5 text-sm font-medium
        no-underline border-0
        hover:bg-[#ffe6ea] dark:hover:bg-[#2b1f23]
        hover:text-black
        transition-colors
      ">
      {children} →
    </a>
  </div>;

export const RecommendedCallout = ({title, children, icon = "⭐"}) => <div style={{
  backgroundColor: 'var(--recommended-bg)',
  borderLeft: '4px solid #f8f1ac',
  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>;

<RecommendedCallout title="Recommended Workflow">
  This guide covers the AS/ERP processing phase of [Integration Level 1](/docs/current/getting-started/accounting-integrations-overview). It explains how Export Items fetched from Pleo are transformed into accounting entries inside the Accounting System or ERP.
</RecommendedCallout>

## What You'll Have Built

After implementing this workflow:

* Each Export Item correctly routed to a journal entry or accounts payable workflow based on its bookkeeping method.
* GL accounts resolved and balanced for every accounting entry.
* Expense data accurately mapped into the Accounting System's required fields, including amounts, dates, tax codes, and dimensions.
* Receipts and supporting documents attached to their corresponding accounting entries.
* Entries assigned to the correct accounting periods, with closed period scenarios handled.
* Entries created with the correct posting status (draft or finalised) per integration configuration.
* Predictable, auditable accounting outcomes for every Export Item in the batch.

## Who This Guide Is For

This guide is intended for:

* Integration developers implementing exports
* Solution architects designing accounting integrations
* Technical partners building Accounting System connectors

## Before You Start

You should be familiar with:

* The [Export Integration Workflow Guide](/docs/current/guides/export-integration-workflow-guide), which covers how Export Jobs are detected and Export Items are fetched from Pleo.
* This guide begins where that guide's [Step 4 (Fetch Export Item Data)](/docs/current/guides/export-integration-workflow-guide#4-fetch-export-item-data-data-layer) ends. Export Items must already be fetched and validated before this workflow starts.

## AS/ERP Processing Workflow Overview

Once Export Items have been fetched from Pleo, the integration processes each Export Item into an accounting entry inside the Accounting System. The six steps in this guide cover everything from determining how the expense should be recorded, through accounts and data mapping, attachment handling, and period assignment, to creating the entry with the correct posting status.

Each step is applied per Export Item. A failure at any step for a given Export Item is recorded as a failed Export Item and does not block other Export Items from being processed. Once all Export Items are processed, the integration returns to the Export Integration Workflow to report outcomes back to Pleo and complete the Export Job.

```mermaid theme={null}
%%{init: {"themeVariables": {"fontSize": "24px"}}}%%
flowchart LR

    subgraph ERP["Process & Record<br/>Export Items"]
    direction LR
        START1[" "]
        A["1.Determine Bookkeeping Method"] --> B["2.Apply Accounts Mapping"]
        B --> C["3.Apply Data Mapping"]
        C --> D["4.Transfer Attachments"]
        D --> E["5.Assign Accounting Period"]
        E --> F["6.Apply Posting Behaviour"]
    end

     %% Click actions
    click A "#1-determine-bookkeeping-method"
    click B "#2-apply-accounts-mapping"
    click C "#3-apply-data-mapping"
    click D "#4-transfer-attachments"
    click E "#5-assign-accounting-period"
    click F "#6-apply-posting-behaviour"


    %% Styling for wrapping
    style A white-space:normal
    style B white-space:normal
    style C white-space:normal
    style D white-space:normal
    style E white-space:normal
    style F white-space:normal

    %% Make subgraph transparent with black border
    style START1 fill:transparent,stroke:transparent,color:transparent
    style ERP fill:none,stroke:#000000

```

***

## Steps

### 1. Determine Bookkeeping Method

#### Purpose

Before any accounting entry can be created, the integration must determine how each expense should be recorded. Pleo provides the bookkeeping method for each Export Item via the `bookkeeping.method` field. The integration reads this value and routes processing accordingly: `journal` produces a standard journal entry, `accounts_payable` produces a vendor-based invoice and payment, and `none` is treated as `journal`. Pleo sets `none` for non-payable balance adjustments such as wallet loads, wallet unloads, and balance amendments.

#### Input

The `bookkeeping.method` field from the Export Item, with one of four values: `journal`, `accounts_payable`, `none` (non-payable balance adjustments such as wallet loads and balance amendments, always treated as journal entry), or `null` (legacy support).

#### Workflow Process

<DetermineBookkeepingMethodDiagramNoClick />

#### Output

* Bookkeeping method resolved for this Export Item: journal entry or accounts payable
* Integration routed to the appropriate recording workflow for the Export Item

#### Why It Matters

The bookkeeping method determines the entire structure of the accounting entry. Journal entries and accounts payable records have different debit/credit structures, different fields, and different downstream behaviour in the Accounting System. Resolving the method first ensures every subsequent mapping and posting step operates on the correct structure for the Export Item.

#### Integration Design

If you're an integration developer or architect, read the [Bookkeeping Method Resolution](/docs/current/integration-design/exports/integration-design-exports-bookkeeping-method-resolution) integration design doc, as well as [Journal Entry Handling](/docs/current/integration-design/exports/integration-design-exports-bookkeeping-method-journal-entry) and [Accounts Payable Handling](/docs/current/integration-design/exports/integration-design-exports-bookkeeping-method-accounts-payable), before implementing this step. They cover the resolution logic for each possible value of `bookkeeping.method`, including how `none` is handled, and the specific entry structures required for journal entries and accounts payable.

#### Step-by-Step Instructions

When you're ready to start implementing, follow the step-by-step instructions in the accompanying How-to article.

<WhatComesNext href="/docs/current/how-tos/accounting-integrations/how-to-determine-the-bookkeeping-method-for-as-erp-processing">
  How to Determine the Bookkeeping Method
</WhatComesNext>

***

### 2. Apply Accounts Mapping

#### Purpose

With the bookkeeping method known, the integration resolves which GL accounts to use for the debit and credit sides of the entry. This includes the expense account (determined by the expense category), the contra account (wallet, bank, or clearing), and for accounts payable entries, the vendor account. The integration relies on its own mapping configuration and the Accounting System to validate that all resolved accounts exist and are active.

#### Input

* The expense category from the Export Item, used to determine the expense GL account
* Wallet, contra, and out-of-pocket account configuration from the integration
* Vendor configuration from the integration and the Accounting System (for accounts payable entries)
* The bookkeeping method resolved in Step 1

#### Workflow Process

<AccountsMappingDiagramNoClick />

#### Output

* All debit and credit GL accounts resolved for this entry
* Accounts validated as existing and active in the Accounting System
* The integration knows exactly which accounts to debit and credit to produce a balanced accounting record

#### Why It Matters

Incorrect accounts mapping produces entries that post to the wrong GL accounts, distorting financial statements, balance sheets, and reconciliations. Getting mapping right is fundamental to the accuracy of the Accounting System and directly affects whether period-end reporting is reliable.

#### Integration Design

If you're an integration developer or architect, read the [Accounts Mapping](/docs/current/integration-design/exports/integration-design-exports-accounts-mapping) integration design doc before implementing this step. It covers the mapping rules for each account type, how the bookkeeping method affects which accounts are required, expense type rules, and how to handle missing or invalid accounts.

#### Step-by-Step Instructions

When you're ready to start implementing, follow the step-by-step instructions in the accompanying How-to article.

<WhatComesNext href="/docs/current/how-tos/accounting-integrations/how-to-determine-accounts-mapping-for-as-erp-processing">
  How to Apply Accounts Mapping
</WhatComesNext>

***

### 3. Apply Data Mapping

#### Purpose

With accounts resolved, the integration maps the financial data from the Export Item into the fields required by the Accounting System. This covers mandatory fields that every entry must include (amounts, dates, currency, and unique identifiers), invoice-specific fields for accounts payable entries (vendor references and payment terms), optional fields where available (dimensions, tags, and notes), and VAT handling rules where the Accounting System requires tax information.

#### Input

* The full Export Item payload from [Step 4 of the Export workflow](/docs/current/guides/export-integration-workflow-guide#4-fetch-export-item-data-data-layer), containing all financial data provided by Pleo
* Integration configuration for dimensions, tax codes, and optional field mappings

#### Workflow Process

<DataMappingDiagramNoClick />

#### Output

* A complete, accounting-ready payload with all required fields mapped to the Accounting System's expected structure
* VAT and tax information applied where required
* The entry is ready to be assigned a period and posted

#### Why It Matters

Accurate data mapping ensures every accounting entry contains the correct amounts, references, tax treatment, and dimensions. Incomplete or incorrect mapping leads to reporting errors, failed reconciliations, and compliance issues that are difficult and costly to correct after posting.

#### Integration Design

If you're an integration developer or architect, read the [Data Mapping](/docs/current/integration-design/exports/integration-design-exports-data-mapping) integration design doc before implementing this step. It covers mandatory, invoice-specific, and optional field mappings, VAT handling rules, and how to handle missing or unsupported fields.

#### Step-by-Step Instructions

When you're ready to start implementing, follow the step-by-step instructions in the accompanying How-to article.

<WhatComesNext href="/docs/current/how-tos/accounting-integrations/how-to-apply-data-mapping-for-as-erp-processing">
  How to Apply Data Mapping
</WhatComesNext>

***

### 4. Transfer Attachments

#### Purpose

Receipts and supporting documents associated with each Export Item must be downloaded from Pleo and uploaded to the Accounting System, where they are linked to the accounting entry. The integration must handle cases where no attachments exist (skipping cleanly), where multiple attachments are present, and where upload failures occur. Idempotency is important: re-running this step should not produce duplicate attachments.

#### Input

* Attachment references from the Export Item payload, including download URLs and metadata for each receipt or supporting document
* The accounting entry reference, used to link uploaded attachments to the correct record in the Accounting System

#### Workflow Process

<TransferAttachmentsDiagramNoClick />

#### Output

* Receipts and supporting documents uploaded to the Accounting System and linked to the corresponding accounting entry
* Items with no attachments skipped without error
* Upload failures recorded and handled without blocking other Export Items in the batch

#### Why It Matters

Attached receipts are essential for audit trails, expense compliance, and bookkeeper review. Without them, accountants must retrieve receipts manually from Pleo or original sources, increasing workload and the risk of documentation gaps during audits or compliance checks.

#### Integration Design

If you're an integration developer or architect, read the [Attachment Handling](/docs/current/integration-design/exports/integration-design-exports-attachment-handling) integration design doc before implementing this step. It covers the attachment retrieval process, how to handle multiple attachments, failure handling, and idempotency requirements.

#### Step-by-Step Instructions

When you're ready to start implementing, follow the step-by-step instructions in the accompanying How-to article.

<WhatComesNext href="/docs/current/how-tos/accounting-integrations/how-to-transfer-attachments-for-as-erp-processing">
  How to Transfer Attachments
</WhatComesNext>

***

### 5. Assign Accounting Period

#### Purpose

The integration must determine which accounting period the entry belongs to and post it to that period. The default posting date is the expense transaction date from the Export Item. If the Accounting System rejects the posting because the period is closed, the integration applies a configured closed-period strategy: either adjusting the posting date to the next open period and retrying, or failing the Export Item with a clear reason. Once posting succeeds, the integration confirms which period the entry was assigned to using the final posting date.

#### Input

* The expense date (`exportItem.date`) as the default posting date
* Integration configuration for the closed-period handling strategy: adjust and retry, or fail the Export Item
* Accounting System period rules, fiscal calendar, and open period information

#### Workflow Process

<AssignAccountingPeriodsDiagramNoClick />

#### Output

* The accounting entry assigned to a valid open period using the correct posting date
* Entries rejected due to closed periods either reassigned to an open period (if adjustment is enabled) or failed with a clear reason
* The final resolved accounting period confirmed

#### Why It Matters

Period assignment determines where entries appear in financial reports. An entry posted to the wrong period distorts profit and loss statements and makes period-end reconciliation unreliable. Handling closed periods correctly prevents entries from being silently rejected or posted to incorrect periods without the bookkeeper being aware.

#### Integration Design

If you're an integration developer or architect, read the [Accounting Periods](/docs/current/integration-design/exports/integration-design-exports-accounting-periods) integration design doc before implementing this step. It covers the expense date vs posting date distinction, the closed-period handling strategies, how to resolve accounting periods for custom or fiscal calendars, and the service period field.

#### Step-by-Step Instructions

When you're ready to start implementing, follow the step-by-step instructions in the accompanying How-to article.

<WhatComesNext href="/docs/current/how-tos/accounting-integrations/how-to-assign-accounting-periods-for-as-erp-processing">
  How to Assign Accounting Periods
</WhatComesNext>

***

### 6. Apply Posting Behaviour

#### Purpose

Before creating the accounting entry, the integration applies the configured posting behaviour: whether entries should be created as drafts (held for bookkeeper review before affecting financial statements) or finalised (posted immediately). The Accounting System may use different terminology for these states, and the integration must translate its configuration into the closest equivalent state supported by the system. If no posting configuration is found, the integration defaults to draft posting.

#### Input

* Integration posting configuration: draft status enabled or disabled
* The Accounting System's supported posting states and their labels (e.g. draft/posted, approved/unapproved, saved/committed)

#### Workflow Process

<PostingBehaviourDiagramNoClick />

#### Output

* The accounting entry created in the Accounting System with the correct posting status
* The entry ID and external URL captured from the Accounting System response, ready to be reported back to Pleo in the Export workflow

#### Why It Matters

Posting behaviour determines whether entries immediately impact financial statements or are held for review first. Draft posting gives bookkeepers the opportunity to verify entries before they affect reporting, particularly valuable during initial integration setup, after configuration changes, or when processing large batches. Defaulting to draft when configuration is missing prevents unintended immediate posting.

#### Integration Design

If you're an integration developer or architect, read the [Posting Behaviour](/docs/current/integration-design/exports/integration-design-exports-posting-behaviour) integration design doc before implementing this step. It covers the supported posting states, how to map them to Accounting System equivalents, the default behaviour rules, and the implementation order within the export workflow.

#### Step-by-Step Instructions

When you're ready to start implementing, follow the step-by-step instructions in the accompanying How-to article.

<WhatComesNext href="/docs/current/how-tos/accounting-integrations/how-to-apply-posting-behaviour-for-as-erp-processing">
  How to Apply Posting Behaviour
</WhatComesNext>

***

## Result

After completing this workflow for all Export Items:

* Accounting entries exist in the Accounting System for each successfully processed Export Item
* Entries are balanced, correctly mapped, and assigned to the correct periods
* Attachments are linked to their corresponding entries where supported
* Each entry reflects the configured posting status (draft or finalised)
* A success or failure result has been captured for every Export Item, ready to be reported back to Pleo

Export Items are now ready for status reporting and Export Job completion in the Export Integration Workflow.

***

## What Comes Next?

Return to the Export Integration Workflow to report Export Item outcomes and close the job:

* [Update Export Items](/docs/current/guides/export-integration-workflow-guide#6-update-export-items)
* [Update and Complete Export Job](/docs/current/guides/export-integration-workflow-guide#7-update--complete-export-job)

***

## Related Reading

* [Exports Overview](/docs/current/integration-design/exports/integration-design-exports-overview)
* [Exports Lifecycle](/docs/current/platform/exports/lifecycle)

***
