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

Two closings set less than two hours apart on the same day are flagged on This week and on both deals' pages, so the agent never books themselves into two title offices at once #187

Merged opened this

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

Merged

mason/deal-clock:mason/183-two-closings-set-less-than-two-hours-apa → main 3 commits fork

  • Merged. mason/183-two-closings-set-less-than-two-hours-apa was merged into main as 5f71285.

Review

Sign in to review this change.
15 files changed +271 −8
README.md +3 −1
@@ -95,7 +95,9 @@ no lender is asked for anything; "Cash" shows beside the side. On a deal's page
9595 you can add a party (**Use someone from your other deals** fills in a person
9696 you already have), fix a typo with Edit, add a date the contract added (an HOA
9797 review), waive a contingency the buyer gave up, change who owes a date, correct
98 the address, and set the closing time and place. An Inspection or Final
98 the address, and set the closing time and place. If two of your open deals close the same day less than two hours apart,
99 an amber "Also closing at 2:30 pm" line names the other deal on This week, on
100 both deals' pages and in the terminal's deal view. An Inspection or Final
99101 walkthrough row has **Set time and place** too (a time on a quarter hour and
100102 one line for where, either optional; clear both to remove them): the buyer
101103 sees them beside the date on the client timeline, your calendar file gives
contract/openapi.json +56
@@ -1227,6 +1227,34 @@
12271227 ]
12281228 }
12291229 },
1230 "closingConflicts": {
1231 "type": "array",
1232 "description": "Other open deals of this agent closing the same day, both with a time set, less than two hours apart. Empty when none.",
1233 "items": {
1234 "type": "object",
1235 "properties": {
1236 "dealId": {
1237 "type": "integer"
1238 },
1239 "address": {
1240 "type": "string"
1241 },
1242 "closing_time": {
1243 "type": [
1244 "string",
1245 "null"
1246 ],
1247 "pattern": "^(0[7-9]|1[0-9]):(00|15|30|45)$|^20:00$",
1248 "description": "When it closes, HH:MM on a quarter hour from 07:00 to 20:00, local time; null while none is set."
1249 }
1250 },
1251 "required": [
1252 "dealId",
1253 "address",
1254 "closing_time"
1255 ]
1256 }
1257 },
12301258 "declined": {
12311259 "type": "array",
12321260 "items": {
@@ -3391,6 +3419,34 @@
33913419 ]
33923420 }
33933421 },
3422 "closingConflicts": {
3423 "type": "array",
3424 "description": "Other open deals of this agent closing the same day, both with a time set, less than two hours apart. Empty when none.",
3425 "items": {
3426 "type": "object",
3427 "properties": {
3428 "dealId": {
3429 "type": "integer"
3430 },
3431 "address": {
3432 "type": "string"
3433 },
3434 "closing_time": {
3435 "type": [
3436 "string",
3437 "null"
3438 ],
3439 "pattern": "^(0[7-9]|1[0-9]):(00|15|30|45)$|^20:00$",
3440 "description": "When it closes, HH:MM on a quarter hour from 07:00 to 20:00, local time; null while none is set."
3441 }
3442 },
3443 "required": [
3444 "dealId",
3445 "address",
3446 "closing_time"
3447 ]
3448 }
3449 },
33943450 "declined": {
33953451 "type": "array",
33963452 "items": {
docs/TECHNICAL.md +2
@@ -357,6 +357,8 @@ The forge sets `PORT`, `FORGE_APP_DATA`, `FORGE_APP_ENV` (`production` or
357357
358358 `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.
359359
360 `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.
361
360362 `deal.closing_time` (`HH:MM`, a quarter hour, 07:00 to 20:00) and `deal.closing_place` (1 to 200
361363 characters) are nullable columns, read and written as `closing_time` and `closing_place` by
362364 `GET`/`PATCH /api/deals/:id`, the `update_closing` tool and `POST /deals/:id/closing`; `src/closing.ts`
docs/design/areas/clock.md +2
@@ -5,3 +5,5 @@ New classes:
55 - `.progress-text` — the "4 of 7 dates done · 1 overdue · closes …" words under a deal's name, on its lane and on its page.
66 - `.progress-bar` — a thin decorative bar (`aria-hidden`) of fixed height under that text, filled to the share of dates done; the text carries the meaning.
77 - `.progress` — the paragraph that holds both at the top of a deal's page.
8
9 - `.closing-clash` — one amber line (`--color-soon`) under a closing on This week, the print sheet and the deal page: "Also closing at 2:30 pm: 2210 Juniper Court", the address linked to its deal.
src/deals.ts +15 −3
@@ -37,6 +37,7 @@ import { outboxes } from "./outbox.ts";
3737 import { conflictLine, conflicts, type Conflict } from "./order.ts";
3838 import { SEND_SPAN, draftOfMoment, statusDrafts, type Agent, type Draft } from "./reminders.ts";
3939 import { audited, conflict, fail, ok, refuse, type Result } from "./result.ts";
40 import { closingConflicts, type ClosingConflict } from "./overlap.ts";
4041 import type { Who } from "./who.ts";
4142
4243 export interface Deal {
@@ -208,6 +209,8 @@ export interface DealView extends Deal {
208209 readonly held: readonly Held[];
209210 /** Open dates due on or after the open closing date (`order.ts`). */
210211 readonly conflicts: readonly Conflict[];
212 /** Other open deals of this agent closing the same day less than two hours from this one (`overlap.ts`). */
213 readonly closingConflicts: readonly ClosingConflict[];
211214 }
212215
213216 export type Moment = "before" | "day_of" | "late" | "moved" | "status" | "checkin" | "anniversary";
@@ -307,9 +310,17 @@ function assemble(deal: Deal, rows: Children, zone: string): DealView {
307310 declined: rows.declined,
308311 held: rows.held,
309312 conflicts: conflicts(rows.deadlines),
313 closingConflicts: [],
310314 };
311315 }
312316
317 /** The deal with the closings of its agent's other deals it overlaps; one read, and only for a timed, open closing. */
318 function withClosingConflicts(db: Database, deal: DealView): DealView {
319 if (deal.closing_time === null || deal.closed || deal.fell_through) return deal;
320 const peers = viewMany(db, " WHERE author_id = ?1", [deal.author_id]);
321 return { ...deal, closingConflicts: closingConflicts(peers).get(deal.id) ?? [] };
322 }
323
313324 function view(db: Database, deal: Deal): DealView {
314325 return assemble(deal, {
315326 deadlines: db
@@ -433,9 +444,10 @@ export function listDeals(db: Database, who: Who): Result<DealView[]> {
433444 ` WHERE ${may.where.map((c) => `${c} = ?1`).join(" OR ")}`,
434445 [who.role === "anon" ? "" : who.id],
435446 );
447 const clashes = closingConflicts(deals);
436448 return ok(
437449 deals
438 .map((d) => shown(who, d))
450 .map((d) => shown(who, { ...d, closingConflicts: clashes.get(d.id) ?? [] }))
439451 .sort((a, b) => a.closing.localeCompare(b.closing) || a.id - b.id),
440452 );
441453 }
@@ -492,7 +504,7 @@ export function getDeal(
492504 input: { id: number },
493505 ): Result<DealView> {
494506 const found = dealFor(db, who, "read", input.id);
495 return found.ok ? ok(shown(who, view(db, found.value))) : found;
507 return found.ok ? ok(shown(who, withClosingConflicts(db, view(db, found.value)))) : found;
496508 }
497509
498510 /** Whether `who` may change `deal`: the table's answer, for a page to draw its controls from. */
@@ -727,7 +739,7 @@ function update(db: Database, who: Who, input: DealEdit): Result<DealView> {
727739 address, price.value, earnest.value, time.value, place.value, side, commissionRate.value, found.value.id,
728740 );
729741 emit("deal.changed", { id: found.value.id });
730 return ok(view(db, { ...found.value, address, sale_price: price.value, earnest_amount: earnest.value, commission_rate: commissionRate.value, closing_time: time.value, closing_place: place.value, side }));
742 return ok(withClosingConflicts(db, view(db, { ...found.value, address, sale_price: price.value, earnest_amount: earnest.value, commission_rate: commissionRate.value, closing_time: time.value, closing_place: place.value, side })));
731743 }
732744
733745 /** What the audit trail calls a deal falling through, and its reopening. */
src/overlap.test.ts added +78
@@ -0,0 +1,78 @@
1 /** Closings less than two hours apart on one day: the pure rule, then the clock, the print sheet, the deal page and the API. */
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, updateDeal } from "./deals.ts";
8 import { closingConflicts } 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 const deal = (id: number, time: string | null, over: Record<string, unknown> = {}) => ({
15 id, address: `${id} Way`, author_id: "u1", closing: "2026-11-30", closing_time: time, closed: false, fell_through: false, ...over,
16 });
17
18 test("same day, under two hours apart is flagged; two hours is not", () => {
19 const got = closingConflicts([deal(1, "14:00"), deal(2, "14:30"), deal(3, "16:00"), deal(4, "12:15")]);
20 expect(got.get(1)?.map((c) => c.dealId)).toEqual([4, 2]);
21 expect(got.get(2)?.map((c) => c.dealId)).toEqual([1, 3]);
22 expect(got.has(4)).toBe(true);
23 expect(got.get(3)?.map((c) => c.dealId)).toEqual([2]); // 16:00 is exactly 2h from 14:00, so only 14:30 counts
24 expect(closingConflicts([deal(1, "14:00"), deal(3, "16:00")]).size).toBe(0);
25 expect(closingConflicts([deal(1, "14:00"), deal(3, "15:45")]).size).toBe(2);
26 });
27
28 test("different days, missing times, closed, fallen and another agent's deals are not compared", () => {
29 expect(closingConflicts([deal(1, "14:00"), deal(2, "14:30", { closing: "2026-12-01" })]).size).toBe(0);
30 expect(closingConflicts([deal(1, "14:00"), deal(2, null)]).size).toBe(0);
31 expect(closingConflicts([deal(1, "14:00"), deal(2, "14:30", { closed: true })]).size).toBe(0);
32 expect(closingConflicts([deal(1, "14:00"), deal(2, "14:30", { fell_through: true })]).size).toBe(0);
33 expect(closingConflicts([deal(1, "14:00"), deal(2, "14:30", { author_id: "u2" })]).size).toBe(0);
34 });
35
36 const db = openDb(mkdtempSync(join(tmpdir(), "app-overlap-")));
37 const alice: Who = { role: "user", id: "u1", name: "alice" };
38 const open = (address: string) => {
39 const made = createDeal(db, alice, { address, buyer: "Ann Buyer", seller: "Sam Seller", contractDate: "2026-10-01", closingDate: "2026-11-30", openAnyway: true });
40 if (!made.ok) throw new Error(made.message);
41 return made.value;
42 };
43 const time = (id: number, closingTime: string) => {
44 const r = updateDeal(db, alice, { id, closingTime });
45 if (!r.ok) throw new Error(r.message);
46 return r.value;
47 };
48
49 test("the pages, the list and the deal read show the line, escaped, and clear it when times move or a deal closes", () => {
50 const a = open("1 <b>Bold</b> Way");
51 const b = open("2 Quiet Way");
52 time(a.id, "14:00");
53 time(b.id, "14:30");
54 const agent = { name: "Dana", brokerage: "Harbor", phone: "555", email: "[email protected]" };
55 const deals = () => { const l = listDeals(db, alice); if (!l.ok) throw new Error(l.message); return l.value; };
56 const flagged = deals().find((d) => d.id === a.id)!;
57 expect(flagged.closingConflicts).toEqual([{ dealId: b.id, address: "2 Quiet Way", closing_time: "14:30" }]);
58
59 const sheet = weekPage({ who: alice, agent, deals: deals().filter((d) => d.id === b.id || d.id === a.id), on: "2026-11-28" });
60 expect(sheet).toContain(`Also closing at 2:00 pm: <a href="/deals/${a.id}">1 &lt;b&gt;Bold&lt;/b&gt; Way</a>`);
61 expect(sheet).not.toContain("<b>Bold</b>");
62 expect(weekCard(deals(), "2026-11-28")).toContain("Also closing at 2:30 pm: 2 Quiet Way");
63
64 const got = getDeal(db, alice, { id: b.id });
65 if (!got.ok) throw new Error(got.message);
66 expect(got.value.closingConflicts[0]?.dealId).toBe(a.id);
67 const page = dealPage({ who: alice, deal: got.value, agent, on: "2026-11-28" } as never);
68 expect(page).toContain("Also closing at 2:00 pm: <a");
69 expect(page).toContain("1 &lt;b&gt;Bold&lt;/b&gt; Way");
70
71 time(a.id, "16:30");
72 expect(deals().every((d) => d.closingConflicts.length === 0)).toBe(true);
73 time(a.id, "14:00");
74 const closing = deals().find((d) => d.id === a.id)!.deadlines.find((d) => d.kind === "closing")!;
75 markDone(db, alice, { id: closing.id, done: true });
76 const after = getDeal(db, alice, { id: b.id });
77 expect(after.ok && after.value.closingConflicts).toEqual([]);
78 });
src/overlap.ts added +64
@@ -0,0 +1,64 @@
1 /**
2 * Closings the agent cannot both attend: two open deals of one agent that close
3 * the same day, both with a time set, less than two hours apart. Pure, over the
4 * deals already loaded; a deal with no time, a closed or fallen-through deal and
5 * another agent's deal are never compared.
6 */
7
8 import { clock12 } from "./closing.ts";
9 import { escape } from "./http.ts";
10
11 /** Two closings closer than this many minutes cannot both be kept. */
12 export const APART = 120;
13
14 export interface ClosingConflict {
15 readonly dealId: number;
16 readonly address: string;
17 readonly closing_time: string;
18 }
19
20 interface Timed {
21 readonly id: number;
22 readonly address: string;
23 readonly author_id: string;
24 readonly closing: string;
25 readonly closing_time: string | null;
26 readonly closed: boolean;
27 readonly fell_through: boolean;
28 }
29
30 const minutes = (time: string): number => Number(time.slice(0, 2)) * 60 + Number(time.slice(3));
31
32 /** For each deal id that has one, the other deals whose closing it overlaps, earliest first. */
33 export function closingConflicts(deals: readonly Timed[]): Map<number, ClosingConflict[]> {
34 const timed = deals.filter((d) => d.closing_time !== null && !d.closed && !d.fell_through);
35 const out = new Map<number, ClosingConflict[]>();
36 for (const a of timed) {
37 const near = timed
38 .filter(
39 (b) =>
40 b.id !== a.id &&
41 b.author_id === a.author_id &&
42 b.closing === a.closing &&
43 Math.abs(minutes(b.closing_time!) - minutes(a.closing_time!)) < APART,
44 )
45 .sort((x, y) => x.closing_time!.localeCompare(y.closing_time!) || x.id - y.id)
46 .map((b) => ({ dealId: b.id, address: b.address, closing_time: b.closing_time! }));
47 if (near.length > 0) out.set(a.id, near);
48 }
49 return out;
50 }
51
52 /** "Also closing at 2:30 pm: 2210 Juniper Court" as plain text, for the terminal; "" for none. */
53 export function clashText(conflicts: readonly ClosingConflict[]): string {
54 const first = conflicts[0];
55 return first === undefined ? "" : `Also closing at ${clock12(first.closing_time)}: ${conflicts.map((c) => c.address).join(", ")}`;
56 }
57
58 /** The amber line "Also closing at 2:30 pm: 2210 Juniper Court", each address linked to its deal (or plain, inside a link already); "" for none. */
59 export function clashLine(conflicts: readonly ClosingConflict[], tag: "p" | "small" = "p", linked = true): string {
60 const first = conflicts[0];
61 if (first === undefined) return "";
62 const links = conflicts.map((c) => (linked ? `<a href="/deals/${c.dealId}">${escape(c.address)}</a>` : escape(c.address))).join(", ");
63 return `<${tag} class="closing-clash">Also closing at ${escape(clock12(first.closing_time))}: ${links}</${tag}>`;
64 }
src/pages/clock.ts +2 −1
@@ -12,6 +12,7 @@ import { escape } from "../http.ts";
1212 import { agent as defaults } from "../env.ts";
1313 import { todaysDrafts, unsent, type Agent } from "../reminders.ts";
1414 import type { Who } from "../who.ts";
15 import { clashLine } from "../overlap.ts";
1516 import { byDay, closingNote, thisWeek } from "../week.ts";
1617 import { layout } from "./layout.ts";
1718 import { mayRestore } from "../actions.ts";
@@ -110,7 +111,7 @@ export function weekCard(deals: readonly DealView[], on: string, q = "", side: S
110111 (g) => `<h3 class="week-day">${escape(g.heading)}</h3>
111112 <ul class="week-list">${g.items
112113 .map(({ deal, deadline: d }) =>
113 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.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>`),
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>`),
114115 )
115116 .join("")}</ul>`,
116117 )
src/pages/deal.ts +2 −1
@@ -11,6 +11,7 @@ import { agent as defaults, standard } from "../env.ts";
1111 import { DEFAULT_LENGTHS, PARTY_LABEL, PARTY_ROLES, SUGGESTED_DATES } from "../deadlines.ts";
1212 import { escape } from "../http.ts";
1313 import { coming, comingLine, type Coming } from "../coming.ts";
14 import { clashLine } from "../overlap.ts";
1415 import { closingLine } from "../closing.ts";
1516 import { commission, dollars, percent } from "../money.ts";
1617 import { anniversaryDrafts, checkinDrafts, drafts, pending, sentLabel, statusDrafts, type Agent } from "../reminders.ts";
@@ -205,7 +206,7 @@ export interface ClosingProblem {
205206
206207 /** 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. */
207208 function closingWhenLine(deal: DealView): string {
208 return deal.closing_time === null && deal.closing_place === null ? "" : `<p class="summary" id="closing-when"><b>${escape(closingLine(deal))}</b></p>`;
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);
209210 }
210211
211212 function closingForm(deal: DealView, path: string, problem: ClosingProblem | undefined): string {
src/pages/week.ts +2
@@ -13,6 +13,7 @@ import { asset, escape } from "../http.ts";
1313 import { STATUS } from "../timeline.ts";
1414 import type { Who } from "../who.ts";
1515 import { byDay, closingNote, owner, thisWeek } from "../week.ts";
16 import { clashLine } from "../overlap.ts";
1617 import { layout } from "./layout.ts";
1718 import { sideLabel } from "./side.ts";
1819 import type { SideFilter } from "../side.ts";
@@ -44,6 +45,7 @@ export function weekPage(input: { who: Who; agent?: Agent | undefined; deals: re
4445 <p class="timeline-date">${escape(deal.address)} · ${sideLabel(deal.side)}</p>
4546 <p class="timeline-label"><b>${escape(d.label)}${closingAt(deal, d)}</b></p>
4647 <p class="timeline-owner">${escape(role)}${name === undefined ? "" : ` · ${escape(name)}`}</p>
48 ${d.kind === "closing" ? clashLine(deal.closingConflicts) : ""}
4749 ${d.note === "" ? "" : `<p class="timeline-owner">${escape(d.note)}</p>`}
4850 <p class="timeline-status"><span aria-hidden="true">${s.mark}</span> ${s.word}</p>
4951 </li>`;
src/partycontact.test.ts +1 −1
@@ -15,7 +15,7 @@ const dealHtml = (contact: string) => bare(
1515 dealPage({
1616 who,
1717 on: "2026-10-10",
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,
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: [], closingConflicts: [], sent: [] } as unknown as DealView,
1919 }));
2020
2121 for (const [page, render] of [["people", peopleHtml], ["deal", dealHtml]] as const) {
src/routes.ts +10
@@ -358,6 +358,16 @@ export const DEAL: Schema = {
358358 required: ["deadline_id", "label", "due", "closing"],
359359 },
360360 },
361 closingConflicts: {
362 type: "array",
363 description:
364 "Other open deals of this agent closing the same day, both with a time set, less than two hours apart. Empty when none.",
365 items: {
366 type: "object",
367 properties: { dealId: { type: "integer" }, address: { type: "string" }, closing_time: CLOSING_TIME },
368 required: ["dealId", "address", "closing_time"],
369 },
370 },
361371 declined: {
362372 type: "array",
363373 items: {
src/terminal.test.ts +23 −1
@@ -7,7 +7,7 @@ import { mkdtempSync } from "node:fs";
77 import { tmpdir } from "node:os";
88 import { join } from "node:path";
99 import { addDays, spoken, today, DEFAULT_ZONE } from "./dates.ts";
10 import { canChange, shown, addDeadline, addParty, createDeal, editParty, getDeal, listDeals, markDone, moveDeadline, sendReminder, type DealView } from "./deals.ts";
10 import { canChange, shown, addDeadline, addParty, createDeal, editParty, getDeal, listDeals, markDone, moveDeadline, sendReminder, updateDeal, type DealView } from "./deals.ts";
1111 import { openDb } from "./db.ts";
1212 import { terminal, type Terminal } from "./terminal.ts";
1313 import type { Who } from "./who.ts";
@@ -929,3 +929,25 @@ test("the deal view lists the reminders still to come, and says nothing is sent
929929 expect(screen).toContain("nothing is sent by itself");
930930 expect(screen).toMatch(/· \d+ days? before · .* due .* · to /);
931931 });
932
933 test("the deal view says which other closing the same day is less than two hours away", () => {
934 const day = addDays(today(DEFAULT_ZONE), 40);
935 const make = (address: string, time: string) => {
936 const made = createDeal(db, alice, { openAnyway: true, address, buyer: "Bea Buyer", seller: "Sid Seller", contractDate: today(DEFAULT_ZONE), closingDate: day });
937 if (!made.ok) throw new Error(made.message);
938 const set = updateDeal(db, alice, { id: made.value.id, closingTime: time });
939 if (!set.ok) throw new Error(set.message);
940 return made.value.id;
941 };
942 make("5 Clash Rd", "14:00");
943 const other = make("6 Clash Rd", "15:30");
944 const t = terminal(db, alice, context);
945 goTo(t, "Closing — 5 Clash Rd");
946 t.press("o");
947 expect(lines(t).join("\n")).toContain("Also closing at 3:30 pm: 6 Clash Rd");
948 updateDeal(db, alice, { id: other, closingTime: "16:00" });
949 t.press("o");
950 goTo(t, "Closing — 5 Clash Rd");
951 t.press("o");
952 expect(lines(t).join("\n")).not.toContain("Also closing at");
953 });
src/terminal.ts +2
@@ -87,6 +87,7 @@ import { people } from "./people.ts";
8787 import { reachedAt } from "./outbox.ts";
8888 import { addresses, refusal, when, wording } from "./activity.ts";
8989 import { listAudit } from "./actions.ts";
90 import { clashText } from "./overlap.ts";
9091 import { owner, thisWeek } from "./week.ts";
9192 import { SIDE_CHOICE, SIDE_LABEL, SIDE_REFUSAL, sideTyped } from "./side.ts";
9293
@@ -908,6 +909,7 @@ export function terminal(
908909 else {
909910 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]}${deal.cash === 1 ? " · Cash" : ""} · 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))]), "");
910911 deal.deadlines.forEach((date, i) => lines.push(dateLine({ deal, date }, i, false)));
912 if (deal.closingConflicts.length > 0) lines.push("", tint("overdue", clashText(deal.closingConflicts)));
911913 if (deal.conflicts.length > 0) lines.push("", ...deal.conflicts.map((c) => tint("overdue", `! ${conflictLine(c)}`)));
912914 lines.push("", bold("Parties"));
913915 deal.parties.forEach((p, i) => {
static/app.css +9
@@ -927,6 +927,15 @@ a.marker {
927927 text-decoration: none;
928928 }
929929
930 /* Two closings less than two hours apart: one amber line under the closing. */
931 .closing-clash {
932 margin: var(--space-2) 0;
933 color: var(--color-soon);
934 }
935 .closing-clash a {
936 color: inherit;
937 }
938
930939 /* A date that falls on or after closing: a words-first line, and a mark on its marker. */
931940 .conflict {
932941 margin: var(--space-2) 0;

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs