Public: anyone can read this; the crew can change it.
Every deal carries an Earnest money deposit date, due a few days after the contract, with reminders to the buyer like the other standard dates #98
Check · Review · Land · Live done — Landed and live in production.
mason/deal-clock:mason/94-every-deal-carries-an-earnest-money-depo → main 1 commit fork
17 files
changed +154
−20
README.md +2 −2
| @@ -121,7 +121,7 @@ Signed out, `/` shows what deal-clock does, three short points, a still picture | ||
| 121 | 121 | A date on a weekend or US federal holiday says "not a business day · next is Mon, Nov 30"; tap Move to (N in the terminal) to take that day, reason kept. |
| 122 | 122 | 10. **Open a new deal.** Back on the clock, tap New deal. Type an address, |
| 123 | 123 | buyer, seller, contract date and closing date. The standard lengths are |
| 124 | already filled in (inspection 10 days, appraisal 21, financing 30, title 14, | |
| 124 | already filled in (earnest money deposit 3 days, inspection 10, appraisal 21, financing 30, title 14, | |
| 125 | 125 | final walkthrough the day before closing) and you can change them; tick |
| 126 | 126 | Count business days to skip weekends. Tap Check the dates to see every |
| 127 | 127 | date the deal would get (label, weekday and date, who owes it) without |
| @@ -187,7 +187,7 @@ Your contracts may use other standard contingency lengths. Set them once and | ||
| 187 | 187 | every New deal form, its date preview, the API and the MCP tool start from them |
| 188 | 188 | (you can still change any length for one deal): |
| 189 | 189 | |
| 190 | - `DEAL_CLOCK_INSPECTION_DAYS` (brief: 10), `DEAL_CLOCK_APPRAISAL_DAYS` (21), | |
| 190 | - `DEAL_CLOCK_EARNEST_DAYS` (brief: 3), `DEAL_CLOCK_INSPECTION_DAYS` (10), `DEAL_CLOCK_APPRAISAL_DAYS` (21), | |
| 191 | 191 | `DEAL_CLOCK_FINANCING_DAYS` (30), `DEAL_CLOCK_TITLE_DAYS` (14): days after the |
| 192 | 192 | contract date. |
| 193 | 193 | - `DEAL_CLOCK_WALKTHROUGH_DAYS` (1): days before closing. |
contract/openapi.json +8
| @@ -353,6 +353,12 @@ | ||
| 353 | 353 | "type": "string", |
| 354 | 354 | "format": "date" |
| 355 | 355 | }, |
| 356 | "earnest": { | |
| 357 | "type": "integer", | |
| 358 | "minimum": 0, | |
| 359 | "maximum": 180, | |
| 360 | "default": 3 | |
| 361 | }, | |
| 356 | 362 | "inspection": { |
| 357 | 363 | "type": "integer", |
| 358 | 364 | "minimum": 0, |
| @@ -633,6 +639,7 @@ | ||
| 633 | 639 | }, |
| 634 | 640 | "kind": { |
| 635 | 641 | "enum": [ |
| 642 | "earnest", | |
| 636 | 643 | "inspection", |
| 637 | 644 | "appraisal", |
| 638 | 645 | "financing", |
| @@ -1949,6 +1956,7 @@ | ||
| 1949 | 1956 | }, |
| 1950 | 1957 | "kind": { |
| 1951 | 1958 | "enum": [ |
| 1959 | "earnest", | |
| 1952 | 1960 | "inspection", |
| 1953 | 1961 | "appraisal", |
| 1954 | 1962 | "financing", |
docs/TECHNICAL.md +5 −2
| @@ -24,8 +24,11 @@ marked sent stay on record. Over the API: `PATCH` or `DELETE | ||
| 24 | 24 | /api/deals/:id/parties/:party` and `DELETE /api/deals/:id/deadlines/:deadline`. |
| 25 | 25 | |
| 26 | 26 | Lead time: every date has `lead_days` (1 to 30, column `deadline.lead_days`, |
| 27 | default 3; new Financing dates and the sample deals start at 7, see `leadOf` in | |
| 28 | `src/deadlines.ts`). The `before` reminder goes out that many days before the due | |
| 27 | default 3; new Financing dates and the sample deals start at 7, new Earnest money | |
| 28 | deposit dates at 1, see `leadOf` in `src/deadlines.ts`). The deposit is the | |
| 29 | buyer's, `DEAL_CLOCK_EARNEST_DAYS` (0 to 180, else 3) after the contract date; it | |
| 30 | is written only into deals opened and samples restored after it existed, never | |
| 31 | into an existing deal on boot. The `before` reminder goes out that many days before the due | |
| 29 | 32 | date (`sendOn`), its label reads "N days before" (`momentLabel`), its words say |
| 30 | 33 | "in N days", and the calendar file's early alarm and This week's reminders follow |
| 31 | 34 | it; an unsent draft is redrafted, a sent one keeps its approved words. Set it with |
src/dates.test.ts +2
| @@ -43,6 +43,7 @@ test("business days step over weekends", () => { | ||
| 43 | 43 | |
| 44 | 44 | test("the standard lengths: inspection 10, appraisal 21, financing 30, walkthrough closing − 1", () => { |
| 45 | 45 | expect(DEFAULT_LENGTHS).toMatchObject({ |
| 46 | earnest: 3, | |
| 46 | 47 | inspection: 10, |
| 47 | 48 | appraisal: 21, |
| 48 | 49 | financing: 30, |
| @@ -57,6 +58,7 @@ test("the standard lengths: inspection 10, appraisal 21, financing 30, walkthrou | ||
| 57 | 58 | }).map((p) => [p.kind, p.due]), |
| 58 | 59 | ); |
| 59 | 60 | expect(dates).toEqual({ |
| 61 | earnest: "2026-10-15", | |
| 60 | 62 | inspection: "2026-10-22", |
| 61 | 63 | title: "2026-10-26", |
| 62 | 64 | appraisal: "2026-11-02", |
src/deadlines.ts +12 −1
| @@ -27,6 +27,7 @@ export const isPartyRole = (v: unknown): v is PartyRole => | ||
| 27 | 27 | PARTY_ROLES.includes(v as PartyRole); |
| 28 | 28 | |
| 29 | 29 | export const KINDS = [ |
| 30 | "earnest", | |
| 30 | 31 | "inspection", |
| 31 | 32 | "appraisal", |
| 32 | 33 | "financing", |
| @@ -46,7 +47,8 @@ export const DEFAULT_LEAD = 3; | ||
| 46 | 47 | export const LEAD_MIN = 1; |
| 47 | 48 | export const LEAD_MAX = 30; |
| 48 | 49 | /** The lead a new date of this kind starts from: a loan commitment needs a week's warning. */ |
| 49 | export const leadOf = (kind: Kind): number => (kind === "financing" ? 7 : DEFAULT_LEAD); | |
| 50 | export const leadOf = (kind: Kind): number => | |
| 51 | kind === "financing" ? 7 : kind === "earnest" ? 1 : DEFAULT_LEAD; | |
| 50 | 52 | |
| 51 | 53 | export interface KindInfo { |
| 52 | 54 | readonly label: string; |
| @@ -61,6 +63,13 @@ export interface KindInfo { | ||
| 61 | 63 | } |
| 62 | 64 | |
| 63 | 65 | export const KIND: Readonly<Record<Kind, KindInfo>> = { |
| 66 | earnest: { | |
| 67 | label: "Earnest money deposit", | |
| 68 | tag: "EMD", | |
| 69 | owes: "buyer", | |
| 70 | what: "Earnest money deposited with the title company", | |
| 71 | notify: ["buyer", "title", "other_agent"], | |
| 72 | }, | |
| 64 | 73 | inspection: { |
| 65 | 74 | label: "Inspection period ends", |
| 66 | 75 | tag: "Insp", |
| @@ -114,6 +123,7 @@ export const KIND: Readonly<Record<Kind, KindInfo>> = { | ||
| 114 | 123 | |
| 115 | 124 | /** The contingency lengths a new deal starts from, each editable on the form. */ |
| 116 | 125 | export interface Lengths { |
| 126 | readonly earnest: number; | |
| 117 | 127 | readonly inspection: number; |
| 118 | 128 | readonly appraisal: number; |
| 119 | 129 | readonly financing: number; |
| @@ -142,6 +152,7 @@ export function schedule(input: { | ||
| 142 | 152 | const { contractDate, closingDate, lengths, businessDays } = input; |
| 143 | 153 | const add = businessDays ? addBusinessDays : addDays; |
| 144 | 154 | const planned: Planned[] = [ |
| 155 | { kind: "earnest", due: add(contractDate, lengths.earnest) }, | |
| 145 | 156 | { kind: "inspection", due: add(contractDate, lengths.inspection) }, |
| 146 | 157 | { kind: "appraisal", due: add(contractDate, lengths.appraisal) }, |
| 147 | 158 | { kind: "financing", due: add(contractDate, lengths.financing) }, |
src/deals.test.ts +22 −3
| @@ -19,6 +19,7 @@ import { | ||
| 19 | 19 | listDeals, |
| 20 | 20 | markDone, |
| 21 | 21 | moveDeadline, |
| 22 | plan, | |
| 22 | 23 | removeDeadline, |
| 23 | 24 | removeParty, |
| 24 | 25 | updateDeal, |
| @@ -75,6 +76,7 @@ test("opening a deal computes its dates, with the buyer and seller as parties", | ||
| 75 | 76 | const deal = open(); |
| 76 | 77 | expect(deal.author_name).toBe("alice"); |
| 77 | 78 | expect(Object.fromEntries(deal.deadlines.map((d) => [d.kind, d.due]))).toEqual({ |
| 79 | earnest: "2026-10-04", | |
| 78 | 80 | inspection: "2026-10-11", |
| 79 | 81 | title: "2026-10-15", |
| 80 | 82 | appraisal: "2026-10-22", |
| @@ -251,12 +253,12 @@ test("an edited send stores the edited words; an empty body is refused; a sent r | ||
| 251 | 253 | expect(fresh(deal.id).sent.map((s) => s.subject)).toEqual(["Inspection <b>Friday</b>"]); |
| 252 | 254 | // Renaming the party leaves the record as it was sent. |
| 253 | 255 | db.query("UPDATE party SET name = 'Zed Renamed' WHERE id = ?1").run(buyer.party_id); |
| 254 | const again = drafts(fresh(deal.id), agent).find((r) => r.party_id === buyer.party_id && r.moment === "before")!; | |
| 256 | const again = drafts(fresh(deal.id), agent).find((r) => r.deadline_id === inspection.id && r.party_id === buyer.party_id && r.moment === "before")!; | |
| 255 | 257 | expect(again.sent_at).not.toBeNull(); |
| 256 | 258 | expect(again.subject).toBe("Inspection <b>Friday</b>"); |
| 257 | 259 | expect(again.body).not.toContain("Zed"); |
| 258 | 260 | // Sent with no words given, the draft as it stands is what is kept. |
| 259 | const plain = drafts(fresh(deal.id), agent).find((r) => r.moment === "before" && r.sent_at === null)!; | |
| 261 | const plain = drafts(fresh(deal.id), agent).find((r) => r.deadline_id === inspection.id && r.moment === "before" && r.sent_at === null)!; | |
| 260 | 262 | const kept = sendReminder(db, alice, { deadlineId: inspection.id, partyId: plain.party_id, moment: "before" }); |
| 261 | 263 | expect(kept.ok && kept.value.body).toBe(plain.body); |
| 262 | 264 | }); |
| @@ -273,7 +275,7 @@ test("the calendar file: one all-day event per date, alarms, escaped and folded" | ||
| 273 | 275 | const ics = calendar(deal, "clock.example", new Date("2026-10-12T08:00:00Z")); |
| 274 | 276 | expect(ics.startsWith("BEGIN:VCALENDAR\r\n")).toBe(true); |
| 275 | 277 | expect(ics.endsWith("END:VCALENDAR\r\n")).toBe(true); |
| 276 | expect(ics.split("BEGIN:VEVENT").length - 1).toBe(6); | |
| 278 | expect(ics.split("BEGIN:VEVENT").length - 1).toBe(7); | |
| 277 | 279 | expect(ics).toContain("DTSTART;VALUE=DATE:20261011\r\nDTEND;VALUE=DATE:20261012"); |
| 278 | 280 | expect(ics).toContain("UID:deadline-"); |
| 279 | 281 | expect(ics).toContain("TRIGGER:-P3D"); |
| @@ -627,3 +629,20 @@ test("a date moved away and back is told of each move afresh", () => { | ||
| 627 | 629 | const again = drafts(fresh(deal.id), agent).find((d) => d.moment === "moved" && d.party_id === p.party_id)!; |
| 628 | 630 | expect(again.sent_at).toBeNull(); |
| 629 | 631 | }); |
| 632 | ||
| 633 | test("the earnest money deposit is the buyer's, three days after the contract, in calendar or business days", () => { | |
| 634 | const deal = open(); | |
| 635 | const earnest = due(deal, "earnest"); | |
| 636 | expect([earnest.label, earnest.owes, earnest.due, earnest.lead_days]).toEqual(["Earnest money deposit", "buyer", "2026-10-04", 1]); | |
| 637 | // Three business days from Thursday Oct 1 is Tuesday Oct 6. | |
| 638 | expect(due(open({ businessDays: "on" }), "earnest").due).toBe("2026-10-06"); | |
| 639 | expect(due(open({ lengths: { earnest: "5" } }), "earnest").due).toBe("2026-10-06"); | |
| 640 | }); | |
| 641 | ||
| 642 | test("an earnest length out of range is refused, naming earnest", () => { | |
| 643 | for (const bad of ["181", "-1", "x"]) { | |
| 644 | const r = plan({ address: "1 Oak", buyer: "A", seller: "B", contractDate: "2026-10-01", closingDate: "2026-12-01", lengths: { earnest: bad } }); | |
| 645 | expect(r.ok).toBe(false); | |
| 646 | if (!r.ok) expect(r.field).toBe("earnest"); | |
| 647 | } | |
| 648 | }); |
src/earnest.test.ts added +74
| @@ -0,0 +1,74 @@ | ||
| 1 | /** The earnest money deposit: validated at the API and MCP boundary, never added to a deal that already exists, carried by the samples. */ | |
| 2 | import { afterAll, 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 { createDeal, listDeals } from "./deals.ts"; | |
| 7 | import { openDb } from "./db.ts"; | |
| 8 | import { restore } from "./sample.ts"; | |
| 9 | import { serve } from "./server.ts"; | |
| 10 | import { sign, type Who } from "./who.ts"; | |
| 11 | ||
| 12 | const alice: Who = { role: "user", id: "u1", name: "alice" }; | |
| 13 | ||
| 14 | const KEY = "a-key-only-the-forge-holds"; | |
| 15 | const server = serve({ port: 0, dataDir: mkdtempSync(join(tmpdir(), "app-emd-")), identityKey: KEY }); | |
| 16 | afterAll(() => server.stop(true)); | |
| 17 | const base = `http://${server.hostname}:${server.port}`; | |
| 18 | const identity = `u1|alice|user|${Date.now() + 600_000}`; | |
| 19 | const who = { "x-forge-identity": identity, "x-forge-signature": sign(identity, KEY) }; | |
| 20 | const post = (path: string, body: object) => | |
| 21 | fetch(base + path, { method: "POST", headers: { ...who, "content-type": "application/json" }, body: JSON.stringify(body) }); | |
| 22 | const fields = { address: "5 Deposit Way", buyer: "B", seller: "S", contract_date: "2026-10-01", closing_date: "2026-11-01" }; | |
| 23 | ||
| 24 | test("the API takes an earnest length and refuses one out of range, naming earnest", async () => { | |
| 25 | const bad = await post("/api/deals", { ...fields, earnest: 181 }); | |
| 26 | expect(bad.status).toBeGreaterThanOrEqual(400); | |
| 27 | expect(bad.status).toBeLessThan(500); | |
| 28 | expect(JSON.stringify(await bad.json())).toContain("earnest"); | |
| 29 | const ok = await post("/api/deals", { ...fields, earnest: 5 }); | |
| 30 | expect(ok.status).toBe(201); | |
| 31 | const deal = (await ok.json()) as { deadlines: { kind: string; due: string }[] }; | |
| 32 | expect(deal.deadlines.find((d) => d.kind === "earnest")?.due).toBe("2026-10-06"); | |
| 33 | }); | |
| 34 | ||
| 35 | test("the MCP open_deal tool takes earnest, and refuses an out-of-range one", async () => { | |
| 36 | const call = async (args: object) => | |
| 37 | (await (await post("/mcp", { jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "open_deal", arguments: args } })).json()) as any; | |
| 38 | const bad = await call({ ...fields, address: "6 Deposit Way", earnest: 181 }); | |
| 39 | expect(bad.result.isError).toBe(true); | |
| 40 | expect(JSON.stringify(bad)).toContain("earnest"); | |
| 41 | const ok = await call({ ...fields, address: "7 Deposit Way", earnest: 2 }); | |
| 42 | expect(ok.result.isError).toBeFalsy(); | |
| 43 | expect(ok.result.content[0].text).toContain("2026-10-03"); | |
| 44 | const list = (await (await post("/mcp", { jsonrpc: "2.0", id: 2, method: "tools/list" })).json()) as any; | |
| 45 | expect(list.result.tools.find((t: any) => t.name === "open_deal").inputSchema.properties.earnest.default).toBe(3); | |
| 46 | }); | |
| 47 | ||
| 48 | test("a deal made before the deposit existed gains no date when the database boots", () => { | |
| 49 | const dir = mkdtempSync(join(tmpdir(), "app-emd-old-")); | |
| 50 | const first = openDb(dir); | |
| 51 | const made = createDeal(first, alice, { address: "1 Old Deal", buyer: "A", seller: "B", contractDate: "2026-10-01", closingDate: "2026-11-01" }); | |
| 52 | if (!made.ok) throw new Error(made.message); | |
| 53 | first.query("DELETE FROM deadline WHERE deal_id = ?1 AND kind = 'earnest'").run(made.value.id); | |
| 54 | first.close(); | |
| 55 | const again = openDb(dir); | |
| 56 | const listed = listDeals(again, alice); | |
| 57 | if (!listed.ok) throw new Error(listed.message); | |
| 58 | expect(listed.value.find((d) => d.id === made.value.id)!.deadlines.map((d) => d.kind)).not.toContain("earnest"); | |
| 59 | }); | |
| 60 | ||
| 61 | test("the restored samples carry the deposit: done on three, ahead on Juniper Court", () => { | |
| 62 | const db = openDb(mkdtempSync(join(tmpdir(), "app-emd-sample-"))); | |
| 63 | restore(db, "2026-10-01"); | |
| 64 | const rows = db | |
| 65 | .query<{ address: string; due: string; done_at: string | null }, []>( | |
| 66 | "SELECT d.address, k.due, k.done_at FROM deadline k JOIN deal d ON d.id = k.deal_id WHERE k.kind = 'earnest' ORDER BY d.id", | |
| 67 | ) | |
| 68 | .all(); | |
| 69 | expect(rows.length).toBe(4); | |
| 70 | const by = (a: string) => rows.find((r) => r.address.includes(a))!; | |
| 71 | expect(by("Alder Lane").done_at).not.toBeNull(); | |
| 72 | expect(by("Juniper").done_at).toBeNull(); | |
| 73 | expect(by("Juniper").due > "2026-10-01").toBe(true); | |
| 74 | }); |
src/env.ts +1
| @@ -55,6 +55,7 @@ export const agent = { | ||
| 55 | 55 | |
| 56 | 56 | /** The brief's contingency lengths, in days: what a new deal starts from unless the agent says otherwise. */ |
| 57 | 57 | export const BRIEF_LENGTHS = { |
| 58 | earnest: 3, | |
| 58 | 59 | inspection: 10, |
| 59 | 60 | appraisal: 21, |
| 60 | 61 | financing: 30, |
src/lead.test.ts +3 −2
| @@ -35,10 +35,11 @@ const fresh = (id: number): DealView => { | ||
| 35 | 35 | const kind = (deal: DealView, k: string) => deal.deadlines.find((d) => d.kind === k)!; |
| 36 | 36 | const before = (deal: DealView, id: number) => drafts(deal, agent).filter((d) => d.deadline_id === id && d.moment === "before"); |
| 37 | 37 | |
| 38 | test("standard dates start at three days; financing starts at seven", () => { | |
| 38 | test("standard dates start at three days; financing starts at seven, the earnest deposit at one", () => { | |
| 39 | 39 | const deal = open(); |
| 40 | 40 | expect(deal.deadlines.map((d) => [d.kind, d.lead_days])).toContainEqual(["financing", 7]); |
| 41 | for (const d of deal.deadlines.filter((d) => d.kind !== "financing")) expect(d.lead_days).toBe(3); | |
| 41 | for (const d of deal.deadlines.filter((d) => d.kind !== "financing" && d.kind !== "earnest")) expect(d.lead_days).toBe(3); | |
| 42 | expect(deal.deadlines.map((d) => [d.kind, d.lead_days])).toContainEqual(["earnest", 1]); | |
| 42 | 43 | const financing = kind(deal, "financing"); |
| 43 | 44 | expect(before(deal, financing.id)[0]!.on).toBe(addDays(financing.due, -7)); |
| 44 | 45 | expect(before(deal, kind(deal, "inspection").id)[0]!.on).toBe(addDays(kind(deal, "inspection").due, -3)); |
src/lengths.test.ts +9 −2
| @@ -4,7 +4,7 @@ import { BRIEF_LENGTHS, resolveLengths } from "./env.ts"; | ||
| 4 | 4 | |
| 5 | 5 | test("nothing set: the brief's lengths, calendar days", () => { |
| 6 | 6 | const r = resolveLengths({}); |
| 7 | expect(r.lengths).toEqual({ inspection: 10, appraisal: 21, financing: 30, title: 14, walkthrough: 1 }); | |
| 7 | expect(r.lengths).toEqual({ earnest: 3, inspection: 10, appraisal: 21, financing: 30, title: 14, walkthrough: 1 }); | |
| 8 | 8 | expect(r.businessDays).toBe(false); |
| 9 | 9 | expect(BRIEF_LENGTHS.inspection).toBe(10); |
| 10 | 10 | }); |
| @@ -18,7 +18,7 @@ test("set values replace the brief's; bad ones fall back without throwing", () = | ||
| 18 | 18 | DEAL_CLOCK_WALKTHROUGH_DAYS: "0", |
| 19 | 19 | DEAL_CLOCK_BUSINESS_DAYS: "1", |
| 20 | 20 | }); |
| 21 | expect(r.lengths).toEqual({ inspection: 7, appraisal: 21, financing: 30, title: 14, walkthrough: 0 }); | |
| 21 | expect(r.lengths).toEqual({ earnest: 3, inspection: 7, appraisal: 21, financing: 30, title: 14, walkthrough: 0 }); | |
| 22 | 22 | expect(r.businessDays).toBe(true); |
| 23 | 23 | expect(resolveLengths({ DEAL_CLOCK_TITLE_DAYS: "2.5" }).lengths.title).toBe(14); |
| 24 | 24 | }); |
| @@ -92,3 +92,10 @@ test("with business days as the agent's standard, a form's unticked box still me | ||
| 92 | 92 | mcpBizDefault: true, |
| 93 | 93 | }); |
| 94 | 94 | }); |
| 95 | ||
| 96 | test("DEAL_CLOCK_EARNEST_DAYS sets the deposit length; out of range falls back to 3", () => { | |
| 97 | expect(resolveLengths({ DEAL_CLOCK_EARNEST_DAYS: "5" }).lengths.earnest).toBe(5); | |
| 98 | expect(resolveLengths({ DEAL_CLOCK_EARNEST_DAYS: "0" }).lengths.earnest).toBe(0); | |
| 99 | expect(resolveLengths({ DEAL_CLOCK_EARNEST_DAYS: "181" }).lengths.earnest).toBe(3); | |
| 100 | expect(resolveLengths({ DEAL_CLOCK_EARNEST_DAYS: "soon" }).lengths.earnest).toBe(3); | |
| 101 | }); |
src/mcp.ts +2
| @@ -256,6 +256,7 @@ export const tools: readonly Tool[] = [ | ||
| 256 | 256 | seller: { type: "string", maxLength: 100 }, |
| 257 | 257 | contract_date: { type: "string", format: "date" }, |
| 258 | 258 | closing_date: { type: "string", format: "date" }, |
| 259 | earnest: { type: "integer", minimum: 0, maximum: LENGTH_MAX, default: DEFAULT_LENGTHS.earnest }, | |
| 259 | 260 | inspection: { type: "integer", minimum: 0, maximum: LENGTH_MAX, default: DEFAULT_LENGTHS.inspection }, |
| 260 | 261 | appraisal: { type: "integer", minimum: 0, maximum: LENGTH_MAX, default: DEFAULT_LENGTHS.appraisal }, |
| 261 | 262 | financing: { type: "integer", minimum: 0, maximum: LENGTH_MAX, default: DEFAULT_LENGTHS.financing }, |
| @@ -274,6 +275,7 @@ export const tools: readonly Tool[] = [ | ||
| 274 | 275 | contractDate: a.contract_date, |
| 275 | 276 | closingDate: a.closing_date, |
| 276 | 277 | lengths: { |
| 278 | earnest: a.earnest, | |
| 277 | 279 | inspection: a.inspection, |
| 278 | 280 | appraisal: a.appraisal, |
| 279 | 281 | financing: a.financing, |
src/pages/deal.ts +1
| @@ -273,6 +273,7 @@ export function newDealPage(input: { | ||
| 273 | 273 | <fieldset> |
| 274 | 274 | <legend>Contingency lengths, in days from the contract date</legend> |
| 275 | 275 | <div class="lengths"> |
| 276 | ${length("earnest", "Earnest money deposit")} | |
| 276 | 277 | ${length("inspection", "Inspection")} |
| 277 | 278 | ${length("appraisal", "Appraisal")} |
| 278 | 279 | ${length("financing", "Financing")} |
src/pages/welcome.ts +1 −1
| @@ -24,7 +24,7 @@ function madeUp(on: string): { due: string; tag: string; done: boolean }[] { | ||
| 24 | 24 | return schedule({ |
| 25 | 25 | contractDate: addDays(on, -12), |
| 26 | 26 | closingDate: addDays(on, 18), |
| 27 | lengths: { inspection: 10, appraisal: 21, financing: 30, title: 14, walkthrough: 1 }, | |
| 27 | lengths: { earnest: 3, inspection: 10, appraisal: 21, financing: 30, title: 14, walkthrough: 1 }, | |
| 28 | 28 | businessDays: false, |
| 29 | 29 | }).map(({ kind, due }) => ({ due, tag: KIND[kind].tag, done: kind === "inspection" })); |
| 30 | 30 | } |
src/routes.ts +3 −1
| @@ -204,7 +204,7 @@ export const DEAL: Schema = { | ||
| 204 | 204 | type: "object", |
| 205 | 205 | properties: { |
| 206 | 206 | id: { type: "integer" }, |
| 207 | kind: { enum: ["inspection", "appraisal", "financing", "title", "walkthrough", "closing", "custom"] }, | |
| 207 | kind: { enum: ["earnest", "inspection", "appraisal", "financing", "title", "walkthrough", "closing", "custom"] }, | |
| 208 | 208 | label: { type: "string" }, |
| 209 | 209 | due: DATE, |
| 210 | 210 | owes: ROLE, |
| @@ -292,6 +292,7 @@ const NEW_DEAL: Schema = { | ||
| 292 | 292 | seller: { type: "string", minLength: 1, maxLength: 100 }, |
| 293 | 293 | contract_date: DATE, |
| 294 | 294 | closing_date: DATE, |
| 295 | earnest: { type: "integer", minimum: 0, maximum: 180, default: DEFAULT_LENGTHS.earnest }, | |
| 295 | 296 | inspection: { type: "integer", minimum: 0, maximum: 180, default: DEFAULT_LENGTHS.inspection }, |
| 296 | 297 | appraisal: { type: "integer", minimum: 0, maximum: 180, default: DEFAULT_LENGTHS.appraisal }, |
| 297 | 298 | financing: { type: "integer", minimum: 0, maximum: 180, default: DEFAULT_LENGTHS.financing }, |
| @@ -495,6 +496,7 @@ const newDeal = (f: Record<string, unknown>): NewDeal => ({ | ||
| 495 | 496 | contractDate: f.contract_date, |
| 496 | 497 | closingDate: f.closing_date, |
| 497 | 498 | lengths: { |
| 499 | earnest: f.earnest, | |
| 498 | 500 | inspection: f.inspection, |
| 499 | 501 | appraisal: f.appraisal, |
| 500 | 502 | financing: f.financing, |
src/sample.test.ts +2 −2
| @@ -38,14 +38,14 @@ test("a sample a person changed is not untouched", () => { | ||
| 38 | 38 | parties: 3, // lender, title, other agent |
| 39 | 39 | customs: 1, |
| 40 | 40 | reminders: 0, |
| 41 | doneAts: ["2026-09-30T17:00:00.000Z", "2026-09-30T17:00:00.000Z", null], | |
| 41 | doneAts: ["2026-09-30T17:00:00.000Z", "2026-09-30T17:00:00.000Z", "2026-09-30T17:00:00.000Z", null], | |
| 42 | 42 | moveAuthors: ["Sample data"], |
| 43 | 43 | }; |
| 44 | 44 | expect(isUntouched(state, "2026-10-01")).toBe(true); |
| 45 | 45 | expect(isUntouched({ ...state, reminders: 1 }, "2026-10-01")).toBe(false); |
| 46 | 46 | expect(isUntouched({ ...state, parties: 4 }, "2026-10-01")).toBe(false); |
| 47 | 47 | expect(isUntouched({ ...state, moveAuthors: ["Sample data", "Ana"] }, "2026-10-01")).toBe(false); |
| 48 | expect(isUntouched({ ...state, doneAts: ["2026-09-30T17:00:00.000Z", "2026-10-02T08:00:00.000Z", null] }, "2026-10-01")).toBe(false); | |
| 48 | expect(isUntouched({ ...state, doneAts: ["2026-09-30T17:00:00.000Z", "2026-09-30T17:00:00.000Z", "2026-10-02T08:00:00.000Z", null] }, "2026-10-01")).toBe(false); | |
| 49 | 49 | expect(isUntouched({ ...state, sample: null }, "2026-10-01")).toBe(false); |
| 50 | 50 | }); |
| 51 | 51 |
src/sample.ts +4 −2
| @@ -42,7 +42,7 @@ const SAMPLES: readonly Sample[] = [ | ||
| 42 | 42 | ["title", "Marcus Lee, Bayside Title", "[email protected]"], |
| 43 | 43 | ["other_agent", "Jordan Ellis, Crestline Homes", "(555) 014-2290"], |
| 44 | 44 | ], |
| 45 | done: ["inspection", "title", "appraisal"], | |
| 45 | done: ["earnest", "inspection", "title", "appraisal"], | |
| 46 | 46 | sent: [ |
| 47 | 47 | "inspection", |
| 48 | 48 | "buyer", |
| @@ -62,6 +62,7 @@ const SAMPLES: readonly Sample[] = [ | ||
| 62 | 62 | ["title", "Bayside Title", "[email protected]"], |
| 63 | 63 | ["other_agent", "Alicia Moreno, Moreno & Co.", "[email protected]"], |
| 64 | 64 | ], |
| 65 | done: ["earnest"], | |
| 65 | 66 | custom: [["HOA documents review ends", 1, "buyer", "Read the HOA budget, rules and minutes; object in writing if needed"]], |
| 66 | 67 | }, |
| 67 | 68 | { |
| @@ -75,7 +76,7 @@ const SAMPLES: readonly Sample[] = [ | ||
| 75 | 76 | ["title", "Northgate Title & Escrow", "[email protected]"], |
| 76 | 77 | ["other_agent", "Ben Adeyemi, Lantern Realty", "[email protected]"], |
| 77 | 78 | ], |
| 78 | done: ["inspection", "title"], | |
| 79 | done: ["earnest", "inspection", "title"], | |
| 79 | 80 | custom: [["Repair credit agreed", 5, "seller", "Signed amendment for the roof repair credit"]], |
| 80 | 81 | moved: ["appraisal", 2, "Appraiser rescheduled — access to the property"], |
| 81 | 82 | }, |
| @@ -85,6 +86,7 @@ const SAMPLES: readonly Sample[] = [ | ||
| 85 | 86 | seller: "Carla Mendes", |
| 86 | 87 | contract: -3, |
| 87 | 88 | closing: 40, |
| 89 | lengths: { earnest: 5 }, | |
| 88 | 90 | parties: [ |
| 89 | 91 | ["lender", "Owen Brandt, First Keel Bank", "[email protected]"], |
| 90 | 92 | ["other_agent", "Jordan Ellis, Crestline Homes", "(555) 014-2290"], |
src/terminal.test.ts +3 −2
| @@ -156,7 +156,7 @@ test("n opens a deal from five answers, and shows it", () => { | ||
| 156 | 156 | if (!listed.ok) throw new Error(listed.message); |
| 157 | 157 | const made = listed.value.find((d) => d.address === "31 Birch Row"); |
| 158 | 158 | expect(made?.parties.map((p) => p.name)).toEqual(["Kim Buyer", "Lou Seller"]); |
| 159 | expect(made?.deadlines.length).toBe(6); | |
| 159 | expect(made?.deadlines.length).toBe(7); | |
| 160 | 160 | expect(lines(t).join("\n")).toContain("Opened 31 Birch Row"); |
| 161 | 161 | expect(lines(t)).toContain("31 Birch Row"); |
| 162 | 162 | // A bad answer is the action's to refuse, and nothing is opened. |
| @@ -392,7 +392,8 @@ test("R then yes puts the sample deals back, leaving a person's deal alone", () | ||
| 392 | 392 | expect(harbor().deadlines.find((d) => d.id === first.id)!.done_at).not.toBeNull(); |
| 393 | 393 | press(t, "R", "yes\r"); |
| 394 | 394 | expect(lines(t).join("\n")).toContain("Sample deals restored."); |
| 395 | expect(harbor().deadlines.every((d) => d.done_at === null)).toBe(true); | |
| 395 | // The sample writes Harbor View with its earnest money deposit already made; every other date is open again. | |
| 396 | expect(harbor().deadlines.every((d) => (d.kind === "earnest") === (d.done_at !== null))).toBe(true); | |
| 396 | 397 | expect(getDeal(db, alice, { id }).ok).toBe(true); |
| 397 | 398 | }); |
| 398 | 399 |
new above
offline