Construction operations software
Dealer OS
I built Dealer OS for Techno Metal Post dealers. It brings a helical pile job’s drawings, quote, crew schedule and invoice into the same record, so the office and the people in the field can follow the same job.
Interactive product preview
The operations desk.
Trace an uncertain invoice, test the retry rules, or book a crew and rig on the day board. The workspace runs on fictional records and a simulated accounting provider.
What if the books commit and the worker disappears?
An approved invoice leaves the dealer’s system. QuickBooks records it, but the worker times out before it can save the receipt. A retry can now create a duplicate. Dealer OS gives each approved operation a stable request identity and reconciles an uncertain submission against the bound accounting company.
The public implementation models this with a SQLite journal and two independent workers. A transaction claims the approved operation before a provider call. A lease expiry moves the operation into reconciliation. A fencing token stops the old worker from overwriting a newer decision when its reply arrives late.
transition(expected, state, evidence, { lease = null, until = null, retryAt = null } = {}) {
return this.transaction(() => {
const { changes } = this.db.prepare(`UPDATE invoices SET state=?,evidence=?,lease=?,until_ms=?,
retry_at=?,version=version+1 WHERE tenant=? AND task=? AND version=?`).run(
state, JSON.stringify(evidence), lease, until, retryAt, expected.tenant, expected.task, expected.version);
if (changes) this.log(expected.tenant, expected.task, state, evidence);
return this.get(expected.tenant, expected.task);
});
}Matching an invoice takes more than a document number.
The production comparison checks company context, customer, date and line content. A matching document with different provider-calculated tax is tracked as a variance. Two identical-looking documents require a human decision. A missing document leaves the outcome open because provider queries can lag behind writes.
In the preview, switch provider scenarios and compare the business fields and amounts side by side. The sample logs each decision and allows another write only when the simulated provider explicitly rejected the request before committing.
export function compareEvidence(approved, candidates) {
const identity = digest(invoiceContent(approved));
const rows = inspectCandidates(approved.reference, candidates);
if (!rows) return { state: 'review', reason: 'incomplete_evidence' };
const exact = rows.filter(candidate => candidate.signature === identity);
if (exact.length !== 1) {
const reason = exact.length ? 'multiple_matches' : rows.length ? 'content_conflict' : 'not_visible';
return { state: reason === 'not_visible' ? 'uncertain' : 'review', reason,
candidates: candidates.map(row => row.remoteId) };
}
const record = exact[0].row;
const differences = ['net', 'tax', 'total'].filter(field => approved[field] !== record[field])
.map(field => ({ field, approved: approved[field], provider: record[field] ?? null }));
return { state: 'posted', reason: 'identified', remoteId: record.remoteId, differences };
}Dispatch reserves people and equipment.
A crew and its rig can be booked on separate jobs. The production scheduler checks both against time overlaps before writing a visit. It records accepted conflicts and rejects edits made against a stale visit revision. The sample day board recalculates both resource lanes when you change crews, equipment or start time.
Dealer OS also connects Gmail and QuickBooks Online, enforces dealer-level access in PostgreSQL, and includes Daylite import workflows for a source dataset of approximately 3,000 jobs and 3,200 contacts.
Source explorer.
Follow the public implementation from integration logic to failure tests.
dealer-os.mjsDispatch the write
Claim the approved operation, check the remote company and distinguish a rejected request from an unknown result.
export async function dispatchInvoice(journal, books, tenant, task, { now = Date.now, leaseMs = 30000 } = {}) { const claim = journal.claim(tenant, task, now(), leaseMs); if (!claim) return journal.get(tenant, task); const finish = (state, detail, flags) => journal.transition(claim, state, detail, flags); if (journal.company(tenant) !== claim.company) return finish('review', { reason: 'company_binding_changed' }); let existing; try { existing = await books.find(claim.company, claim.reference); } catch { return finish('retryable', { reason: 'preflight_read_failed' }, { retryAt: now() + 1000 }); } if (!inspectCandidates(claim.reference, existing)) { return finish('review', { reason: 'preflight_incomplete' }); } if (existing.length) { return finish('review', { reason: 'reference_already_used', candidates: existing.map(row => row.remoteId) }); } if (journal.company(tenant) !== claim.company) return finish('review', { reason: 'company_binding_changed' }); if (now() >= claim.until_ms || journal.get(tenant, task).lease !== claim.lease) { return finish('uncertain', { reason: 'lost_lease' }); } try { const receipt = await books.create(claim.company, claim.snapshot, claim.request_id); const evidence = compareEvidence(claim.snapshot, [receipt]); return finish(evidence.state, evidence); } catch (error) { if (error instanceof RetryBeforeWrite) { return finish('retryable', { reason: 'confirmed_no_write' }, { retryAt: now() + error.delayMs }); } return finish('uncertain', { reason: 'acknowledgement_unknown' }); }}