Close the two cycles that decide whether finance trusts the systems — automate procure-to-pay across Coupa and ERP with three-way match, run order-to-cash from fulfillment through invoice and cash application, and handle the gross-to-net deductions that make pharma billing unlike anyone else's.
Tags: life-sciences, pharma, medtech, order-to-cash, procure-to-pay, sap, netsuite, x12, api-led
Financial and Billing Operations: Order-to-Cash and Procure-to-Pay
Objective: Automate the two financial cycles that touch every other system: procure-to-pay from requisition through payment, and order-to-cash from shipment through cash application. In pharma the second cycle carries a complication other industries do not have — invoiced price is rarely the price that survives, because chargebacks, rebates, and government pricing pull it apart afterwards. The integration has to make gross-to-net deductions traceable rather than an accrual nobody can explain.
What's Getting Built
- Procure-to-Pay Intake (System API) — syncs suppliers, purchase orders, and receipts between Coupa and ERP ·
GET /suppliers, GET /purchase-orders, GET /receipts, GET /po/{number}/status
- Invoice, Match, and Post (Process API) — runs three-way match on invoice, PO, and goods receipt and posts idempotently to ERP ·
POST /invoices, POST /three-way-match, POST /post, GET /exceptions/{id}
- Order-to-Cash (Process API) — converts shipment confirmation into an invoice and applies cash from bank files ·
POST /invoice-events, POST /invoices/transmit, POST /cash-application, GET /aging
- Gross-to-Net Deductions (Process API) — validates chargeback and rebate claims against contract eligibility and accrues from actual claims ·
POST /chargebacks, POST /rebates, POST /accruals, GET /deductions/{id}
- ERP financials (target) — posts documents through released OData interfaces keyed on an external reference ·
POST /invoice-post, POST /credit-memo, GET /document/{ref}
- Control Total Reconciliation (Batch flow) — computes a control total per interface run and reconciles source, integration, and ERP counts ·
BATCH reconcile per interface run, GET /control-totals/{runId}
Value chain coverage
This plan cuts across phases rather than sitting inside one.
| Phase |
Name |
What this plan does there |
| 04 |
Manufacturing & QC |
Procure-to-pay for raw materials, CMO services, and lab consumables, with purchase order and receipt evidence tied to production. |
| 05 |
Supply Chain & Logistics |
Shipment confirmation converted into invoice, and freight and 3PL charges captured against the movement that caused them. |
| 06 |
Commercial & Patient Services |
Order-to-cash across distributors and providers, including chargebacks, rebates, and the deductions behind net revenue. |
Prerequisites
- Anypoint Platform org with API Manager and a non-production deployment target.
- Secrets Manager or secure properties configured for every system credential.
- Named owner for each source system — integration stalls on access, not on code.
- ERP financial access — SAP S/4HANA, Oracle, or NetSuite — with an integration user and a defined posting path.
- Procurement platform access if Coupa or equivalent is in use, plus the certified connector or its REST API.
- Agreed chart of accounts, company codes, and tax determination approach before the first mapping is written.
- Contract and pricing source for chargeback and rebate eligibility, with named ownership of price lists.
Choose your path
- Procure-to-pay first — Choose when invoice processing cost and late-payment penalties are the visible problem — the cycle is self-contained and returns value without touching revenue recognition.
- Order-to-cash first — Choose when days sales outstanding and unapplied cash are the problem, or when gross-to-net accruals cannot be explained to auditors.
Platform notes
SAP S/4HANA
- Prefer released OData APIs over direct table access, and post through the standard interfaces so document flow stays intact.
- Idempotency matters more than throughput — a retried invoice post creates a duplicate document that finance has to reverse manually.
NetSuite
- The Anypoint connector uses the SuiteTalk WSDL for SOAP operations and can call RESTlets built with SuiteScript for anything the standard API does not cover.
- Governance limits are real; batch record operations and back off on limit errors rather than retrying immediately.
Coupa
- A MuleSoft Certified connector from AcquisLink covers the Coupa REST APIs, and support for certified connectors routes through the partner rather than MuleSoft.
- Keep approval workflow in Coupa; the integration moves documents and status, and never becomes a second approval engine.
Pharma and MedTech differences
The architecture below is shared. These are the points where the two diverge, and they are the only places an implementation should read differently.
| Aspect |
Pharma |
MedTech |
| What is being sold |
Product units, priced per pack. |
Consumables, capital equipment on multi-year terms, and service contracts — three revenue shapes on one account. |
| The deduction that distorts revenue |
Chargebacks, rebates, and government pricing. |
GPO administrative fees and contract rebates, tied to the agreement rather than to class of trade. |
| What triggers the invoice |
Shipment confirmation. |
Shipment for stock orders, but usage capture for consignment — the invoice follows the procedure. |
| Common ERP |
SAP S/4HANA, with Oracle in places. |
SAP, Oracle, and JD Edwards, frequently more than one after acquisitions. |
Architecture
1. Business requirements
- Straight-through invoice processing for the majority of supplier invoices, with exceptions routed rather than queued.
- Order-to-cash cycle time and days sales outstanding reduced without weakening credit control.
- Gross-to-net deductions traceable from the accrual back to the contract and the transaction.
- A single reconciliation view finance can defend at close, rather than spreadsheets assembled the week before.
2. Procure-to-pay
- Sync suppliers, purchase orders, and receipts between the procurement platform and ERP with one owner per object.
- Perform three-way match on invoice, purchase order, and goods receipt, and route only genuine exceptions to a human.
- Handle service-based procurement — CMO and CRO work is milestone-billed, so match against service entry rather than quantity.
- Return payment status to the procurement platform so suppliers stop calling accounts payable for it.
3. Order-to-cash
- Convert shipment confirmation into an invoice event with the movement, lot, and pricing context attached.
- Transmit invoices by the channel each customer supports — EDI 810, portal, or API — from one canonical invoice document.
- Apply cash from bank files and remittance advice, matching on invoice reference before falling back to heuristics.
- Expose collections-ready aging with dispute reason codes rather than a flat overdue list.
4. Gross-to-net and deductions
- Validate chargeback claims against contract eligibility and the customer's class of trade before crediting.
- Process rebate and administrative fee claims on their own cadence, and hold the evidence with the credit.
- Accrue deductions from actual claim behavior rather than a fixed percentage, and expose the drivers behind the number.
- Reconcile government pricing inputs separately, because a restatement there is a reportable event.
5. Controls and reconciliation
- Make every posting idempotent with an external document reference, and prove it under retry.
- Emit a control total per interface run and reconcile source, integration, and ERP counts automatically.
- Keep segregation of duties intact — the integration user is not an approver, and should not hold rights that let it become one.
- Retain the transformation record for every posted document so audit can trace a number to its source.
6. Security, financial controls, and GxP boundaries
- Validate the integration under GAMP 5 — requirements, design, IQ/OQ/PQ evidence, and a traceability matrix retained for inspection.
- Meet 21 CFR Part 11 and EU Annex 11 for electronic records and signatures on every GxP-relevant flow.
- Preserve ALCOA+ data integrity — attributable, legible, contemporaneous, original, and accurate — with audit trails no operator can edit.
- Encrypt regulated data in transit and at rest, and keep production payload visibility to validated support roles only.
- Treat a mapping change on a GxP flow as a controlled change under change management, never as a hotfix.
- Treat these flows as in scope for financial controls testing — evidence of completeness, accuracy, and authorization is the deliverable auditors ask for.
- Keep bank credentials and payment file signing outside the application layer, in the platform's secrets management.
- Most of this cycle is not GxP, but anything touching material receipt or CMO batch services inherits the quality record — do not let a financial optimization rewrite a regulated one.
For pre-built API specifications, implementation templates, and reference architecture, see the MuleSoft Accelerator for Life Sciences on Anypoint Exchange.
Sample payload — Three-way match exception
{
"exceptionId": "AP-EXC-2026-04481",
"invoice": { "supplierId": "SUP-10932", "number": "INV-77219", "amount": 184320.00, "currency": "USD" },
"purchaseOrder": { "number": "4500091827", "lineNumber": 20, "orderedQty": 1200, "uom": "KG" },
"goodsReceipt": { "number": "5000238811", "receivedQty": 1150, "postedOn": "2026-07-24" },
"variance": { "type": "quantity", "invoicedQty": 1200, "matchedQty": 1150, "valueImpact": 7680.00 },
"tolerance": { "quantityPct": 2.0, "valueAbsolute": 500.00, "breached": true },
"routing": { "queue": "ap_procurement_review", "slaHours": 48 }
}
Testing and validation
- Replay an invoice post twice with the same external reference and confirm ERP holds one document, not two.
- Submit an invoice inside tolerance and confirm it clears without human touch; submit one outside and confirm it routes with the variance explained.
- Load a bank file with partial remittance and verify cash applies to the correct invoices with the residual visible.
- Submit a chargeback claim for an ineligible class of trade and confirm it is rejected with a reason code.
- Break the ERP connection mid-run and confirm the control totals report a mismatch rather than a silent partial post.
Phased rollout
Phase 1 — Connect
- Connect procurement and ERP, sync master data, and prove document flow read-only before writing anything.
- Agree tolerances, exception queues, and control totals with finance in writing.
Phase 2 — Map and validate
- Run three-way match in parallel with the current process for one supplier segment and compare outcomes daily.
- Implement invoice output and cash application for one customer channel end to end.
Phase 3 — Production
- Extend by supplier and customer segment, watching exception rates rather than volume.
- Add gross-to-net deductions once transactional flows are stable, and reconcile accruals against actuals for a full quarter.
Success metrics
- Straight-through invoice processing rate, with exceptions trending down rather than being absorbed.
- Days sales outstanding and unapplied cash reduced against the pre-integration baseline.
- Close cycle shortened by the reconciliation work no longer done by hand.
- Gross-to-net accrual variance narrowing as deductions are driven by actual claims.
Troubleshooting
- Duplicate documents in ERP after a retry — Likely cause: posting keyed on an internally generated reference instead of an external idempotency key. Fix: Carry a stable external reference from the source document and let ERP reject the duplicate.
- Exception queue growing faster than it is worked — Likely cause: tolerances set tighter than the business actually enforces. Fix: Re-derive tolerances from twelve months of historical variance and review quarterly.
- Cash applies to the wrong invoices — Likely cause: heuristic matching applied before exact reference matching. Fix: Match on invoice reference first, then amount and customer, and leave the remainder unapplied for review.
- Chargeback credits exceed contract value — Likely cause: eligibility validated against the customer rather than the contract and class of trade. Fix: Validate each claim line against the contract in force on the sale date, not the current price list.
Deliverable: Automated procure-to-pay with three-way match and exception routing, order-to-cash from shipment through cash application, and gross-to-net deductions that reconcile from accrual back to contract with control totals on every run.