recess-cli 3.55.0 → 3.56.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
@@ -7,6 +7,7 @@ import { CliError } from "./errors.js";
7
7
  export const REPEATABLE_FLAGS = new Set([
8
8
  "amount",
9
9
  "bill-date",
10
+ "installment",
10
11
  "due-date",
11
12
  "existing-kid",
12
13
  "kid",
@@ -1,5 +1,5 @@
1
1
  import { unwrap } from "../api.js";
2
- import { flagString, hasFlag } from "../args.js";
2
+ import { flagList, flagString, hasFlag } from "../args.js";
3
3
  import { CliError } from "../errors.js";
4
4
  import { assertChoice, positional, renderColumns, } from "./shared.js";
5
5
  const STATUSES = [
@@ -50,7 +50,7 @@ function renderSchedule({ schedule, signed, events, revisions, }) {
50
50
  ...schedule.installments.map((row) => [
51
51
  String(row.sequence),
52
52
  row.status,
53
- `${dollars(row.amountCents)}${row.creditedCents ? ` (${dollars(row.amountCents - row.creditedCents)} after credit)` : ""}${row.refundedCents ? ` (${dollars(row.refundedCents)} refunded)` : ""}`,
53
+ `${dollars(row.amountCents)}${row.creditedCents ? ` (${dollars(row.amountCents - row.creditedCents)} after credit)` : ""}${row.refundedCents ? ` (${dollars(row.refundedCents)} refunded)` : ""}${row.feeCents ? ` (${dollars(row.feeCents)} fee withheld)` : ""}`,
54
54
  row.invoiceDate,
55
55
  row.dueDate,
56
56
  row.collection,
@@ -276,6 +276,83 @@ export async function runTuitionCommand({ parsed, api, writeCommand, }) {
276
276
  request: body,
277
277
  }, async () => shown(unwrap(await api.client.PATCH("/admin/tuition-billing/installments/{installmentId}", { params: { path: { installmentId } }, body })).schedule));
278
278
  }
279
+ if (verb === "create") {
280
+ const kidUserId = textFlag(parsed, "student", true);
281
+ if (!UUID.test(kidUserId)) {
282
+ throw new CliError("invalid_arguments", "--student must be a kid ID.");
283
+ }
284
+ const stateCode = textFlag(parsed, "state", true).toUpperCase();
285
+ if (!/^[A-Z]{2}$/.test(stateCode)) {
286
+ throw new CliError("invalid_arguments", "--state is a two-letter code.");
287
+ }
288
+ const enrollmentType = choiceFlag(parsed, "enrollment", {
289
+ direct: "DIRECT",
290
+ "partner-school": "PARTNER_SCHOOL",
291
+ program: "PROGRAM",
292
+ });
293
+ if (!enrollmentType) {
294
+ throw new CliError("invalid_arguments", "Missing required --enrollment direct|partner-school|program.");
295
+ }
296
+ const partnerSchoolSlug = textFlag(parsed, "partner-school");
297
+ if (enrollmentType === "PARTNER_SCHOOL" && !partnerSchoolSlug) {
298
+ throw new CliError("invalid_arguments", "--enrollment partner-school needs --partner-school <slug>.");
299
+ }
300
+ const partner = enrollmentType === "PARTNER_SCHOOL";
301
+ const payer = choiceFlag(parsed, "payer", PAYERS) ??
302
+ (partner ? "PARTNER_SCHOOL" : "FAMILY");
303
+ const defaultCollection = choiceFlag(parsed, "collection", COLLECTIONS) ??
304
+ (partner ? "OUT_OF_BAND" : "EMAIL_INVOICE");
305
+ const specs = flagList(parsed, "installment");
306
+ if (!specs.length) {
307
+ throw new CliError("invalid_arguments", 'Add at least one --installment "LABEL|DOLLARS|INVOICE-DATE|DUE-DATE[|SERVICE-START|SERVICE-END]".');
308
+ }
309
+ const installments = specs.map((spec) => {
310
+ const [label, amount, invoiceDate, dueDate, serviceStart, serviceEnd] = spec.split("|").map((part) => part.trim());
311
+ const raw = amount?.replace(/^\$/, "").replaceAll(",", "");
312
+ const dates = [invoiceDate, dueDate, serviceStart, serviceEnd].filter((d) => d !== undefined && d !== "");
313
+ if (!label ||
314
+ !raw ||
315
+ !/^\d+(\.\d{1,2})?$/.test(raw) ||
316
+ Number(raw) <= 0 ||
317
+ !invoiceDate ||
318
+ !dueDate ||
319
+ dates.some((d) => !ISO_DATE.test(d))) {
320
+ throw new CliError("invalid_arguments", `Bad --installment "${spec}": use "LABEL|DOLLARS|INVOICE-DATE|DUE-DATE[|SERVICE-START|SERVICE-END]".`);
321
+ }
322
+ return {
323
+ label,
324
+ amountCents: Math.round(Number(raw) * 100),
325
+ invoiceDate,
326
+ dueDate,
327
+ ...(serviceStart ? { serviceStart } : {}),
328
+ ...(serviceEnd ? { serviceEnd } : {}),
329
+ };
330
+ });
331
+ const note = textFlag(parsed, "note");
332
+ const body = {
333
+ kidUserId,
334
+ institutionSlug: textFlag(parsed, "school") ?? "recess-academy",
335
+ enrollmentType,
336
+ ...(partnerSchoolSlug ? { partnerSchoolSlug } : {}),
337
+ stateCode,
338
+ payer,
339
+ defaultCollection,
340
+ installments,
341
+ ...(note ? { note } : {}),
342
+ };
343
+ const { preview } = unwrap(await api.client.POST("/admin/tuition-billing/", {
344
+ body: { ...body, dryRun: true },
345
+ }));
346
+ return writeCommand(parsed, {
347
+ action: `record a ${dollars(preview.totalCents)} tuition schedule (${installments.length} installment(s), payer ${payer}, ${defaultCollection}) for ${preview.kidName} with no signed packet. Nothing is emailed; automatic invoicing stays off`,
348
+ target: { kidUserId },
349
+ request: body,
350
+ details: preview,
351
+ }, async () => {
352
+ const { schedule } = unwrap(await api.client.POST("/admin/tuition-billing/", { body }));
353
+ return shown(schedule);
354
+ });
355
+ }
279
356
  if (verb === "add") {
280
357
  const scheduleId = positional(parsed, 2, "schedule ID");
281
358
  const amountCents = centsFlag(parsed, "amount");
@@ -335,14 +412,16 @@ export async function runTuitionCommand({ parsed, api, writeCommand, }) {
335
412
  if (verb === "mark-paid") {
336
413
  const installmentId = positional(parsed, 2, "installment ID");
337
414
  const paidCents = centsFlag(parsed, "paid");
415
+ const feeCents = centsFlag(parsed, "fee");
338
416
  const paidOn = dateFlag(parsed, "paid-on");
339
417
  const body = {
340
418
  note: textFlag(parsed, "note", true),
341
419
  ...(paidCents !== undefined ? { paidCents } : {}),
420
+ ...(feeCents !== undefined ? { feeCents } : {}),
342
421
  ...(paidOn ? { paidOn } : {}),
343
422
  };
344
423
  return writeCommand(parsed, {
345
- action: `mark tuition installment ${installmentId} as paid outside Recess`,
424
+ action: `mark tuition installment ${installmentId} as paid outside Recess${feeCents ? ` (${dollars(feeCents)} withheld as a fee before it reached us)` : ""}`,
346
425
  target: { installmentId },
347
426
  request: body,
348
427
  }, async () => shown(unwrap(await api.client.POST("/admin/tuition-billing/installments/{installmentId}/mark-paid", { params: { path: { installmentId } }, body })).schedule));
@@ -512,6 +591,6 @@ export async function runTuitionCommand({ parsed, api, writeCommand, }) {
512
591
  request: body,
513
592
  }, async () => unwrap(await api.client.POST("/admin/tuition-billing/auto-invoice", { body })));
514
593
  }
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`.");
594
+ throw new CliError("invalid_arguments", "Usage: recess tuition summary|list|show|create|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
595
  }
517
596
  //# sourceMappingURL=tuition.js.map
package/dist/help.js CHANGED
@@ -391,11 +391,12 @@ Usage:
391
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
392
  recess [--json] tuition show <schedule-id>
393
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 create --student <kid-id> --state XX --enrollment direct|partner-school|program [--partner-school <slug>] [--school <institution-slug>] [--payer family|az-esa|fl-scholarship|partner-school] [--collection invoice|auto-charge|out-of-band] --installment "LABEL|DOLLARS|INVOICE-DATE|DUE-DATE[|SERVICE-START|SERVICE-END]"... [--note TEXT] [--confirm]
394
395
  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
396
  recess [--json] tuition release <installment-id> [--note TEXT] [--confirm]
396
397
  recess [--json] tuition void <installment-id> --reason TEXT [--ask-family [--family-note TEXT]] [--confirm]
397
398
  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 mark-paid <installment-id> --note TEXT [--paid DOLLARS] [--fee DOLLARS] [--paid-on YYYY-MM-DD] [--confirm]
399
400
  recess [--json] tuition draft <installment-id> [--confirm]
400
401
  recess [--json] tuition send <installment-id> [--confirm]
401
402
  recess [--json] tuition pull-back <installment-id> --reason TEXT [--confirm]
@@ -1596,6 +1597,7 @@ export const COMMAND_SUMMARIES = {
1596
1597
  "tuition list": "List tuition schedules built from signed admission packets.",
1597
1598
  "tuition show": "One tuition schedule: its installments, the signed plan, the history.",
1598
1599
  "tuition edit": "Change an installment now (invoiced: void and reissue), or --ask-family first.",
1600
+ "tuition create": "Record a tuition schedule for a kid with no signed packet (sends nothing).",
1599
1601
  "tuition add": "Add an installment that was not on the signed plan.",
1600
1602
  "tuition release": "Release a past-dated installment from review.",
1601
1603
  "tuition void": "Void an installment (a Stripe draft is deleted, a sent invoice voided).",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recess-cli",
3
- "version": "3.55.0",
3
+ "version": "3.56.0",
4
4
  "description": "Safe Recess administration and family AI tools from the command line.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {