---
title: "Match to purchase orders | Docs | e-Factura Gateway by R&D Copilot"
description: "Match a received invoice to your own purchase order by its reference, with a fallback on the supplier and the total."
canonical: "https://efactura.rdcopilot.com/docs/receive/match-to-purchase-orders/"
language: en
updated: 2026-11-22
---

# Match to purchase orders

Match a received invoice to your own purchase order by its reference, with a fallback on the supplier and the total.

The gateway does not hold your purchase orders. It gives you the fields to match on, and your software decides. A received invoice carries `reference`, which is the reference the supplier printed on it, usually the number of your purchase order. It is empty when the supplier printed none.

## What to match on

| Field | Use |
| --- | --- |
| `reference` | First choice. Compare it with the number of your purchase order. |
| `partnerCif` | The supplier. Use it when `reference` is empty, or to confirm a match. |
| `total` | The amount with VAT. Compare it with the total of the order and its VAT. |
| `lines` | The `code`, `quantity` and `unitPrice` of each line, for a match line by line. |

## Match what you downloaded

Read the received invoices of a company page by page, and match each against your orders. Compare amounts as decimal strings or in the smallest unit of the currency; never as floating-point numbers.

Match by reference, then by supplier and total

```javascript
const base = process.env.RDC_BASE_URL;
const headers = {Authorization: `Bearer ${process.env.RDC_TOKEN}`};

async function receivedInvoices(companyId) {
  const found = [];
  let cursor = null;
  do {
    const query = new URLSearchParams({companyId, limit: '100'});
    if (cursor) query.set('cursor', cursor);
    const response = await fetch(`${base}/efactura/v1/received-invoices?${query}`, {headers});
    const page = await response.json();
    for (const item of page.items) found.push(item);
    cursor = page.nextCursor;
  } while (cursor);
  return found;
}

// orders: [{number, supplierCif, total}] from your own system
function orderOf(invoice, orders) {
  const byReference = orders.find(order => invoice.reference !== '' && order.number === invoice.reference);
  if (byReference) return byReference;
  return orders.find(order => order.supplierCif === invoice.partnerCif && order.total === invoice.total);
}
```

An invoice that matches no order is not an error of the gateway. Send it to the person who owns purchasing, with its `reference` and its `partner`. See [Sync received invoices](https://efactura.rdcopilot.com/docs/receive/sync-received-invoices/).
