recess-cli 3.20.0 → 3.21.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/args.js CHANGED
@@ -26,6 +26,7 @@ export const BOOLEAN_FLAGS = new Set([
26
26
  "custom-only",
27
27
  "no-agreement",
28
28
  "paywall-offline",
29
+ "override-aid-price",
29
30
  "no-email",
30
31
  "no-paywall",
31
32
  "no-text",
@@ -70,6 +70,22 @@ function renderAnswers(responses, questions) {
70
70
  }
71
71
  return lines;
72
72
  }
73
+ /** Which aid application the new packet carries and where its price came from. */
74
+ function aidLines(aid, priceSource) {
75
+ const how = {
76
+ explicit: "named with --financial-aid",
77
+ application: "the application's own aid form",
78
+ email: "matched by the parent's email",
79
+ };
80
+ return [
81
+ aid
82
+ ? `Financial aid: application ${aid.id} (${how[aid.matchedBy]}), ${aid.reviewed ? `reviewed${aid.determinedAnnualTuition !== null ? `, $${aid.determinedAnnualTuition.toLocaleString("en-US")}/yr after aid` : ""}` : "not reviewed yet"}.`
83
+ : "Financial aid: none attached.",
84
+ ...(priceSource === "aid_review"
85
+ ? ["Annual price taken from the aid review (no --annual given)."]
86
+ : []),
87
+ ];
88
+ }
73
89
  function renderPacket(packet, admissionUrl, questions = []) {
74
90
  const when = (iso) => (iso ? iso.slice(0, 10) : "–");
75
91
  const out = [
@@ -78,7 +94,7 @@ function renderPacket(packet, admissionUrl, questions = []) {
78
94
  `${packet.enrollmentType === "PARTNER_SCHOOL" ? `Through ${packet.partnerSchool?.name ?? "partner school"}` : packet.enrollmentType === "PROGRAM" ? "Online learning program" : "Direct enrollment"} · ${packet.institution.name} · tier ${packet.tierId}${packet.paywallOutOfBand ? ` · out-of-band paywall${packet.paywallCents ? ` ${dollars(packet.paywallCents)}` : " (the signed plan's first invoice)"}` : packet.paywallCents ? ` · paywall ${dollars(packet.paywallCents)}` : " · no paywall"}`,
79
95
  `Status: ${packet.status} (${STEP_LABELS[packet.step]})${packet.noAgreement ? " · no tuition agreement" : ""}`,
80
96
  packet.financialAidApplication
81
- ? `Financial aid answers in the envelope: application ${packet.financialAidApplication.id} (${packet.financialAidApplication.createdAt.slice(0, 10)})`
97
+ ? `Financial aid answers in the envelope: application ${packet.financialAidApplication.id} (${packet.financialAidApplication.createdAt.slice(0, 10)})${packet.financialAidApplication.determinedAnnualTuition !== null && packet.kids.length > 1 ? ` · reviewed at $${packet.financialAidApplication.determinedAnnualTuition.toLocaleString("en-US")}/yr for the family (the plan's annual is per child)` : packet.financialAidApplication.determinedAnnualTuition !== null ? ` · reviewed at $${packet.financialAidApplication.determinedAnnualTuition.toLocaleString("en-US")}/yr after aid${Number(packet.planSpec.annualTuition) === packet.financialAidApplication.determinedAnnualTuition || packet.noAgreement ? "" : ` (plan uses $${Number(packet.planSpec.annualTuition).toLocaleString("en-US")}${packet.financialAidApplication.reviewedAt && packet.financialAidApplication.reviewedAt > packet.planSetAt && !packet.paidAt ? ": the review changed since, requote to match" : ""})`}` : " · not reviewed"}`
82
98
  : "No financial aid application attached (nothing to initial).",
83
99
  "",
84
100
  renderColumns([
@@ -275,7 +291,10 @@ export async function runAdmissionsCommand({ parsed, api, writeCommand, }) {
275
291
  (flagString(parsed, "start") || flagString(parsed, "annual"))) {
276
292
  throw new CliError("invalid_arguments", "--no-agreement takes no tuition plan; drop --start/--annual and the other plan flags.");
277
293
  }
278
- const plan = noAgreement ? null : parseTuitionPlanSpecFlags(parsed);
294
+ // No --annual: the server prices the plan from the aid review.
295
+ const plan = noAgreement
296
+ ? null
297
+ : parseTuitionPlanSpecFlags(parsed, { annualOptional: true });
279
298
  const offline = hasFlag(parsed, "paywall-offline");
280
299
  if (noAgreement && offline) {
281
300
  throw new CliError("invalid_arguments", "--paywall-offline bills the signed plan's first invoice, so it needs an agreement. Use --paywall DOLLARS instead.");
@@ -301,6 +320,9 @@ export async function runAdmissionsCommand({ parsed, api, writeCommand, }) {
301
320
  ...(flagString(parsed, "financial-aid")
302
321
  ? { financialAidApplicationId: flagString(parsed, "financial-aid") }
303
322
  : {}),
323
+ ...(hasFlag(parsed, "override-aid-price")
324
+ ? { overrideAidPrice: true }
325
+ : {}),
304
326
  institutionSlug: flagString(parsed, "school", { required: true }),
305
327
  enrollment,
306
328
  ...(partnerSchool ? { partnerSchool } : {}),
@@ -326,7 +348,7 @@ export async function runAdmissionsCommand({ parsed, api, writeCommand, }) {
326
348
  sendEmail: !hasFlag(parsed, "no-email"),
327
349
  };
328
350
  return writeCommand(parsed, {
329
- action: `create an admission packet${noAgreement ? " without a tuition agreement" : ""} for ${body.parentEmail} (${kids.map((k) => k.firstName).join(", ")}) and ${body.sendEmail ? "email them the link" : "return the link without emailing"}`,
351
+ action: `create an admission packet${noAgreement ? " without a tuition agreement" : plan && plan.annualTuition === undefined ? " priced from the reviewed financial aid application" : ""} for ${body.parentEmail} (${kids.map((k) => k.firstName).join(", ")}) and ${body.sendEmail ? "email them the link" : "return the link without emailing"}`,
330
352
  target: { parentEmail: body.parentEmail, school: body.institutionSlug },
331
353
  request: body,
332
354
  ...(warnings.length ? { details: { warnings } } : {}),
@@ -347,10 +369,16 @@ export async function runAdmissionsCommand({ parsed, api, writeCommand, }) {
347
369
  "No tuition agreement: the parent goes from the account to consent.",
348
370
  ]),
349
371
  "",
372
+ ...aidLines(result.financialAid, result.priceSource),
350
373
  result.emailed
351
374
  ? `Emailed ${result.packet.parentEmail}.`
352
375
  : "Not emailed (--no-email); send the link yourself.",
353
376
  ...warnings.map((w) => `Warning: ${w}`),
377
+ ...(result.financialAid?.matchedBy === "email"
378
+ ? [
379
+ `Warning: the aid application was matched by email only (no aid form on the application). If it is the wrong one, void this packet and recreate it with --financial-aid <id> or --financial-aid none.`,
380
+ ]
381
+ : []),
354
382
  ].join("\n"),
355
383
  };
356
384
  });
@@ -413,7 +441,10 @@ export async function runAdmissionsCommand({ parsed, api, writeCommand, }) {
413
441
  if (keepPlan && dropAgreement) {
414
442
  throw new CliError("invalid_arguments", "Use --keep-plan, --no-agreement or new plan flags, not a mix.");
415
443
  }
416
- const plan = keepPlan || dropAgreement ? null : parseTuitionPlanSpecFlags(parsed);
444
+ // No --annual: the server takes the packet's reviewed aid price.
445
+ const plan = keepPlan || dropAgreement
446
+ ? null
447
+ : parseTuitionPlanSpecFlags(parsed, { annualOptional: true });
417
448
  const paywallRaw = flagString(parsed, "paywall")?.replace(/[$,]/g, "");
418
449
  const paywall = paywallRaw === undefined ? undefined : Number(paywallRaw);
419
450
  if (paywall !== undefined && (!Number.isFinite(paywall) || paywall <= 0)) {
@@ -437,6 +468,9 @@ export async function runAdmissionsCommand({ parsed, api, writeCommand, }) {
437
468
  const body = {
438
469
  ...(plan ? { plan: plan } : {}),
439
470
  ...(dropAgreement ? { noAgreement: true } : {}),
471
+ ...(hasFlag(parsed, "override-aid-price")
472
+ ? { overrideAidPrice: true }
473
+ : {}),
440
474
  ...(offlinePaywall
441
475
  ? { paywallOutOfBand: true }
442
476
  : paywallCents !== undefined
@@ -456,6 +490,57 @@ export async function runAdmissionsCommand({ parsed, api, writeCommand, }) {
456
490
  return json ? result : { help: await render(result.packet) };
457
491
  });
458
492
  }
493
+ if (verb === "attach-aid") {
494
+ // A financial aid form that arrived after the packet went out. The price
495
+ // is not changed here; when the review disagrees with the plan the packet
496
+ // is flagged for a requote, which also puts the aid answers in the envelope.
497
+ const packetId = positional(parsed, 2, "packet ID");
498
+ const raw = flagString(parsed, "financial-aid", { required: true }).trim();
499
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
500
+ if (raw !== "none" && !UUID.test(raw)) {
501
+ throw new CliError("invalid_arguments", "--financial-aid takes a financial aid application id, or none to detach.");
502
+ }
503
+ const financialAidApplicationId = raw === "none" ? null : raw;
504
+ return writeCommand(parsed, {
505
+ action: financialAidApplicationId
506
+ ? `attach financial aid application ${financialAidApplicationId} to admission packet ${packetId}`
507
+ : `detach the financial aid application from admission packet ${packetId}`,
508
+ target: { packetId },
509
+ request: { financialAidApplicationId },
510
+ }, async () => {
511
+ const result = unwrap(await api.client.POST("/admin/admissions/{packetId}/financial-aid", {
512
+ params: { path: { packetId } },
513
+ body: { financialAidApplicationId },
514
+ }));
515
+ if (json)
516
+ return result;
517
+ const p = result.packet;
518
+ const reviewed = p.financialAidApplication?.determinedAnnualTuition ?? null;
519
+ const annual = Number(p.planSpec.annualTuition);
520
+ const differs = reviewed !== null &&
521
+ p.kids.length === 1 &&
522
+ !p.noAgreement &&
523
+ Number.isFinite(annual) &&
524
+ annual !== reviewed;
525
+ return {
526
+ help: [
527
+ financialAidApplicationId ? "Attached." : "Detached.",
528
+ ...(result.resigning
529
+ ? [
530
+ "Signing had started, so the packet was requoted on its current plan: the family signs again with the new aid answers.",
531
+ ]
532
+ : []),
533
+ ...(differs
534
+ ? [
535
+ `The aid review ($${reviewed.toLocaleString("en-US")}/yr) differs from the plan ($${annual.toLocaleString("en-US")}/yr). Requote to match: recess admissions requote ${packetId} --start ... (leave out --annual to use the review).`,
536
+ ]
537
+ : []),
538
+ "",
539
+ await render(p),
540
+ ].join("\n"),
541
+ };
542
+ });
543
+ }
459
544
  if (verb === "archive-agreement") {
460
545
  const packetId = positional(parsed, 2, "packet ID");
461
546
  return writeCommand(parsed, {
@@ -105,14 +105,14 @@ function renderPlan(plan, webUrl, pdfPath) {
105
105
  out.push(`PDF: ${pdfPath}`);
106
106
  return out.join("\n");
107
107
  }
108
- /**
109
- * The tuition-plan flags that describe the plan itself (everything but who
110
- * it is for): shared by `tuition-plans generate` and `admissions create`,
111
- * which stores them as the packet's plan spec.
112
- */
113
- export function parseTuitionPlanSpecFlags(parsed) {
114
- const annual = Number(requiredFlag(parsed, "annual").replace(/[$,]/g, ""));
115
- if (!Number.isFinite(annual) || annual <= 0) {
108
+ export function parseTuitionPlanSpecFlags(parsed, options) {
109
+ const annualRaw = options?.annualOptional && flagString(parsed, "annual") === undefined
110
+ ? undefined
111
+ : requiredFlag(parsed, "annual");
112
+ const annual = annualRaw === undefined
113
+ ? undefined
114
+ : Number(annualRaw.replace(/[$,]/g, ""));
115
+ if (annual !== undefined && (!Number.isFinite(annual) || annual <= 0)) {
116
116
  throw new CliError("invalid_arguments", "--annual must be a positive dollar amount (net of Recess financial aid).");
117
117
  }
118
118
  // Add-on overrides; omitted = the server's school-pricing defaults.
@@ -256,7 +256,7 @@ export function parseTuitionPlanSpecFlags(parsed) {
256
256
  };
257
257
  return {
258
258
  startDate: requiredFlag(parsed, "start", ISO_DATE),
259
- annualTuition: annual,
259
+ ...(annual !== undefined ? { annualTuition: annual } : {}),
260
260
  stateFunding: hasFlag(parsed, "state-funding") ? "true" : "false",
261
261
  ...addOnQuery,
262
262
  ...subsetQuery,
package/dist/help.js CHANGED
@@ -271,7 +271,7 @@ Usage:
271
271
  [--application <application-id>]
272
272
  [--financial-aid <financial-aid-application-id>|none]
273
273
  [--tier complete] [--paywall DOLLARS|--paywall-offline] [--staff-note TEXT]... [--no-email]
274
- (--no-agreement | --start YYYY-MM-DD --annual DOLLARS) [--state-funding] [--end YYYY-MM-DD]
274
+ (--no-agreement | --start YYYY-MM-DD [--annual DOLLARS] [--override-aid-price]) [--state-funding] [--end YYYY-MM-DD]
275
275
  [--terms full-year,school-year,custom] [--payments upfront,installments] [--note TEXT]...
276
276
  [--bill-date upfront|N=YYYY-MM-DD]... [--due-date upfront|N=YYYY-MM-DD]... [--amount N=DOLLARS]... [--even-installments] [--force-direct]
277
277
  [--esa-award DOLLARS | --esa-award-unknown [--esa-scenarios DOLLARS,...]] [--custom-plan JSON|@file] [--custom-only]
@@ -282,9 +282,10 @@ Usage:
282
282
  recess [--json] admissions resend <packet-id> [--no-email] [--confirm]
283
283
  recess [--json] admissions void <packet-id> --reason TEXT [--confirm]
284
284
  recess [--json] admissions mark-signed <packet-id> --option <term:payment> [--note TEXT] [--confirm]
285
- recess [--json] admissions requote <packet-id> (--keep-plan | --no-agreement | --start YYYY-MM-DD --annual DOLLARS [plan flags as in create])
285
+ recess [--json] admissions requote <packet-id> (--keep-plan | --no-agreement | --start YYYY-MM-DD [--annual DOLLARS] [--override-aid-price] [plan flags as in create])
286
286
  [--paywall DOLLARS|--paywall-offline|--no-paywall] [--note TEXT] [--confirm]
287
287
  recess [--json] admissions archive-agreement <packet-id> [--confirm]
288
+ recess [--json] admissions attach-aid <packet-id> --financial-aid <financial-aid-application-id>|none [--confirm]
288
289
  recess [--json] admissions mark-paid <packet-id> [--note TEXT] [--confirm]
289
290
  recess [--json] admissions set-paywall <packet-id> (--paywall DOLLARS | --paywall-offline | --no-paywall) [--note TEXT] [--confirm]
290
291
  recess [--json] admissions contract <packet-id> [--option <term:payment>] [--out <file>]
@@ -932,7 +933,12 @@ instead of creating one: the kid must be in the family of the guardian who owns
932
933
  --email, the parent signs in with that account to start, and the kid's account,
933
934
  tier and history are left as they are. The envelope opens with the family's financial aid answers
934
935
  for them to initial as true; they come from --financial-aid, else the application's
935
- aid form, else the newest aid form under the parent's email ("none" leaves it out). "resend" mints a new link (the old one dies) and emails
936
+ aid form, else the newest aid form under the parent's email ("none" leaves it out); create
937
+ prints which one it attached and warns when it was an email match. The plan's price comes
938
+ from that aid form's review: leave --annual out and the reviewed annual (after Recess aid)
939
+ is used for a one-child packet (the review is the family's total; with more children give
940
+ the per-child --annual); an --annual that differs from a reviewed price is refused unless
941
+ --override-aid-price is given (requote checks the packet's aid form the same way). "resend" mints a new link (the old one dies) and emails
936
942
  it. "get" prints the agreed plan as signed (each child's option, term and every
937
943
  installment) and whether the signed agreement is archived in our storage; the
938
944
  copy is taken when the envelope completes, and "archive-agreement" retries it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recess-cli",
3
- "version": "3.20.0",
3
+ "version": "3.21.0",
4
4
  "description": "Safe Recess administration and family AI tools from the command line.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {