Public: anyone can read this; the crew can change it.

A deal prints as a one-page broker file: price, earnest money, commission, every party, every date with the day it was done, waived or moved, and every message the agent approved #159

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A deal's page now has a Print broker file link to /deals/:id/file. That page is the one-page record for the brokerage's transaction file, built for the agent rather than the client.

Notes

shipped production is serving it deploy d2eada7

opened this

A deal's page now has a Print broker file link to /deals/:id/file. That page is the one-page record for the brokerage's transaction file, built for the agent rather than the client.

What it shows:

  • Figures: address, side, sale price, earnest money, commission rate and the commission it pays, and the closing day, time and place.
  • People: every party with role and contact.
  • Dates: each with its due day and its state. A state is done on (early, on time or late), waived, or open, and each move shows from, to, why, who and when. Dates that were removed show only as a "(date removed)" note beside a message, not as a row of their own.
  • Messages: every message approved, with the exact subject and body, who approved it and when. Every one declined is listed with its reason.
  • Outcome: open, closed and fell-through deals all print, and a fell-through deal shows its reason and who marked it.

How it's built:

  • Permission: the route reads the deal through the same permit-backed getDeal as the deal page, and contract.json is untouched. A signed-out visitor is refused. The lookup moved into a shared helper in src/routes.ts, which the client timeline now uses too.
  • Code reused: the page is built only from the deal view the deal page already reads, so no new SQL.
  • Layout: it is a new src/pages/file.ts plus print rules in static/app.css scoped to .file-page. They hide the header, footer, tools and toast. The Print button reuses static/print.js.
  • Client timeline: the client timeline is unchanged.
  • Docs: the README gets one sentence in the timeline walkthrough step.
  • Speed test: I added the page to src/speed.test.ts, which asserts under 50 ms with 200 deals.

Tests:

  • New: src/file.test.ts covers the content for a sample deal (a moved date, a waived date, a sent message, a declined one, a fell-through reason), escaping, a signed-in visitor getting 200 and a signed-out one being refused, and that every print rule is scoped to .file-page and hides navigation.
  • Changed: I changed one existing test, in src/timeline.test.ts. It assumed every print rule in the stylesheet belongs to the timeline page, so I limited it to the timeline's own print block.
  • Ran: the four test files above pass, and bun scripts/lint-design.ts printed nothing. The issue calls it design-lint.ts, but the script is named lint-design.ts.
  • Not run: bun x tsc --noEmit could not run here. The package has no TypeScript dependency, so tsc only printed its help. I did not run the whole suite, since the forge's check does that on push.

Not done: the terminal and MCP have no broker-file view, because the issue only asked for the page.

To try it, open any deal and tap Print broker file, then use the browser's print preview.

🤖 Generated with Claude Code

Closes #152

1 earlier comment · 1 event
commented

A deal's page now has a Print broker file link to /deals/:id/file. That page is the one-page record for the brokerage's transaction file, built for the agent rather than the client.

What it shows:

  • Figures: address, side, sale price, earnest money, commission rate and the commission it pays, and the closing day, time and place.
  • People: every party with role and contact.
  • Dates: each with its due day and its state. A state is done on (early, on time or late), waived, or open, and each move shows from, to, why, who and when. Dates that were removed show only as a "(date removed)" note beside a message, not as a row of their own.
  • Messages: every message approved, with the exact subject and body, who approved it and when. Every one declined is listed with its reason.
  • Outcome: open, closed and fell-through deals all print, and a fell-through deal shows its reason and who marked it.

How it's built:

  • Permission: the route reads the deal through the same permit-backed getDeal as the deal page, and contract.json is untouched. A signed-out visitor is refused. The lookup moved into a shared helper in src/routes.ts, which the client timeline now uses too.
  • Code reused: the page is built only from the deal view the deal page already reads, so no new SQL.
  • Layout: it is a new src/pages/file.ts plus print rules in static/app.css scoped to .file-page. They hide the header, footer, tools and toast. The Print button reuses static/print.js.
  • Client timeline: the client timeline is unchanged.
  • Docs: the README gets one sentence in the timeline walkthrough step.
  • Speed test: I added the page to src/speed.test.ts, which asserts under 50 ms with 200 deals.

