Public: anyone can read this; the crew can change it.
A deal's closing carries a time and a place, like "2:00 pm at Lakeside Title, 400 Main St", on its page, the client timeline, the closing reminders and the calendar file #126
Check · Review · Land · Live done — Landed and live in production.
mason/deal-clock:mason/122-a-deal-s-closing-carries-a-time-and-a-pl → main 5 commits fork
18 files
changed +501
−26
README.md +11
| @@ -176,6 +176,17 @@ Signed out, `/` shows what deal-clock does, three short points, a still picture | ||
| 176 | 176 | with none shows nothing, and the earnest money reminder says the amount |
| 177 | 177 | ("Your $12,750 earnest money deposit is due Nov 7"). The sample deals carry |
| 178 | 178 | figures. Over MCP, the `update_figures` tool; the terminal does not edit them. |
| 179 | **Closing time and place.** The closing may carry a time (a quarter hour | |
| 180 | from 7:00 am to 8:00 pm) and a place (up to 200 characters): tap Edit | |
| 181 | closing time and place on the deal's page, and clear either by leaving it | |
| 182 | blank. The page and the client timeline read "Closing Nov 21 · 2:00 pm · | |
| 183 | Lakeside Title, 400 Main St", the closing and final walk-through reminders | |
| 184 | say them, and the calendar file makes closing a one-hour event with its | |
| 185 | location (local time, no time zone); with no time it stays an all-day | |
| 186 | event. Moving the closing date keeps them, and the date-changed notice | |
| 187 | names them. The sample closing this week has both. Over MCP, the | |
| 188 | `update_closing` tool; in the terminal, press C on a deal and answer the time | |
| 189 | and the place (blank clears), and the deal view shows the same closing line. | |
| 179 | 190 | **Which side you are on.** Each deal says whether you are the buyer's agent, |
| 180 | 191 | the listing agent or both, chosen when you open it (Buyer's agent unless you |
| 181 | 192 | say otherwise) and changed with Save side on its page. A small label, "Buyer |
contract/openapi.json +53 −2
| @@ -729,6 +729,23 @@ | ||
| 729 | 729 | "maximum": 100000000, |
| 730 | 730 | "description": "The earnest money amount in whole dollars; null while none is set." |
| 731 | 731 | }, |
| 732 | "closing_time": { | |
| 733 | "type": [ | |
| 734 | "string", | |
| 735 | "null" | |
| 736 | ], | |
| 737 | "pattern": "^(0[7-9]|1[0-9]):(00|15|30|45)$|^20:00$", | |
| 738 | "description": "When it closes, HH:MM on a quarter hour from 07:00 to 20:00, local time; null while none is set." | |
| 739 | }, | |
| 740 | "closing_place": { | |
| 741 | "type": [ | |
| 742 | "string", | |
| 743 | "null" | |
| 744 | ], | |
| 745 | "minLength": 1, | |
| 746 | "maxLength": 200, | |
| 747 | "description": "Where it closes; null while none is set." | |
| 748 | }, | |
| 732 | 749 | "business_days": { |
| 733 | 750 | "enum": [ |
| 734 | 751 | 0, |
| @@ -1089,7 +1106,7 @@ | ||
| 1089 | 1106 | } |
| 1090 | 1107 | }, |
| 1091 | 1108 | "patch": { |
| 1092 | "summary": "Correct a deal's address, sale price, earnest money amount or side (buyer, listing or both); a field left out stays as it is, and a figure sent as null is cleared. Dates move one at a time, with a reason (POST /deadlines/:id/move).", | |
| 1109 | "summary": "Correct a deal's address, sale price, earnest money amount, closing time, closing place or side (buyer, listing or both); a field left out stays as it is, and one sent as null is cleared (not the side). Dates move one at a time, with a reason (POST /deadlines/:id/move).", | |
| 1093 | 1110 | "operationId": "patchApiDealsId", |
| 1094 | 1111 | "parameters": [ |
| 1095 | 1112 | { |
| @@ -1129,6 +1146,23 @@ | ||
| 1129 | 1146 | "minimum": 0, |
| 1130 | 1147 | "maximum": 100000000 |
| 1131 | 1148 | }, |
| 1149 | "closing_time": { | |
| 1150 | "type": [ | |
| 1151 | "string", | |
| 1152 | "null" | |
| 1153 | ], | |
| 1154 | "pattern": "^(0[7-9]|1[0-9]):(00|15|30|45)$|^20:00$", | |
| 1155 | "description": "When it closes, HH:MM on a quarter hour from 07:00 to 20:00, local time; null while none is set." | |
| 1156 | }, | |
| 1157 | "closing_place": { | |
| 1158 | "type": [ | |
| 1159 | "string", | |
| 1160 | "null" | |
| 1161 | ], | |
| 1162 | "minLength": 1, | |
| 1163 | "maxLength": 200, | |
| 1164 | "description": "Where it closes; null while none is set." | |
| 1165 | }, | |
| 1132 | 1166 | "side": { |
| 1133 | 1167 | "enum": [ |
| 1134 | 1168 | "buyer", |
| @@ -1143,7 +1177,7 @@ | ||
| 1143 | 1177 | }, |
| 1144 | 1178 | "responses": { |
| 1145 | 1179 | "200": { |
| 1146 | "description": "Correct a deal's address, sale price, earnest money amount or side (buyer, listing or both); a field left out stays as it is, and a figure sent as null is cleared. Dates move one at a time, with a reason (POST /deadlines/:id/move).", | |
| 1180 | "description": "Correct a deal's address, sale price, earnest money amount, closing time, closing place or side (buyer, listing or both); a field left out stays as it is, and one sent as null is cleared (not the side). Dates move one at a time, with a reason (POST /deadlines/:id/move).", | |
| 1147 | 1181 | "content": { |
| 1148 | 1182 | "application/json": { |
| 1149 | 1183 | "schema": { |
| @@ -2658,6 +2692,23 @@ | ||
| 2658 | 2692 | "maximum": 100000000, |
| 2659 | 2693 | "description": "The earnest money amount in whole dollars; null while none is set." |
| 2660 | 2694 | }, |
| 2695 | "closing_time": { | |
| 2696 | "type": [ | |
| 2697 | "string", | |
| 2698 | "null" | |
| 2699 | ], | |
| 2700 | "pattern": "^(0[7-9]|1[0-9]):(00|15|30|45)$|^20:00$", | |
| 2701 | "description": "When it closes, HH:MM on a quarter hour from 07:00 to 20:00, local time; null while none is set." | |
| 2702 | }, | |
| 2703 | "closing_place": { | |
| 2704 | "type": [ | |
| 2705 | "string", | |
| 2706 | "null" | |
| 2707 | ], | |
| 2708 | "minLength": 1, | |
| 2709 | "maxLength": 200, | |
| 2710 | "description": "Where it closes; null while none is set." | |
| 2711 | }, | |
| 2661 | 2712 | "business_days": { |
| 2662 | 2713 | "enum": [ |
| 2663 | 2714 | 0, |
docs/TECHNICAL.md +5 −1
| @@ -165,7 +165,7 @@ marked sent, as JSON — call it each morning as a signed-in account (a | ||
| 165 | 165 | stranger gets 401; it sends nothing and changes nothing). `GET /deals/:id/ics` is a deal's calendar file. `GET /deals/csv` (and `GET /api/deals.csv`, in openapi) is the spreadsheet, below. The JSON API is |
| 166 | 166 | `/api/deals`, described at `/openapi.json`; the same operations are MCP |
| 167 | 167 | tools at `POST /mcp` (`list_deals`, `get_deal`, `client_timeline`, `reminders_today`, `this_week`, `list_people`, |
| 168 | `open_deal`, `add_date`, `update_address`, `update_figures`, `set_side`, `add_party`, `edit_party`, `remove_party`, | |
| 168 | `open_deal`, `add_date`, `update_address`, `update_figures`, `update_closing`, `set_side`, `add_party`, `edit_party`, `remove_party`, | |
| 169 | 169 | `remove_date` — custom dates only — `remove_deal` — its author or an admin — |
| 170 | 170 | `mark_done` — with `done: false` to |
| 171 | 171 | reopen a date — `waive_date` — with `waived: false` to un-waive it — `move_date`, `set_reminder_lead`, `amend_deal` (several dates, one reason), `send_reminder`, `restore_samples` — admin only: puts the |
| @@ -335,6 +335,10 @@ The forge sets `PORT`, `FORGE_APP_DATA`, `FORGE_APP_ENV` (`production` or | ||
| 335 | 335 | |
| 336 | 336 | `conflicts` on a deal (`GET /api/deals/:id`, the list, MCP `get_deal`, the terminal deal view) lists each open, non-Closing date due on or after the open Closing date: `{deadline_id, label, due, closing}`. It is computed once per assembled deal by `src/order.ts` and is empty for a closed deal and for done dates. A move still succeeds; the form notice names the conflict. |
| 337 | 337 | |
| 338 | `deal.closing_time` (`HH:MM`, a quarter hour, 07:00 to 20:00) and `deal.closing_place` (1 to 200 | |
| 339 | characters) are nullable columns, read and written as `closing_time` and `closing_place` by | |
| 340 | `GET`/`PATCH /api/deals/:id`, the `update_closing` tool and `POST /deals/:id/closing`; `src/closing.ts` | |
| 341 | validates and words them. The calendar file writes a timed closing as floating local time. | |
| 338 | 342 | ### Side |
| 339 | 343 | |
| 340 | 344 | `deal.side` (`buyer`, `listing` or `both`; migration default `buyer`) says which side the agent represents. `src/side.ts` holds the words, `sideOf` (nothing or blank is `buyer`, anything but the three words is refused with 422 and `field: "side"`) and `onSide` (the narrowing: a `both` deal is on each side). It is an `update` of the deal, audited as one: `PATCH /api/deals/:id` with `side`, `POST /deals/:id/side`, MCP `set_side`. `GET /` and `GET /week` take `?side=buyer|listing|all` beside `?q=`; `GET /api/deals` and `list_deals` take `side` too. `GET /reminders/today` does not narrow by side. No new contract cell. |
src/closing.test.ts added +187
| @@ -0,0 +1,187 @@ | ||
| 1 | /** A deal's closing time and place: validated at every door, shown, said in the drafts, in the calendar file, kept through a move, audited, carried by the samples. */ | |
| 2 | import { afterAll, beforeEach, expect, test } from "bun:test"; | |
| 3 | import { mkdtempSync } from "node:fs"; | |
| 4 | import { tmpdir } from "node:os"; | |
| 5 | import { join } from "node:path"; | |
| 6 | import { clock12, closingLine, closingPlace, closingTime } from "./closing.ts"; | |
| 7 | import { openDb } from "./db.ts"; | |
| 8 | import { createDeal, getDeal, moveDeadline, updateDeal } from "./deals.ts"; | |
| 9 | import { book, calendar } from "./ics.ts"; | |
| 10 | import { dealPage } from "./pages/deal.ts"; | |
| 11 | import { timelinePage } from "./pages/timeline.ts"; | |
| 12 | import { drafts } from "./reminders.ts"; | |
| 13 | import { restore } from "./sample.ts"; | |
| 14 | import { forgetRationing } from "./security.ts"; | |
| 15 | import { serve } from "./server.ts"; | |
| 16 | import { sign, type Who } from "./who.ts"; | |
| 17 | ||
| 18 | const KEY = "a-key-only-the-forge-holds"; | |
| 19 | const dir = mkdtempSync(join(tmpdir(), "app-closing-")); | |
| 20 | const db = openDb(dir); | |
| 21 | const alice: Who = { role: "user", id: "u1", name: "alice" }; | |
| 22 | const server = serve({ port: 0, dataDir: dir, identityKey: KEY }); | |
| 23 | const base = `http://${server.hostname}:${server.port}`; | |
| 24 | afterAll(() => server.stop(true)); | |
| 25 | beforeEach(forgetRationing); | |
| 26 | ||
| 27 | const identity = `u1|alice|user|${Date.now() + 600_000}`; | |
| 28 | const user = { "x-forge-identity": identity, "x-forge-signature": sign(identity, KEY) }; | |
| 29 | const json = (path: string, method: string, body: object) => | |
| 30 | fetch(base + path, { method, headers: { ...user, "content-type": "application/json" }, body: JSON.stringify(body) }); | |
| 31 | const agent = { name: "Dana", brokerage: "Harbor", phone: "555", email: "[email protected]" }; | |
| 32 | const PLACE = "Lakeside Title, 400 Main St; Suite 2\nsecond floor"; | |
| 33 | ||
| 34 | let n = 0; | |
| 35 | const open = () => { | |
| 36 | const made = createDeal(db, alice, { address: `${++n} Closing Way`, buyer: "Ann Buyer", seller: "Sam Seller", contractDate: "2026-10-01", closingDate: "2026-11-21", openAnyway: true }); | |
| 37 | if (!made.ok) throw new Error(made.message); | |
| 38 | return made.value; | |
| 39 | }; | |
| 40 | const set = (id: number, closingTime: unknown, closingPlace: unknown) => { | |
| 41 | const r = updateDeal(db, alice, { id, closingTime, closingPlace }); | |
| 42 | if (!r.ok) throw new Error(r.message); | |
| 43 | return r.value; | |
| 44 | }; | |
| 45 | ||
| 46 | test("a time is HH:MM on a quarter hour from 7:00 am to 8:00 pm; a place is 1 to 200 characters; blank clears", () => { | |
| 47 | for (const bad of ["25:00", "2pm", "14:10", "06:45", "20:15", "7:00", 1400, "14:00:00"]) { | |
| 48 | const r = closingTime(bad); | |
| 49 | expect(r.ok).toBe(false); | |
| 50 | } | |
| 51 | expect(closingTime("07:00")).toEqual({ ok: true, value: "07:00" }); | |
| 52 | expect(closingTime("20:00")).toEqual({ ok: true, value: "20:00" }); | |
| 53 | expect(closingTime("")).toEqual({ ok: true, value: null }); | |
| 54 | expect(closingTime(null)).toEqual({ ok: true, value: null }); | |
| 55 | expect(closingPlace("x".repeat(201)).ok).toBe(false); | |
| 56 | expect(closingPlace(5).ok).toBe(false); | |
| 57 | expect(closingPlace(" ")).toEqual({ ok: true, value: null }); | |
| 58 | expect(clock12("14:00")).toBe("2:00 pm"); | |
| 59 | expect(clock12("00:15")).toBe("12:15 am"); | |
| 60 | expect(clock12("12:30")).toBe("12:30 pm"); | |
| 61 | }); | |
| 62 | ||
| 63 | test("set, kept when only one is sent, cleared, and refused without a change", () => { | |
| 64 | const deal = open(); | |
| 65 | const a = set(deal.id, "14:00", "Lakeside Title"); | |
| 66 | expect([a.closing_time, a.closing_place]).toEqual(["14:00", "Lakeside Title"]); | |
| 67 | const b = updateDeal(db, alice, { id: deal.id, closingPlace: "Elsewhere" }); | |
| 68 | expect(b.ok && [b.value.closing_time, b.value.closing_place]).toEqual(["14:00", "Elsewhere"]); | |
| 69 | const bad = updateDeal(db, alice, { id: deal.id, closingTime: "2pm" }); | |
| 70 | expect(bad.ok).toBe(false); | |
| 71 | expect(getDeal(db, alice, { id: deal.id }).ok && (getDeal(db, alice, { id: deal.id }) as any).value.closing_time).toBe("14:00"); | |
| 72 | const c = set(deal.id, "", null); | |
| 73 | expect([c.closing_time, c.closing_place]).toEqual([null, null]); | |
| 74 | }); | |
| 75 | ||
| 76 | test("the page and the timeline say it; a deal with neither reads as before", () => { | |
| 77 | const bare = open(); | |
| 78 | const on = "2026-11-08"; | |
| 79 | expect(dealPage({ who: alice, deal: bare, on })).not.toContain("closing-when"); | |
| 80 | expect(timelinePage({ who: alice, deal: bare, on })).not.toContain("closing-when"); | |
| 81 | const deal = set(open().id, "14:00", "Lakeside Title, 400 Main St"); | |
| 82 | expect(closingLine(deal)).toBe("Closing Nov 21 · 2:00 pm · Lakeside Title, 400 Main St"); | |
| 83 | expect(dealPage({ who: alice, deal, on })).toContain("Closing Nov 21 · 2:00 pm · Lakeside Title, 400 Main St"); | |
| 84 | expect(timelinePage({ who: alice, deal, on })).toContain("Closing Nov 21 · 2:00 pm · Lakeside Title, 400 Main St"); | |
| 85 | const xss = set(open().id, null, "<script>alert(1)</script>"); | |
| 86 | expect(timelinePage({ who: alice, deal: xss, on })).not.toContain("<script>alert"); | |
| 87 | }); | |
| 88 | ||
| 89 | test("closing and walk-through reminders name the time and place when set, and not otherwise", () => { | |
| 90 | const plain = open(); | |
| 91 | const wordsOf = (d: typeof plain, kind: string) => drafts(d, agent).filter((r) => r.label === (kind === "closing" ? "Closing" : "Final walkthrough")).map((r) => r.body); | |
| 92 | for (const b of [...wordsOf(plain, "closing"), ...wordsOf(plain, "walk")]) expect(b).not.toContain(" pm"); | |
| 93 | const deal = set(open().id, "14:00", "Lakeside Title, 400 Main St"); | |
| 94 | const closing = drafts(deal, agent).filter((r) => r.label === "Closing"); | |
| 95 | expect(closing.length).toBeGreaterThan(0); | |
| 96 | for (const r of closing) expect(r.body).toContain("2:00 pm at Lakeside Title, 400 Main St"); | |
| 97 | const walk = drafts(deal, agent).filter((r) => r.label === "Final walkthrough"); | |
| 98 | expect(walk.length).toBeGreaterThan(0); | |
| 99 | for (const r of walk.filter((r) => r.moment !== "late")) expect(r.body).toContain("Closing follows on"); | |
| 100 | const timeOnly = set(open().id, "09:30", null); | |
| 101 | expect(drafts(timeOnly, agent).find((r) => r.label === "Closing")!.body).toContain("at 9:30 am."); | |
| 102 | }); | |
| 103 | ||
| 104 | test("the calendar file: a timed hour with an escaped LOCATION, or all day as before", () => { | |
| 105 | const deal = set(open().id, "14:00", PLACE); | |
| 106 | const ics = calendar(deal, "x.example", new Date("2026-11-08T00:00:00Z"), agent); | |
| 107 | expect(ics).toContain("DTSTART:20261121T140000"); | |
| 108 | expect(ics).toContain("DTEND:20261121T150000"); | |
| 109 | expect(ics).toContain("LOCATION:Lakeside Title\\, 400 Main St\\; Suite 2 second floor"); | |
| 110 | expect(ics).toContain("TRIGGER:-PT300M"); | |
| 111 | expect(book([deal], "x.example", new Date("2026-11-08T00:00:00Z"))).toContain("DTSTART:20261121T140000"); | |
| 112 | const late = set(open().id, "20:00", null); | |
| 113 | expect(calendar(late, "x.example")).toContain("DTEND:20261121T210000"); | |
| 114 | const allDay = calendar(open(), "x.example"); | |
| 115 | expect(allDay).toContain("DTSTART;VALUE=DATE:20261121"); | |
| 116 | expect(allDay).not.toContain("LOCATION"); | |
| 117 | // Only the closing is timed. | |
| 118 | expect(ics.match(/DTSTART:/g)!.length).toBe(1); | |
| 119 | }); | |
| 120 | ||
| 121 | test("moving the closing date keeps the time and place, and the notice names them", () => { | |
| 122 | const deal = set(open().id, "14:00", "Lakeside Title"); | |
| 123 | const closing = deal.deadlines.find((d) => d.kind === "closing")!; | |
| 124 | const moved = moveDeadline(db, alice, { id: closing.id, due: "2026-11-24", reason: "Lender needs more time" }); | |
| 125 | if (!moved.ok) throw new Error(moved.message); | |
| 126 | const after = getDeal(db, alice, { id: deal.id }); | |
| 127 | if (!after.ok) throw new Error(after.message); | |
| 128 | expect([after.value.closing_time, after.value.closing_place]).toEqual(["14:00", "Lakeside Title"]); | |
| 129 | const notice = drafts(after.value, agent).find((r) => r.moment === "moved" && r.label === "Closing")!; | |
| 130 | expect(notice.body).toContain("2:00 pm at Lakeside Title"); | |
| 131 | }); | |
| 132 | ||
| 133 | test("the page form: refused keeps what was typed, saves, clears, is same-origin, audited", async () => { | |
| 134 | const deal = open(); | |
| 135 | const post = (fields: Record<string, string>, headers: Record<string, string> = {}) => { | |
| 136 | const form = new FormData(); | |
| 137 | for (const [k, v] of Object.entries(fields)) form.set(k, v); | |
| 138 | return fetch(`${base}/deals/${deal.id}/closing`, { method: "POST", body: form, headers: { ...user, ...headers }, redirect: "manual" }); | |
| 139 | }; | |
| 140 | const refused = await post({ closing_time: "2pm", closing_place: "Lakeside Title" }); | |
| 141 | expect(refused.status).toBe(422); | |
| 142 | const page = await refused.text(); | |
| 143 | expect(page).toContain('value="2pm"'); | |
| 144 | expect(page).toContain('value="Lakeside Title"'); | |
| 145 | expect(page).toContain("quarter hour"); | |
| 146 | expect((await post({ closing_time: "14:00", closing_place: "Lakeside Title" })).status).toBe(303); | |
| 147 | const shown = await (await fetch(`${base}/deals/${deal.id}`, { headers: user })).text(); | |
| 148 | expect(shown).toContain("Closing Nov 21 · 2:00 pm · Lakeside Title"); | |
| 149 | expect((await post({ closing_time: "", closing_place: "" })).status).toBe(303); | |
| 150 | const cleared = getDeal(db, alice, { id: deal.id }); | |
| 151 | expect(cleared.ok && [cleared.value.closing_time, cleared.value.closing_place]).toEqual([null, null]); | |
| 152 | const foreign = await post({ closing_time: "10:00" }, { origin: "https://evil.example", "sec-fetch-site": "cross-site" }); | |
| 153 | expect(foreign.status).toBeGreaterThanOrEqual(400); | |
| 154 | const rootId = `u0|root|admin|${Date.now() + 600_000}`; | |
| 155 | const activity = await (await fetch(`${base}/activity`, { headers: { "x-forge-identity": rootId, "x-forge-signature": sign(rootId, KEY) } })).text(); | |
| 156 | expect(activity).toContain("changed a deal"); | |
| 157 | }); | |
| 158 | ||
| 159 | test("the API and the MCP tool read and write both, and refuse a bad time", async () => { | |
| 160 | const deal = open(); | |
| 161 | const bad = await json(`/api/deals/${deal.id}`, "PATCH", { closing_time: "25:00" }); | |
| 162 | expect(bad.status).toBe(422); | |
| 163 | expect((await json(`/api/deals/${deal.id}`, "PATCH", { closing_time: "2pm" })).status).toBe(422); | |
| 164 | const patched = await json(`/api/deals/${deal.id}`, "PATCH", { closing_time: "14:00", closing_place: "Lakeside Title" }); | |
| 165 | expect(patched.status).toBe(200); | |
| 166 | const got = (await (await fetch(`${base}/api/deals/${deal.id}`, { headers: user })).json()) as any; | |
| 167 | expect([got.closing_time, got.closing_place]).toEqual(["14:00", "Lakeside Title"]); | |
| 168 | const call = async (name: string, args: object) => | |
| 169 | (await (await json("/mcp", "POST", { jsonrpc: "2.0", id: 1, method: "tools/call", params: { name, arguments: args } })).json()) as any; | |
| 170 | const cleared = await call("update_closing", { deal_id: deal.id, closing_place: null }); | |
| 171 | expect(JSON.parse(cleared.result.content[0].text)).toMatchObject({ closing_time: "14:00", closing_place: null }); | |
| 172 | expect((await call("update_closing", { deal_id: deal.id, closing_time: "8am" })).result.isError).toBe(true); | |
| 173 | expect((await call("update_closing", { deal_id: deal.id })).result.isError).toBe(true); | |
| 174 | const tl = await call("client_timeline", { id: deal.id }); | |
| 175 | expect(JSON.parse(tl.result.content[0].text)).toMatchObject({ closing_time: "14:00", closing_place: null }); | |
| 176 | }); | |
| 177 | ||
| 178 | test("the sample deal closing this week has a time and a place, and restoring brings them back", () => { | |
| 179 | const rows = () => | |
| 180 | db.query<{ address: string; closing_time: string | null; closing_place: string | null }, []>("SELECT address, closing_time, closing_place FROM deal WHERE author_id = 'sample' AND closing_time IS NOT NULL").all(); | |
| 181 | expect(rows().length).toBe(1); | |
| 182 | expect(rows()[0]!.closing_place).toContain("Title"); | |
| 183 | const before = rows(); | |
| 184 | db.query("UPDATE deal SET closing_time = NULL, closing_place = NULL WHERE author_id = 'sample'").run(); | |
| 185 | restore(db); | |
| 186 | expect(rows()).toEqual(before); | |
| 187 | }); |
src/closing.ts added +67
| @@ -0,0 +1,67 @@ | ||
| 1 | /** | |
| 2 | * When and where a deal closes, beyond the day: an optional time (HH:MM, a | |
| 3 | * quarter hour, 7:00 am to 8:00 pm) and an optional place (1 to 200 | |
| 4 | * characters). Pure functions: `closingTime` and `closingPlace` check what a | |
| 5 | * person or a door sent, `clock12` and `closingWhere` say it the one way every | |
| 6 | * page, draft and calendar does. | |
| 7 | */ | |
| 8 | ||
| 9 | import { short } from "./dates.ts"; | |
| 10 | import { fail, ok, type Result } from "./result.ts"; | |
| 11 | ||
| 12 | const TIME = /^([01][0-9]|2[0-3]):(00|15|30|45)$/; | |
| 13 | ||
| 14 | /** "14:00" → "2:00 pm". */ | |
| 15 | export function clock12(time: string): string { | |
| 16 | const h = Number(time.slice(0, 2)); | |
| 17 | return `${h % 12 === 0 ? 12 : h % 12}:${time.slice(3)} ${h < 12 ? "am" : "pm"}`; | |
| 18 | } | |
| 19 | ||
| 20 | /** The closing time from a form, a JSON body or a prompt: HH:MM on a quarter hour, 07:00 to 20:00. Blank or null is none. */ | |
| 21 | export function closingTime(value: unknown): Result<string | null> { | |
| 22 | if (value === undefined || value === null) return ok(null); | |
| 23 | const text = typeof value === "string" ? value.trim() : undefined; | |
| 24 | if (text === "") return ok(null); | |
| 25 | if (text === undefined || !TIME.test(text) || text < "07:00" || text > "20:00") | |
| 26 | return fail("invalid", "The closing time is HH:MM on a quarter hour, from 07:00 to 20:00.", "closing_time"); | |
| 27 | return ok(text); | |
| 28 | } | |
| 29 | ||
| 30 | /** The closing place from a form, a JSON body or a prompt: one line, 1 to 200 characters. Blank or null is none. */ | |
| 31 | export function closingPlace(value: unknown): Result<string | null> { | |
| 32 | if (value === undefined || value === null) return ok(null); | |
| 33 | if (typeof value !== "string") return fail("invalid", "The closing place is 1 to 200 characters.", "closing_place"); | |
| 34 | // Control characters have no place in a field: they would reach a calendar file or a terminal. | |
| 35 | const text = value.replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ").replace(/\s+/g, " ").trim(); | |
| 36 | if (text === "") return ok(null); | |
| 37 | if (text.length > 200) return fail("invalid", "The closing place is 1 to 200 characters.", "closing_place"); | |
| 38 | return ok(text); | |
| 39 | } | |
| 40 | ||
| 41 | interface Closing { | |
| 42 | readonly closing_time: string | null; | |
| 43 | readonly closing_place: string | null; | |
| 44 | } | |
| 45 | ||
| 46 | /** "2:00 pm at Lakeside Title, 400 Main St", or what part of it is set; "" when neither. */ | |
| 47 | export function closingWhere(deal: Closing): string { | |
| 48 | const time = deal.closing_time === null ? "" : clock12(deal.closing_time); | |
| 49 | const place = deal.closing_place ?? ""; | |
| 50 | return time !== "" && place !== "" ? `${time} at ${place}` : `${time}${place}`; | |
| 51 | } | |
| 52 | ||
| 53 | /** "Closing Nov 21 · 2:00 pm · Lakeside Title, 400 Main St": the one line pages show. */ | |
| 54 | export const closingLine = (deal: Closing & { closing: string }): string => | |
| 55 | ["Closing " + short(deal.closing), deal.closing_time === null ? "" : clock12(deal.closing_time), deal.closing_place ?? ""] | |
| 56 | .filter((p) => p !== "") | |
| 57 | .join(" · "); | |
| 58 | ||
| 59 | /** | |
| 60 | * How a draft says where the closing is, after its date: ", 2:00 pm at Lakeside | |
| 61 | * Title" (or " at 2:00 pm", or " at Lakeside Title"); "" when neither is set. | |
| 62 | */ | |
| 63 | export function closingAfterDate(deal: Closing): string { | |
| 64 | const where = closingWhere(deal); | |
| 65 | if (where === "") return ""; | |
| 66 | return deal.closing_time !== null && deal.closing_place !== null ? `, ${where}` : ` at ${where}`; | |
| 67 | } |
src/db.ts +3
| @@ -416,6 +416,9 @@ export const migrations: string[] = [ | ||
| 416 | 416 | AND length(trim(contact)) - length(replace(trim(contact), '@', '')) = 1 AND length(trim(contact)) <= 200`, |
| 417 | 417 | `UPDATE party SET phone = trim(contact) |
| 418 | 418 | WHERE email = '' AND trim(contact) NOT GLOB '*[^0-9 +().-]*' AND trim(contact) GLOB '*[0-9]*' AND length(trim(contact)) <= 30`, |
| 419 | // When and where the deal closes, beyond the day; null while unset. | |
| 420 | `ALTER TABLE deal ADD COLUMN closing_time TEXT CHECK (closing_time IS NULL OR closing_time GLOB '[0-2][0-9]:[0-5][0-9]')`, | |
| 421 | `ALTER TABLE deal ADD COLUMN closing_place TEXT CHECK (closing_place IS NULL OR length(closing_place) BETWEEN 1 AND 200)`, | |
| 419 | 422 | // Which side the agent represents: the buyer's, a listing, or both. |
| 420 | 423 | `ALTER TABLE deal ADD COLUMN side TEXT NOT NULL DEFAULT 'buyer' CHECK (side IN ('buyer', 'listing', 'both'))`, |
| 421 | 424 | ]; |
src/deals.ts +15 −3
| @@ -28,6 +28,7 @@ import { | ||
| 28 | 28 | import { LENGTH_MAX, standard, validEmail, validPhone } from "./env.ts"; |
| 29 | 29 | import { agentOf } from "./profile.ts"; |
| 30 | 30 | import { emit } from "./live.ts"; |
| 31 | import { closingPlace, closingTime } from "./closing.ts"; | |
| 31 | 32 | import { amount } from "./money.ts"; |
| 32 | 33 | import { SIDE_REFUSAL, sideOf, type Side } from "./side.ts"; |
| 33 | 34 | import { outboxes } from "./outbox.ts"; |
| @@ -51,6 +52,9 @@ export interface Deal { | ||
| 51 | 52 | /** The sale price and the earnest money amount, in whole dollars; null while none is set. */ |
| 52 | 53 | readonly sale_price: number | null; |
| 53 | 54 | readonly earnest_amount: number | null; |
| 55 | /** When and where it closes beyond the day: "14:00" and a place; null while unset. */ | |
| 56 | readonly closing_time: string | null; | |
| 57 | readonly closing_place: string | null; | |
| 54 | 58 | /** Which side the agent represents on this deal. */ |
| 55 | 59 | readonly side: Side; |
| 56 | 60 | } |
| @@ -657,6 +661,8 @@ export interface DealEdit { | ||
| 657 | 661 | readonly address?: unknown; |
| 658 | 662 | readonly salePrice?: unknown; |
| 659 | 663 | readonly earnestAmount?: unknown; |
| 664 | readonly closingTime?: unknown; | |
| 665 | readonly closingPlace?: unknown; | |
| 660 | 666 | readonly side?: unknown; |
| 661 | 667 | } |
| 662 | 668 | |
| @@ -666,7 +672,7 @@ export const updateDeal = (db: Database, who: Who, input: DealEdit): Result<Deal | ||
| 666 | 672 | function update(db: Database, who: Who, input: DealEdit): Result<DealView> { |
| 667 | 673 | const found = dealFor(db, who, "update", input.id); |
| 668 | 674 | if (!found.ok) return found; |
| 669 | const bare = input.address === undefined && input.salePrice === undefined && input.earnestAmount === undefined && input.side === undefined; | |
| 675 | const bare = input.address === undefined && input.salePrice === undefined && input.earnestAmount === undefined && input.closingTime === undefined && input.closingPlace === undefined && input.side === undefined; | |
| 670 | 676 | const address = input.address === undefined && !bare ? found.value.address : line(input.address, 3, 200); |
| 671 | 677 | if (address === undefined) |
| 672 | 678 | return fail("invalid", "The address is 3 to 200 characters.", "address"); |
| @@ -674,11 +680,17 @@ function update(db: Database, who: Who, input: DealEdit): Result<DealView> { | ||
| 674 | 680 | if (!price.ok) return price; |
| 675 | 681 | const earnest = input.earnestAmount === undefined ? ok(found.value.earnest_amount) : amount(input.earnestAmount, "earnest_amount", "earnest money amount"); |
| 676 | 682 | if (!earnest.ok) return earnest; |
| 683 | const time = input.closingTime === undefined ? ok(found.value.closing_time) : closingTime(input.closingTime); | |
| 684 | if (!time.ok) return time; | |
| 685 | const place = input.closingPlace === undefined ? ok(found.value.closing_place) : closingPlace(input.closingPlace); | |
| 686 | if (!place.ok) return place; | |
| 677 | 687 | const side = input.side === undefined ? found.value.side : input.side === "" || input.side === null ? undefined : sideOf(input.side); |
| 678 | 688 | if (side === undefined) return fail("invalid", SIDE_REFUSAL, "side"); |
| 679 | db.query("UPDATE deal SET address = ?1, sale_price = ?2, earnest_amount = ?3, side = ?4 WHERE id = ?5").run(address, price.value, earnest.value, side, found.value.id); | |
| 689 | db.query("UPDATE deal SET address = ?1, sale_price = ?2, earnest_amount = ?3, closing_time = ?4, closing_place = ?5, side = ?6 WHERE id = ?7").run( | |
| 690 | address, price.value, earnest.value, time.value, place.value, side, found.value.id, | |
| 691 | ); | |
| 680 | 692 | emit("deal.changed", { id: found.value.id }); |
| 681 | return ok(view(db, { ...found.value, address, sale_price: price.value, earnest_amount: earnest.value, side })); | |
| 693 | return ok(view(db, { ...found.value, address, sale_price: price.value, earnest_amount: earnest.value, closing_time: time.value, closing_place: place.value, side })); | |
| 682 | 694 | } |
| 683 | 695 | |
| 684 | 696 | /** What the audit trail calls a deal falling through, and its reopening. */ |
src/ics.ts +21 −3
| @@ -39,6 +39,19 @@ const compact = (date: string): string => date.replaceAll("-", ""); | ||
| 39 | 39 | |
| 40 | 40 | const stampOf = (stamp: Date): string => stamp.toISOString().replace(/[-:]/g, "").replace(/\.\d+/, ""); |
| 41 | 41 | |
| 42 | /** The end of a one-hour event starting at `time` on `date`, which may spill into the next day. */ | |
| 43 | function endOfHour(date: string, time: string): string[] { | |
| 44 | const h = Number(time.slice(0, 2)) + 1; | |
| 45 | const day = h >= 24 ? addDays(date, 1) : date; | |
| 46 | return [`DTEND:${compact(day)}T${String(h % 24).padStart(2, "0")}${time.slice(3)}00`]; | |
| 47 | } | |
| 48 | ||
| 49 | /** An alarm trigger, relative to the start, that fires at 9 a.m. the day of. */ | |
| 50 | function nineAm(time: string): string { | |
| 51 | const delta = 540 - (Number(time.slice(0, 2)) * 60 + Number(time.slice(3))); | |
| 52 | return delta >= 0 ? `PT${delta}M` : `-PT${-delta}M`; | |
| 53 | } | |
| 54 | ||
| 42 | 55 | /** One deal's events; the UID is the date's own, so a deal's file and the book never double. */ |
| 43 | 56 | function events(deal: DealView, host: string, now: string, openOnly: boolean): string[] { |
| 44 | 57 | const lines: string[] = []; |
| @@ -46,12 +59,17 @@ function events(deal: DealView, host: string, now: string, openOnly: boolean): s | ||
| 46 | 59 | if (openOnly && !isOpen(d)) continue; |
| 47 | 60 | const owner = deal.parties.find((p) => p.role === d.owes); |
| 48 | 61 | const who = owner === undefined ? PARTY_LABEL[d.owes] : `${owner.name} (${PARTY_LABEL[d.owes]})`; |
| 62 | // Closing with a time is a timed hour in floating local time (no zone invented); otherwise all day. | |
| 63 | const timed = d.kind === "closing" && deal.closing_time !== null ? deal.closing_time : null; | |
| 64 | const place = d.kind === "closing" && deal.closing_place !== null ? deal.closing_place : null; | |
| 49 | 65 | lines.push( |
| 50 | 66 | "BEGIN:VEVENT", |
| 51 | 67 | `UID:deadline-${d.id}@${host}`, |
| 52 | 68 | `DTSTAMP:${now}`, |
| 53 | `DTSTART;VALUE=DATE:${compact(d.due)}`, | |
| 54 | `DTEND;VALUE=DATE:${compact(addDays(d.due, 1))}`, | |
| 69 | ...(timed === null | |
| 70 | ? [`DTSTART;VALUE=DATE:${compact(d.due)}`, `DTEND;VALUE=DATE:${compact(addDays(d.due, 1))}`] | |
| 71 | : [`DTSTART:${compact(d.due)}T${timed.replace(":", "")}00`, ...endOfHour(d.due, timed)]), | |
| 72 | ...(place === null ? [] : [`LOCATION:${icsText(place)}`]), | |
| 55 | 73 | `SUMMARY:${icsText(`${d.waived_at !== null ? "Waived: " : d.done_at === null ? "" : "Done: "}${d.label} — ${deal.address}`)}`, |
| 56 | 74 | `DESCRIPTION:${icsText(`${who} owes: ${d.what || d.label}`)}`, |
| 57 | 75 | "STATUS:CONFIRMED", |
| @@ -67,7 +85,7 @@ function events(deal: DealView, host: string, now: string, openOnly: boolean): s | ||
| 67 | 85 | "BEGIN:VALARM", |
| 68 | 86 | "ACTION:DISPLAY", |
| 69 | 87 | `DESCRIPTION:${icsText(`${d.label} today`)}`, |
| 70 | "TRIGGER:PT9H", | |
| 88 | `TRIGGER:${timed === null ? "PT9H" : nineAm(timed)}`, | |
| 71 | 89 | "END:VALARM", |
| 72 | 90 | ); |
| 73 | 91 | lines.push("END:VEVENT"); |
src/mcp.ts +19 −2
| @@ -9,7 +9,7 @@ | ||
| 9 | 9 | import type { Database } from "bun:sqlite"; |
| 10 | 10 | import { restoreSamples, type Result } from "./actions.ts"; |
| 11 | 11 | import { today } from "./dates.ts"; |
| 12 | import { ok } from "./result.ts"; | |
| 12 | import { fail, ok } from "./result.ts"; | |
| 13 | 13 | import { DEFAULT_LENGTHS, PARTY_ROLES } from "./deadlines.ts"; |
| 14 | 14 | import { |
| 15 | 15 | addDeadline, |
| @@ -90,7 +90,7 @@ export const tools: readonly Tool[] = [ | ||
| 90 | 90 | const got = getDeal(db, who, { id: Number(args.id) }); |
| 91 | 91 | if (!got.ok) return got; |
| 92 | 92 | const dates = timelineRows(got.value, today()).map(({ label, due, role, name, status }) => ({ label, due, owed_by: { role, name: name ?? null }, status })); |
| 93 | return { ok: true, value: { address: got.value.address, sale_price: got.value.sale_price, earnest_amount: got.value.earnest_amount, agent: agentOf(db), dates } }; | |
| 93 | return { ok: true, value: { address: got.value.address, sale_price: got.value.sale_price, earnest_amount: got.value.earnest_amount, closing_time: got.value.closing_time, closing_place: got.value.closing_place, agent: agentOf(db), dates } }; | |
| 94 | 94 | }, |
| 95 | 95 | }, |
| 96 | 96 | { |
| @@ -417,6 +417,23 @@ export const tools: readonly Tool[] = [ | ||
| 417 | 417 | }, |
| 418 | 418 | run: (db, who, a) => updateDeal(db, who, { id: Number(a.deal_id), salePrice: a.sale_price, earnestAmount: a.earnest_amount }), |
| 419 | 419 | }, |
| 420 | { | |
| 421 | name: "update_closing", | |
| 422 | description: "Set when and where a deal closes: closing_time as HH:MM on a quarter hour from 07:00 to 20:00 (local time) and closing_place of 1 to 200 characters. A field left out stays as it is; null clears it. Drafts, the client timeline and the calendar file say them; reminders already sent keep their words.", | |
| 423 | inputSchema: { | |
| 424 | type: "object", | |
| 425 | properties: { | |
| 426 | deal_id: { type: "integer" }, | |
| 427 | closing_time: { type: ["string", "null"], pattern: "^(0[7-9]|1[0-9]):(00|15|30|45)$|^20:00$" }, | |
| 428 | closing_place: { type: ["string", "null"], minLength: 1, maxLength: 200 }, | |
| 429 | }, | |
| 430 | required: ["deal_id"], | |
| 431 | }, | |
| 432 | run: (db, who, a) => { | |
| 433 | if (a.closing_time === undefined && a.closing_place === undefined) return fail("invalid", "Give a closing_time, a closing_place, or null to clear one."); | |
| 434 | return updateDeal(db, who, { id: Number(a.deal_id), closingTime: a.closing_time, closingPlace: a.closing_place }); | |
| 435 | }, | |
| 436 | }, | |
| 420 | 437 | { |
| 421 | 438 | name: "add_party", |
| 422 | 439 | description: "Add a party (lender, title company, the other agent…) to a deal.", |
src/pages/deal.ts +37
| @@ -10,6 +10,7 @@ import { matchKnown, type Known } from "../people.ts"; | ||
| 10 | 10 | import { agent as defaults, standard } from "../env.ts"; |
| 11 | 11 | import { DEFAULT_LENGTHS, PARTY_LABEL, PARTY_ROLES } from "../deadlines.ts"; |
| 12 | 12 | import { escape } from "../http.ts"; |
| 13 | import { closingLine } from "../closing.ts"; | |
| 13 | 14 | import { dollars } from "../money.ts"; |
| 14 | 15 | import { drafts, sentLabel, statusDrafts, type Agent } from "../reminders.ts"; |
| 15 | 16 | import type { Who } from "../who.ts"; |
| @@ -142,6 +143,37 @@ function figuresLine(deal: DealView): string { | ||
| 142 | 143 | return parts.length === 0 ? "" : `<p class="summary" id="figures">${parts.join(" · ")}</p>`; |
| 143 | 144 | } |
| 144 | 145 | |
| 146 | /** What was typed into the closing form and why it was refused, to show beside the field. */ | |
| 147 | export interface ClosingProblem { | |
| 148 | readonly values: { readonly closing_time: string; readonly closing_place: string }; | |
| 149 | readonly field: string | undefined; | |
| 150 | readonly message: string; | |
| 151 | } | |
| 152 | ||
| 153 | /** The closing line, said in the one way: "Closing Nov 21 · 2:00 pm · Lakeside Title"; nothing for a time and place unset beyond the day the page already says. */ | |
| 154 | function closingWhenLine(deal: DealView): string { | |
| 155 | return deal.closing_time === null && deal.closing_place === null ? "" : `<p class="summary" id="closing-when"><b>${escape(closingLine(deal))}</b></p>`; | |
| 156 | } | |
| 157 | ||
| 158 | function closingForm(deal: DealView, path: string, problem: ClosingProblem | undefined): string { | |
| 159 | const bad = (name: string): string => | |
| 160 | problem?.field === name ? ` aria-invalid="true" aria-describedby="${name}-why"` : ""; | |
| 161 | const why = (name: string): string => | |
| 162 | problem?.field === name ? `<span class="field-error" id="${name}-why" role="alert">${escape(problem.message)}</span>` : ""; | |
| 163 | const time = problem?.values.closing_time ?? deal.closing_time ?? ""; | |
| 164 | const place = problem?.values.closing_place ?? deal.closing_place ?? ""; | |
| 165 | return `<details class="address-edit"${problem === undefined ? "" : " open"}> | |
| 166 | <summary class="button button-quiet button-small">Edit closing time and place</summary> | |
| 167 | <form class="stack" method="post" action="${path}/closing"> | |
| 168 | <div class="pair"> | |
| 169 | <label>Closing time <span class="muted">(optional)</span><input class="input" type="time" name="closing_time" step="900" min="07:00" max="20:00" value="${escape(time)}"${bad("closing_time")}>${why("closing_time")}</label> | |
| 170 | <label>Closing place <span class="muted">(optional)</span><input class="input" name="closing_place" maxlength="200" autocomplete="off" placeholder="Lakeside Title, 400 Main St" value="${escape(place)}"${bad("closing_place")}>${why("closing_place")}</label> | |
| 171 | </div> | |
| 172 | <button class="button">Save</button> | |
| 173 | </form> | |
| 174 | </details>`; | |
| 175 | } | |
| 176 | ||
| 145 | 177 | export function dealPage(input: { |
| 146 | 178 | who: Who; |
| 147 | 179 | /** How many of today's messages wait for approval, for the header. */ |
| @@ -160,6 +192,8 @@ export function dealPage(input: { | ||
| 160 | 192 | amend?: AmendState | undefined; |
| 161 | 193 | /** A sale price or earnest money amount that was refused: what was typed and why. */ |
| 162 | 194 | figures?: FiguresProblem | undefined; |
| 195 | /** A closing time or place that was refused: what was typed and why. */ | |
| 196 | closing?: ClosingProblem | undefined; | |
| 163 | 197 | /** A party added or corrected and refused: what was typed and why, so the form keeps it. */ |
| 164 | 198 | party?: PartyProblem | undefined; |
| 165 | 199 | /** People from other deals the add-party form offers, and the one picked to prefill it. */ |
| @@ -191,6 +225,7 @@ export function dealPage(input: { | ||
| 191 | 225 | </form> |
| 192 | 226 | </details>` |
| 193 | 227 | : ""; |
| 228 | const editClosing = may ? closingForm(deal, path, input.closing) : ""; | |
| 194 | 229 | const editSide = may |
| 195 | 230 | ? `<form class="side-edit" method="post" action="${path}/side"> |
| 196 | 231 | <label for="deal-side">Side</label> ${sideSelect(deal.side, "deal-side")} |
| @@ -279,9 +314,11 @@ export function dealPage(input: { | ||
| 279 | 314 | <p class="summary">${deal.fell_through ? `<b>Fell through on ${escape(spoken(fellOn(deal)))}</b> · ${escape(deal.fell_reason ?? "")}${deal.fell_by ? ` (${escape(deal.fell_by)})` : ""} · ` : ""}${deal.closed ? `<b>Closed on ${escape(spoken(closedOn(deal)))}</b> · ` : ""}Under contract ${escape(spoken(deal.contract_date))} · closes ${escape(spoken(deal.closing))}, ${escape(relative(deal.closing, on))}${deal.business_days ? " · business days" : ""}</p> |
| 280 | 315 | <p class="summary">${sideLabel(deal.side)}</p> |
| 281 | 316 | ${figuresLine(deal)} |
| 317 | ${closingWhenLine(deal)} | |
| 282 | 318 | ${editSide} |
| 283 | 319 | ${editAddress} |
| 284 | 320 | ${editFigures} |
| 321 | ${editClosing} | |
| 285 | 322 | </div> |
| 286 | 323 | <div class="row"><a class="button button-quiet" href="${path}/timeline">Client timeline</a> <a class="button button-quiet" href="${path}/ics" download>Add to calendar</a></div> |
| 287 | 324 | </section> |
src/pages/timeline.ts +2 −1
| @@ -9,6 +9,7 @@ | ||
| 9 | 9 | import type { DealView } from "../deals.ts"; |
| 10 | 10 | import type { Agent } from "../reminders.ts"; |
| 11 | 11 | import { agent as defaults } from "../env.ts"; |
| 12 | import { closingLine } from "../closing.ts"; | |
| 12 | 13 | import { dollars } from "../money.ts"; |
| 13 | 14 | import { asset, escape } from "../http.ts"; |
| 14 | 15 | import { timelineRows } from "../timeline.ts"; |
| @@ -37,7 +38,7 @@ export function timelinePage(input: { who: Who; agent?: Agent | undefined; deal: | ||
| 37 | 38 | const body = `<p class="crumb timeline-tools"><a href="/deals/${deal.id}">← Back to the deal</a> · <button type="button" class="button button-small" data-print hidden>Print</button> <span class="muted">or your browser's print (Ctrl/Cmd+P)</span></p> |
| 38 | 39 | <section class="timeline"> |
| 39 | 40 | <h1>${escape(deal.address)}</h1> |
| 40 | ${figures.length === 0 ? "" : `<p class="summary" id="figures">${escape(figures.join(" · "))}</p>`}<p class="summary">Key dates, prepared by ${escape(agent.name)}, ${escape(agent.brokerage)}</p> | |
| 41 | ${figures.length === 0 ? "" : `<p class="summary" id="figures">${escape(figures.join(" · "))}</p>`}${deal.closing_time === null && deal.closing_place === null ? "" : `<p class="summary" id="closing-when"><b>${escape(closingLine(deal))}</b></p>`}<p class="summary">Key dates, prepared by ${escape(agent.name)}, ${escape(agent.brokerage)}</p> | |
| 41 | 42 | <p class="summary">${contactLinks(agent)}</p> |
| 42 | 43 | <ol class="timeline-list">${rows}</ol> |
| 43 | 44 | </section> |
src/partycontact.test.ts +1 −1
| @@ -15,7 +15,7 @@ const dealHtml = (contact: string) => bare( | ||
| 15 | 15 | dealPage({ |
| 16 | 16 | who, |
| 17 | 17 | on: "2026-10-10", |
| 18 | deal: { id: 1, address: "A", closed: false, contract_date: "2026-10-01", closing: "2026-11-01", business_days: 0, parties: [{ id: 1, deal_id: 1, role: "lender", name: "P", contact, email: "", phone: "" }], deadlines: [], conflicts: [], sent: [] } as unknown as DealView, | |
| 18 | deal: { id: 1, address: "A", closed: false, contract_date: "2026-10-01", closing: "2026-11-01", closing_time: null, closing_place: null, business_days: 0, parties: [{ id: 1, deal_id: 1, role: "lender", name: "P", contact, email: "", phone: "" }], deadlines: [], conflicts: [], sent: [] } as unknown as DealView, | |
| 19 | 19 | })); |
| 20 | 20 | |
| 21 | 21 | for (const [page, render] of [["people", peopleHtml], ["deal", dealHtml]] as const) { |
src/reminders.ts +8 −5
| @@ -9,6 +9,7 @@ | ||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | import { addDays, relative, short, spoken, today, weekday } from "./dates.ts"; |
| 12 | import { closingAfterDate } from "./closing.ts"; | |
| 12 | 13 | import { dollars } from "./money.ts"; |
| 13 | 14 | import { memoizer, print } from "./memo.ts"; |
| 14 | 15 | import { DEFAULT_LEAD, isOpen, KIND, PARTY_LABEL, type PartyRole } from "./deadlines.ts"; |
| @@ -150,7 +151,7 @@ function words( | ||
| 150 | 151 | : `${party.role === "buyer" ? "Your" : "The buyer's"} ${dollars(sum)} earnest money deposit ${late ? "is still outstanding" : `is due ${short(deadline.due)}`}. `; |
| 151 | 152 | if (moment === "moved" && notice !== undefined && notice.items.length > 1) { |
| 152 | 153 | const changes = notice.items |
| 153 | .map(({ deadline: d, move }) => `• ${d.label}: from ${spoken(move.from_due)} to ${spoken(move.to_due)}`) | |
| 154 | .map(({ deadline: d, move }) => `• ${d.label}: from ${spoken(move.from_due)} to ${spoken(move.to_due)}${d.kind === "closing" ? closingAfterDate(deal) : ""}`) | |
| 154 | 155 | .join("\n"); |
| 155 | 156 | return { |
| 156 | 157 | subject: `${deal.address} — dates changed`, |
| @@ -161,7 +162,7 @@ function words( | ||
| 161 | 162 | const move = lastMove(deadline)!; |
| 162 | 163 | return { |
| 163 | 164 | subject: `${deadline.label} — ${deal.address} — date changed`, |
| 164 | body: `Hi ${first(party.name)}, a change of date: the ${deadline.label.toLowerCase()} for ${deal.address} has moved from ${spoken(move.from_due)} to ${spoken(move.to_due)}. ${owed}Please work to the new date, and let me know if it causes a problem.\n\n${signOff(agent)}`, | |
| 165 | body: `Hi ${first(party.name)}, a change of date: the ${deadline.label.toLowerCase()} for ${deal.address} has moved from ${spoken(move.from_due)} to ${spoken(move.to_due)}${deadline.kind === "closing" ? closingAfterDate(deal) : ""}. ${owed}Please work to the new date, and let me know if it causes a problem.\n\n${signOff(agent)}`, | |
| 165 | 166 | }; |
| 166 | 167 | } |
| 167 | 168 | if (moment === "late") { |
| @@ -170,14 +171,16 @@ function words( | ||
| 170 | 171 | body: `Hi ${first(party.name)}, the ${deadline.label.toLowerCase()} for ${deal.address} was due ${spoken(deadline.due)} and has passed without being marked done. ${deposit(true)}${owed}Could you send me an update today on where it stands and when it will be done?\n\n${signOff(agent)}`, |
| 171 | 172 | }; |
| 172 | 173 | } |
| 173 | const when = moment === "before" ? `in ${days(deadline.lead_days)}, on ${spoken(deadline.due)}` : `today, ${spoken(deadline.due)}`; | |
| 174 | const when = `${moment === "before" ? `in ${days(deadline.lead_days)}, on ${spoken(deadline.due)}` : `today, ${spoken(deadline.due)}`}${deadline.kind === "closing" ? closingAfterDate(deal) : ""}`; | |
| 175 | // The walk-through is the day before the keys change hands: it says where and when that is. | |
| 176 | const closes = deadline.kind === "walkthrough" && closingAfterDate(deal) !== "" ? `Closing follows on ${spoken(deal.closing)}${closingAfterDate(deal)}. ` : ""; | |
| 174 | 177 | const yours = party.role === deadline.owes; |
| 175 | 178 | const ask = yours |
| 176 | 179 | ? "This one is yours — please let me know right away if anything could hold it up." |
| 177 | 180 | : `${owner === undefined ? PARTY_LABEL[deadline.owes] : owner.name} (${PARTY_LABEL[deadline.owes].toLowerCase()}) is on it; nothing is needed from you unless you hear otherwise.`; |
| 178 | 181 | return { |
| 179 | 182 | subject: `${deadline.label} — ${deal.address} — ${moment === "before" ? spoken(deadline.due) : "today"}`, |
| 180 | body: `Hi ${first(party.name)}, a reminder that the ${deadline.label.toLowerCase()} for ${deal.address} is ${when}. ${deposit(false)}${owed}${ask}\n\n${signOff(agent)}`, | |
| 183 | body: `Hi ${first(party.name)}, a reminder that the ${deadline.label.toLowerCase()} for ${deal.address} is ${when}. ${deposit(false)}${owed}${closes}${ask}\n\n${signOff(agent)}`, | |
| 181 | 184 | }; |
| 182 | 185 | } |
| 183 | 186 | |
| @@ -276,7 +279,7 @@ function statusWords(deal: DealView, party: Party, agent: Agent): { subject: str | ||
| 276 | 279 | const finished = done.length === 0 ? "Nothing is finished yet." : done.map((d) => `• ${d.label}${d.waived_at === null ? "" : " (waived)"}`).join("\n"); |
| 277 | 280 | return { |
| 278 | 281 | subject: `${deal.address} — where things stand`, |
| 279 | body: `Hi ${first(party.name)}, here is where things stand on ${deal.address}.\n\nDone:\n${finished}\n\nNext:\n${next.length === 0 ? "Nothing else before closing." : next.join("\n")}${more}\n\nClosing is ${spoken(closing.due)} (${relative(closing.due, today())}).\n\nLet me know if you have any questions.\n\n${signOff(agent)}`, | |
| 282 | body: `Hi ${first(party.name)}, here is where things stand on ${deal.address}.\n\nDone:\n${finished}\n\nNext:\n${next.length === 0 ? "Nothing else before closing." : next.join("\n")}${more}\n\nClosing is ${spoken(closing.due)}${closingAfterDate(deal)} (${relative(closing.due, today())}).\n\nLet me know if you have any questions.\n\n${signOff(agent)}`, | |
| 280 | 283 | }; |
| 281 | 284 | } |
| 282 | 285 |
src/routes.ts +24 −4
| @@ -221,6 +221,8 @@ const PROGRESS: Schema = { | ||
| 221 | 221 | }; |
| 222 | 222 | /** A sale price or earnest money amount: whole dollars, or null for none. */ |
| 223 | 223 | const FIGURE: Schema = { type: ["integer", "null"], minimum: 0, maximum: AMOUNT_MAX }; |
| 224 | const CLOSING_TIME: Schema = { type: ["string", "null"], pattern: "^(0[7-9]|1[0-9]):(00|15|30|45)$|^20:00$", description: "When it closes, HH:MM on a quarter hour from 07:00 to 20:00, local time; null while none is set." }; | |
| 225 | const CLOSING_PLACE: Schema = { type: ["string", "null"], minLength: 1, maxLength: 200, description: "Where it closes; null while none is set." }; | |
| 224 | 226 | export const DEAL: Schema = { |
| 225 | 227 | type: "object", |
| 226 | 228 | properties: { |
| @@ -236,6 +238,8 @@ export const DEAL: Schema = { | ||
| 236 | 238 | side: { enum: [...SIDES], description: "Which side the agent represents: buyer, listing or both." }, |
| 237 | 239 | sale_price: { ...FIGURE, description: "The sale price in whole dollars; null while none is set." }, |
| 238 | 240 | earnest_amount: { ...FIGURE, description: "The earnest money amount in whole dollars; null while none is set." }, |
| 241 | closing_time: CLOSING_TIME, | |
| 242 | closing_place: CLOSING_PLACE, | |
| 239 | 243 | business_days: { enum: [0, 1] }, |
| 240 | 244 | author_id: { type: "string" }, |
| 241 | 245 | author_name: { type: "string" }, |
| @@ -654,7 +658,7 @@ export const routes: readonly Route[] = [ | ||
| 654 | 658 | const side = sideFilter(c.url.searchParams.get("side")); |
| 655 | 659 | if (side === undefined) |
| 656 | 660 | return html(refusedPage({ who: c.who, agent: agentFor(c), path: "/", heading: "The clock", error: "invalid", message: SIDE_REFUSAL }), 422, clear); |
| 657 | return html(clock({ who: c.who, waiting: waitingFor(c), agent: agentFor(c), deals: deals.value, on: today(), notice, open, q, side }), 200, clear); | |
| 661 | return html(clock({ who: c.who, waiting: waitingCount(deals.value, today(), agentFor(c)), agent: agentFor(c), deals: deals.value, on: today(), notice, open, q, side }), 200, clear); | |
| 658 | 662 | }, |
| 659 | 663 | }, |
| 660 | 664 | { |
| @@ -996,6 +1000,22 @@ export const routes: readonly Route[] = [ | ||
| 996 | 1000 | return html(dealPage({ who: c.who, waiting: waitingFor(c), agent: agentFor(c), deal: found.value, on: today(), figures: { values, field: saved.field, message: saved.message } }), STATUS.invalid); |
| 997 | 1001 | }, |
| 998 | 1002 | }, |
| 1003 | { | |
| 1004 | method: "POST", | |
| 1005 | path: "/deals/:id/closing", | |
| 1006 | handle: async (c) => { | |
| 1007 | const f = await form(c); | |
| 1008 | if (f instanceof Response) return f; | |
| 1009 | const id = Number(c.params.id); | |
| 1010 | const saved = updateDeal(c.db, c.who, { id, closingTime: f.closing_time ?? "", closingPlace: f.closing_place ?? "" }); | |
| 1011 | if (saved.ok) return back("Closing time and place saved.", `/deals/${id}`); | |
| 1012 | if (saved.error !== "invalid") return back(saved.message, `/deals/${id}`); | |
| 1013 | const found = getDeal(c.db, c.who, { id }); | |
| 1014 | if (!found.ok) return back(found.message, `/deals/${id}`); | |
| 1015 | const values = { closing_time: String(f.closing_time ?? ""), closing_place: String(f.closing_place ?? "") }; | |
| 1016 | return html(dealPage({ who: c.who, waiting: waitingFor(c), agent: agentFor(c), deal: found.value, on: today(), closing: { values, field: saved.field, message: saved.message } }), STATUS.invalid); | |
| 1017 | }, | |
| 1018 | }, | |
| 999 | 1019 | { |
| 1000 | 1020 | method: "POST", |
| 1001 | 1021 | path: "/deals/:id/amend", |
| @@ -1364,11 +1384,11 @@ export const routes: readonly Route[] = [ | ||
| 1364 | 1384 | const body = await readJson(c.request); |
| 1365 | 1385 | if (body === undefined) return json({ error: "too_large" }, 413); |
| 1366 | 1386 | const f = fields(body); |
| 1367 | return answer(updateDeal(c.db, c.who, { id: Number(c.params.id), address: f.address, salePrice: f.sale_price, earnestAmount: f.earnest_amount, side: f.side })); | |
| 1387 | return answer(updateDeal(c.db, c.who, { id: Number(c.params.id), address: f.address, salePrice: f.sale_price, earnestAmount: f.earnest_amount, closingTime: f.closing_time, closingPlace: f.closing_place, side: f.side })); | |
| 1368 | 1388 | }, |
| 1369 | 1389 | api: { |
| 1370 | summary: "Correct a deal's address, sale price, earnest money amount or side (buyer, listing or both); a field left out stays as it is, and a figure sent as null is cleared. Dates move one at a time, with a reason (POST /deadlines/:id/move).", | |
| 1371 | body: { type: "object", properties: { address: { type: "string", minLength: 3, maxLength: 200 }, sale_price: FIGURE, earnest_amount: FIGURE, side: { enum: [...SIDES] } } }, | |
| 1390 | summary: "Correct a deal's address, sale price, earnest money amount, closing time, closing place or side (buyer, listing or both); a field left out stays as it is, and one sent as null is cleared (not the side). Dates move one at a time, with a reason (POST /deadlines/:id/move).", | |
| 1391 | body: { type: "object", properties: { address: { type: "string", minLength: 3, maxLength: 200 }, sale_price: FIGURE, earnest_amount: FIGURE, closing_time: CLOSING_TIME, closing_place: CLOSING_PLACE, side: { enum: [...SIDES] } } }, | |
| 1372 | 1392 | answer: DEAL, |
| 1373 | 1393 | }, |
| 1374 | 1394 | }, |
src/sample.ts +5
| @@ -27,6 +27,8 @@ interface Sample { | ||
| 27 | 27 | /** Which side the agent is on; buyer unless said. */ |
| 28 | 28 | readonly side?: Side; |
| 29 | 29 | readonly lengths?: Partial<typeof BRIEF_LENGTHS>; |
| 30 | /** When and where it closes, for the sample that closes this week. */ | |
| 31 | readonly closingAt?: readonly [string, string]; | |
| 30 | 32 | /** Role, name, email or phone, and a phone besides when the first is an email. */ |
| 31 | 33 | readonly parties: readonly (readonly [PartyRole, string, string] | readonly [PartyRole, string, string, string])[]; |
| 32 | 34 | readonly done?: readonly string[]; |
| @@ -50,6 +52,7 @@ const SAMPLES: readonly Sample[] = [ | ||
| 50 | 52 | price: 425_000, |
| 51 | 53 | earnest: 12_750, |
| 52 | 54 | lengths: { financing: 28 }, |
| 55 | closingAt: ["14:00", "Bayside Title, 400 Main St"], | |
| 53 | 56 | parties: [ |
| 54 | 57 | ["lender", "Priya Nair, Coastline Mortgage", "[email protected]", "(555) 010-0177"], |
| 55 | 58 | ["title", "Marcus Lee, Bayside Title", "[email protected]"], |
| @@ -251,6 +254,8 @@ function writeSamples(db: Database, on: string): void { | ||
| 251 | 254 | earnestAmount: s.earnest, |
| 252 | 255 | side: s.side ?? "buyer", |
| 253 | 256 | }); |
| 257 | if (s.closingAt !== undefined) | |
| 258 | db.query("UPDATE deal SET closing_time = ?1, closing_place = ?2 WHERE id = ?3").run(s.closingAt[0], s.closingAt[1], deal.id); | |
| 254 | 259 | db.query("INSERT INTO sample_deal (deal_id, sample) VALUES (?1, ?2)").run(deal.id, s.address); |
| 255 | 260 | for (const [role, name, first, second] of s.parties) { |
| 256 | 261 | const email = validEmail(first) ? first : ""; |
src/server.test.ts +1
| @@ -198,6 +198,7 @@ test("the MCP server lists the tools and calls them as the caller", async () => | ||
| 198 | 198 | "update_address", |
| 199 | 199 | "set_side", |
| 200 | 200 | "update_figures", |
| 201 | "update_closing", | |
| 201 | 202 | "add_party", |
| 202 | 203 | "edit_party", |
| 203 | 204 | "remove_party", |
src/terminal.test.ts +30
| @@ -775,6 +775,36 @@ test("T sets and clears a date's note, shown beside the date, through setNote", | ||
| 775 | 775 | expect(db.query("SELECT count(*) AS n FROM deadline WHERE note = ?1").get("Title co. confirms Friday")).toEqual({ n: 0 }); |
| 776 | 776 | }); |
| 777 | 777 | |
| 778 | test("C sets the closing time and place of the open deal, a bad time is refused, and the deal view says the closing", () => { | |
| 779 | const own = createDeal(db, alice, { openAnyway: true, address: "4 Pine St", buyer: "Bea Buyer", seller: "Sid Seller", contractDate: today(), closingDate: addDays(today(), 30) }); | |
| 780 | if (!own.ok) throw new Error(own.message); | |
| 781 | const read = () => { | |
| 782 | const got = getDeal(db, alice, { id: own.value.id }); | |
| 783 | if (!got.ok) throw new Error(got.message); | |
| 784 | return [got.value.closing_time, got.value.closing_place]; | |
| 785 | }; | |
| 786 | const t = terminal(db, alice, context); | |
| 787 | goTo(t, "Closing — 4 Pine St"); | |
| 788 | t.press("o"); | |
| 789 | press(t, "C", "2pm\r", "Lakeside Title\r"); | |
| 790 | expect(read()).toEqual([null, null]); | |
| 791 | expect(lines(t).join("\n")).toContain("The closing time is HH:MM"); | |
| 792 | press(t, "C", "14:00\r", "Lakeside Title, 400 Main St\r"); | |
| 793 | expect(read()).toEqual(["14:00", "Lakeside Title, 400 Main St"]); | |
| 794 | const shownLines = lines(t).join("\n"); | |
| 795 | expect(shownLines).toContain("2:00 pm · Lakeside Title, 400 Main St"); | |
| 796 | expect(shownLines).toContain("Closing is now"); | |
| 797 | press(t, "C", "\r", "\r"); | |
| 798 | expect(read()).toEqual([null, null]); | |
| 799 | expect(lines(t).join("\n")).not.toContain("Lakeside Title"); | |
| 800 | }); | |
| 801 | ||
| 802 | test("a signed-out terminal is not asked for a closing time", () => { | |
| 803 | const t = terminal(db, { role: "anon" }, context); | |
| 804 | t.press("C"); | |
| 805 | expect(lines(t).join("\n")).not.toContain("Closing time (HH:MM"); | |
| 806 | }); | |
| 807 | ||
| 778 | 808 | test("n asks which side, defaults to Buyer's agent, and refuses an unknown word", () => { |
| 779 | 809 | const t = terminal(db, alice, context); |
| 780 | 810 | press(t, "n", "51 Side St\r", "Kim Buyer\r", "Lou Seller\r", `${today()}\r`, `${addDays(today(), 40)}\r`, "Listing agent\r"); |
src/terminal.ts +12 −4
| @@ -10,7 +10,7 @@ | ||
| 10 | 10 | * timeline a deal's dates as a client would get them (t on a deal) |
| 11 | 11 | * activity who approved, declined or changed what, newest first (L, admins); m only messages, o older, y newer |
| 12 | 12 | * profile your name, brokerage, phone and email (I); e edits them, U goes back to the defaults |
| 13 | * deal one deal's dates and parties; a adds a date, p a party, A corrects the address, M amends the contract, S drafts a status update for the party under the cursor, D removes it, F marks it fell through (or brings it back), Y changes the side (buyer, listing or both) | |
| 13 | * deal one deal's dates and parties; a adds a date, p a party, A corrects the address, C sets the closing time and place, M amends the contract, S drafts a status update for the party under the cursor, D removes it, F marks it fell through (or brings it back), Y changes the side (buyer, listing or both) | |
| 14 | 14 | * |
| 15 | 15 | * On a date (dates or deal view): x marks it done, W waives it (the buyer gave it up), u reopens it or un-waives it, m moves it |
| 16 | 16 | * (a new date, then the reason), N moves one flagged "not a business day" to the next business day, l sets how many days before it reminds. o or enter opens its deal; n opens a new |
| @@ -20,6 +20,7 @@ | ||
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | 22 | import type { Database } from "bun:sqlite"; |
| 23 | import { closingLine } from "./closing.ts"; | |
| 23 | 24 | import { timelineRows } from "./timeline.ts"; |
| 24 | 25 | import { isDate, relative, spoken, today, urgencyOf, type Urgency } from "./dates.ts"; |
| 25 | 26 | import { |
| @@ -247,7 +248,7 @@ export function terminal( | ||
| 247 | 248 | |
| 248 | 249 | function onDeal(key: string): boolean { |
| 249 | 250 | const deal = openDeal(); |
| 250 | if (deal === undefined || !["a", "p", "D", "e", "X", "A", "M", "S", "F", "Y"].includes(key)) return false; | |
| 251 | if (deal === undefined || !["a", "p", "D", "e", "X", "A", "C", "M", "S", "F", "Y"].includes(key)) return false; | |
| 251 | 252 | const party = deal.parties[cursor - deal.deadlines.length]; |
| 252 | 253 | const date = deal.deadlines[cursor]; |
| 253 | 254 | if (key === "S") { |
| @@ -287,6 +288,13 @@ export function terminal( | ||
| 287 | 288 | ask(deal, [`Address (now ${deal.address})`], ([address]) => |
| 288 | 289 | report(updateDeal(db, me, { id: deal.id, address }), `Address is now ${address!.trim()}.`), |
| 289 | 290 | ); |
| 291 | if (key === "C") | |
| 292 | ask(deal, [`Closing time (HH:MM, now ${deal.closing_time ?? "none"}; blank clears)`, `Closing place (now ${deal.closing_place ?? "none"}; blank clears)`], ([closingTime, closingPlace]) => | |
| 293 | report(updateDeal(db, me, { id: deal.id, closingTime, closingPlace }), () => { | |
| 294 | const got = getDeal(db, me, { id: deal.id }); | |
| 295 | return `Closing is now ${got.ok && (got.value.closing_time !== null || got.value.closing_place !== null) ? closingLine(got.value) : "the day only"}.`; | |
| 296 | }), | |
| 297 | ); | |
| 290 | 298 | if (key === "M") { |
| 291 | 299 | const open = deal.deadlines.filter(isOpen); |
| 292 | 300 | ask(deal, [...open.map((d) => `${d.label} (now ${d.due}; blank keeps it)`), "Why the dates moved"], (answers) => { |
| @@ -797,7 +805,7 @@ export function terminal( | ||
| 797 | 805 | const deal = openDeal(); |
| 798 | 806 | if (deal === undefined) lines.push(dim("That deal is gone.")); |
| 799 | 807 | else { |
| 800 | lines.push(bold(deal.address), ...(deal.fell_through ? [bold(`Fell through on ${spoken(fellOn(deal))}: ${deal.fell_reason ?? ""}`)] : []), ...(deal.closed ? [bold(`Closed on ${spoken(closedOn(deal))}`)] : []), dim(`${SIDE_LABEL[deal.side]} · under contract ${spoken(deal.contract_date)} · closes ${spoken(deal.closing)}, ${relative(deal.closing, day)}`), ""); | |
| 808 | lines.push(bold(deal.address), ...(deal.fell_through ? [bold(`Fell through on ${spoken(fellOn(deal))}: ${deal.fell_reason ?? ""}`)] : []), ...(deal.closed ? [bold(`Closed on ${spoken(closedOn(deal))}`)] : []), dim(`${SIDE_LABEL[deal.side]} · under contract ${spoken(deal.contract_date)} · closes ${spoken(deal.closing)}, ${relative(deal.closing, day)}`), ...(deal.closing_time === null && deal.closing_place === null ? [] : [dim(closingLine(deal))]), ""); | |
| 801 | 809 | deal.deadlines.forEach((date, i) => lines.push(dateLine({ deal, date }, i, false))); |
| 802 | 810 | if (deal.conflicts.length > 0) lines.push("", ...deal.conflicts.map((c) => tint("overdue", `! ${conflictLine(c)}`))); |
| 803 | 811 | lines.push("", bold("Parties")); |
| @@ -843,7 +851,7 @@ export function terminal( | ||
| 843 | 851 | : view === "timeline" |
| 844 | 852 | ? "b back to the deal · d dates · q quit" |
| 845 | 853 | : view === "deal" |
| 846 | ? "j/k move · t client timeline · s messages · x done · W waive · u reopen/un-waive · m move · N next business day · l remind lead · T note · a add date · p add party · e edit party · A edit address · M amend the contract · S status update to the party · X remove date/party · D remove deal · b back · q quit" | |
| 854 | ? "j/k move · t client timeline · s messages · x done · W waive · u reopen/un-waive · m move · N next business day · l remind lead · T note · a add date · p add party · e edit party · A edit address · C closing time and place · M amend the contract · S status update to the party · X remove date/party · D remove deal · b back · q quit" | |
| 847 | 855 | : `j/k move · x done · W waive · u reopen · m move · N next business day · l lead · T note · o open deal · n new deal · c check dates · / find · R restore samples · h ${showDone ? "hide" : "show"} done · w this week · r reminders · P people · I profile · L activity · q quit`; |
| 848 | 856 | lines.push(dim(me.role === "anon" ? `${keys} · sign in with a key the forge knows to change anything` : keys)); |
| 849 | 857 | } |
new above
offline