Side-by-side diff
Before on the left, after on the right, rows lined up and blank where a line has no partner. Good for config files and short changes.
.halden.yml+4−3
| v3.1 | v3.2 | ||
|---|---|---|---|
| 1 | invoices: | 1 | invoices: |
| 2 | prefix: INV | 2 | prefix: INV |
| 3 | − due_days: 14 | 3 | + due_days: 30 |
| 4 | rounding: line | 4 | rounding: line |
| 5 | − tax: 0.0825 | 5 | + tax: |
| 6 | + rate: 0.0825 | ||
| 7 | + labor: false | ||
| 6 | − legacy_pdf: true | ||
| 7 | reminders: on | 8 | reminders: on |
The code
Plain HTML and CSS on your kit's variables. Put it next to tokens/variables.css from your kit's files and it draws in your look.
<div class="ukc-code-split-diff">
<div class="sx">
<div class="hd"><span class="fn">.halden.yml</span><span class="ct"><span>+4</span><span class="minus">−3</span></span></div>
<div class="scroll">
<table class="sbs">
<caption class="sr">Changes to .halden.yml. Version 3.1 on the left, version 3.2 on the right.</caption>
<colgroup><col class="cn"><col><col class="cn"><col></colgroup>
<thead><tr><th colspan="2" scope="colgroup">v3.1</th><th colspan="2" scope="colgroup">v3.2</th></tr></thead>
<tbody>
<tr><td class="no">1</td><td>invoices:</td><td class="no">1</td><td>invoices:</td></tr>
<tr><td class="no">2</td><td> prefix: INV</td><td class="no">2</td><td> prefix: INV</td></tr>
<tr><td class="no rm">3</td><td class="rm"><span class="sg">−</span> due_days: <span class="w">14</span></td><td class="no ad">3</td><td class="ad"><span class="sg">+</span> due_days: <span class="w">30</span></td></tr>
<tr><td class="no">4</td><td> rounding: line</td><td class="no">4</td><td> rounding: line</td></tr>
<tr><td class="no rm">5</td><td class="rm"><span class="sg">−</span> tax: <span class="n">0.0825</span></td><td class="no ad">5</td><td class="ad"><span class="sg">+</span> tax:</td></tr>
<tr><td class="no void"></td><td class="void"></td><td class="no ad">6</td><td class="ad"><span class="sg">+</span> rate: <span class="n">0.0825</span></td></tr>
<tr><td class="no void"></td><td class="void"></td><td class="no ad">7</td><td class="ad"><span class="sg">+</span> labor: <span class="k">false</span></td></tr>
<tr><td class="no rm">6</td><td class="rm"><span class="sg">−</span> legacy_pdf: <span class="k">true</span></td><td class="no void"></td><td class="void"></td></tr>
<tr><td class="no">7</td><td> reminders: <span class="k">on</span></td><td class="no">8</td><td> reminders: <span class="k">on</span></td></tr>
</tbody>
</table>
</div>
</div>
</div>
.ukc-code-split-diff { position: relative; font-family: var(--uk-font-body, system-ui, sans-serif); color: var(--uk-ink); font-size: 15px; line-height: 1.5;
--tint: color-mix(in srgb, var(--uk-accent) 12%, var(--uk-paper));
--tint-strong: color-mix(in srgb, var(--uk-accent) 22%, var(--uk-paper));
--accent-deep: color-mix(in srgb, var(--uk-accent) 72%, black);
--ink-soft: color-mix(in srgb, var(--uk-ink) 8%, var(--uk-paper));
--line-strong: color-mix(in srgb, var(--uk-ink) 32%, var(--uk-paper));
--danger-tint: color-mix(in srgb, var(--uk-danger) 12%, var(--uk-paper));
--high-tint: color-mix(in srgb, var(--uk-highlight) 28%, var(--uk-paper)); }
.ukc-code-split-diff *, .ukc-code-split-diff *::before, .ukc-code-split-diff *::after { box-sizing: border-box; }
.ukc-code-split-diff :where(h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote) { margin: 0; }
.ukc-code-split-diff :where(ul, ol) { padding: 0; list-style: none; }
.ukc-code-split-diff :where(button, input, select, textarea) { font: inherit; color: inherit; }
.ukc-code-split-diff :where(a) { color: inherit; }
.ukc-code-split-diff svg { flex: none; }
.ukc-code-split-diff .sr { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ukc-code-split-diff .sx { max-width: 640px; border: var(--uk-border-width) solid var(--uk-line); border-radius: var(--uk-radius-lg); overflow: hidden; background: var(--uk-surface); box-shadow: var(--uk-card-shadow); }
.ukc-code-split-diff .hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--uk-line); background: var(--uk-paper); font: 600 12.5px/1.5 var(--uk-font-mono, ui-monospace, monospace); }
.ukc-code-split-diff .ct { display: inline-flex; gap: 8px; font-variant-numeric: tabular-nums; }
.ukc-code-split-diff .minus { color: color-mix(in srgb, var(--uk-danger) 80%, var(--uk-ink)); }
.ukc-code-split-diff .scroll { overflow-x: auto; }
.ukc-code-split-diff .sbs { width: 100%; min-width: 380px; border-collapse: collapse; table-layout: fixed; font: 12px/1.7 var(--uk-font-mono, ui-monospace, monospace); }
.ukc-code-split-diff .cn { width: 4ch; }
.ukc-code-split-diff .sbs th { padding: 5px 10px; border-bottom: 1px solid var(--uk-line); color: var(--uk-muted); font: 600 11.5px/1.5 var(--uk-font-mono, ui-monospace, monospace); text-align: left; }
.ukc-code-split-diff .sbs th + th, .ukc-code-split-diff .sbs td:nth-child(3) { border-left: 1px solid var(--uk-line); }
.ukc-code-split-diff .sbs td { position: relative; padding: 0 8px 0 2.6ch; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
.ukc-code-split-diff .sbs td.no { padding: 0 0.8ch 0 0; color: color-mix(in srgb, var(--uk-ink) 40%, var(--uk-surface)); text-align: right; user-select: none; }
.ukc-code-split-diff .sbs tbody tr:first-child td { padding-top: 6px; }
.ukc-code-split-diff .sbs tbody tr:last-child td { padding-bottom: 8px; }
.ukc-code-split-diff .sg { position: absolute; left: 0.8ch; font-weight: 700; }
.ukc-code-split-diff .rm { background: color-mix(in srgb, var(--uk-danger) 13%, var(--uk-surface)); }
.ukc-code-split-diff .rm .sg { color: color-mix(in srgb, var(--uk-danger) 80%, var(--uk-ink)); }
.ukc-code-split-diff .sbs td.no.rm { background: color-mix(in srgb, var(--uk-danger) 22%, var(--uk-surface)); color: var(--uk-ink); }
.ukc-code-split-diff .sbs .w { color: var(--uk-ink); font-weight: 600; }
.ukc-code-split-diff .rm .w { background: color-mix(in srgb, var(--uk-danger) 30%, var(--uk-surface)); }
.ukc-code-split-diff .ad { background: color-mix(in srgb, var(--uk-highlight) 24%, var(--uk-surface)); }
.ukc-code-split-diff .sbs td.no.ad { background: color-mix(in srgb, var(--uk-highlight) 42%, var(--uk-surface)); color: var(--uk-ink); }
.ukc-code-split-diff .ad .w { background: color-mix(in srgb, var(--uk-highlight) 40%, var(--uk-surface)); }
.ukc-code-split-diff .void { background: var(--ink-soft); }
.ukc-code-split-diff .sbs .n { color: color-mix(in srgb, var(--accent-deep) 60%, var(--uk-ink)); }
.ukc-code-split-diff .sbs .k { color: color-mix(in srgb, var(--uk-accent) 60%, var(--uk-ink)); }
More code blocks
All 24export default { crew: "reyes-framing", currency: "USD", rounding: "line", reminders: [7, 14, 30], // Sync offline sheets sync: { every: "15m" }, };TypeScriptLn 5, Col 25
- POST
/v2/invoicesCreate an invoice from a signed-off job sheet.Request
Authorization: Bearer $HALDEN_KEY Content-Type: application/json { "job": "JS-2207", "due_days": 30, "send": true }Response
{ "id": "inv_0418", "number": "INV-0418", "status": "sent", "total": 2140.00, "currency": "USD", "pdf": "/v2/invoices/inv_0418.pdf" }{ "error": "job_not_signed_off", "message": "JS-2207 has no sign-off yet", "field": "job" }201 Created · 184 ms422 Unprocessable · 61 ms
- job-sheet.json1.2 kB
{ 7 keys }
"id": "JS-2207","site": "14 Alder St","signed_off": true,"crew": [ 2 items ],
"Ines Ortega","Dana Whitfield"],"hours": { 3 keys },
"labor": 22.5,"travel": 1.5,"overtime": 0},"materials": [ 2 items ],
{ 3 keys },
"sku": "OAK-WT-30","qty": 1,"unit_cost": 41800},{ 3 keys }
"sku": "2x6-PT-12","qty": 40,"unit_cost": 1145}],"invoice": null}Path
$.materials[1].qty Step 3Handle the webhook
export async function POST(req: Request) { const raw = await req.text(); const event = verify(raw, req.headers); (note 1) if (event.type === "invoice.paid") { (note 2) await markPaid(event.invoice); } return new Response(null, { status: 204 }); (note 3) }Note 1:
verifythrows if the signature or timestamp is off, so a forged call never reaches your code.Note 2: Check the type first. New event types get added, so skip the ones you don't handle.
Note 3: Answer within 10 seconds. Slow or failed deliveries are retried for three days.
TypeError: Cannot read properties of undefined (reading 'rate')
lineTotalsrc/totals.ts:15:23
export function lineTotal(l: Line) { const price = PRICES[l.sku]; return l.qty * price.rate; ^^^^^ price is undefined }buildInvoicesrc/invoices.ts:42:18
for (const line of sheet.lines) { totals.push(lineTotal(line)); }POSTapp/api/invoices/route.ts:18:9
const sheet = await getSheet(body.job); const draft = buildInvoice(sheet);3 frames in node_modules
- handle @halden/sdk/dist/http.js:88:11
- dispatch router-lite/index.js:41:7
- run router-lite/index.js:12:3