> ## 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 Payable Handling

When `bookkeeping.method` is `accounts_payable`, Export Items must be recorded using Accounts Payable bookkeeping.

Accounts Payable bookkeeping separates **vendor liability** (invoice) from **vendor settlement** (payment). These events may occur at different times and may originate from different Export Jobs.

This page defines how integrations must construct invoice entries, payment entries, and reconciliation behaviour once the resolved bookkeeping method for an Export Item is `accounts_payable`.

## Implementation

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

* [How to Determine the Bookkeeping Method](/docs/current/how-tos/accounting-integrations/how-to-determine-the-bookkeeping-method-for-as-erp-processing)

## Processing Model

Accounts Payable handling follows this processing order:

1. Vendor Resolution
2. Invoice and Payment Recording
3. Expense Type Handling
4. Reconciliation
5. Special Cases

Each Export Item must pass through these steps during processing.

```mermaid theme={null}

%%{init: {"themeVariables": {"fontSize": "12px"}}}%%
flowchart TD

A[Fetch Export Items] --> B[Resolve bookkeeping.method]

B -->|accounts_payable| C[Resolve Vendor]

C -->|Vendor Found| D[Determine Expense Type]
C -->|Vendor Not Found| X[Fail Export Item]

D --> E[Create Invoice Entry?]
D --> F[Create Payment Entry?]

E --> G[Invoice Recorded]
F --> H[Payment Recorded]

G --> I{Matching Payment Exists?}
H --> I

I -->|Yes| J[Reconcile Invoice and Payment]
I -->|No| K[Wait for Future Export Job]

J --> L[Set Invoice Status = Paid]

    %% Styling for readability
    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
    style G white-space:normal
    style H white-space:normal
    style I white-space:normal
    style J white-space:normal

```

<br />

<br />

<Accordion title="Example Export Item Payload (Accounts Payable)">
  ```
  {
    "data": [
      # [other Export Items omitted for brevity]
      {
        "companyId": "12abc3d4-e567-890e-1234-abc56e78fabc",
        "accountingEntryId": "98441fe2-6d31-4d52-8569-687de8368cb2",
        "type": "invoice",
        "subType": null,
        "date": "2025-04-18T00:00:00Z",
        "amount": {
          "inSupplierCurrency": {
            "currency": "GBP",
            "value": 130000
          },
          "inWalletCurrency": {
            "currency": "GBP",
            "value": 130000
          }
        },
        "note": "This was approved before the event.",
        "files": [
          {
            "url": "https://pleo-invoices.../12abc3d4-e567-890e-1234-abc56e78fabc/CR4VBJ7UUGK00/original.pdf..."
          }
        ],
        "supplier": {
          "code": null,
          "name": "TestSupplier123",
          "categoryCode": null,
          "country": "GB",
          "account": null,
          "taxIdentifier": "12345"
        },
        "user": {
          "id": "f1b5d950-1dbd-4493-8e8c-59fcfe13964f",
          "name": "Natalie White",
          "code": null
        },
        "team": null,
        "accountingEntryLines": [
          {
            "accountingEntryLineId": "98441fe2-6d31-4d52-8569-687de8368cb2",
            "lineAmount": {
              "inSupplierCurrency": {
                "currency": "GBP",
                "value": 130000
              },
              "inWalletCurrency": {
                "currency": "GBP",
                "value": 130000
              }
            },
            "netAmount": {
              "inSupplierCurrency": {
                "currency": "GBP",
                "value": 108333
              },
              "inWalletCurrency": {
                "currency": "GBP",
                "value": 108333
              }
            },
            "account": {
              "id": "eef29cf3-c6aa-45a8-b316-ae5b61d3a497",
              "code": "4650000",
              "name": "Marketing",
              "identifier": "4650000"
            },
            "tax": {
              "id": "b7440cfa-080e-42f2-a267-feb065ac98c9",
              "code": "0002",
              "type": "inclusive",
              "amount": {
                "inSupplierCurrency": {
                  "currency": "GBP",
                  "value": 21667
                },
                "inWalletCurrency": {
                  "currency": "GBP",
                  "value": 21667
                }
              },
              "rate": 0.20
            },
            "tags": [
              {
                "id": "4818af60-c790-4208-930a-87db98108193",
                "groupCode": "Project A",
                "code": "004"
              }
            ]
          }
        ],
        "additionalInformation": {
          "reconciliationId": "0",
          "reconciledEntries": null,
          "attendees": [],
          "invoiceInformation": {
            "invoiceNumber": "WZM259435",
            "status": "ready",
            "invoiceDate": "2025-04-18T00:00:00Z",
            "dueDate": "2025-04-30T00:00:00Z",
            "paymentDate": null,
            "supplierBankAccount": {
              "bankName": "NATIONAL WESTMINSTER BANK PLC",
              "bankCode": "123456",
              "accountNumber": "09876543",
              "country": "GB",
              "bic": null,
              "iban": null
            }
          }
        },
        "bookkeeping": {
          "method": "accounts_payable"
        },
        "vendor": {
          "id": "22e1f2c9-1360-4291-ab41-6b23dcea8888",
          "name": "TestVendor",
          "code": "acc1234",
          "externalId": "ext12345",
          "registrationNumber": "reg001234",
          "taxRegistrationNumber": "taxreg1234",
          "country": "UK",
          "defaultCurrency": "GBP"
        },
        "contraAccount": null,
        "_links": {
          "web": {
            "exportItem": "https://app.staging.pleo.io/export/export-item/98441fe2-6d31-4d52-8569-687de8368cb2"
          }
        },
        "servicePeriod": {
          "from": "2025-04-18T00:00:00Z",
          "to": "2025-04-18T00:00:00Z"
        }
      }
    ],
    "pagination": {
      "hasPreviousPage": false,
      "hasNextPage": false,
      "currentRequestPagination": {
        "sortingKeys": [],
        "sortingOrder": [],
        "parameters": {
          "job_id": [
            "c62931c9-ecd4-4a6f-9f43-f759ac297707"
          ]
        }
      },
      "startCursor": "AAAAAADJ5MVAOIR2ZFYA=ZOA73ZCZDVDJNGJSQHCX2LCGPY",
      "endCursor": "AAAAAADJ5MVAOIRZQFIA=GBA43XWBQRCCLFTOWOQKVJUAUU",
      "total": 4
    }
  }
  ```
</Accordion>

## 1. Vendor Resolution

### Detection

`bookkeeping.method = accounts_payable`

```mermaid theme={null}

%%{init: {"themeVariables": {"fontSize": "12px"}}}%%
flowchart TD

A[Start Vendor Resolution] --> B{Vendor Object Present?}

B -->|Yes| C[Match vendor.code]
C --> D{Match Found?}

D -->|Yes| E[Vendor Resolved]
D -->|No| F[Try account or taxIdentifier]

F --> G{Match Found?}
G -->|Yes| E
G -->|No| H[Fail Export Item]

B -->|No| I[Check Legacy supplier Object]
I --> J{Vendor Found?}

J -->|Yes| E
J -->|No| H

    %% Styling for readability
    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
    style G white-space:normal
    style H white-space:normal
    style I white-space:normal
    style J white-space:normal
```

### Rule

A vendor **must** be resolved before creating invoice entries.

The integration must attempt vendor matching using the following priority order:

1. **`vendor.code`**
2. **`vendor.account`**
3. **`vendor.taxIdentifier`**

If a `vendor` object exists, the `supplier` object must be ignored.

### Failure Behaviour

If vendor matching fails:

* The Export Item must not be recorded
* The Export Item must fail in Pleo

Failure reporting:

* **failureReasonType**
  * `vendor_unknown` (Export V3)
  * `accounting_system_validation_failure` (Export V2)

* **failureReasonMessage**

  Selected vendor cannot be processed because it does not exist or is currently blocked. Please verify the vendor's status in the accounting system and try again.

### Legacy Support

If no `bookkeeping` object is present but a `supplier` object exists, attempt
vendor resolution using the supplier object's identifiers.

Use the following priority order to find a matching vendor in your AS:

| Priority | Supplier Field           | Match Against in AS                              |
| -------- | ------------------------ | ------------------------------------------------ |
| 1        | `supplier.code`          | Vendor ID                                        |
| 2        | `supplier.account`       | Vendor account number                            |
| 3        | `supplier.taxIdentifier` | Vendor tax identifier or tax registration number |

Work through each field in order, stopping as soon as a match is found.

If no match is found after all three, fail the Export Item using the same
failure behaviour as standard vendor resolution.

## 2. Invoice and Payment Model

### Detection

`bookkeeping.method = accounts_payable`

### Rule

