{
  "id": 19919269,
  "title": "Three-Way Invoice Matching: Automating AP in Custom ERP",
  "url": "https://urgent.news/2026/11/14/three-way-invoice-matching-automating-ap-in-custom-erp",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-14T04:43:08.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/muhammadalimughal/three-way-invoice-matching-automating-ap-in-custom-erp-3hih"
  },
  "original_language": "en",
  "account": "Three-way invoice matching is an essential control mechanism for preventing errors in accounts payable, such as overcharging or incorrect quantities. It involves comparing three pieces of data before approving an invoice: the purchase order, goods receipt, and invoice. The process ensures that the prices, items, and quantities align properly, with some acceptable tolerances to accommodate normal business fluctuations.\n\nIn a custom ERP system, implementing three-way matching is a focused piece of software that helps maintain control over this critical aspect of finance. However, building it poorly can create a backlog of exceptions that no one clears. The author, Loop Origin, has spent nine years developing order, inventory, and finance modules in Laravel, Vue, Nuxt, and PostgreSQL, and this guide aims to cover all aspects of three-way invoice matching.\n\nThe data model is structured around individual lines rather than document totals. There are three main tables: purchase order lines (po_lines), goods receipt lines (grn_lines), and invoice lines (invoice_lines). Each line includes essential information like SKU, quantity, and unit price. The PO line table supports multiple match types, including two-way and three-way matching. Goods receipt and invoice lines track received quantities and approved invoices, respectively.\n\nA crucial detail is the prevention of duplicate invoice numbers, as the same invoice number should never be submitted by a supplier. Additionally, the system must account for partial deliveries that might otherwise lead to double payments.\n\nMatching rules and tolerances are essential to adapt to various business policies. These rules are typically defined per supplier or category, with a company-wide default in case no specific rule exists. The author emphasizes that hard-coding tolerance values like 2% is a frequent mistake found in inherited AP code. The exact values for each rule, such as price and quantity comparisons, must be carefully considered to prevent overbilling or under-receipting.\n\nBy following this structured approach to three-way invoice matching, mid-market importers and distributors can maintain financial integrity while accommodating the unique needs of their business.",
  "summary": "Accounts payable is where a growing distributor quietly loses money: a supplier bills 500 units when 480 arrived, a price creeps up two percent, an invoice gets paid twice because it came in by email and by post. Three-way matching (purchase order, goods receipt, invoice) is the control that stops this, and in a custom ERP it is a small, well-defined piece of software. Built badly, it becomes a…",
  "key_points": [
    "Three-way invoice matching prevents errors in accounts payable",
    "Custom ERP system implements focused software for control",
    "Data model structured around individual lines, not document totals"
  ],
  "editors_take": "Structuring three-way matching around individual line items rather than document totals allows mid-market distributors to maintain financial integrity while preventing the costly backlogs caused by rigid, hard-coded tolerance rules.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}