{"skills":[{"name":"Match a purchase order, receipt and bill","description":"Check the amount supported by orders and accepted deliveries before a supplier bill enters the approval queue.","content":"# Match a purchase order, receipt and bill\n\nCheck the amount supported by orders and accepted deliveries before a supplier bill enters the approval queue.\n\n## When to use this skill\n\n- A supplier invoice needs checking against the purchase order and what was actually received before it is approved.\n- Goods were part-delivered, returned or rejected, or the order has already been part-invoiced.\n- An invoice price differs from the purchase order price.\n\n## When not to use it\n\n- Approving or releasing a payment. The result is evidence for the approver under the organisation's own policy and tolerances.\n- Checking whether the invoice is a valid VAT invoice or uses the right VAT rate. Ask the accounts team, using the tax authority's rules.\n- A request to change the supplier's bank details. Use the supplier bank change skill before anything is paid.\n\n## What you need\n\n- Purchase order with quantity, unit and net price for each line.\n- Accepted receipts, returns, previously billed quantities and this bill.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- Is the order billed on ordered quantities or on received quantities? That decides what the bill can claim.\n- Do the receipt figures already exclude returns and rejected goods, and what has already been billed on each order line?\n- Are the order, receipt and bill in the same unit, such as cases or single items, and the same currency, net of tax?\n- Does your policy set a price or quantity tolerance? The full difference is reported either way, with a note of what falls inside it.\n\n## Method\n\n1. Match on purchase order, line ID, currency and unit. Resolve case-versus-each conversions from the actual order before comparing quantities. Missing receipts leave the position unverified.\n2. Work out net accepted units. Identify whether the receipt figure is gross or already net of returns and rejects, then deduct each adjustment once.\n3. Under received-quantity billing, the units available to bill are the lesser of ordered and net accepted units, less units already billed, floored at zero. Accepting an over-delivery does not enlarge the order.\n4. Allocate from one remaining balance per order line across all current bill lines, in the documented matching order. If line attribution is ambiguous, give aggregate support instead.\n5. For each bill line, split supported units from excess units. Compare the billed unit price with the contract price separately, so an excess quantity and a price difference are not charged twice.\n6. Value supported units at the contract price, net of tax. Report billed minus supported as a signed amount and break it into its quantity part and its price part.\n7. Apply the organisation's tolerance only after reporting the full difference. Hand the result to the approver as evidence, not as a payment instruction.\n\n## Checks before you deliver\n\n- A physical delivery note may include damaged goods that the receiver rejected.\n- Previously billed quantities include earlier part-invoices. Using gross deliveries again can approve the same quantity twice.\n- Accepting a price variance because it sits inside tolerance without recording it. Small variances add up across part-invoices on the same line.\n- Comparing a case price with a unit price, or a gross amount with a net amount.\n- Billing extra goods that were accepted but never ordered. They need an order change before the bill can be supported.\n\n## How to present the result\n\nLead with the amount supported and the amount to query. Then give a table per bill line: units billed, units available, supported and excess units, billed and contract unit prices, and the value of each difference. Finish with a short query to the supplier listing each disputed line and the figure expected, ready to send.\n\n## Worked example\n\n**Request:** Perform a three-way match for this received-quantity PO.\n\n**Supplied material:**\n\n```text\nOrder L1 20 stands at \u00a312 each. Delivered 16, rejected 2, previously billed 5. Current bill L1 10 stands at \u00a313. GBP net.\n```\n\n**Answer:** Nine stands are supported at \u00a312, or \u00a3108 net. The bill requests \u00a3130. Query \u00a322: the tenth stand contributes \u00a313 and the nine supported stands are \u00a31 each above contract. Five of the 14 accepted units were billed previously.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nReturn available_units, supported_units and excess_units as objects keyed by current bill line ID. Return supported_value at contract prices and billed_less_supported as signed amounts in the stated currency, net of tax. Use null values for unverified inputs rather than manufacturing a receipt.\n\n## Sources\n\n- [Odoo: Manage vendor bills](https:\/\/www.odoo.com\/documentation\/19.0\/applications\/inventory_and_mrp\/purchase\/manage_deals\/control_bills.html): Odoo's bill control policy separates billing on ordered quantities from billing on received quantities, and describes three-way matching as making sure bills are paid only once some or all of the ordered products have been received.\n- [Microsoft Dynamics 365: Accounts payable invoice matching](https:\/\/learn.microsoft.com\/en-us\/dynamics365\/finance\/accounts-payable\/accounts-payable-invoice-matching): Microsoft defines three-way matching as matching invoice price to the purchase order and invoice quantity to the product receipts selected for the invoice, with configurable price tolerances. Its price totals example includes earlier invoices on the same line, which is why the skill tracks prior billing.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/match-purchase-order-receipt-and-bill\n","scope":"contextual","trigger_keywords":["Match a purchase order, receipt and bill","match-purchase-order-receipt-and-bill","match purchase order receipt and bill","Does this supplier invoice match what we ordered and what actually arrived?","Does this supplier invoice match what we ordered and what actually arrived","three-way match","three way match","match this po to the invoice"],"is_private":true,"is_active":true,"scripts":[{"name":"match-purchase-order-receipt-and-bill-check","description":"Compare a saved JSON answer with a published test. Pass tests\/case-1\/expected.json (or another case) and the path to your answer.","language":"python","filename":"match-purchase-order-receipt-and-bill-check.py","content":"from pathlib import Path\nimport runpy\n\nrunpy.run_path(str(Path(__file__).parent \/ 'tests' \/ 'check.py'), run_name='__main__')\n","supporting_files":[{"path":"SKILL.md","content":"---\nname: match-purchase-order-receipt-and-bill\ndescription: \"Three-way match a supplier invoice against the purchase order and goods received, net of returns and earlier bills, to find over-billing on quantity or price before approval. Use when checking a supplier bill or invoice against a PO, delivery notes or goods received notes.\"\nlicense: CC-BY-4.0\nmetadata:\n  author: Raq.com\n  version: \"2026-11-22\"\n  homepage: https:\/\/skills.raq.com\/skills\/match-purchase-order-receipt-and-bill\n---\n\n# Match a purchase order, receipt and bill\n\nCheck the amount supported by orders and accepted deliveries before a supplier bill enters the approval queue.\n\n## When to use this skill\n\n- A supplier invoice needs checking against the purchase order and what was actually received before it is approved.\n- Goods were part-delivered, returned or rejected, or the order has already been part-invoiced.\n- An invoice price differs from the purchase order price.\n\n## When not to use it\n\n- Approving or releasing a payment. The result is evidence for the approver under the organisation's own policy and tolerances.\n- Checking whether the invoice is a valid VAT invoice or uses the right VAT rate. Ask the accounts team, using the tax authority's rules.\n- A request to change the supplier's bank details. Use the supplier bank change skill before anything is paid.\n\n## What you need\n\n- Purchase order with quantity, unit and net price for each line.\n- Accepted receipts, returns, previously billed quantities and this bill.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- Is the order billed on ordered quantities or on received quantities? That decides what the bill can claim.\n- Do the receipt figures already exclude returns and rejected goods, and what has already been billed on each order line?\n- Are the order, receipt and bill in the same unit, such as cases or single items, and the same currency, net of tax?\n- Does your policy set a price or quantity tolerance? The full difference is reported either way, with a note of what falls inside it.\n\n## Method\n\n1. Match on purchase order, line ID, currency and unit. Resolve case-versus-each conversions from the actual order before comparing quantities. Missing receipts leave the position unverified.\n2. Work out net accepted units. Identify whether the receipt figure is gross or already net of returns and rejects, then deduct each adjustment once.\n3. Under received-quantity billing, the units available to bill are the lesser of ordered and net accepted units, less units already billed, floored at zero. Accepting an over-delivery does not enlarge the order.\n4. Allocate from one remaining balance per order line across all current bill lines, in the documented matching order. If line attribution is ambiguous, give aggregate support instead.\n5. For each bill line, split supported units from excess units. Compare the billed unit price with the contract price separately, so an excess quantity and a price difference are not charged twice.\n6. Value supported units at the contract price, net of tax. Report billed minus supported as a signed amount and break it into its quantity part and its price part.\n7. Apply the organisation's tolerance only after reporting the full difference. Hand the result to the approver as evidence, not as a payment instruction.\n\n## Checks before you deliver\n\n- A physical delivery note may include damaged goods that the receiver rejected.\n- Previously billed quantities include earlier part-invoices. Using gross deliveries again can approve the same quantity twice.\n- Accepting a price variance because it sits inside tolerance without recording it. Small variances add up across part-invoices on the same line.\n- Comparing a case price with a unit price, or a gross amount with a net amount.\n- Billing extra goods that were accepted but never ordered. They need an order change before the bill can be supported.\n\n## How to present the result\n\nLead with the amount supported and the amount to query. Then give a table per bill line: units billed, units available, supported and excess units, billed and contract unit prices, and the value of each difference. Finish with a short query to the supplier listing each disputed line and the figure expected, ready to send.\n\n## Worked example\n\n**Request:** Perform a three-way match for this received-quantity PO.\n\n**Supplied material:**\n\n```text\nOrder L1 20 stands at \u00a312 each. Delivered 16, rejected 2, previously billed 5. Current bill L1 10 stands at \u00a313. GBP net.\n```\n\n**Answer:** Nine stands are supported at \u00a312, or \u00a3108 net. The bill requests \u00a3130. Query \u00a322: the tenth stand contributes \u00a313 and the nine supported stands are \u00a31 each above contract. Five of the 14 accepted units were billed previously.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nReturn available_units, supported_units and excess_units as objects keyed by current bill line ID. Return supported_value at contract prices and billed_less_supported as signed amounts in the stated currency, net of tax. Use null values for unverified inputs rather than manufacturing a receipt.\n\n## Sources\n\n- [Odoo: Manage vendor bills](https:\/\/www.odoo.com\/documentation\/19.0\/applications\/inventory_and_mrp\/purchase\/manage_deals\/control_bills.html): Odoo's bill control policy separates billing on ordered quantities from billing on received quantities, and describes three-way matching as making sure bills are paid only once some or all of the ordered products have been received.\n- [Microsoft Dynamics 365: Accounts payable invoice matching](https:\/\/learn.microsoft.com\/en-us\/dynamics365\/finance\/accounts-payable\/accounts-payable-invoice-matching): Microsoft defines three-way matching as matching invoice price to the purchase order and invoice quantity to the product receipts selected for the invoice, with configurable price tolerances. Its price totals example includes earlier invoices on the same line, which is why the skill tracks prior billing.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/match-purchase-order-receipt-and-bill\n"},{"path":"LICENSE.txt","content":"Original Raq.com instructions and synthetic examples: CC BY 4.0.\nhttps:\/\/creativecommons.org\/licenses\/by\/4.0\/\nAttribution: Raq.com, https:\/\/skills.raq.com\/skills\/match-purchase-order-receipt-and-bill\nReferenced third-party materials retain their own terms.\n"},{"path":"examples\/worked-example.md","content":"# Part-invoice after damage\n\nPerform a three-way match for this received-quantity PO.\n\n## Supplied material\n\nOrder L1 20 stands at \u00a312 each. Delivered 16, rejected 2, previously billed 5. Current bill L1 10 stands at \u00a313. GBP net.\n\n## Worked answer\n\nNine stands are supported at \u00a312, or \u00a3108 net. The bill requests \u00a3130. Query \u00a322: the tenth stand contributes \u00a313 and the nine supported stands are \u00a31 each above contract. Five of the 14 accepted units were billed previously.\n\n## Reasoning\n\nNine units are available. The \u00a322 difference combines one extra unit with a unit price change.\n"},{"path":"tests\/check.py","content":"\"\"\"Check a saved agent answer locally with Python 3 (standard library only).\"\"\"\nimport json\nimport math\nimport sys\nfrom pathlib import Path\n\n\ndef compare(expected, actual, path=\"$\", accepted=None):\n    if isinstance(expected, bool) or isinstance(actual, bool):\n        if expected is not actual:\n            yield path\n    elif isinstance(expected, (int, float)) and isinstance(actual, (int, float)):\n        if not math.isclose(expected, actual, rel_tol=0, abs_tol=1e-8):\n            yield path\n    elif isinstance(expected, dict) and isinstance(actual, dict):\n        for key in sorted(set(expected) | set(actual)):\n            if key not in expected or key not in actual:\n                yield f\"{path}.{key}\"\n            elif not any(\n                not list(compare(option, actual[key]))\n                for option in (accepted or {}).get(key, [])\n            ):\n                yield from compare(expected[key], actual[key], f\"{path}.{key}\")\n    elif isinstance(expected, list) and isinstance(actual, list):\n        if len(expected) != len(actual):\n            yield f\"{path} (length)\"\n        for i, (left, right) in enumerate(zip(expected, actual)):\n            yield from compare(left, right, f\"{path}[{i}]\")\n    elif type(expected) != type(actual) or expected != actual:\n        yield path\n\n\ndef main():\n    if len(sys.argv) != 3:\n        raise SystemExit(\"Usage: python3 check.py expected.json answer.json\")\n    try:\n        expected, actual = [json.loads(Path(p).read_text(encoding=\"utf-8\")) for p in sys.argv[1:]]\n        alternatives = Path(sys.argv[1]).with_name(\"accepted.json\")\n        accepted = json.loads(alternatives.read_text(encoding=\"utf-8\")) if alternatives.is_file() else {}\n    except (ValueError, OSError) as error:\n        raise SystemExit(str(error))\n    differences = list(compare(expected, actual, accepted=accepted))\n    if differences:\n        raise SystemExit(\"Different fields: \" + \", \".join(differences))\n    print(\"Pass\")\n\n\nif __name__ == \"__main__\":\n    main()\n"},{"path":"tests\/README.md","content":"Give your agent SKILL.md and one request.txt in a fresh session. Keep the expected answer aside. Save the reply as answer.json, then run this from the tests folder:\n\n    python3 check.py case-1\/expected.json answer.json\n\nEach case also has an explanation. Where accepted.json exists, the checker accepts the alternatives listed there.\n"},{"path":"tests\/case-1\/request.txt","content":"Perform a three-way match for this received-quantity PO.\nReturn only the JSON specified in SKILL.md for this test.\n\nOrder L1 20 stands at \u00a312 each. Delivered 16, rejected 2, previously billed 5. Current bill L1 10 stands at \u00a313. GBP net.\n"},{"path":"tests\/case-1\/expected.json","content":"{\n    \"available_units\": {\n        \"L1\": 9\n    },\n    \"supported_units\": {\n        \"L1\": 9\n    },\n    \"excess_units\": {\n        \"L1\": 1\n    },\n    \"supported_value\": 108,\n    \"billed_less_supported\": 22\n}\n"},{"path":"tests\/case-1\/explanation.txt","content":"Nine units are available. The \u00a322 difference combines one extra unit with a unit price change.\n"},{"path":"tests\/case-2\/request.txt","content":"How much of this bill is covered by the order?\nReturn only the JSON specified in SKILL.md for this test.\n\nOrder P2 6 lamps at \u20ac20. Accepted 8, billed previously 2. Current P2 5 at \u20ac20. EUR net.\n"},{"path":"tests\/case-2\/expected.json","content":"{\n    \"available_units\": {\n        \"P2\": 4\n    },\n    \"supported_units\": {\n        \"P2\": 4\n    },\n    \"excess_units\": {\n        \"P2\": 1\n    },\n    \"supported_value\": 80,\n    \"billed_less_supported\": 20\n}\n"},{"path":"tests\/case-2\/explanation.txt","content":"Accepting an extra delivery does not enlarge the recorded order.\n"},{"path":"tests\/case-3\/request.txt","content":"Check the split bill in the stated processing order.\nReturn only the JSON specified in SKILL.md for this test.\n\nPO P 100 units @ \u00a39. Receipt 70 gross, 5 returned; 60 previously billed. Current bill line X 4 units then Y 6 units, both @ \u00a39 against P. Apply eligible stock to X first per the supplied matching rule.\n"},{"path":"tests\/case-3\/expected.json","content":"{\n    \"available_units\": {\n        \"X\": 5,\n        \"Y\": 1\n    },\n    \"supported_units\": {\n        \"X\": 4,\n        \"Y\": 1\n    },\n    \"excess_units\": {\n        \"X\": 0,\n        \"Y\": 5\n    },\n    \"supported_value\": 45,\n    \"billed_less_supported\": 45\n}\n"},{"path":"tests\/case-3\/explanation.txt","content":"Five received units remain to support new charges. The second line cannot reuse the four allocated to the first.\n"}],"is_active":true,"is_approved":false}]}]}