The integration must record:

* Vendor liability as an **invoice object**
* Vendor settlement as a **payment entry**

Payment recording may occur by:

* Marking the invoice as paid, and/or
* Creating a separate payment entry

Implementation depends on Accounting System capabilities.

### Behaviour Notes

Invoice and payment entries may be recorded at different times and may originate from separate Export Jobs.

## 3. Expense Type Handling

### Detection

After vendor resolution succeeds.

```mermaid theme={null}

%%{init: {"themeVariables": {"fontSize": "12px"}}}%%
flowchart TD

A[Export Item Type] --> B{Type}

B -->|card_purchase / card_invoice / fee| C[Create Invoice]
C --> D[Create Payment]
D --> E[Reconcile Immediately]

B -->|invoice| F[Create Invoice Only]
F --> G[Status = Unpaid]

B -->|invoice_payment paid| H[Create Payment Only]
H --> I[Reconcile Using reconciliationId]

B -->|invoice_payment failed_payment| J[Create Return Payment]
J --> K[Status = Unpaid]

    %% Styling for readability
    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
    style G white-space:normal
    style H white-space:normal
    style I white-space:normal
    style J white-space:normal

```

### Rule

Export Item type determines whether an invoice, payment, or both must be recorded.

### card\_invoice, card\_purchase, fee

* Record an invoice entry
* Record a payment entry
* Reconcile invoice and payment
* Set invoice status to `paid`

### invoice

* Record an invoice entry only
* Set invoice status to `unpaid`
* Reconcile once payment is recorded

### invoice\_payment (`invoiceInformation.status = paid`)

* Record a payment entry only
* Reconcile using `reconciliationId`
* Set invoice status to `paid`

### invoice\_payment (`invoiceInformation.status = failed_payment`)

If the bank rejects the payment and funds return to the Pleo wallet:

* Record a return vendor payment
* Set invoice status to `unpaid`

## 4. Recording and Reconciliation

### Detection

Both invoice and payment entries exist.

```mermaid theme={null}
%%{init: {"themeVariables": {"fontSize": "12px"}}}%%
flowchart TD

A[Invoice Recorded] --> C{Both Entries Present?}
B[Payment Recorded] --> C

C -->|No| D[Wait for Future Export Job]
C -->|Yes| E[Reconcile Entries]

E --> F[Set Invoice Status = Paid]

    %% Styling for readability
    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

```

### Rule

The integration must reconcile invoice and payment entries.

Reconciliation may occur across Export Jobs.

After reconciliation:

* Invoice payment status must be set to `paid`.

## 5. Special Cases

### Refunds and Chargebacks

#### Detection

Export Item type is `refund` or `chargeback`.

#### Rule

If supported by the Accounting System:

* Record a **credit note** instead of an invoice
* Record the corresponding refund payment
* Reconcile credit note and payment
* Set credit note status to `paid`

### Split Expenses

#### Detection

If the Export Item contains more than one split line (`accountingEntryLines.length > 1`), it must be treated as a split expense.

#### Rule

* Record each split line as a separate line on the invoice
* Record a single payment line representing the total amount across all splits
* Reconcile invoice lines with the payment as usual

#### Example

Create the following in your Accounting System if the expense has 2 splits:

* Line 1 (API): £120 → create 1 invoice line
* Line 2 (API): £80 → create 1 invoice line
* Line 3 (calculated total): £200 → create 1 payment line

## Upstream Dependencies

* Export Job has been started (status = `in_progress`)
* Fetch Export Item Data (data layer)
* Bookkeeping method resolved

## Downstream Dependencies

Accounts Payable entries rely on several platform concepts to be **complete and reconcilable**:

* **Accounts Mapping** – determines which GL accounts are debited and credited
* **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?

* [Accounts Mapping](/docs/current/integration-design/exports/integration-design-exports-accounts-mapping)

***

## Related Reading

* [How to Determine the Bookkeeping Method](/docs/current/how-tos/accounting-integrations/how-to-determine-the-bookkeeping-method-for-as-erp-processing)
* [Journal Entry Handling](/docs/current/integration-design/exports/integration-design-exports-bookkeeping-method-journal-entry)
* [Export Integration Workflow Guide](/docs/current/guides/export-integration-workflow-guide)
* [AS/ERP Processing Workflow Guide](/docs/current/guides/accounting-system-processing-workflow-guide)

***
