@usethrottle/auth 0.8.0 → 0.10.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/index.d.cts CHANGED
@@ -164,6 +164,18 @@ interface Invoice {
164
164
  sourceType: string | null;
165
165
  /** Frozen at issue — the lines actually billed, not the order's lines today. */
166
166
  lineItems: InvoiceLineItem[];
167
+ /**
168
+ * Set when the invoice bills less than the order: the order total its lines
169
+ * add up to. `total` is then the amount due (Net-N invoice) or the amount
170
+ * paid (a deposit receipt). Null when the invoice bills the whole order.
171
+ */
172
+ orderTotal: number | null;
173
+ /** Net-N invoices: paid on the order before this invoice (e.g. a deposit). */
174
+ amountPaid: number | null;
175
+ /** Net-N invoices: waived by a comp. */
176
+ compWaived: number | null;
177
+ /** Deposit receipts: the balance still due, billed on the Net-N invoice. */
178
+ balanceDue: number | null;
167
179
  /** Resolved on the detail read only; null on list rows and when the hop fails. */
168
180
  orderId: string | null;
169
181
  orderNumber: string | null;
package/dist/index.d.ts CHANGED
@@ -164,6 +164,18 @@ interface Invoice {
164
164
  sourceType: string | null;
165
165
  /** Frozen at issue — the lines actually billed, not the order's lines today. */
166
166
  lineItems: InvoiceLineItem[];
167
+ /**
168
+ * Set when the invoice bills less than the order: the order total its lines
169
+ * add up to. `total` is then the amount due (Net-N invoice) or the amount
170
+ * paid (a deposit receipt). Null when the invoice bills the whole order.
171
+ */
172
+ orderTotal: number | null;
173
+ /** Net-N invoices: paid on the order before this invoice (e.g. a deposit). */
174
+ amountPaid: number | null;
175
+ /** Net-N invoices: waived by a comp. */
176
+ compWaived: number | null;
177
+ /** Deposit receipts: the balance still due, billed on the Net-N invoice. */
178
+ balanceDue: number | null;
167
179
  /** Resolved on the detail read only; null on list rows and when the hop fails. */
168
180
  orderId: string | null;
169
181
  orderNumber: string | null;
@@ -1209,6 +1209,12 @@ var enUS = {
1209
1209
  viewSubscription: "View subscription",
1210
1210
  payButton: "Pay this invoice",
1211
1211
  billedTo: "Billed to",
1212
+ /** Shown when an invoice bills less than the order, matching the PDF. */
1213
+ orderTotal: "Order total",
1214
+ amountPaid: "Amount paid",
1215
+ waived: "Waived",
1216
+ amountDue: "Amount due",
1217
+ balanceDue: "Balance due",
1212
1218
  /** Display copy for `invoice.status` — the wire values are paid|open|void. */
1213
1219
  statusLabels: { paid: "Paid", open: "Open", void: "Void" },
1214
1220
  downloadUnavailable: "This invoice is not available to download right now."
@@ -3797,6 +3803,21 @@ function formatDate(value, locale) {
3797
3803
  return date.toISOString().slice(0, 10);
3798
3804
  }
3799
3805
  }
3806
+ function scheduleDueLabel(row, locale) {
3807
+ if (row.intervalUnit !== "hour") return formatDate(row.dueAt, locale);
3808
+ const date = new Date(row.dueAt);
3809
+ if (Number.isNaN(date.getTime())) return "";
3810
+ const opts = {
3811
+ dateStyle: "medium",
3812
+ timeStyle: "short",
3813
+ timeZone: "UTC"
3814
+ };
3815
+ try {
3816
+ return `${new Intl.DateTimeFormat(locale, opts).format(date)} UTC`;
3817
+ } catch {
3818
+ return `${new Intl.DateTimeFormat("en-US", opts).format(date)} UTC`;
3819
+ }
3820
+ }
3800
3821
 
3801
3822
  // src/react/components/account/OrderStatus.tsx
3802
3823
  var import_jsx_runtime36 = require("react/jsx-runtime");
@@ -4224,6 +4245,9 @@ function InvoiceDetail(props) {
4224
4245
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelState, { resource, isEmpty: (i) => i === null, emptyTitle: t.invoices.empty, skeletonRows: 4, children: (invoice) => {
4225
4246
  const money = (v) => formatMoney(v, invoice.currency, locale);
4226
4247
  const lines = invoice.lineItems ?? [];
4248
+ const partOfOrder = invoice.orderTotal != null;
4249
+ const isDepositReceipt = partOfOrder && invoice.balanceDue != null;
4250
+ const headlineLabel = !partOfOrder ? t.invoices.total : isDepositReceipt ? t.invoices.amountPaid : t.invoices.amountDue;
4227
4251
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.layout", "throttle-detail"), children: [
4228
4252
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.main", "throttle-detail__main"), children: [
4229
4253
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-detail__section", children: [
@@ -4257,10 +4281,14 @@ function InvoiceDetail(props) {
4257
4281
  ] }),
4258
4282
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("aside", { ...a.el("invoiceDetail.rail", "throttle-detail__rail"), children: [
4259
4283
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-detail__section", children: [
4260
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__label", children: t.invoices.total }),
4284
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__label", children: headlineLabel }),
4261
4285
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__headline", children: money(invoice.total) })
4262
4286
  ] }),
4263
4287
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.totals", "throttle-totals"), children: [
4288
+ partOfOrder ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.orderTotal, value: money(invoice.orderTotal) }) : null,
4289
+ partOfOrder && invoice.amountPaid ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.amountPaid, value: `-${money(invoice.amountPaid)}` }) : null,
4290
+ partOfOrder && invoice.compWaived ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.waived, value: `-${money(invoice.compWaived)}` }) : null,
4291
+ isDepositReceipt && invoice.balanceDue ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.balanceDue, value: money(invoice.balanceDue) }) : null,
4264
4292
  invoice.dueAt ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.due, value: formatDate(invoice.dueAt, locale) }) : null,
4265
4293
  invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4266
4294
  Line2,
@@ -4483,12 +4511,15 @@ function SubscriptionsPanel(props) {
4483
4511
  const nextPaymentLabel = (sub) => {
4484
4512
  if (!isVariedSchedule(sub.paymentSchedule) || !sub.paymentSchedule || sub.nextPaymentAmount == null) return null;
4485
4513
  const upcoming = sub.paymentSchedule.find((r) => r.status !== "paid");
4486
- return t.subscriptions.installmentNext.replace("{amount}", formatMoney(sub.nextPaymentAmount, sub.currency, locale)).replace("{date}", formatDate(upcoming?.dueAt ?? sub.currentPeriodEnd, locale));
4514
+ return t.subscriptions.installmentNext.replace("{amount}", formatMoney(sub.nextPaymentAmount, sub.currency, locale)).replace(
4515
+ "{date}",
4516
+ upcoming?.dueAt ? scheduleDueLabel({ dueAt: upcoming.dueAt, intervalUnit: upcoming.intervalUnit }, locale) : formatDate(sub.currentPeriodEnd, locale)
4517
+ );
4487
4518
  };
4488
4519
  const upcomingList = (sub) => {
4489
4520
  const upcoming = upcomingSchedulePayments(sub.paymentSchedule);
4490
4521
  if (upcoming.length === 0) return null;
4491
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("ul", { className: "throttle-muted", "aria-label": t.subscriptions.upcomingPayments, children: upcoming.map((r) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("li", { children: t.subscriptions.upcomingPayment.replace("{amount}", formatMoney(r.net, sub.currency, locale)).replace("{date}", formatDate(r.dueAt, locale)) }, r.dueAt)) });
4522
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("ul", { className: "throttle-muted", "aria-label": t.subscriptions.upcomingPayments, children: upcoming.map((r) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("li", { children: t.subscriptions.upcomingPayment.replace("{amount}", formatMoney(r.net, sub.currency, locale)).replace("{date}", scheduleDueLabel(r, locale)) }, r.dueAt)) });
4492
4523
  };
4493
4524
  const renewsLabel = (sub) => formatDate(
4494
4525
  sub.status === "completed" ? sub.completedAt ?? sub.currentPeriodEnd : sub.status === "cancelled" ? sub.cancelledAt ?? sub.currentPeriodEnd : sub.currentPeriodEnd,