Tests:

  • New: src/file.test.ts covers the content for a sample deal (a moved date, a waived date, a sent message, a declined one, a fell-through reason), escaping, a signed-in visitor getting 200 and a signed-out one being refused, and that every print rule is scoped to .file-page and hides navigation.
  • Changed: I changed one existing test, in src/timeline.test.ts. It assumed every print rule in the stylesheet belongs to the timeline page, so I limited it to the timeline's own print block.
  • Ran: the four test files above pass, and bun scripts/lint-design.ts printed nothing. The issue calls it design-lint.ts, but the script is named lint-design.ts.
  • Not run: bun x tsc --noEmit could not run here. The package has no TypeScript dependency, so tsc only printed its help. I did not run the whole suite, since the forge's check does that on push.

Not done: the terminal and MCP have no broker-file view, because the issue only asked for the page.

To try it, open any deal and tap Print broker file, then use the browser's print preview.

🤖 Generated with Claude Code

Changes requested — before the latest push

Security looks fine: the route reads through getDeal/permit, contract.json is untouched, output is escaped, no forms. Three misses need fixing in one round.

  1. Removed dates are not on the page (issue box 2, every date with its state: done, waived, removed or moved). Removed dates appear only as a "(date removed)" note beside a message. Print each removed date as a row with its due day and "Removed", and who removed it and when if the deal view carries that. Add a test for it.
  2. The terminal door is missing (checklist: both doors). The page is not the only door, so src/tty.ts needs a broker-file view of the open deal. It must gate as the page does (guest sees nothing, signed-in sees it) and the README must say how to reach it. A "not done" note in the pull does not satisfy this.
  3. The contract table has no row for the new door. Add the /deals/:id/file row to src/contract.test.ts (read as deal: user allowed, anon refused).

Smaller: file.ts imports ../http.ts twice (escape, asset), so merge them. Also run tsc and the design lint before pushing. The builder said tsc could not run.

Boxes 1, 3, 4, 5 and 6 look met, but I am not ticking them on a changes_requested verdict.

commented

Removed dates now print on the broker file, with one gap: a removed date that had no message sent or declined leaves no trace on the page. The terminal door and the contract row are also in, and the duplicate import is merged. The tests for the broker file, contract, timeline and speed pass, and bun scripts/lint-design.ts prints nothing.

  • Removed dates (item 1): removing a date deletes its row, so the deal view has no record of who removed it or when. I rebuild each removed date from the messages sent or declined about it. It prints as a row with its label, its due day and "Removed", and the message lines still carry "(date removed)". Showing every removed date would need a new table or a migration to record removals. I didn't add that, because the issue says to reuse the existing queries. src/file.test.ts has a test for this.
  • Terminal door (item 2): f on an open deal shows the broker file in the terminal. The page and the terminal print from the same fileRecord in src/pages/file.ts, and the terminal reads the deal through getDeal as the page does. A guest sees nothing, and a test covers that. The README says to open the deal with o and press f.
  • Contract row (item 3): src/contract.test.ts now checks /deals/:id/file as every identity against permit(deal, read), with anon refused (401).
  • Smaller points: the duplicate ../http.ts import is merged.
  • tsc still not run: bun x tsc --noEmit can't run here. The package has no TypeScript or Bun type definitions and no tsconfig.json. As a substitute I ran tsc directly on src/pages/file.ts and src/terminal.ts. The only errors it reported for them come from the missing bun:sqlite types (one in src/terminal.ts line 155 already existed), so the forge's check is the real type gate.
Approved

Earlier asks are met: removed dates print as a Removed row, the terminal door (f on a deal) reads through getDeal and a guest sees nothing, the contract test has the /deals/:id/file row (anon 401), and the duplicate import is merged. contract.json is untouched, the route reads through permit via the shared dealOrRefusal helper, every value is escaped, and the page has no forms. Non-blocking: a removed date that had no message sent or declined leaves no trace, because removal keeps no record. A removals record would fix it, and that is a separate issue. Non-blocking: the README sentence says "When a deal closes" but the link is on every deal. Non-blocking: the setup in file.test.ts has an odd getDeal(...).ok ? ann.id : 0. I could not read the preview with the token (401), so I judged from the diff.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs