ERP job creation
Turns each deal signed in HubSpot into a Deltek ComputerEase job import, in an XML format worked out with the vendor’s support, and brings job financials back to the deal.
Data paths and guards
- HubSpot: Where deals are signed; a deal card shows the job’s financials.
- Job service: Node.js on Vercel: the job webhook, the key rotation and the financial sync.
- Key store: Current and emergency API keys, deal-to-job mappings and per-deal claims.
- Slack alerts: Alerts on rotations, created jobs and uncertain imports.
- ComputerEase, the ERP: Jobs, their cost types and financials, and an import queue that accounting approves.
- From HubSpot to Job service: Signed deal webhook. The deal’s id; the service reads the deal and its contact from HubSpot itself. A HubSpot workflow, when a deal reaches the signed stage.
- From Job service to ComputerEase, the ERP: Zipped XML job. Schema-valid XML with all 16 cost types, zipped and base64-encoded, sent to the import API. A claimed deal not yet linked to a job.
- From Job service to Key store: Keys, claims, job map. Each new key, the emergency slot, deal-to-job mappings and per-deal claims. Every rotation and every job.
- From ComputerEase, the ERP to Job service: Financials and new keys. Contract, cost to date, invoiced, profit, margin and percent complete; a fresh key at each rotation. Crons: key rotation every 8 hours, financial sync 4 times a day.
- From Job service to HubSpot: Job id and financials. The ERP job id on the deal, then 11 job financial fields. Each import, and the financial sync.
- From Job service to Slack alerts: Alerts. Failed rotations, created jobs and uncertain imports. Each rotation and each job.
- On Signed deal webhook: One claim per deal. Each deal takes a claim before it is sent; merged deals resolve to the survivor, and a deal already linked to a job is skipped.
- On Zipped XML job: Hold when unsure. A timeout or server error from the ERP holds the deal for a person, and so does a deal whose amount is zero.
- On Financials and new keys: Rotation every 8 hours. The 24-hour keys rotate every 8 hours, so a failed rotation still has two more chances before the key expires.
- On Keys, claims, job map: Retries, emergency slot. Each new key is saved with retries and backoff, with an emergency slot behind them, because the old key dies the moment it rotates.
- On Alerts: Failed cron, loud alert. A failed rotation posts to Slack and returns an error, so the cron run shows as failed.
- Built by me
- Platforms I connect to
- Guards
- In production
| Signed deal webhook The deal’s id; the service reads the deal and its contact from HubSpot itself |
|---|
| Zipped XML job Schema-valid XML with all 16 cost types, zipped and base64-encoded, sent to the import API |
| Keys, claims, job map Each new key, the emergency slot, deal-to-job mappings and per-deal claims |
| Financials and new keys |
|---|
| Job id and financials The ERP job id on the deal, then 11 job financial fields |
| Alerts Failed rotations, created jobs and uncertain imports |
-
Systems
Deals are signed in HubSpot. The ERP keeps jobs and their costs. Between them runs a Node.js service on Vercel functions, with its keys and claims in Vercel KV, a Redis store, and its alerts in Slack.
-
Data paths
When a deal is signed, a HubSpot workflow calls the service. It reads the deal, builds XML with all 16 cost types, zips it with its own encoder and posts it to the ERP’s import queue, keeping a claim in the store.
- a Signed deal webhook
- b Zipped XML job
- c Keys, claims, job map
-
Keys and financials
A cron rotates the 24-hour API keys every 8 hours. Another pulls job financials 4 times a day into 11 deal fields, shown on a React deal card. Rotations and jobs report to Slack.
- d Financials and new keys
- e Job id and financials
- f Alerts
-
Guards
Each deal is claimed once and held when the result is unsure. Keys get three chances in every expiry window and an emergency slot, and a failed rotation shows up as a failed cron.
- One claim per deal on a
- Hold when unsure on b
- Rotation every 8 hours on d
- Retries, emergency slot on c
- Failed cron, loud alert on f
-
Result
Signed deals reach the ERP’s import queue for accounting to approve, and each deal shows its job’s cost, billing and margin, refreshed 4 times a day.
Signed jobs re-keyed by hand, and API keys that expire daily
Accounting typed every signed job into the ERP by hand, and HubSpot had no view of job cost. The ERP has no endpoint that creates a job, its import format was missing from the public docs, and its API keys expire every 24 hours: miss one rotation and a person must re-key from the desktop app.
What I built
- A webhook service on Vercel that reads each signed deal from HubSpot, builds an XML job with all 16 cost types and posts it to the ERP’s import API.
- A ZIP and CRC-32 encoder written by hand with no dependencies, so the import can be packed inside a serverless function.
- A key lifecycle for the 24-hour API keys: rotation every 8 hours, expiry read from the token itself, retried saves, an emergency slot and Slack alerts.
- A sync that brings job financials back 4 times a day into 11 deal fields, shown on a React deal card, with a settings page that maps 34 ERP fields.
- An idempotent job handler: one claim per deal, merged deals resolved to the survivor, deals already linked to a job skipped, and uncertain results held for a person.
What the guards protect against
| The risk | The guard |
|---|---|
| A retried call or a merged deal creates the same job twice. | One claim per deal Each deal takes a claim before it is sent; merged deals resolve to the survivor, and a deal already linked to a job is skipped. |
| A retry imports a job the ERP already has, or a job lands with no contract value. | Hold when unsure A timeout or server error from the ERP holds the deal for a person, and so does a deal whose amount is zero. |
| One missed rotation leaves a dead key that only a person at the desktop app can replace. | Rotation every 8 hours The 24-hour keys rotate every 8 hours, so a failed rotation still has two more chances before the key expires. |
| A new key is lost in a failed save after the old one has already died. | Retries, emergency slot Each new key is saved with retries and backoff, with an emergency slot behind them, because the old key dies the moment it rotates. |
| A failed rotation goes unseen until the key expires. | Failed cron, loud alert A failed rotation posts to Slack and returns an error, so the cron run shows as failed. |
Decisions
-
Build the job as XML against the vendor’s own schema
- Chose
- Rebuilt the payload as XML that validates against the job schema the vendor’s support supplied, with all 16 cost types, zipped and base64-encoded.
- Instead of
-
- JSON job imports. They landed in the ERP’s archive instead of the queue accounting imports from.
- Accepting that the API cannot create jobs. 20+ approaches from the public docs pointed that way; the schema from the vendor’s support showed a path the docs did not.
- Trade-off
- Imported jobs wait in the ERP’s queue until accounting approves them, and every job must carry all 16 cost types.
-
Rotate 24-hour keys every 8 hours
- Chose
- A cron rotates the keys every 8 hours, which gives three chances in each expiry window.
- Instead of
- Rotating once per 24-hour window. One failed rotation would leave a dead key, and only a person at the desktop app could restore access.
- Trade-off
- The old key dies the moment it rotates, so every save of the new one retries with backoff and falls back to an emergency slot.
-
Ask HubSpot to retry only when nothing reached the ERP
- Chose
- The handler returns a retryable error only when nothing reached the ERP; a timeout or server error from the ERP holds the deal for a person.
- Instead of
- Answering every failure with a server error. HubSpot retries server errors for up to 3 days, so a job that did reach the ERP would be imported again.
- Trade-off
- An uncertain result waits for a person to check the ERP instead of clearing itself.
Results
- Job financials synced to 11 deal fields, 4 times a day.
- The job handler passed 60 of 60 offline cases and 18 of 18 in a shadow run, and a real signed deal has reached the import queue through it.
- 4 jobs that accounting had built by hand were linked to their deals, so the handler skips those deals instead of importing the jobs again.
Facts
- Backend: 4,238 lines of JavaScript across 19 route files and 6 modules
- A CSV fallback maps ERP exports: 25 columns under about 110 header spellings
- The ERP reads a job’s contract amount from its phases and categories, so the XML sets it at every level
Related builds
-
ERP project automation
Date: Oct 2026
Fact: Customer key collision-free across 6,025 contacts
Client: For a residential roofing and exteriors contractor
Systems: Acumatica
Status: In production
-
QuickBooks job costing
Date: Aug 2026
Fact: On day one of a 3-day hackathon, an invoice posted through the approval gate
Client: For contractors on HubSpot (a hackathon build)
Systems: QuickBooks Online, Stripe and Claude
Status: Active
-
Desktop accounting connector
Date: Jun 2026
Fact: Sales recognition reconciled to the cent across 3,709 deals
Client: For a residential roofing and solar contractor
Systems: QuickBooks Desktop
Status: In production