recess-cli 3.54.0 → 3.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -27,6 +27,7 @@ import { runStudentsTextsCommand, runUsersPhoneCommand, runUsersTextCommand, run
27
27
  import { hasCommunityHour, runUsersCommunityHourCommand, } from "./commands/community-hour.js";
28
28
  import { runUsersBirthdayCommand } from "./commands/birthday.js";
29
29
  import { runTuitionPlansCommand } from "./commands/tuition-plans.js";
30
+ import { runTuitionCommand } from "./commands/tuition.js";
30
31
  import { runReportsCommand } from "./commands/reports.js";
31
32
  import { runMasteryCommand } from "./commands/mastery.js";
32
33
  import { runOnboardingCommand } from "./commands/onboarding.js";
@@ -3930,6 +3931,9 @@ export async function executeRecessCommand(argv, options = {}) {
3930
3931
  if (noun === "admissions") {
3931
3932
  return runAdmissionsCommand({ parsed, api, writeCommand });
3932
3933
  }
3934
+ if (noun === "tuition") {
3935
+ return runTuitionCommand({ parsed, api, writeCommand });
3936
+ }
3933
3937
  if (noun === "apps") {
3934
3938
  return runAppsCommand({
3935
3939
  parsed,
@@ -0,0 +1,517 @@
1
+ import { unwrap } from "../api.js";
2
+ import { flagString, hasFlag } from "../args.js";
3
+ import { CliError } from "../errors.js";
4
+ import { assertChoice, positional, renderColumns, } from "./shared.js";
5
+ const STATUSES = [
6
+ "NEEDS_REVIEW",
7
+ "SCHEDULED",
8
+ "DRAFTED",
9
+ "SENT",
10
+ "PAID",
11
+ "PAID_OUT_OF_BAND",
12
+ "VOID",
13
+ ];
14
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
15
+ const dollars = (cents) => `$${(cents / 100).toLocaleString("en-US", {
16
+ minimumFractionDigits: cents % 100 === 0 ? 0 : 2,
17
+ maximumFractionDigits: 2,
18
+ })}`;
19
+ /** The next row still owed, by invoice date. */
20
+ function nextOpen(schedule) {
21
+ return schedule.installments
22
+ .filter((row) => ["NEEDS_REVIEW", "SCHEDULED", "DRAFTED", "SENT"].includes(row.status))
23
+ .sort((a, b) => a.invoiceDate.localeCompare(b.invoiceDate))[0];
24
+ }
25
+ function renderSchedule({ schedule, signed, events, revisions, }) {
26
+ const out = [
27
+ `${schedule.kidName} · ${schedule.parentName} <${schedule.parentEmail}> · ${schedule.stateCode}`,
28
+ `Schedule ${schedule.id} · packet ${schedule.packetId}`,
29
+ `Payer ${schedule.payer} · collection ${schedule.defaultCollection} · automatic invoicing ${schedule.autoInvoice ? "on" : "OFF"} · option ${schedule.sourceOptionId}`,
30
+ `Signed ${dollars(schedule.agreedTotalCents)} · scheduled ${dollars(schedule.scheduledCents)} · paid ${dollars(schedule.paidCents)} · open ${dollars(schedule.openCents)}`,
31
+ ];
32
+ if (schedule.scheduledCents !== schedule.agreedTotalCents) {
33
+ out.push(`!! The rows add up to ${dollars(schedule.scheduledCents)}, not the signed ${dollars(schedule.agreedTotalCents)}.`);
34
+ }
35
+ if (schedule.held)
36
+ out.push(`!! Held: ${schedule.held}`);
37
+ if (schedule.recordOnly)
38
+ out.push(`Record only: ${schedule.recordOnly}`);
39
+ out.push(`Family last consented ${schedule.lastConsentAt.slice(0, 10)}${schedule.changesWithoutConsent
40
+ ? `; ${schedule.changesWithoutConsent} change(s) applied since without their consent`
41
+ : ""}.`);
42
+ if (schedule.pendingRevision) {
43
+ out.push(`!! Change ${schedule.pendingRevision.id} waits for the family (sent ${schedule.pendingRevision.requestedAt.slice(0, 10)}${schedule.pendingRevision.emailSentAt ? "" : ", email NOT sent"}). The rows it touches are held.`);
44
+ }
45
+ if (schedule.pausedAt) {
46
+ out.push(`!! Paused ${schedule.pausedAt.slice(0, 10)}${schedule.pausedNote ? `: ${schedule.pausedNote}` : ""}`);
47
+ }
48
+ out.push("", renderColumns([
49
+ ["#", "Status", "Amount", "Invoice", "Due", "Collection", "Label", "ID"],
50
+ ...schedule.installments.map((row) => [
51
+ String(row.sequence),
52
+ row.status,
53
+ `${dollars(row.amountCents)}${row.creditedCents ? ` (${dollars(row.amountCents - row.creditedCents)} after credit)` : ""}${row.refundedCents ? ` (${dollars(row.refundedCents)} refunded)` : ""}`,
54
+ row.invoiceDate,
55
+ row.dueDate,
56
+ row.collection,
57
+ `${row.label}${row.paidNote ? ` (${row.paidNote})` : ""}`,
58
+ row.id,
59
+ ]),
60
+ ]));
61
+ if (signed.length) {
62
+ out.push("", "As signed:", renderColumns([
63
+ ["Row", "Amount", "Invoice", "Due", "Label"],
64
+ ...signed.map((row) => [
65
+ String(row.sourceIndex + 1),
66
+ `${row.award === "PENDING" ? "up to " : ""}${dollars(row.amountCents)}`,
67
+ row.invoiceDate || "none",
68
+ row.dueDate || "none",
69
+ row.label,
70
+ ]),
71
+ ]));
72
+ }
73
+ if (events.length) {
74
+ out.push(...(revisions.length
75
+ ? [
76
+ "",
77
+ "Change record:",
78
+ ...revisions.flatMap((revision) => [
79
+ ` ${revision.createdAt.slice(0, 16).replace("T", " ")} ${revision.id} ${revision.status === "PENDING"
80
+ ? "WAITING FOR FAMILY"
81
+ : revision.status === "APPLYING"
82
+ ? "STOPPED PARTWAY: `recess tuition retry-change`"
83
+ : revision.status === "CANCELED"
84
+ ? `WITHDRAWN${revision.cancelReason ? `: ${revision.cancelReason}` : ""}`
85
+ : revision.consentedAt
86
+ ? `FAMILY CONSENTED (${revision.consentMethod === "PARENT_ONLINE" ? `online as "${revision.consentName}"` : `recorded: ${revision.consentName}`})`
87
+ : "APPLIED WITHOUT FAMILY CONSENT"}${revision.createdByName ? ` · by ${revision.createdByName}` : ""}${revision.reason ? ` · ${revision.reason}` : ""}`,
88
+ ...revision.operations.map((op) => ` ${op.op === "add"
89
+ ? `add ${op.label} ${dollars(op.amountCents)} due ${op.dueDate}`
90
+ : op.op === "void"
91
+ ? `remove #${op.sequence} ${op.label} ${dollars(op.amountCents)}${op.voidsInvoice ? " (invoice voided)" : ""}`
92
+ : `#${op.sequence} ${op.label}: ${JSON.stringify(op.before)} -> ${JSON.stringify(op.after)}${op.reissue ? " (invoice reissued)" : ""}`}`),
93
+ ]),
94
+ ]
95
+ : []), "", "History:", ...events.map((event) => ` ${event.at.slice(0, 16).replace("T", " ")} ${event.sequence === null ? "schedule" : `#${event.sequence}`} ${event.kind}${event.actorName ? ` by ${event.actorName}` : ""}${typeof event.detail?.reason === "string"
96
+ ? `: ${event.detail.reason}`
97
+ : ""}`));
98
+ }
99
+ return out.join("\n");
100
+ }
101
+ const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
102
+ const COLLECTIONS = {
103
+ invoice: "EMAIL_INVOICE",
104
+ "auto-charge": "AUTO_CHARGE",
105
+ "out-of-band": "OUT_OF_BAND",
106
+ };
107
+ const PAYERS = {
108
+ family: "FAMILY",
109
+ "az-esa": "AZ_ESA_CLASSWALLET",
110
+ "fl-scholarship": "FL_SCHOLARSHIP",
111
+ "partner-school": "PARTNER_SCHOOL",
112
+ };
113
+ /** `--ask-family [--family-note TEXT]`: hold the change for the family's approval. */
114
+ function askFamily(parsed) {
115
+ if (!hasFlag(parsed, "ask-family"))
116
+ return {};
117
+ const familyNote = flagString(parsed, "family-note")?.trim();
118
+ return { askFamily: true, ...(familyNote ? { familyNote } : {}) };
119
+ }
120
+ /** `--amount 1750` or `--amount 1750.50`, as cents. */
121
+ function centsFlag(parsed, name) {
122
+ const raw = flagString(parsed, name)
123
+ ?.trim()
124
+ .replace(/^\$/, "")
125
+ .replaceAll(",", "");
126
+ if (raw === undefined)
127
+ return undefined;
128
+ if (!/^\d+(\.\d{1,2})?$/.test(raw) || Number(raw) <= 0) {
129
+ throw new CliError("invalid_arguments", `--${name} takes dollars, e.g. --${name} 1750 or --${name} 1750.50.`);
130
+ }
131
+ return Math.round(Number(raw) * 100);
132
+ }
133
+ function dateFlag(parsed, name) {
134
+ const raw = flagString(parsed, name)?.trim();
135
+ if (raw === undefined)
136
+ return undefined;
137
+ if (!ISO_DATE.test(raw)) {
138
+ throw new CliError("invalid_arguments", `--${name} must be YYYY-MM-DD.`);
139
+ }
140
+ return raw;
141
+ }
142
+ function choiceFlag(parsed, name, values) {
143
+ const raw = flagString(parsed, name)?.trim().toLowerCase();
144
+ if (raw === undefined)
145
+ return undefined;
146
+ const value = values[raw];
147
+ if (!value) {
148
+ throw new CliError("invalid_arguments", `--${name} must be one of: ${Object.keys(values).join(", ")}.`);
149
+ }
150
+ return value;
151
+ }
152
+ function textFlag(parsed, name, required = false) {
153
+ const value = flagString(parsed, name)?.trim();
154
+ if (!value && required) {
155
+ throw new CliError("invalid_arguments", `Missing required --${name}.`);
156
+ }
157
+ return value || undefined;
158
+ }
159
+ /**
160
+ * `recess tuition`: the tuition schedules built from signed admission
161
+ * packets, and staff changes to installments no invoice has gone out for.
162
+ */
163
+ export async function runTuitionCommand({ parsed, api, writeCommand, }) {
164
+ const verb = parsed.positionals[1];
165
+ const json = hasFlag(parsed, "json");
166
+ if (verb === "list") {
167
+ const status = flagString(parsed, "status");
168
+ const family = flagString(parsed, "family");
169
+ const packet = flagString(parsed, "packet");
170
+ for (const [name, value] of [
171
+ ["family", family],
172
+ ["packet", packet],
173
+ ]) {
174
+ if (value && !UUID.test(value)) {
175
+ throw new CliError("invalid_arguments", `--${name} must be an ID.`);
176
+ }
177
+ }
178
+ const { schedules, counts } = unwrap(await api.client.GET("/admin/tuition-billing/", {
179
+ params: {
180
+ query: {
181
+ ...(status
182
+ ? {
183
+ status: assertChoice(status.toUpperCase().replaceAll("-", "_"), STATUSES, "--status"),
184
+ }
185
+ : {}),
186
+ ...(family ? { familyId: family } : {}),
187
+ ...(packet ? { packetId: packet } : {}),
188
+ ...(flagString(parsed, "q") ? { q: flagString(parsed, "q") } : {}),
189
+ limit: Number(flagString(parsed, "limit") ?? 100),
190
+ },
191
+ },
192
+ }));
193
+ if (json)
194
+ return { schedules, counts };
195
+ if (!schedules.length)
196
+ return { help: "No tuition schedules." };
197
+ return {
198
+ help: [
199
+ renderColumns([
200
+ ["Schedule", "Student", "Parent", "Payer", "Open", "Next", "Flags"],
201
+ ...schedules.map((s) => {
202
+ const next = nextOpen(s);
203
+ return [
204
+ s.id,
205
+ s.kidName,
206
+ `${s.parentName} <${s.parentEmail}>`,
207
+ s.payer,
208
+ dollars(s.openCents),
209
+ next
210
+ ? `${next.invoiceDate} ${dollars(next.amountCents)} ${next.status}`
211
+ : "nothing open",
212
+ [
213
+ s.needsReviewCount ? `${s.needsReviewCount} to review` : null,
214
+ s.pausedAt ? "paused" : null,
215
+ s.held ? "held" : null,
216
+ ]
217
+ .filter(Boolean)
218
+ .join(", "),
219
+ ];
220
+ }),
221
+ ]),
222
+ "",
223
+ `Installments: ${STATUSES.map((s) => `${counts[s] ?? 0} ${s}`).join(" · ")}`,
224
+ ].join("\n"),
225
+ };
226
+ }
227
+ if (verb === "show") {
228
+ const scheduleId = positional(parsed, 2, "schedule ID");
229
+ const detail = unwrap(await api.client.GET("/admin/tuition-billing/{scheduleId}", {
230
+ params: { path: { scheduleId } },
231
+ }));
232
+ return json ? detail : { help: renderSchedule(detail) };
233
+ }
234
+ /** After a change: the schedule as it now stands, with its history. */
235
+ const shown = async (schedule) => {
236
+ if (json)
237
+ return { schedule };
238
+ const detail = unwrap(await api.client.GET("/admin/tuition-billing/{scheduleId}", {
239
+ params: { path: { scheduleId: schedule.id } },
240
+ }));
241
+ return { help: renderSchedule(detail) };
242
+ };
243
+ if (verb === "edit") {
244
+ const installmentId = positional(parsed, 2, "installment ID");
245
+ const collection = flagString(parsed, "collection")?.trim().toLowerCase();
246
+ const body = {
247
+ ...(textFlag(parsed, "label")
248
+ ? { label: textFlag(parsed, "label") }
249
+ : {}),
250
+ ...(centsFlag(parsed, "amount") !== undefined
251
+ ? { amountCents: centsFlag(parsed, "amount") }
252
+ : {}),
253
+ ...(dateFlag(parsed, "invoice-date")
254
+ ? { invoiceDate: dateFlag(parsed, "invoice-date") }
255
+ : {}),
256
+ ...(dateFlag(parsed, "due-date")
257
+ ? { dueDate: dateFlag(parsed, "due-date") }
258
+ : {}),
259
+ ...(textFlag(parsed, "note") ? { note: textFlag(parsed, "note") } : {}),
260
+ ...askFamily(parsed),
261
+ // "default" clears the row's own method.
262
+ ...(collection === undefined
263
+ ? {}
264
+ : collection === "default"
265
+ ? { collection: null }
266
+ : { collection: choiceFlag(parsed, "collection", COLLECTIONS) }),
267
+ };
268
+ if (Object.keys(body).filter((key) => !["note", "askFamily", "familyNote"].includes(key)).length === 0) {
269
+ throw new CliError("invalid_arguments", "Nothing to change. Use --amount, --invoice-date, --due-date, --label or --collection.");
270
+ }
271
+ return writeCommand(parsed, {
272
+ action: body.askFamily
273
+ ? `propose a change to tuition installment ${installmentId} and EMAIL the family to approve it (nothing changes until they do)`
274
+ : `change tuition installment ${installmentId} now, without the family's consent (an invoiced installment is voided and reissued)`,
275
+ target: { installmentId },
276
+ request: body,
277
+ }, async () => shown(unwrap(await api.client.PATCH("/admin/tuition-billing/installments/{installmentId}", { params: { path: { installmentId } }, body })).schedule));
278
+ }
279
+ if (verb === "add") {
280
+ const scheduleId = positional(parsed, 2, "schedule ID");
281
+ const amountCents = centsFlag(parsed, "amount");
282
+ const invoiceDate = dateFlag(parsed, "invoice-date");
283
+ const dueDate = dateFlag(parsed, "due-date");
284
+ if (amountCents === undefined || !invoiceDate || !dueDate) {
285
+ throw new CliError("invalid_arguments", "Use --label TEXT --amount DOLLARS --invoice-date YYYY-MM-DD --due-date YYYY-MM-DD.");
286
+ }
287
+ const collection = choiceFlag(parsed, "collection", COLLECTIONS);
288
+ const note = textFlag(parsed, "note");
289
+ const body = {
290
+ label: textFlag(parsed, "label", true),
291
+ amountCents,
292
+ invoiceDate,
293
+ dueDate,
294
+ ...(collection ? { collection } : {}),
295
+ ...(note ? { note } : {}),
296
+ ...askFamily(parsed),
297
+ };
298
+ return writeCommand(parsed, {
299
+ action: `add a ${dollars(amountCents)} installment to tuition schedule ${scheduleId}`,
300
+ target: { scheduleId },
301
+ request: body,
302
+ }, async () => shown(unwrap(await api.client.POST("/admin/tuition-billing/{scheduleId}/installments", { params: { path: { scheduleId } }, body })).schedule));
303
+ }
304
+ if (verb === "release") {
305
+ const installmentId = positional(parsed, 2, "installment ID");
306
+ const note = textFlag(parsed, "note");
307
+ const body = note ? { note } : {};
308
+ return writeCommand(parsed, {
309
+ action: `release tuition installment ${installmentId} from review: it is still owed and will be scheduled`,
310
+ target: { installmentId },
311
+ request: body,
312
+ }, async () => shown(unwrap(await api.client.POST("/admin/tuition-billing/installments/{installmentId}/release", { params: { path: { installmentId } }, body })).schedule));
313
+ }
314
+ if (verb === "void" || verb === "reopen") {
315
+ const installmentId = positional(parsed, 2, "installment ID");
316
+ const body = {
317
+ reason: textFlag(parsed, "reason", true),
318
+ ...(verb === "void" ? askFamily(parsed) : {}),
319
+ };
320
+ return writeCommand(parsed, {
321
+ action: verb === "void"
322
+ ? "askFamily" in body
323
+ ? `propose voiding tuition installment ${installmentId} and EMAIL the family to approve it`
324
+ : `void tuition installment ${installmentId} now, without the family's consent (a sent invoice is voided in Stripe)`
325
+ : `reopen tuition installment ${installmentId}: it goes back to review and any staff-recorded payment is cleared`,
326
+ target: { installmentId },
327
+ request: body,
328
+ }, async () => shown(unwrap(verb === "void"
329
+ ? await api.client.POST("/admin/tuition-billing/installments/{installmentId}/void", { params: { path: { installmentId } }, body })
330
+ : await api.client.POST("/admin/tuition-billing/installments/{installmentId}/reopen", {
331
+ params: { path: { installmentId } },
332
+ body: { reason: body.reason },
333
+ })).schedule));
334
+ }
335
+ if (verb === "mark-paid") {
336
+ const installmentId = positional(parsed, 2, "installment ID");
337
+ const paidCents = centsFlag(parsed, "paid");
338
+ const paidOn = dateFlag(parsed, "paid-on");
339
+ const body = {
340
+ note: textFlag(parsed, "note", true),
341
+ ...(paidCents !== undefined ? { paidCents } : {}),
342
+ ...(paidOn ? { paidOn } : {}),
343
+ };
344
+ return writeCommand(parsed, {
345
+ action: `mark tuition installment ${installmentId} as paid outside Recess`,
346
+ target: { installmentId },
347
+ request: body,
348
+ }, async () => shown(unwrap(await api.client.POST("/admin/tuition-billing/installments/{installmentId}/mark-paid", { params: { path: { installmentId } }, body })).schedule));
349
+ }
350
+ if (verb === "pause" || verb === "resume" || verb === "set") {
351
+ const scheduleId = positional(parsed, 2, "schedule ID");
352
+ const note = textFlag(parsed, "note");
353
+ const payer = choiceFlag(parsed, "payer", PAYERS);
354
+ const defaultCollection = choiceFlag(parsed, "collection", COLLECTIONS);
355
+ const auto = choiceFlag(parsed, "auto-invoice", {
356
+ on: "on",
357
+ off: "off",
358
+ });
359
+ const body = verb === "pause"
360
+ ? { paused: true, ...(note ? { pausedNote: note } : {}) }
361
+ : verb === "resume"
362
+ ? { paused: false }
363
+ : {
364
+ ...(payer ? { payer } : {}),
365
+ ...(defaultCollection ? { defaultCollection } : {}),
366
+ ...(auto ? { autoInvoice: auto === "on" } : {}),
367
+ };
368
+ if (Object.keys(body).length === 0) {
369
+ throw new CliError("invalid_arguments", "Nothing to change. Use --payer family|az-esa|fl-scholarship|partner-school, --collection invoice|auto-charge|out-of-band, or --auto-invoice on|off.");
370
+ }
371
+ return writeCommand(parsed, {
372
+ action: verb === "pause"
373
+ ? `pause tuition schedule ${scheduleId}: nothing on it is drafted or sent while paused`
374
+ : verb === "resume"
375
+ ? `resume tuition schedule ${scheduleId}`
376
+ : `change tuition schedule ${scheduleId}'s settings${"autoInvoice" in body ? ` (automatic invoicing ${body.autoInvoice ? "ON: the daily run drafts, sends and chases its invoices" : "OFF"})` : ""}`,
377
+ target: { scheduleId },
378
+ request: body,
379
+ }, async () => shown(unwrap(await api.client.PATCH("/admin/tuition-billing/{scheduleId}", {
380
+ params: { path: { scheduleId } },
381
+ body,
382
+ })).schedule));
383
+ }
384
+ if (verb === "summary") {
385
+ const summary = unwrap(await api.client.GET("/admin/tuition-billing/summary"));
386
+ if (json)
387
+ return summary;
388
+ const t = summary.totals;
389
+ const a = summary.attention;
390
+ return [
391
+ `Tuition billing as of ${summary.today} (automatic invoicing ${summary.invoicingEnabled ? "on" : "off"} on this server)`,
392
+ "",
393
+ `Sold ${dollars(t.contracted.cents)} (${t.contracted.count} installments)`,
394
+ `Collected ${dollars(t.collected.cents)}`,
395
+ `Invoiced, open ${dollars(t.invoicedOpen.cents)} (${t.invoicedOpen.count})`,
396
+ `Past due ${dollars(t.pastDue.cents)} (${t.pastDue.count})`,
397
+ `Not yet invoiced ${dollars(t.notYetInvoiced.cents)} (${t.notYetInvoiced.count})`,
398
+ `Due in 30 days ${dollars(t.dueNext30Days.cents)} (${t.dueNext30Days.count})`,
399
+ `Earned ${dollars(t.earnedCents)} (uncollected ${dollars(t.earnedUncollectedCents)}, collected ahead ${dollars(t.collectedAheadCents)})`,
400
+ `Partner schools ${dollars(summary.partner.received.cents)} received of ${dollars(summary.partner.contracted.cents)}, ${dollars(summary.partner.overdue.cents)} overdue`,
401
+ "",
402
+ `Needs review ${a.needsReview} · invoiced by hand ${a.manualInvoicing} · changes waiting for family ${a.awaitingFamily} · applied without consent ${a.appliedWithoutConsent} · written notice due ${a.formalNoticeDue} · failed payments ${a.paymentFailed} · paused ${a.paused}`,
403
+ ...(summary.pastDue.length
404
+ ? [
405
+ "",
406
+ "Past due:",
407
+ renderColumns([
408
+ ["Due", "Days late", "Student", "Parent", "Owed", "Schedule"],
409
+ ...summary.pastDue.map((row) => [
410
+ row.dueDate,
411
+ String(row.daysPastDue),
412
+ row.kidName,
413
+ row.parentEmail,
414
+ dollars(row.outstandingCents),
415
+ row.scheduleId,
416
+ ]),
417
+ ]),
418
+ ]
419
+ : []),
420
+ ].join("\n");
421
+ }
422
+ if (verb === "draft" || verb === "send" || verb === "pull-back") {
423
+ const installmentId = positional(parsed, 2, "installment ID");
424
+ const path = { installmentId };
425
+ if (verb === "pull-back") {
426
+ const body = { reason: textFlag(parsed, "reason", true) };
427
+ return writeCommand(parsed, {
428
+ action: `pull back the Stripe draft for tuition installment ${installmentId}: the draft is deleted and the installment can be edited again`,
429
+ target: path,
430
+ request: body,
431
+ }, async () => shown(unwrap(await api.client.POST("/admin/tuition-billing/installments/{installmentId}/pull-back", { params: { path }, body })).schedule));
432
+ }
433
+ return writeCommand(parsed, {
434
+ action: verb === "draft"
435
+ ? `create the Stripe draft invoice for tuition installment ${installmentId}`
436
+ : `finalize the invoice for tuition installment ${installmentId} and EMAIL the family the payment request now`,
437
+ target: path,
438
+ request: {},
439
+ }, async () => shown(unwrap(verb === "draft"
440
+ ? await api.client.POST("/admin/tuition-billing/installments/{installmentId}/draft", { params: { path } })
441
+ : await api.client.POST("/admin/tuition-billing/installments/{installmentId}/send", { params: { path } })).schedule));
442
+ }
443
+ if (verb === "email") {
444
+ const installmentId = positional(parsed, 2, "installment ID");
445
+ const kind = choiceFlag(parsed, "kind", {
446
+ request: "REQUEST",
447
+ reminder: "REMINDER",
448
+ "past-due": "PAST_DUE",
449
+ }) ?? "REQUEST";
450
+ const body = { kind };
451
+ return writeCommand(parsed, {
452
+ action: `EMAIL the family about sent tuition installment ${installmentId} again (${kind.toLowerCase().replace("_", "-")})`,
453
+ target: { installmentId },
454
+ request: body,
455
+ }, async () => shown(unwrap(await api.client.POST("/admin/tuition-billing/installments/{installmentId}/email", { params: { path: { installmentId } }, body })).schedule));
456
+ }
457
+ if (verb === "retry-change") {
458
+ const revisionId = positional(parsed, 2, "change (revision) ID");
459
+ return writeCommand(parsed, {
460
+ action: `finish plan change ${revisionId}, which stopped partway (may cancel and reissue Stripe invoices and EMAIL the family new ones)`,
461
+ target: { revisionId },
462
+ request: {},
463
+ }, async () => shown(unwrap(await api.client.POST("/admin/tuition-billing/revisions/{revisionId}/retry", { params: { path: { revisionId } } })).schedule));
464
+ }
465
+ if (verb === "resend-approval" ||
466
+ verb === "record-consent" ||
467
+ verb === "withdraw") {
468
+ const revisionId = positional(parsed, 2, "change (revision) ID");
469
+ const path = { revisionId };
470
+ if (verb === "resend-approval") {
471
+ return writeCommand(parsed, {
472
+ action: `EMAIL the family the approval link for plan change ${revisionId} again`,
473
+ target: path,
474
+ request: {},
475
+ }, async () => shown(unwrap(await api.client.POST("/admin/tuition-billing/revisions/{revisionId}/resend", { params: { path } })).schedule));
476
+ }
477
+ if (verb === "record-consent") {
478
+ const body = { note: textFlag(parsed, "note", true) };
479
+ return writeCommand(parsed, {
480
+ action: `record the family's consent to plan change ${revisionId} (a change waiting for them is applied now)`,
481
+ target: path,
482
+ request: body,
483
+ }, async () => shown(unwrap(await api.client.POST("/admin/tuition-billing/revisions/{revisionId}/consent", { params: { path }, body })).schedule));
484
+ }
485
+ const body = { reason: textFlag(parsed, "reason", true) };
486
+ return writeCommand(parsed, {
487
+ action: `withdraw plan change ${revisionId}: nothing on the plan changes`,
488
+ target: path,
489
+ request: body,
490
+ }, async () => shown(unwrap(await api.client.POST("/admin/tuition-billing/revisions/{revisionId}/cancel", { params: { path }, body })).schedule));
491
+ }
492
+ if (verb === "auto-invoice") {
493
+ const mode = positional(parsed, 2, "on|off");
494
+ if (mode !== "on" && mode !== "off") {
495
+ throw new CliError("invalid_arguments", "Use `recess tuition auto-invoice on|off`.");
496
+ }
497
+ const scheduleIds = parsed.positionals.slice(3);
498
+ const all = hasFlag(parsed, "all");
499
+ if (!all && scheduleIds.length === 0) {
500
+ throw new CliError("invalid_arguments", "Name schedule IDs, or pass --all for every live schedule set the other way.");
501
+ }
502
+ const body = {
503
+ enabled: mode === "on",
504
+ ...(all ? { all: true } : { scheduleIds }),
505
+ };
506
+ const preview = unwrap(await api.client.POST("/admin/tuition-billing/auto-invoice", {
507
+ body: { ...body, dryRun: true },
508
+ }));
509
+ return writeCommand(parsed, {
510
+ action: `turn automatic invoicing ${mode.toUpperCase()} for ${preview.count} tuition schedule(s)${mode === "on" ? ": the daily run will draft, send and chase their invoices" : ""}`,
511
+ target: { scheduleIds: preview.scheduleIds },
512
+ request: body,
513
+ }, async () => unwrap(await api.client.POST("/admin/tuition-billing/auto-invoice", { body })));
514
+ }
515
+ throw new CliError("invalid_arguments", "Usage: recess tuition summary|list|show|edit|add|release|void|reopen|mark-paid|draft|send|pull-back|email|resend-approval|record-consent|withdraw|retry-change|auto-invoice|pause|resume|set. See `recess help`.");
516
+ }
517
+ //# sourceMappingURL=tuition.js.map
package/dist/help.js CHANGED
@@ -387,6 +387,27 @@ Usage:
387
387
  [--esa-award DOLLARS | --esa-award-unknown [--esa-scenarios DOLLARS,...]] [--custom-plan JSON|@file] [--custom-only]
388
388
  [--pdf <path>] [--open]
389
389
  recess [--json] tuition-plans states
390
+ recess [--json] tuition summary
391
+ recess [--json] tuition list [--status NEEDS_REVIEW|SCHEDULED|DRAFTED|SENT|PAID|PAID_OUT_OF_BAND|VOID] [--family <family-id>] [--packet <packet-id>] [--q TEXT] [--limit N]
392
+ recess [--json] tuition show <schedule-id>
393
+ recess [--json] tuition edit <installment-id> [--amount DOLLARS] [--invoice-date YYYY-MM-DD] [--due-date YYYY-MM-DD] [--label TEXT] [--collection invoice|auto-charge|out-of-band|default] [--note TEXT] [--ask-family [--family-note TEXT]] [--confirm]
394
+ recess [--json] tuition add <schedule-id> --label TEXT --amount DOLLARS --invoice-date YYYY-MM-DD --due-date YYYY-MM-DD [--collection invoice|auto-charge|out-of-band] [--note TEXT] [--ask-family [--family-note TEXT]] [--confirm]
395
+ recess [--json] tuition release <installment-id> [--note TEXT] [--confirm]
396
+ recess [--json] tuition void <installment-id> --reason TEXT [--ask-family [--family-note TEXT]] [--confirm]
397
+ recess [--json] tuition reopen <installment-id> --reason TEXT [--confirm]
398
+ recess [--json] tuition mark-paid <installment-id> --note TEXT [--paid DOLLARS] [--paid-on YYYY-MM-DD] [--confirm]
399
+ recess [--json] tuition draft <installment-id> [--confirm]
400
+ recess [--json] tuition send <installment-id> [--confirm]
401
+ recess [--json] tuition pull-back <installment-id> --reason TEXT [--confirm]
402
+ recess [--json] tuition email <installment-id> [--kind request|reminder|past-due] [--confirm]
403
+ recess [--json] tuition resend-approval <change-id> [--confirm]
404
+ recess [--json] tuition record-consent <change-id> --note TEXT [--confirm]
405
+ recess [--json] tuition withdraw <change-id> --reason TEXT [--confirm]
406
+ recess [--json] tuition retry-change <change-id> [--confirm]
407
+ recess [--json] tuition auto-invoice on|off (<schedule-id>... | --all) [--confirm]
408
+ recess [--json] tuition pause <schedule-id> [--note TEXT] [--confirm]
409
+ recess [--json] tuition resume <schedule-id> [--confirm]
410
+ recess [--json] tuition set <schedule-id> [--payer family|az-esa|fl-scholarship|partner-school] [--collection invoice|auto-charge|out-of-band] [--auto-invoice on|off] [--confirm]
390
411
  recess [--json] admissions create --school <institution-slug> --enrollment direct|partner-school|program
391
412
  [--partner-school <slug|id>] --parent "First Last" --email EMAIL [--phone TEXT] --state XX
392
413
  --kid "First Last:YYYY-MM-DD[:grade]" (repeat per child) [--existing-kid USER_ID[:grade]]...
@@ -1571,6 +1592,27 @@ export const COMMAND_SUMMARIES = {
1571
1592
  "channels members remove": "Remove members from a channel (soft).",
1572
1593
  "tuition-plans generate": "Compute a tuition plan sheet (web URL, optional PDF); stores nothing.",
1573
1594
  "tuition-plans states": "List states supported by tuition plans.",
1595
+ "tuition summary": "Billing totals (sold, collected, past due, earned) and the past-due list.",
1596
+ "tuition list": "List tuition schedules built from signed admission packets.",
1597
+ "tuition show": "One tuition schedule: its installments, the signed plan, the history.",
1598
+ "tuition edit": "Change an installment now (invoiced: void and reissue), or --ask-family first.",
1599
+ "tuition add": "Add an installment that was not on the signed plan.",
1600
+ "tuition release": "Release a past-dated installment from review.",
1601
+ "tuition void": "Void an installment (a Stripe draft is deleted, a sent invoice voided).",
1602
+ "tuition draft": "Create an installment's Stripe draft invoice now.",
1603
+ "tuition send": "Finalize an installment's invoice and email the family the payment request.",
1604
+ "tuition pull-back": "Delete an installment's Stripe draft so it can be edited.",
1605
+ "tuition email": "Email the family about a sent installment again (request, reminder, past-due).",
1606
+ "tuition resend-approval": "Email the family the approval link for a plan change waiting for them again.",
1607
+ "tuition record-consent": "Record a family's consent to a plan change (applies one still waiting).",
1608
+ "tuition withdraw": "Withdraw a plan change waiting for the family.",
1609
+ "tuition retry-change": "Finish a plan change that stopped partway.",
1610
+ "tuition auto-invoice": "Turn automatic invoicing on/off for schedules (--all: every one set the other way).",
1611
+ "tuition reopen": "Undo a void or a staff-recorded payment (back to review).",
1612
+ "tuition mark-paid": "Record an installment paid outside Recess.",
1613
+ "tuition pause": "Hold everything on a tuition schedule.",
1614
+ "tuition resume": "Resume a paused tuition schedule.",
1615
+ "tuition set": "Change a schedule's payer, default collection or automatic invoicing.",
1574
1616
  "placement give": "Give a kid the math or reading placement quest as a todo.",
1575
1617
  "placement show": "One kid's placement answers, mistakes, timing and sounds check.",
1576
1618
  "placement results": "Kids' placement quest results beside their latest MAP score.",
@@ -1856,6 +1898,7 @@ export const NOUN_SUMMARIES = {
1856
1898
  me: "Your own to-dos and challenges (a parent learning too).",
1857
1899
  channels: "Community channels and their members.",
1858
1900
  "tuition-plans": "Compute tuition plan sheets (stores nothing).",
1901
+ tuition: "Tuition billing: totals, schedules, invoices, and family approval of changes.",
1859
1902
  placement: "Give placement quests, one kid's results, results vs MAP, question bank, mastery sync.",
1860
1903
  feed: "Post messages to users' feeds.",
1861
1904
  changelog: "Preview, test and send changelog posts, and read past sends.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recess-cli",
3
- "version": "3.54.0",
3
+ "version": "3.55.0",
4
4
  "description": "Safe Recess administration and family AI tools from the command line.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -46,8 +46,8 @@
46
46
  "oxlint-tsgolint": "^0.6.0",
47
47
  "typescript": "^5.9.2",
48
48
  "vitest": "^1.6.0",
49
- "@tryrecess/typescript-config": "0.0.0",
50
- "@tryrecess/api-types": "0.0.0"
49
+ "@tryrecess/api-types": "0.0.0",
50
+ "@tryrecess/typescript-config": "0.0.0"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "node node_modules/@tryrecess/typescript-config/bin/tsc-fast.mjs",