Public: anyone can read this; the crew can change it.
The README's "What is real, and what is not yet" names what the app does today, so a realtor reading it before the meeting is not surprised #208
mason/deal-clock:mason/191-the-readme-s-what-is-real-and-what-is-no → main 5 commits fork
19 files
changed +395
−27
README.md +25 −3
| @@ -104,7 +104,7 @@ you already have), fix a typo with Edit, add a date the contract added (an HOA | ||
| 104 | 104 | review), waive a contingency the buyer gave up, change who owes a date, correct |
| 105 | 105 | the address, and set the closing time and place. If two of your open deals close the same day less than two hours apart, |
| 106 | 106 | an amber "Also closing at 2:30 pm" line names the other deal on This week, on |
| 107 | both deals' pages and in the terminal's deal view. An Inspection or Final | |
| 107 | both deals' pages and in the terminal's deal view; an inspection, walkthrough or closing less than two hours from another of your timed appointments that day gets an "Also at 10:00 am: Inspection, 12 Elm St" line the same way. An Inspection or Final | |
| 108 | 108 | walkthrough row has **Set time and place** too (a time on a quarter hour and |
| 109 | 109 | one line for where, either optional; clear both to remove them): the buyer |
| 110 | 110 | sees them beside the date on the client timeline, your calendar file gives |
| @@ -143,7 +143,9 @@ An admin sees **Activity** in the header: the newest hundred things anyone | ||
| 143 | 143 | tried to change, one plain line each (who, what, on which deal, when, and why |
| 144 | 144 | it was refused if it was). **Messages** narrows it to sends, declines and |
| 145 | 145 | undos, so the sales meeting can show that every message that went out was |
| 146 | approved by a named person at a stated time. Anyone else is told no. | |
| 146 | approved by a named person at a stated time. **Download spreadsheet** on that | |
| 147 | page saves the same lines (or just the messages) as a file that opens in Excel | |
| 148 | or Numbers. Anyone else is told no. | |
| 147 | 149 | |
| 148 | 150 | ## Spreadsheets and calendar |
| 149 | 151 | |
| @@ -187,7 +189,27 @@ return as they were, dated from today, and the deals you opened are left alone. | ||
| 187 | 189 | - **Real:** the dates and their math, mark done, moves with their reasons, |
| 188 | 190 | who owes what, the reminder drafts and editing them, the record of what was |
| 189 | 191 | sent, the reasons for messages you chose not to send, the calendar file, and |
| 190 | adding parties, dates and deals. | |
| 192 | adding parties, dates and deals (see [opening and shaping a | |
| 193 | deal](#opening-and-shaping-a-deal)). | |
| 194 | - **Real:** you can download all your deals as one file and bring them back | |
| 195 | later, on this app or another account; the record of messages is saved but not | |
| 196 | brought back ([](#make-it-yours)). | |
| 197 | - **Real:** an inspection, final walkthrough or closing can carry a time and a | |
| 198 | place, which show on the client timeline, in your calendar file and in the | |
| 199 | reminder ([](#opening-and-shaping-a-deal)). | |
| 200 | - **Real:** two closings, or an inspection or walkthrough and another of your | |
| 201 | timed appointments, on the same day less than two hours apart are flagged | |
| 202 | on both deals' pages ([opening and shaping a | |
| 203 | deal](#opening-and-shaping-a-deal)). | |
| 204 | - **Real:** a month after closing a "How is the new home?" note, and a year | |
| 205 | after a "Happy home anniversary" note, are drafted and wait for your approval | |
| 206 | ([](#opening-and-shaping-a-deal)). | |
| 207 | - **Real:** an admin can read the Activity record of who tried to change what, | |
| 208 | and download it as a spreadsheet ([](#activity)). | |
| 209 | - **Real:** price, earnest money and commission rate on a deal, the commission | |
| 210 | pending and earned this year under the clock, and a broker file to print | |
| 211 | ([](#commission-and-your-year)); spreadsheets of your | |
| 212 | deals ([](#spreadsheets-and-calendar)). | |
| 191 | 213 | - **Real:** the clock, a deal page and the client timeline answer in under 50 |
| 192 | 214 | ms with 200 deals. |
| 193 | 215 | - **Real:** every page is checked for keyboard and screen-reader use. |
contract/openapi.json +64
| @@ -1211,6 +1211,38 @@ | ||
| 1211 | 1211 | "format": "date" |
| 1212 | 1212 | } |
| 1213 | 1213 | } |
| 1214 | }, | |
| 1215 | "clashes": { | |
| 1216 | "type": "array", | |
| 1217 | "description": "Other timed open inspections, walkthroughs or closings of this agent the same day, less than two hours from this timed date. Empty when none.", | |
| 1218 | "items": { | |
| 1219 | "type": "object", | |
| 1220 | "properties": { | |
| 1221 | "dealId": { | |
| 1222 | "type": "integer" | |
| 1223 | }, | |
| 1224 | "address": { | |
| 1225 | "type": "string" | |
| 1226 | }, | |
| 1227 | "label": { | |
| 1228 | "type": "string" | |
| 1229 | }, | |
| 1230 | "time": { | |
| 1231 | "type": [ | |
| 1232 | "string", | |
| 1233 | "null" | |
| 1234 | ], | |
| 1235 | "pattern": "^(0[7-9]|1[0-9]):(00|15|30|45)$|^20:00$", | |
| 1236 | "description": "When it closes, HH:MM on a quarter hour from 07:00 to 20:00, local time; null while none is set." | |
| 1237 | } | |
| 1238 | }, | |
| 1239 | "required": [ | |
| 1240 | "dealId", | |
| 1241 | "address", | |
| 1242 | "label", | |
| 1243 | "time" | |
| 1244 | ] | |
| 1245 | } | |
| 1214 | 1246 | } |
| 1215 | 1247 | } |
| 1216 | 1248 | } |
| @@ -3422,6 +3454,38 @@ | ||
| 3422 | 3454 | "format": "date" |
| 3423 | 3455 | } |
| 3424 | 3456 | } |
| 3457 | }, | |
| 3458 | "clashes": { | |
| 3459 | "type": "array", | |
| 3460 | "description": "Other timed open inspections, walkthroughs or closings of this agent the same day, less than two hours from this timed date. Empty when none.", | |
| 3461 | "items": { | |
| 3462 | "type": "object", | |
| 3463 | "properties": { | |
| 3464 | "dealId": { | |
| 3465 | "type": "integer" | |
| 3466 | }, | |
| 3467 | "address": { | |
| 3468 | "type": "string" | |
| 3469 | }, | |
| 3470 | "label": { | |
| 3471 | "type": "string" | |
| 3472 | }, | |
| 3473 | "time": { | |
| 3474 | "type": [ | |
| 3475 | "string", | |
| 3476 | "null" | |
| 3477 | ], | |
| 3478 | "pattern": "^(0[7-9]|1[0-9]):(00|15|30|45)$|^20:00$", | |
| 3479 | "description": "When it closes, HH:MM on a quarter hour from 07:00 to 20:00, local time; null while none is set." | |
| 3480 | } | |
| 3481 | }, | |
| 3482 | "required": [ | |
| 3483 | "dealId", | |
| 3484 | "address", | |
| 3485 | "label", | |
| 3486 | "time" | |
| 3487 | ] | |
| 3488 | } | |
| 3425 | 3489 | } |
| 3426 | 3490 | } |
| 3427 | 3491 | } |
docs/TECHNICAL.md +2
| @@ -365,6 +365,8 @@ The forge sets `PORT`, `FORGE_APP_DATA`, `FORGE_APP_ENV` (`production` or | ||
| 365 | 365 | |
| 366 | 366 | `closingConflicts` on a deal (`GET /api/deals/:id` and the list) lists the agent's other open deals closing the same day, both with a time set, less than two hours apart: `{dealId, address, closing_time}`. `src/overlap.ts` computes it in memory over the deals already loaded; it is empty for a closed or fallen-through deal, a deal with no time, and deals of another agent. |
| 367 | 367 | |
| 368 | Each date in a deal's `deadlines` carries `clashes`: the agent's other open, timed inspections, walkthroughs and closings the same day, less than two hours from this date's own time (`{dealId, address, label, time}`, label being Inspection, Walkthrough or Closing). Only pairs with at least one inspection or walkthrough appear here; two closings stay in `closingConflicts`. `appointmentClashes` in `src/overlap.ts` computes it over the deals already loaded. | |
| 369 | ||
| 368 | 370 | `deal.closing_time` (`HH:MM`, a quarter hour, 07:00 to 20:00) and `deal.closing_place` (1 to 200 |
| 369 | 371 | characters) are nullable columns, read and written as `closing_time` and `closing_place` by |
| 370 | 372 | `GET`/`PATCH /api/deals/:id`, the `update_closing` tool and `POST /deals/:id/closing`; `src/closing.ts` |
src/clash.test.ts added +102
| @@ -0,0 +1,102 @@ | ||
| 1 | /** An inspection or walkthrough less than two hours from another timed appointment or closing of the agent's: flagged, escaped, linked. */ | |
| 2 | import { 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 { openDb } from "./db.ts"; | |
| 7 | import { createDeal, getDeal, listDeals, markDone, setAppointment } from "./deals.ts"; | |
| 8 | import { appointmentClashes } from "./overlap.ts"; | |
| 9 | import { dealPage } from "./pages/deal.ts"; | |
| 10 | import { weekCard } from "./pages/clock.ts"; | |
| 11 | import { weekPage } from "./pages/week.ts"; | |
| 12 | import type { Who } from "./who.ts"; | |
| 13 | ||
| 14 | type D = { id: number; kind: string; label: string; due: string; time: string | null; done_at: string | null; waived_at: string | null }; | |
| 15 | const date = (id: number, kind: string, time: string | null, over: Partial<D> = {}): D => ({ id, kind, label: "Inspection period ends", due: "2026-11-20", time, done_at: null, waived_at: null, ...over }); | |
| 16 | const deal = (id: number, deadlines: D[], over: Record<string, unknown> = {}) => ({ | |
| 17 | id, address: `${id} Way`, author_id: "u1", closing: "2026-11-30", closing_time: null, closed: false, fell_through: false, deadlines, ...over, | |
| 18 | }); | |
| 19 | const ids = (m: Map<number, { dealId: number }[]>, k: number) => m.get(k)?.map((c) => c.dealId); | |
| 20 | ||
| 21 | test("inspection vs inspection: 90 minutes flagged, two hours not", () => { | |
| 22 | const got = appointmentClashes([deal(1, [date(11, "inspection", "10:00")]), deal(2, [date(21, "inspection", "11:30")])]); | |
| 23 | expect(ids(got, 11)).toEqual([2]); | |
| 24 | expect(ids(got, 21)).toEqual([1]); | |
| 25 | expect(appointmentClashes([deal(1, [date(11, "inspection", "10:00")]), deal(2, [date(21, "inspection", "12:00")])]).size).toBe(0); | |
| 26 | }); | |
| 27 | ||
| 28 | test("an inspection against a closing the same day is flagged both ways; two closings are left to closingConflicts", () => { | |
| 29 | const closing = date(31, "closing", null, { label: "Closing", due: "2026-11-20" }); | |
| 30 | const got = appointmentClashes([deal(1, [date(11, "walkthrough", "09:00")]), deal(3, [closing], { closing: "2026-11-20", closing_time: "10:00" })]); | |
| 31 | expect(ids(got, 11)).toEqual([3]); | |
| 32 | expect(got.get(11)?.[0]).toMatchObject({ label: "Closing", time: "10:00" }); | |
| 33 | expect(ids(got, 31)).toEqual([1]); | |
| 34 | const two = appointmentClashes([deal(3, [closing], { closing: "2026-11-20", closing_time: "10:00" }), deal(4, [{ ...closing, id: 41 }], { closing: "2026-11-20", closing_time: "10:30" })]); | |
| 35 | expect(two.size).toBe(0); | |
| 36 | }); | |
| 37 | ||
| 38 | test("done, waived, untimed, other-day, closed, fallen and another agent's dates are not compared", () => { | |
| 39 | const base = deal(1, [date(11, "inspection", "10:00")]); | |
| 40 | const against = (d: D, over: Record<string, unknown> = {}) => appointmentClashes([base, deal(2, [d], over)]).size; | |
| 41 | expect(against(date(21, "inspection", "10:30"))).toBe(2); | |
| 42 | expect(against(date(21, "inspection", "10:30", { done_at: "2026-11-20T10:00:00Z" }))).toBe(0); | |
| 43 | expect(against(date(21, "inspection", "10:30", { waived_at: "2026-11-19T10:00:00Z" }))).toBe(0); | |
| 44 | expect(against(date(21, "inspection", null))).toBe(0); | |
| 45 | expect(against(date(21, "inspection", "10:30", { due: "2026-11-21" }))).toBe(0); | |
| 46 | expect(against(date(21, "inspection", "10:30"), { closed: true })).toBe(0); | |
| 47 | expect(against(date(21, "inspection", "10:30"), { fell_through: true })).toBe(0); | |
| 48 | expect(against(date(21, "inspection", "10:30"), { author_id: "u2" })).toBe(0); | |
| 49 | }); | |
| 50 | ||
| 51 | const db = openDb(mkdtempSync(join(tmpdir(), "app-clash-"))); | |
| 52 | const alice: Who = { role: "user", id: "u1", name: "alice" }; | |
| 53 | const bob: Who = { role: "user", id: "u2", name: "bob" }; | |
| 54 | const agent = { name: "Dana", brokerage: "Harbor", phone: "555", email: "[email protected]" }; | |
| 55 | const open = (who: Who, address: string) => { | |
| 56 | const made = createDeal(db, who, { address, buyer: "Ann Buyer", seller: "Sam Seller", contractDate: "2026-10-01", closingDate: "2026-11-30", openAnyway: true }); | |
| 57 | if (!made.ok) throw new Error(made.message); | |
| 58 | return made.value; | |
| 59 | }; | |
| 60 | const all = (who: Who) => { const l = listDeals(db, who); if (!l.ok) throw new Error(l.message); return l.value; }; | |
| 61 | const inspection = (d: { deadlines: readonly { id: number; kind: string }[] }) => d.deadlines.find((x) => x.kind === "inspection")!; | |
| 62 | ||
| 63 | test("the week, the deal page and the read show the clash, escaped and linked, and another agent's never", () => { | |
| 64 | const a = open(alice, "1 <script>x</script> Way"); | |
| 65 | const b = open(alice, "2 Quiet Way"); | |
| 66 | const c = open(bob, "3 Bob Way"); | |
| 67 | const set = (who: Who, deal: { id: number; deadlines: readonly { id: number; kind: string }[] }, time: string) => { | |
| 68 | const r = setAppointment(db, who, { id: inspection(deal).id, time, place: "" }); | |
| 69 | if (!r.ok) throw new Error(r.message); | |
| 70 | }; | |
| 71 | const dueA = all(alice).find((d) => d.id === a.id)!.deadlines.find((d) => d.kind === "inspection")!.due; | |
| 72 | // Align the two inspections on one day, as the standard schedule may differ. | |
| 73 | for (const d of [b, c]) { | |
| 74 | const x = all(d === c ? bob : alice).find((v) => v.id === d.id)!; | |
| 75 | db.query("UPDATE deadline SET due = ?1 WHERE id = ?2").run(dueA, inspection(x).id); | |
| 76 | } | |
| 77 | set(alice, a, "10:00"); | |
| 78 | set(alice, b, "11:30"); | |
| 79 | set(bob, c, "10:30"); | |
| 80 | ||
| 81 | const mine = all(alice); | |
| 82 | const first = mine.find((d) => d.id === a.id)!; | |
| 83 | expect(inspection(first)).toMatchObject({ clashes: [{ dealId: b.id, address: "2 Quiet Way", label: "Inspection", time: "11:30" }] }); | |
| 84 | expect(inspection(mine.find((d) => d.id === c.id)!)).toMatchObject({ clashes: [] }); | |
| 85 | ||
| 86 | const sheet = weekPage({ who: alice, agent, deals: mine, on: dueA }); | |
| 87 | expect(sheet).toContain(`Also at 11:30 am: Inspection, <a href="/deals/${b.id}">2 Quiet Way</a>`); | |
| 88 | expect(weekCard(mine, dueA)).toContain("Also at 10:00 am: Inspection, 1 <script>x</script> Way"); | |
| 89 | expect(weekCard(mine, dueA)).not.toContain("<script>x"); | |
| 90 | ||
| 91 | const got = getDeal(db, alice, { id: b.id }); | |
| 92 | if (!got.ok) throw new Error(got.message); | |
| 93 | const page = dealPage({ who: alice, deal: got.value, agent, on: dueA }); | |
| 94 | expect(page).toContain(`Also at 10:00 am: Inspection, <a href="/deals/${a.id}">1 <script>x</script> Way</a>`); | |
| 95 | expect(page).not.toContain("<script>x"); | |
| 96 | ||
| 97 | // Done or waived clears it. | |
| 98 | const done = markDone(db, alice, { id: inspection(first).id, done: true }); | |
| 99 | expect(done.ok).toBe(true); | |
| 100 | const after = getDeal(db, alice, { id: b.id }); | |
| 101 | expect(after.ok && inspection(after.value)).toMatchObject({ clashes: [] }); | |
| 102 | }); |
src/deals.ts +18 −6
| @@ -40,7 +40,7 @@ import { outboxes } from "./outbox.ts"; | ||
| 40 | 40 | import { conflictLine, conflicts, type Conflict } from "./order.ts"; |
| 41 | 41 | import { SEND_SPAN, draftOfMoment, statusDrafts, type Agent, type Draft } from "./reminders.ts"; |
| 42 | 42 | import { audited, conflict, fail, ok, refuse, type Result } from "./result.ts"; |
| 43 | import { closingConflicts, type ClosingConflict } from "./overlap.ts"; | |
| 43 | import { appointmentClashes, closingConflicts, type Clash, type ClosingConflict } from "./overlap.ts"; | |
| 44 | 44 | import type { Who } from "./who.ts"; |
| 45 | 45 | |
| 46 | 46 | export interface Deal { |
| @@ -188,6 +188,8 @@ export interface DeadlineView extends Omit<Deadline, "owes_from" | "owes_by" | " | ||
| 188 | 188 | readonly moves: readonly Move[]; |
| 189 | 189 | /** An open date due on a weekend or US federal holiday: the business day it rolls to. Null otherwise. */ |
| 190 | 190 | readonly nonBusinessDay: { readonly next: string } | null; |
| 191 | /** Other timed appointments or closings of this agent the same day, less than two hours from this timed one; empty when none. */ | |
| 192 | readonly clashes: readonly Clash[]; | |
| 191 | 193 | } |
| 192 | 194 | /** The day the Closing date was marked done, by the app's own calendar (the one `today()` keeps). */ |
| 193 | 195 | export const closedOn = (deal: { zone: string; deadlines: readonly { kind: Kind; done_at: string | null }[]; closing: string }): string => { |
| @@ -308,6 +310,7 @@ function assemble(deal: Deal, rows: Children, zone: string): DealView { | ||
| 308 | 310 | owes_changed: owes_from === null || owes_by === null || owes_on === null ? null : { from: owes_from, by: owes_by, on: owes_on }, |
| 309 | 311 | moves: moves.filter((m) => m.deadline_id === d.id), |
| 310 | 312 | nonBusinessDay: isOpen(d) && !isBusinessDay(d.due) ? { next: nextBusinessDay(d.due) } : null, |
| 313 | clashes: [], | |
| 311 | 314 | })), |
| 312 | 315 | sent: rows.sent.map((m) => withHref(m, rows.parties, zone)), |
| 313 | 316 | declined: rows.declined, |
| @@ -319,9 +322,19 @@ function assemble(deal: Deal, rows: Children, zone: string): DealView { | ||
| 319 | 322 | |
| 320 | 323 | /** The deal with the closings of its agent's other deals it overlaps; one read, and only for a timed, open closing. */ |
| 321 | 324 | function withClosingConflicts(db: Database, deal: DealView): DealView { |
| 322 | if (deal.closing_time === null || deal.closed || deal.fell_through) return deal; | |
| 325 | if (deal.closed || deal.fell_through) return deal; | |
| 326 | if (deal.closing_time === null && !deal.deadlines.some((d) => d.time !== null)) return deal; | |
| 323 | 327 | const peers = viewMany(db, " WHERE author_id = ?1", [deal.author_id]); |
| 324 | return { ...deal, closingConflicts: closingConflicts(peers).get(deal.id) ?? [] }; | |
| 328 | return withClashes([deal], closingConflicts(peers), appointmentClashes(peers))[0]!; | |
| 329 | } | |
| 330 | ||
| 331 | /** The deals with the closing conflicts and the appointment clashes read off the loaded set. */ | |
| 332 | function withClashes(deals: readonly DealView[], closings: Map<number, ClosingConflict[]>, clashes: Map<number, Clash[]>): DealView[] { | |
| 333 | return deals.map((d) => ({ | |
| 334 | ...d, | |
| 335 | closingConflicts: closings.get(d.id) ?? [], | |
| 336 | deadlines: d.deadlines.map((x) => (clashes.has(x.id) ? { ...x, clashes: clashes.get(x.id)! } : x)), | |
| 337 | })); | |
| 325 | 338 | } |
| 326 | 339 | |
| 327 | 340 | function view(db: Database, deal: Deal): DealView { |
| @@ -447,10 +460,9 @@ export function listDeals(db: Database, who: Who): Result<DealView[]> { | ||
| 447 | 460 | ` WHERE ${may.where.map((c) => `${c} = ?1`).join(" OR ")}`, |
| 448 | 461 | [who.role === "anon" ? "" : who.id], |
| 449 | 462 | ); |
| 450 | const clashes = closingConflicts(deals); | |
| 451 | 463 | return ok( |
| 452 | deals | |
| 453 | .map((d) => shown(who, { ...d, closingConflicts: clashes.get(d.id) ?? [] })) | |
| 464 | withClashes(deals, closingConflicts(deals), appointmentClashes(deals)) | |
| 465 | .map((d) => shown(who, d)) | |
| 454 | 466 | .sort((a, b) => a.closing.localeCompare(b.closing) || a.id - b.id), |
| 455 | 467 | ); |
| 456 | 468 | } |
src/order.page.test.ts +3
| @@ -29,6 +29,9 @@ test("on a fresh boot only 9 Orchard Row is flagged, for its listing expiring be | ||
| 29 | 29 | expect(deal.conflicts.map((c) => c.label)).toEqual(deal.address === "9 Orchard Row" ? ["Listing agreement expires"] : []); |
| 30 | 30 | const page = await (await fetch(`${base}/`, { headers: alice })).text(); |
| 31 | 31 | expect(page).toContain("1 out of order"); |
| 32 | const label = page.match(/aria-label="(Listing agreement expires[^"]*)"/)![1]!; | |
| 33 | expect(label).toContain("closing falls after the listing agreement expires"); | |
| 34 | expect(label).not.toContain("falls on or after closing"); | |
| 32 | 35 | }); |
| 33 | 36 | |
| 34 | 37 | test("moving Alder Lane's financing past closing succeeds and shows the flag everywhere", async () => { |
src/order.test.ts +11 −1
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { expect, test } from "bun:test"; |
| 2 | import { conflictLine, conflicts } from "./order.ts"; | |
| 2 | import { conflictLine, conflictShort, conflicts } from "./order.ts"; | |
| 3 | import { LISTING_EXPIRES } from "./deadlines.ts"; | |
| 3 | 4 | |
| 4 | 5 | const d = (id: number, kind: string, due: string, done_at: string | null = null) => ({ |
| 5 | 6 | id, |
| @@ -33,3 +34,12 @@ test("the line says it in words", () => { | ||
| 33 | 34 | expect(conflictLine(c)).toBe("Financing (Nov 24) now falls after closing (Nov 20): move one or the other."); |
| 34 | 35 | expect(conflictLine({ ...c, due: "2026-11-20" })).toContain("now falls on closing"); |
| 35 | 36 | }); |
| 37 | ||
| 38 | test("the marker's short words: the listing's own, or on or after closing", () => { | |
| 39 | const listing = { deadline_id: 1, label: LISTING_EXPIRES, due: "2026-11-30", closing: "2026-12-03" }; | |
| 40 | expect(conflictShort(listing)).toBe("closing falls after the listing agreement expires"); | |
| 41 | expect(conflictShort({ ...listing, due: "2026-12-03" })).toBe("closing falls on the day the listing agreement expires"); | |
| 42 | const late = { deadline_id: 2, label: "Financing", due: "2026-11-24", closing: "2026-11-20" }; | |
| 43 | expect(conflictShort(late)).toBe("falls on or after closing"); | |
| 44 | expect(conflictShort({ ...late, due: "2026-11-20" })).toBe("falls on or after closing"); | |
| 45 | }); |
src/order.ts +4
| @@ -41,3 +41,7 @@ export const conflictLine = (c: Conflict): string => | ||
| 41 | 41 | c.label === LISTING_EXPIRES |
| 42 | 42 | ? `Closing (${short(c.closing)}) falls ${c.due === c.closing ? "on the day" : "after"} the listing agreement expires (${short(c.due)}): extend the listing or move closing.` |
| 43 | 43 | : `${c.label} (${short(c.due)}) now falls ${c.due === c.closing ? "on" : "after"} closing (${short(c.closing)}): move one or the other.`; |
| 44 | ||
| 45 | /** The conflict in a few words, for a marker's spoken label: "closing falls after the listing agreement expires"; otherwise "falls on or after closing". */ | |
| 46 | export const conflictShort = (c: Conflict): string => | |
| 47 | c.label === LISTING_EXPIRES ? `closing falls ${c.due === c.closing ? "on the day" : "after"} the listing agreement expires` : "falls on or after closing"; |
src/overlap.ts +88
| @@ -6,7 +6,9 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | import { clock12 } from "./closing.ts"; |
| 9 | import { isOpen } from "./deadlines.ts"; | |
| 9 | 10 | import { escape } from "./http.ts"; |
| 11 | import { isAppointment } from "./appointment.ts"; | |
| 10 | 12 | |
| 11 | 13 | /** Two closings closer than this many minutes cannot both be kept. */ |
| 12 | 14 | export const APART = 120; |
| @@ -62,3 +64,89 @@ export function clashLine(conflicts: readonly ClosingConflict[], tag: "p" | "sma | ||
| 62 | 64 | const links = conflicts.map((c) => (linked ? `<a href="/deals/${c.dealId}">${escape(c.address)}</a>` : escape(c.address))).join(", "); |
| 63 | 65 | return `<${tag} class="closing-clash">Also closing at ${escape(clock12(first.closing_time))}: ${links}</${tag}>`; |
| 64 | 66 | } |
| 67 | ||
| 68 | /** Another timed date of the same agent (label is the kind: Inspection, Walkthrough or Closing), the same day, less than `APART` minutes from this one. */ | |
| 69 | export interface Clash { | |
| 70 | readonly dealId: number; | |
| 71 | readonly address: string; | |
| 72 | readonly label: string; | |
| 73 | readonly time: string; | |
| 74 | } | |
| 75 | ||
| 76 | interface Booked { | |
| 77 | readonly id: number; | |
| 78 | readonly address: string; | |
| 79 | readonly author_id: string; | |
| 80 | readonly closing: string; | |
| 81 | readonly closing_time: string | null; | |
| 82 | readonly closed: boolean; | |
| 83 | readonly fell_through: boolean; | |
| 84 | readonly deadlines: readonly { | |
| 85 | readonly id: number; | |
| 86 | readonly kind: string; | |
| 87 | readonly label: string; | |
| 88 | readonly due: string; | |
| 89 | readonly time: string | null; | |
| 90 | readonly done_at: string | null; | |
| 91 | readonly waived_at: string | null; | |
| 92 | }[]; | |
| 93 | } | |
| 94 | ||
| 95 | interface Slot { | |
| 96 | readonly deadlineId: number; | |
| 97 | readonly dealId: number; | |
| 98 | readonly address: string; | |
| 99 | readonly label: string; | |
| 100 | readonly kind: string; | |
| 101 | readonly day: string; | |
| 102 | readonly time: string; | |
| 103 | readonly author: string; | |
| 104 | } | |
| 105 | ||
| 106 | /** | |
| 107 | * For each deadline id that has one, the other timed appointments or closings of the | |
| 108 | * same agent the same day, less than `APART` minutes away. Only pairs with at least | |
| 109 | * one inspection or walkthrough: two closings are `closingConflicts`. Done, waived, | |
| 110 | * untimed dates and closed or fallen-through deals are never compared. | |
| 111 | */ | |
| 112 | export function appointmentClashes(deals: readonly Booked[]): Map<number, Clash[]> { | |
| 113 | const byDay = new Map<string, Slot[]>(); | |
| 114 | for (const deal of deals) { | |
| 115 | if (deal.closed || deal.fell_through) continue; | |
| 116 | for (const d of deal.deadlines) { | |
| 117 | const closing = d.kind === "closing"; | |
| 118 | const time = closing ? deal.closing_time : d.time; | |
| 119 | if (time === null || !(closing || isAppointment(d.kind)) || !isOpen(d)) continue; | |
| 120 | const day = closing ? deal.closing : d.due; | |
| 121 | const key = `${deal.author_id}|${day}`; | |
| 122 | const slot: Slot = { deadlineId: d.id, dealId: deal.id, address: deal.address, label: d.kind[0]!.toUpperCase() + d.kind.slice(1), kind: d.kind, day, time, author: deal.author_id }; | |
| 123 | byDay.set(key, [...(byDay.get(key) ?? []), slot]); | |
| 124 | } | |
| 125 | } | |
| 126 | const out = new Map<number, Clash[]>(); | |
| 127 | for (const slots of byDay.values()) { | |
| 128 | for (const a of slots) { | |
| 129 | const near = slots | |
| 130 | .filter((b) => b.deadlineId !== a.deadlineId && (a.kind !== "closing" || b.kind !== "closing") && Math.abs(minutes(b.time) - minutes(a.time)) < APART) | |
| 131 | .sort((x, y) => x.time.localeCompare(y.time) || x.deadlineId - y.deadlineId) | |
| 132 | .map((b) => ({ dealId: b.dealId, address: b.address, label: b.label, time: b.time })); | |
| 133 | if (near.length > 0) out.set(a.deadlineId, near); | |
| 134 | } | |
| 135 | } | |
| 136 | return out; | |
| 137 | } | |
| 138 | ||
| 139 | /** "Also at 10:00 am: Inspection, 12 Elm St" as plain text, for the terminal; "" for none. */ | |
| 140 | export function clashesText(clashes: readonly Clash[]): string { | |
| 141 | return clashes.map((c, i) => `${i === 0 ? "Also" : "also"} at ${clock12(c.time)}: ${c.label}, ${c.address}`).join("; "); | |
| 142 | } | |
| 143 | ||
| 144 | /** "Also at 10:00 am: Inspection, 12 Elm St", each address linked to its deal; "" for none. */ | |
| 145 | export function clashesLine(clashes: readonly Clash[], tag: "p" | "small" = "p", linked = true): string { | |
| 146 | if (clashes.length === 0) return ""; | |
| 147 | const items = clashes.map((c, i) => { | |
| 148 | const where = linked ? `<a href="/deals/${c.dealId}">${escape(c.address)}</a>` : escape(c.address); | |
| 149 | return `${i === 0 ? "Also" : "also"} at ${escape(clock12(c.time))}: ${escape(c.label)}, ${where}`; | |
| 150 | }); | |
| 151 | return `<${tag} class="closing-clash">${items.join("; ")}</${tag}>`; | |
| 152 | } |
src/pages/appointment.ts +2 −1
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | * that says them and the small form that sets them. Escaped here, once. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | import { clashesLine } from "../overlap.ts"; | |
| 6 | 7 | import { appointmentLine, isAppointment } from "../appointment.ts"; |
| 7 | 8 | import type { DeadlineView } from "../deals.ts"; |
| 8 | 9 | import { escape } from "../http.ts"; |
| @@ -17,7 +18,7 @@ export interface AppointmentProblem { | ||
| 17 | 18 | |
| 18 | 19 | /** "10:00 am · 12 Elm St" under the date; nothing when unset or when the date is no appointment. */ |
| 19 | 20 | export const appointmentText = (d: DeadlineView): string => |
| 20 | appointmentLine(d) === "" ? "" : `<p class="small appointment"><b>${escape(appointmentLine(d))}</b></p>`; | |
| 21 | (appointmentLine(d) === "" ? "" : `<p class="small appointment"><b>${escape(appointmentLine(d))}</b></p>`) + clashesLine(d.clashes); | |
| 21 | 22 | |
| 22 | 23 | /** "Set time and place" for an inspection or a walkthrough; the form stays open, with the agent's text, when it was refused. */ |
| 23 | 24 | export function appointmentForm(d: DeadlineView, to: string, problem: AppointmentProblem | undefined): string { |
src/pages/clock.ts +6 −5
| @@ -12,8 +12,9 @@ import { escape } from "../http.ts"; | ||
| 12 | 12 | import { agent as defaults } from "../env.ts"; |
| 13 | 13 | import { todaysDrafts, unsent, type Agent } from "../reminders.ts"; |
| 14 | 14 | import type { Who } from "../who.ts"; |
| 15 | import { clashLine } from "../overlap.ts"; | |
| 16 | import { byDay, closingNote, thisWeek } from "../week.ts"; | |
| 15 | import { conflictShort } from "../order.ts"; | |
| 16 | import { clashLine, clashesLine } from "../overlap.ts"; | |
| 17 | import { byDay, thisWeek, whereNote } from "../week.ts"; | |
| 17 | 18 | import { layout } from "./layout.ts"; |
| 18 | 19 | import { mayRestore } from "../actions.ts"; |
| 19 | 20 | import { badge, draftLink, opens, owedBy, URGENCY_LABEL } from "./sheet.ts"; |
| @@ -66,8 +67,8 @@ function drawLane(deal: DealView, start: string, on: string): string { | ||
| 66 | 67 | const d = deal.deadlines[i]!; |
| 67 | 68 | const u = urgencyOf(d, on); |
| 68 | 69 | const tag = d.kind === "custom" ? d.label.split(" ")[0]! : KIND[d.kind].tag; |
| 69 | const flagged = deal.conflicts.some((c) => c.deadline_id === d.id); | |
| 70 | return `<a class="marker" data-u="${u}"${flagged ? " data-conflict" : ""} ${opens(deal, d)} style="left:${at(x)};top:calc(${row} * 3rem)" aria-label="${escape(`${d.label}, ${spoken(d.due)} — ${URGENCY_LABEL[u]}${flagged ? " — falls on or after closing" : ""}`)}"><span class="dot"></span>${escape(tag)}</a>`; | |
| 70 | const flagged = deal.conflicts.find((c) => c.deadline_id === d.id); | |
| 71 | return `<a class="marker" data-u="${u}"${flagged !== undefined ? " data-conflict" : ""} ${opens(deal, d)} style="left:${at(x)};top:calc(${row} * 3rem)" aria-label="${escape(`${d.label}, ${spoken(d.due)} — ${URGENCY_LABEL[u]}${flagged ? ` — ${conflictShort(flagged)}` : ""}`)}"><span class="dot"></span>${escape(tag)}</a>`; | |
| 71 | 72 | }) |
| 72 | 73 | .join(""); |
| 73 | 74 | return `<li class="lane"> |
| @@ -111,7 +112,7 @@ export function weekCard(deals: readonly DealView[], on: string, q = "", side: S | ||
| 111 | 112 | (g) => `<h3 class="week-day">${escape(g.heading)}</h3> |
| 112 | 113 | <ul class="week-list">${g.items |
| 113 | 114 | .map(({ deal, deadline: d }) => |
| 114 | weekRows(`${on}|${print(deal)}|${d.id}`, () => `<li><a class="week-row" ${opens(deal, d)}><span class="week-what"><b>${escape(d.label)}${closingNote(deal, d) === "" ? "" : ` · ${escape(closingNote(deal, d))}`}</b><small class="muted">${escape(deal.address)} · ${sideLabel(deal.side)} · ${owedBy(deal, d)}</small>${d.kind === "closing" ? clashLine(deal.closingConflicts, "small", false) : ""}${d.nonBusinessDay === null ? "" : `<small class="muted">Not a business day · next is ${escape(spoken(d.nonBusinessDay.next))}</small>`}${d.note === "" ? "" : `<small class="muted">${escape(d.note)}</small>`}</span>${badge(d, on)}</a></li>`), | |
| 115 | weekRows(`${on}|${print(deal)}|${d.id}`, () => `<li><a class="week-row" ${opens(deal, d)}><span class="week-what"><b>${escape(d.label)}${whereNote(deal, d) === "" ? "" : ` · ${escape(whereNote(deal, d))}`}</b><small class="muted">${escape(deal.address)} · ${sideLabel(deal.side)} · ${owedBy(deal, d)}</small>${d.kind === "closing" ? clashLine(deal.closingConflicts, "small", false) : ""}${clashesLine(d.clashes, "small", false)}${d.nonBusinessDay === null ? "" : `<small class="muted">Not a business day · next is ${escape(spoken(d.nonBusinessDay.next))}</small>`}${d.note === "" ? "" : `<small class="muted">${escape(d.note)}</small>`}</span>${badge(d, on)}</a></li>`), | |
| 115 | 116 | ) |
| 116 | 117 | .join("")}</ul>`, |
| 117 | 118 | ) |
src/pages/deal.ts +2 −2
| @@ -11,7 +11,7 @@ import { agent as defaults, standard } from "../env.ts"; | ||
| 11 | 11 | import { CONTACT_ROLES, DEFAULT_LENGTHS, PARTY_LABEL, PARTY_ROLES, suggestedFor } from "../deadlines.ts"; |
| 12 | 12 | import { escape } from "../http.ts"; |
| 13 | 13 | import { coming, comingLine, type Coming } from "../coming.ts"; |
| 14 | import { clashLine } from "../overlap.ts"; | |
| 14 | import { clashLine, clashesLine } from "../overlap.ts"; | |
| 15 | 15 | import { closingLine } from "../closing.ts"; |
| 16 | 16 | import { commission, dollars, percent } from "../money.ts"; |
| 17 | 17 | import { anniversaryDrafts, checkinDrafts, drafts, pending, sentLabel, statusDrafts, type Agent } from "../reminders.ts"; |
| @@ -206,7 +206,7 @@ export interface ClosingProblem { | ||
| 206 | 206 | |
| 207 | 207 | /** 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. */ |
| 208 | 208 | function closingWhenLine(deal: DealView): string { |
| 209 | return (deal.closing_time === null && deal.closing_place === null ? "" : `<p class="summary" id="closing-when"><b>${escape(closingLine(deal))}</b></p>`) + clashLine(deal.closingConflicts); | |
| 209 | return (deal.closing_time === null && deal.closing_place === null ? "" : `<p class="summary" id="closing-when"><b>${escape(closingLine(deal))}</b></p>`) + clashLine(deal.closingConflicts) + clashesLine(deal.deadlines.find((d) => d.kind === "closing")?.clashes ?? []); | |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | function closingForm(deal: DealView, path: string, problem: ClosingProblem | undefined): string { |
src/pages/week.ts +4 −6
| @@ -12,16 +12,14 @@ import { agent as defaults } from "../env.ts"; | ||
| 12 | 12 | import { asset, escape } from "../http.ts"; |
| 13 | 13 | import { STATUS } from "../timeline.ts"; |
| 14 | 14 | import type { Who } from "../who.ts"; |
| 15 | import { appointmentNote, byDay, closingNote, owner, thisWeek } from "../week.ts"; | |
| 16 | import { clashLine } from "../overlap.ts"; | |
| 15 | import { byDay, owner, whereNote, thisWeek } from "../week.ts"; | |
| 16 | import { clashLine, clashesLine } from "../overlap.ts"; | |
| 17 | 17 | import { layout } from "./layout.ts"; |
| 18 | 18 | import { sideLabel } from "./side.ts"; |
| 19 | 19 | import type { SideFilter } from "../side.ts"; |
| 20 | 20 | |
| 21 | 21 | const closingAt = (deal: DealView, d: DealView["deadlines"][number]): string => { |
| 22 | const where = closingNote(deal, d); | |
| 23 | const appt = appointmentNote(d); | |
| 24 | const text = where === "" ? appt : where; | |
| 22 | const text = whereNote(deal, d); | |
| 25 | 23 | return text === "" ? "" : ` · ${escape(text)}`; |
| 26 | 24 | }; |
| 27 | 25 | |
| @@ -47,7 +45,7 @@ export function weekPage(input: { who: Who; agent?: Agent | undefined; deals: re | ||
| 47 | 45 | <p class="timeline-date">${escape(deal.address)} · ${sideLabel(deal.side)}</p> |
| 48 | 46 | <p class="timeline-label"><b>${escape(d.label)}${closingAt(deal, d)}</b></p> |
| 49 | 47 | <p class="timeline-owner">${escape(role)}${name === undefined ? "" : ` · ${escape(name)}`}</p> |
| 50 | ${d.kind === "closing" ? clashLine(deal.closingConflicts) : ""} | |
| 48 | ${d.kind === "closing" ? clashLine(deal.closingConflicts) : ""}${clashesLine(d.clashes)} | |
| 51 | 49 | ${d.note === "" ? "" : `<p class="timeline-owner">${escape(d.note)}</p>`} |
| 52 | 50 | <p class="timeline-status"><span aria-hidden="true">${s.mark}</span> ${s.word}</p> |
| 53 | 51 | </li>`; |
src/readme.test.ts added +22
| @@ -0,0 +1,22 @@ | ||
| 1 | import { expect, test } from "bun:test"; | |
| 2 | import { readFileSync } from "node:fs"; | |
| 3 | ||
| 4 | const readme = readFileSync(new URL("../README.md", import.meta.url), "utf8"); | |
| 5 | ||
| 6 | /** The anchor GitHub gives a heading: lower case, punctuation dropped, spaces to hyphens. */ | |
| 7 | const slug = (h: string) => h.toLowerCase().replace(/[^\w\s-]/g, "").trim().replace(/\s/g, "-"); | |
| 8 | ||
| 9 | test("every in-page link in the README lands on a heading in it", () => { | |
| 10 | const anchors = new Set([...readme.matchAll(/^#{1,6}\s+(.+)$/gm)].map((m) => slug(m[1]!))); | |
| 11 | const links = [...readme.replace(/\s+/g, " ").matchAll(/\]\(#([^)\s]*)\)/g)].map((m) => m[1]!); | |
| 12 | expect(links.length).toBeGreaterThan(0); | |
| 13 | for (const l of links) expect(anchors.has(l), `#${l}`).toBe(true); | |
| 14 | }); | |
| 15 | ||
| 16 | test("the honest-limits section still says nothing is sent and links each feature", () => { | |
| 17 | const section = readme.slice(readme.indexOf("## What is real"), readme.indexOf("## Signing in")).replace(/\s+/g, " "); | |
| 18 | expect(section).toContain("no email or text message leaves the app"); | |
| 19 | for (const word of ["bring them back", "time and a place", "two hours apart", "anniversary", "Activity", "commission"]) { | |
| 20 | expect(section).toContain(word); | |
| 21 | } | |
| 22 | }); |
src/routes.ts +9
| @@ -345,6 +345,15 @@ export const DEAL: Schema = { | ||
| 345 | 345 | description: "An open date due on a weekend or US federal holiday: next is the business day it rolls to. Null otherwise.", |
| 346 | 346 | properties: { next: DATE }, |
| 347 | 347 | }, |
| 348 | clashes: { | |
| 349 | type: "array", | |
| 350 | description: "Other timed open inspections, walkthroughs or closings of this agent the same day, less than two hours from this timed date. Empty when none.", | |
| 351 | items: { | |
| 352 | type: "object", | |
| 353 | properties: { dealId: { type: "integer" }, address: { type: "string" }, label: { type: "string" }, time: CLOSING_TIME }, | |
| 354 | required: ["dealId", "address", "label", "time"], | |
| 355 | }, | |
| 356 | }, | |
| 348 | 357 | }, |
| 349 | 358 | }, |
| 350 | 359 | }, |
src/terminal.test.ts +23 −1
| @@ -7,7 +7,7 @@ import { mkdtempSync } from "node:fs"; | ||
| 7 | 7 | import { tmpdir } from "node:os"; |
| 8 | 8 | import { join } from "node:path"; |
| 9 | 9 | import { addDays, spoken, today, DEFAULT_ZONE } from "./dates.ts"; |
| 10 | import { canChange, shown, addDeadline, addParty, createDeal, editParty, getDeal, listDeals, markDone, moveDeadline, sendReminder, updateDeal, type DealView } from "./deals.ts"; | |
| 10 | import { canChange, setAppointment, shown, addDeadline, addParty, createDeal, editParty, getDeal, listDeals, markDone, moveDeadline, sendReminder, updateDeal, type DealView } from "./deals.ts"; | |
| 11 | 11 | import { openDb } from "./db.ts"; |
| 12 | 12 | import { terminal, type Terminal } from "./terminal.ts"; |
| 13 | 13 | import type { Who } from "./who.ts"; |
| @@ -951,3 +951,25 @@ test("the deal view says which other closing the same day is less than two hours | ||
| 951 | 951 | t.press("o"); |
| 952 | 952 | expect(lines(t).join("\n")).not.toContain("Also closing at"); |
| 953 | 953 | }); |
| 954 | ||
| 955 | test("the deal view and the week say which other appointment the same day is less than two hours away", () => { | |
| 956 | const make = (address: string, time: string) => { | |
| 957 | const made = createDeal(db, alice, { openAnyway: true, address, buyer: "Bea Buyer", seller: "Sid Seller", contractDate: today(DEFAULT_ZONE), closingDate: addDays(today(DEFAULT_ZONE), 60) }); | |
| 958 | if (!made.ok) throw new Error(made.message); | |
| 959 | const view = getDeal(db, alice, { id: made.value.id }); | |
| 960 | if (!view.ok) throw new Error(view.message); | |
| 961 | const inspection = view.value.deadlines.find((d) => d.kind === "inspection")!; | |
| 962 | db.query("UPDATE deadline SET due = ?1 WHERE id = ?2").run(addDays(today(DEFAULT_ZONE), 2), inspection.id); | |
| 963 | const set = setAppointment(db, alice, { id: inspection.id, time, place: "" }); | |
| 964 | if (!set.ok) throw new Error(set.message); | |
| 965 | }; | |
| 966 | make("7 Twin Ln", "10:00"); | |
| 967 | make("8 Twin Ln", "11:30"); | |
| 968 | const t = terminal(db, alice, context); | |
| 969 | goTo(t, "Inspection period ends — 7 Twin Ln"); | |
| 970 | t.press("o"); | |
| 971 | expect(lines(t).join("\n")).toContain("Also at 11:30 am: Inspection, 8 Twin Ln"); | |
| 972 | t.press("o"); | |
| 973 | t.press("w"); | |
| 974 | expect(lines(t).join("\n")).toContain("Also at 10:00 am: Inspection, 7 Twin Ln"); | |
| 975 | }); |
src/terminal.ts +3 −2
| @@ -87,7 +87,7 @@ import { people } from "./people.ts"; | ||
| 87 | 87 | import { reachedAt } from "./outbox.ts"; |
| 88 | 88 | import { addresses, refusal, when, wording } from "./activity.ts"; |
| 89 | 89 | import { listAudit } from "./actions.ts"; |
| 90 | import { clashText } from "./overlap.ts"; | |
| 90 | import { clashText, clashesText } from "./overlap.ts"; | |
| 91 | 91 | import { owner, thisWeek } from "./week.ts"; |
| 92 | 92 | import { SIDE_CHOICE, SIDE_LABEL, SIDE_REFUSAL, sideTyped } from "./side.ts"; |
| 93 | 93 | |
| @@ -763,7 +763,8 @@ export function terminal( | ||
| 763 | 763 | const lead = isOpen(date) ? dim(` reminds ${date.lead_days}d before`) : ""; |
| 764 | 764 | const note = date.note === "" ? "" : dim(` note: ${date.note}`); |
| 765 | 765 | const where = appointmentLine(date) === "" ? "" : dim(` ${appointmentLine(date)}`); |
| 766 | return `${i === cursor ? "▸" : " "} ${when} ${i === cursor ? bold(text) : text}${where}${flag}${lead}${moved}${note}`; | |
| 766 | const clash = date.clashes.length === 0 ? "" : tint("overdue", ` ${clashesText(date.clashes)}`); | |
| 767 | return `${i === cursor ? "▸" : " "} ${when} ${i === cursor ? bold(text) : text}${where}${clash}${flag}${lead}${moved}${note}`; | |
| 767 | 768 | }; |
| 768 | 769 | |
| 769 | 770 | function screen(): string[] { |
src/upgrade.test.ts +1
| @@ -110,6 +110,7 @@ async function boots(list: string[], n: number, name: string) { | ||
| 110 | 110 | } |
| 111 | 111 | expect(shape(check), `schema at version ${n} differs from a fresh database`).toEqual(wanted); |
| 112 | 112 | check.close(); |
| 113 | expect((await get("/healthz")).status, `/healthz at version ${n}`).toBe(200); | |
| 113 | 114 | const pages = ["/", "/people"]; |
| 114 | 115 | if (hadDeal) pages.push("/deals/1", "/deals/1/timeline"); |
| 115 | 116 | for (const path of pages) { |
src/week.ts +6
| @@ -39,6 +39,12 @@ export function closingNote(deal: WeekDeal<unknown>, d: { kind?: string }): stri | ||
| 39 | 39 | return d.kind === "closing" ? closingWhere({ closing_time: deal.closing_time ?? null, closing_place: deal.closing_place ?? null }) : ""; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | /** The time and place after a row's label: the closing's, or an inspection's or walkthrough's; "" when there is none. */ | |
| 43 | export function whereNote(deal: WeekDeal<unknown>, d: { kind: string; time?: string | null; place?: string | null }): string { | |
| 44 | const where = closingNote(deal, d); | |
| 45 | return where === "" ? appointmentNote(d) : where; | |
| 46 | } | |
| 47 | ||
| 42 | 48 | export function thisWeek<D extends { due: string; done_at: string | null; waived_at: string | null }, Deal extends WeekDeal<D>>( |
| 43 | 49 | deals: readonly Deal[], |
| 44 | 50 | on: string, |
new above
offline