QuickBooks job costing
Brings QuickBooks Online job cost onto the HubSpot deal and posts milestone invoices only after a named person approves, with Claude writing line text and code computing every amount.
Data paths and guards
- HubSpot: The deal card shows cost and margin, and a named person approves each invoice there.
- Resend: Sends the app’s own account email: verification, password and invite messages.
- Job-cost backend: 34 route files on Vercel: cost sync, invoice proposals and the drain cron.
- State store: Queue, encrypted QuickBooks tokens, cost lines and approvals, built over 20 migrations.
- Claude API: Claude Haiku 4.5 writes each invoice line’s text, never an amount.
- QuickBooks Online: Bills, purchase orders, vendor credits and time in; milestone invoices out, emailed to the customer.
- Stripe: Checkout, a billing portal and signed webhooks for the app’s own plans.
- From QuickBooks Online to Job-cost backend: Cost lines and webhooks. Bills, purchase orders, vendor credits and time, line by line. A QuickBooks webhook, queued, then the drain cron.
- From Job-cost backend to State store: Queue, tokens, approvals. Queued work, encrypted QuickBooks tokens, cost lines and each approval with its approver. Every webhook and request.
- From Job-cost backend to HubSpot: Cost and margin on the deal. Actual cost and margin, rolled up from each job’s lines into deal properties. Each synced cost line.
- From HubSpot to Job-cost backend: Proposals and approvals. Milestone invoice proposals and a named person’s approval, sent as signed requests from the card. Someone acts on the deal card.
- From Job-cost backend to Claude API: Job and milestone. The job’s name, the milestone and its billing basis, never an amount; Claude returns one line of text. Each proposed invoice, when the portal allows AI.
- From Job-cost backend to QuickBooks Online: Approved invoices. The milestone invoice, posted to the job in QuickBooks, which emails it to the customer once when auto-send is on. A named person’s approval.
- From Stripe to Job-cost backend: Signed billing webhooks. Checkout and plan changes for each installed portal. A Stripe event.
- From Job-cost backend to Resend: Account email. Account verification, password and invite email for the app’s users. A sign-up, a password reset or an invite.
- On Queue, tokens, approvals: Transient or permanent. Webhooks only enqueue work in the store; a drain cron claims it and sorts each failure as transient or permanent, so only transient ones retry.
- On Cost and margin on the deal: No margin against zero revenue. The card refuses a margin when there is no revenue, and a missing estimate withholds figures instead of showing 100%.
- On Job and milestone: Text only, never amounts. Claude writes only the line text, within a 6-second cap and with a fallback written in code; every amount comes from rules, and each portal can switch the call off.
- On Approved invoices: Named approver required. An invoice posts only after a named person approves it; the database refuses an approval without one.
- Built by me
- Platforms I connect to
- Guards
- Active
| Cost lines and webhooks Bills, purchase orders, vendor credits and time, line by line |
|---|
| Queue, tokens, approvals Queued work, encrypted QuickBooks tokens, cost lines and each approval with its approver |
| Cost and margin on the deal Actual cost and margin, rolled up from each job’s lines into deal properties |
| Proposals and approvals Milestone invoice proposals and a named person’s approval, sent as signed requests from the card |
|---|
| Job and milestone The job’s name, the milestone and its billing basis, never an amount; Claude returns one line of text |
| Approved invoices The milestone invoice, posted to the job in QuickBooks, which emails it to the customer once when auto-send is on |
| Signed billing webhooks Checkout and plan changes for each installed portal |
| Account email Account verification, password and invite email for the app’s users |
-
Systems
Contractors sell in HubSpot and keep their books in QuickBooks Online. A Node.js backend on Vercel functions sits between them, with its queue and state in Supabase Postgres. The Claude API writes invoice line text, Resend sends account email, and Stripe runs the app’s own billing.
-
Data paths
QuickBooks bills, purchase orders, vendor credits and time arrive line by line, attributed to each job through sub-customers. The backend queues them, keeps its state in the store and rolls actual cost and margin onto the deal in HubSpot.
- a Cost lines and webhooks
- b Queue, tokens, approvals
- c Cost and margin on the deal
-
Approved invoices
The deal card proposes milestone invoices, with Claude writing each line’s text. A named person approves one, and the backend posts it to QuickBooks, which can email it to the customer. Stripe’s signed webhooks keep each portal’s plan current, and Resend sends account email.
- d Proposals and approvals
- e Job and milestone
- f Approved invoices
- g Signed billing webhooks
- h Account email
-
Guards
No invoice posts without a named approver, and Claude never writes an amount. Webhooks only enqueue, and a drain cron retries only transient failures. A deal with no revenue shows no margin.
- Transient or permanent on b
- No margin against zero revenue on c
- Text only, never amounts on e
- Named approver required on f
-
Result
On day one of a 3-day hackathon, an invoice posted to sandbox QuickBooks through the approval gate, with cost across 3 cost codes on the deal at a 44.1% margin.
Job cost stayed in the books, away from the deal
Contractors sell in HubSpot and keep their books in QuickBooks, so a job’s actual cost never reaches the deal it belongs to. The native QuickBooks Online connector for HubSpot was rated 2.1 stars across 105 reviews on 15,000 installs.
What I built
- A HubSpot app with a deal card and a settings page, calling a Vercel backend of 34 route files that checks HubSpot’s request signatures.
- Line-level cost sync from QuickBooks Online: bills, purchase orders, vendor credits and time, attributed to each job through sub-customers and rolled onto the deal with its margin.
- Milestone invoices that the app proposes and posts only after a named person approves, a rule the database enforces with a CHECK constraint.
- Webhooks that only enqueue work, and a drain cron that sorts each failure as transient or permanent.
- A Supabase Postgres store built over 20 migrations, with row-level security and QuickBooks tokens encrypted with AES-256-GCM.
- Claude Haiku 4.5, called through the Claude API, writes each invoice line’s text from the job, the milestone and its billing basis; every amount comes from deterministic rules.
What the guards protect against
| The risk | The guard |
|---|---|
| A failed webhook is lost, or a permanent error retries forever. | Transient or permanent Webhooks only enqueue work in the store; a drain cron claims it and sorts each failure as transient or permanent, so only transient ones retry. |
| A deal with no revenue shows a fake 100% margin. | No margin against zero revenue The card refuses a margin when there is no revenue, and a missing estimate withholds figures instead of showing 100%. |
| A model writes a number onto an invoice. | Text only, never amounts Claude writes only the line text, within a 6-second cap and with a fallback written in code; every amount comes from rules, and each portal can switch the call off. |
| An invoice reaches the books without a person’s approval. | Named approver required An invoice posts only after a named person approves it; the database refuses an approval without one. |
Results
- Day one: an invoice posted to sandbox QuickBooks through the approval gate, with cost across 3 cost codes on the deal at a 44.1% margin.
- On the same day, a three-way billing schedule that summed exactly to the contract.
- A check gate of 1,505 of 1,505 passing.
- Carried past the hackathon with billing and usage metering; launch waits on Intuit’s production keys and compliance.
Facts
- Technical lead: 227 of 250 commits on main and about 100 pull requests
- A rubric written before the choice scored this idea 4.75 against 2.65 for the other candidate
- QuickBooks sparse updates measured in the sandbox: an explicit null is ignored, yet the version still advances
- Stripe Checkout, a billing portal and signed webhooks run trials and plans, still on test keys
- Distributable through the HubSpot App Marketplace, not listed there
- Approving twice posts once: a second approval returns the invoice already posted
Related builds
-
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
-
Two-way field-service sync
Date: Feb 2026
Fact: 11,683 deals and 8,182 tickets in a two-way sync
Client: For a commercial roofing service contractor
Systems: CenterPoint Connect, Zapier, QuickBooks Online and Make.com
Status: In production
-
Business-card lead intake
Date: Feb 2026
Fact: Prototype app in 1 day, then a prompt with 20+ lead-source rules
Client: For a construction company
Systems: Claude
Status: In production