ERP Integrations
Lesson opener
In one line: An ERP integration copies a named master or posts a named transaction. It does not silently merge two truths.
Why it matters: Northline's webshop created a customer the ERP already had, because the match used the display name. "Harbour Tools" and "Harbour Tools Pvt Ltd" became two accounts. Invoices split, and credit control saw only half the balance.
Before this lesson: Consuming APIs.
What you will be able to do
- Name the system of record for customer, supplier, item, sales, and procurement flows.
- Match on a stable identifier, not a display name.
- Stop a sync when both sides changed the same field since the last exchange.
- Post a sales or procurement document once, with its own identity.
Prerequisites
Lessons 1 to 6. No particular ERP product is required. Field names below are Northline's illustrative contract, not a universal schema for SAP, Oracle, or any other product.
Five flows
| Flow | System of record | What moves | What must not happen |
|---|---|---|---|
| Customer sync | ERP account | account id, name, order block, payment terms | A second account because the name differed |
| Supplier sync | ERP supplier | supplier id, name, payment terms | Bank details copied into a system whose role forbids them |
| Inventory sync | Warehouse | sku, on-hand, as-of time | The webshop overwriting the warehouse count |
| Sales integration | ERP sales order | order id, account id, lines | A second order when the webshop retries |
| Procurement integration | ERP purchase order | order id, supplier id, lines | A receipt posted against the wrong order |
The match key is the identifier the system of record already issued (account_id, supplier_id, sku, order_id). A name is a label. Names collide.
When both sides changed the same field after the last successful sync, the job stops on that record and raises a conflict for a person. It does not pick the newer timestamp unless the owner has signed that rule. A timestamp is evidence. It is not automatically the decision.
Sales and procurement posts use the idempotency rule from lesson 2. The webshop order number is stored on the ERP order so a repeat finds the original.
def match_customer(incoming_name, erp_rows):
hits = [row for row in erp_rows if row["name"].casefold() == incoming_name.casefold()]
return hits
def sync_decision(local_version, remote_version, last_synced_version):
local_changed = local_version != last_synced_version
remote_changed = remote_version != last_synced_version
if local_changed and remote_changed:
return "conflict"
if remote_changed:
return "take_remote"
if local_changed:
return "send_local"
return "unchanged"
erp = [
{"account_id": "C-1044", "name": "Harbour Tools"},
{"account_id": "C-1090", "name": "Harbour Tools Pvt Ltd"},
]
assert len(match_customer("Harbour Tools", erp)) == 1
assert sync_decision(2, 3, 1) == "conflict"
assert sync_decision(1, 3, 1) == "take_remote"Name matching is shown here so you can see the collision. The integration must not create an account from a name match of one row. It asks for account_id.
Teacher walkthrough: customer and stock
Illustrative.
- Webshop has a checkout for account id C-1044. It does not search by name.
- ERP returns
order_block: false,payment_terms_days: 30. - Warehouse GET for FX-100 returns
on_hand: 80,as_of: "2026-09-30T08:00:00+05:30". The webshop displays 80 and the time. It does not write 80 back. - A sales order POST carries webshop id W-501 and one line, SKU FX-100, quantity 2. The ERP returns ERP order S-8801. A repeat POST with W-501 returns S-8801 again.
- Validation: one ERP account, one ERP order, and the warehouse quantity unchanged by the webshop.
A second workplace case
Procurement creates a purchase order in the ERP and expects the supplier portal to show it. The portal is a copy. The receipt is posted only in the ERP, against that purchase order id. A receipt that arrives with no purchase order id is rejected. It is not "received into a suspense pile" by this course's contract, because Northline has not signed a suspense process.
Failure example: last write wins on payment terms
Symptom: Credit set terms to 30 in the ERP. Sales set 45 in the CRM a minute later. The sync wrote 45 into the ERP because the CRM timestamp was newer. Invoices changed.
Diagnosis: Both sides changed the field. The job treated the clock as the owner. The root cause is a missing conflict rule. The ERP is the system of record for payment terms.
Correction: Stop on that account. Show both values to the ERP owner. Write 45 only if that owner accepts it. Do not let the CRM push terms.
Validation: After the conflict, the ERP still says 30 until the owner changes it. The sync log says conflict for C-1044.
Guided practice: three records
Scenario: Last synced version is 1 for every row. Figures are illustrative.
| Record | ERP version | Other system version |
|---|---|---|
| Customer C-1044 terms | 1 | 4 |
| Supplier S-9 name | 2 | 1 |
| Item FX-100 on-hand in the webshop | 5 | 5 |
The webshop is not the system of record for on-hand.
Hints:
- Use
sync_decisiononly when the other system is allowed to send that field. - Stock is a one-way read.
Complete solution:
Customer terms: ERP version 1 equals last sync, the other system is 4, so take_remote would apply only if the other system were allowed to own terms. It is not. The job ignores the CRM value and does not call it a conflict with the ERP's unchanged record. If the CRM must display 30, it takes the ERP value. Supplier name: ERP changed (2) and the other system did not, so send_local if that system is a copy of the name. Item on-hand: the webshop must not send a quantity. The warehouse remains the source. The webshop reads it. Validation: terms stay at the ERP value, the supplier name update has one direction, and no webshop write hits stock.
Independent practice
Describe one ERP flow you know, or Northline's sales order.
Acceptance criteria:
- You name the system of record and the match key.
- You say whether the flow is a copy or a new document.
- You state the conflict behaviour when both sides change a field.
- You include an idempotency identity for any create.
- You do not use a vendor's private field list unless you label it as that vendor's documented contract.
- Bank fields stay on the identity that lesson 4 allowed.
Common mistakes
- Matching customers on name.
- Letting the webshop write the warehouse on-hand figure.
- Last-write-wins on a field the ERP owns.
- Posting a receipt that has no purchase order id "so the goods are visible."
Quick check
- What is the match key for a Northline customer sync?
- Why did "Harbour Tools" and "Harbour Tools Pvt Ltd" become a defect?
- Who may update on-hand?
- What does the job do when both sides changed payment terms?
- What ties a retried webshop order to one ERP order?
Answers:
account_id, issued by the ERP.- They are two names. A name match does not prove one account.
- The warehouse system. The webshop reads a copy.
- It stops and asks the ERP owner. It does not pick the later clock.
- The webshop order id stored on the ERP order, so the repeat finds S-8801 instead of creating another.
Lesson summary
Sync masters on the system of record's identifier. Copy stock in one direction. Post sales and procurement documents once. When both sides change an owned field, stop and ask the owner.
Bridge to the next lesson
The sales order was a pull: the webshop called the ERP. The next lesson is the other pattern, where the ERP pushes an event to a webhook when something changes.