@saasicat/core 1.0.0-rc.23 → 1.0.0-rc.25

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.js CHANGED
@@ -11,7 +11,8 @@ function buildActivePlanVersionWhere(asOf, options = {}) {
11
11
  const asOfDayStart = startOfUtcDay(asOf);
12
12
  const validityWindow = [
13
13
  { OR: [{ validFrom: null }, { validFrom: { lte: asOf } }] },
14
- { OR: [{ validUntil: null }, { validUntil: { gte: asOfDayStart } }] }
14
+ { OR: [{ validUntil: null }, { validUntil: { gte: asOfDayStart } }] },
15
+ { OR: [{ supersededAt: null }, { validUntil: { not: null } }] }
15
16
  ];
16
17
  if (!options.withEndsAt) {
17
18
  return { publishedAt: { not: null }, AND: validityWindow };
@@ -21,6 +22,16 @@ function buildActivePlanVersionWhere(asOf, options = {}) {
21
22
  AND: [...validityWindow, { OR: [{ endsAt: null }, { endsAt: { gt: asOf } }] }]
22
23
  };
23
24
  }
25
+ function isVersionActiveAt(version, asOf) {
26
+ const at = (value) => value === null || value === void 0 ? null : new Date(value);
27
+ const validFrom = at(version.validFrom);
28
+ const validUntil = at(version.validUntil);
29
+ const endsAt = at(version.endsAt);
30
+ if (validFrom && validFrom > asOf) return false;
31
+ if (validUntil && validUntil < startOfUtcDay(asOf)) return false;
32
+ if (version.supersededAt && !validUntil) return false;
33
+ return !(endsAt && endsAt <= asOf);
34
+ }
24
35
  var buildActiveVersionWhere = buildActivePlanVersionWhere;
25
36
 
26
37
  // src/bundle-draft-defaults.ts
@@ -74,6 +85,79 @@ function definedFields(data, keys) {
74
85
  var MARKETING_PRIORITY_MIN = 0;
75
86
  var MARKETING_PRIORITY_MAX = 1e4;
76
87
 
88
+ // src/money.ts
89
+ var HUNDRED = { units: 100n, scale: 0 };
90
+ function exactDecimal(value) {
91
+ if (!Number.isFinite(value)) {
92
+ throw new RangeError(`${String(value)} is not an amount money can be computed from.`);
93
+ }
94
+ const text = String(value);
95
+ const exponentAt = text.indexOf("e");
96
+ const mantissa = exponentAt === -1 ? text : text.slice(0, exponentAt);
97
+ const exponent = exponentAt === -1 ? 0 : Number(text.slice(exponentAt + 1));
98
+ const pointAt = mantissa.indexOf(".");
99
+ const whole = pointAt === -1 ? mantissa : mantissa.slice(0, pointAt);
100
+ const fraction = pointAt === -1 ? "" : mantissa.slice(pointAt + 1);
101
+ let units = BigInt(whole + fraction);
102
+ let scale = fraction.length - exponent;
103
+ if (scale < 0) {
104
+ units *= 10n ** BigInt(-scale);
105
+ scale = 0;
106
+ }
107
+ return { units, scale };
108
+ }
109
+ function sum(a, b) {
110
+ const scale = Math.max(a.scale, b.scale);
111
+ return {
112
+ units: a.units * 10n ** BigInt(scale - a.scale) + b.units * 10n ** BigInt(scale - b.scale),
113
+ scale
114
+ };
115
+ }
116
+ function roundHalfAwayFromZero(numerator, denominator) {
117
+ if (denominator === 0n) throw new RangeError("An amount cannot be divided by zero.");
118
+ const negative = numerator < 0n !== denominator < 0n;
119
+ const n = numerator < 0n ? -numerator : numerator;
120
+ const d = denominator < 0n ? -denominator : denominator;
121
+ const quotient = n / d;
122
+ const rounded = n % d * 2n >= d ? quotient + 1n : quotient;
123
+ return negative ? -rounded : rounded;
124
+ }
125
+ function cents(amount, factor, divisor) {
126
+ const numerator = amount.units * factor.units * 10n ** BigInt(divisor.scale) * 100n;
127
+ const denominator = divisor.units * 10n ** BigInt(amount.scale + factor.scale);
128
+ return roundHalfAwayFromZero(numerator, denominator);
129
+ }
130
+ function amountOf(inCents) {
131
+ return Number(inCents) / 100;
132
+ }
133
+ var ONE = { units: 1n, scale: 0 };
134
+ function roundToCents(amount) {
135
+ return amountOf(cents(exactDecimal(amount), ONE, ONE));
136
+ }
137
+ function sumToCents(...terms) {
138
+ const total = terms.map(exactDecimal).reduce(sum, { units: 0n, scale: 0 });
139
+ return amountOf(cents(total, ONE, ONE));
140
+ }
141
+ function toCents(amount) {
142
+ return Number(cents(exactDecimal(amount), ONE, ONE));
143
+ }
144
+ function percentOf(amount, percent) {
145
+ return amountOf(cents(exactDecimal(amount), exactDecimal(percent), HUNDRED));
146
+ }
147
+ function prorate(amount, part, whole) {
148
+ return amountOf(cents(exactDecimal(amount), exactDecimal(part), exactDecimal(whole)));
149
+ }
150
+ function grossFromNet(net, vatRate) {
151
+ return amountOf(cents(exactDecimal(net), sum(HUNDRED, exactDecimal(vatRate)), HUNDRED));
152
+ }
153
+ function netFromGross(gross, vatRate) {
154
+ return amountOf(cents(exactDecimal(gross), HUNDRED, sum(HUNDRED, exactDecimal(vatRate))));
155
+ }
156
+ function computeIncludedVat(gross, vatRate) {
157
+ const rate = exactDecimal(vatRate);
158
+ return amountOf(cents(exactDecimal(gross), rate, sum(HUNDRED, rate)));
159
+ }
160
+
77
161
  // src/promotion.types.ts
78
162
  function promoStatus(promo, today = /* @__PURE__ */ new Date()) {
79
163
  const from = new Date(promo.validFrom);
@@ -96,7 +180,9 @@ function boundedPromo(promo, basePrice) {
96
180
  const pct = withinBounds(promo.value, 100);
97
181
  return {
98
182
  kind: "percent",
99
- discounted: Math.round(basePrice * (100 - pct)) / 100,
183
+ // The discount is rounded and taken off, as a promo code's is: two
184
+ // rules for one percentage would state two prices for it.
185
+ discounted: sumToCents(basePrice, -percentOf(basePrice, pct)),
100
186
  original: basePrice,
101
187
  pct
102
188
  };
@@ -105,7 +191,7 @@ function boundedPromo(promo, basePrice) {
105
191
  const saved = withinBounds(promo.value, basePrice);
106
192
  return {
107
193
  kind: "amount",
108
- discounted: Math.round((basePrice - saved) * 100) / 100,
194
+ discounted: sumToCents(basePrice, -saved),
109
195
  original: basePrice,
110
196
  saved
111
197
  };
@@ -283,11 +369,222 @@ function appendNullableDecimalChange(out, field, oldValue, newValue, polarity) {
283
369
  appendDecimalChange(out, field, oldValue, newValue, polarity);
284
370
  }
285
371
 
372
+ // src/version-offer.ts
373
+ function takesSomethingAway(change) {
374
+ if (change.direction !== "REGRESSION") return false;
375
+ return change.field === "features.removed" || change.field.startsWith("quotas.");
376
+ }
377
+ function classifyVersionOffer(bound, candidate) {
378
+ const { changes } = classifyBundleVersionDiff(bound, candidate);
379
+ if (changes.some(takesSomethingAway)) return { class: "takes-something-away", changes };
380
+ if (changes.some((change) => change.direction === "REGRESSION")) {
381
+ return { class: "more-for-more", changes };
382
+ }
383
+ return { class: changes.length > 0 ? "improvement" : "same", changes };
384
+ }
385
+
286
386
  // src/maintenance-window.types.ts
287
387
  var MAINTENANCE_MESSAGE_MAX_LENGTH = 500;
288
388
  var MAINTENANCE_STATE_MAX_AGE_SECONDS = 5;
289
389
  var MAINTENANCE_CAPABILITY = "maintenance.manage";
290
390
 
391
+ // src/closed-value.ts
392
+ function oneOf(allowed, value, source) {
393
+ const match = allowed.find((entry) => entry === value);
394
+ if (match === void 0) {
395
+ throw new Error(
396
+ `${source.table} row '${source.id}' holds ${source.column} '${value}', which is none of ${allowed.join(", ")}.`
397
+ );
398
+ }
399
+ return match;
400
+ }
401
+
402
+ // src/subscription-notice-mapping.ts
403
+ var TABLE = "subscription_notices";
404
+ var KINDS = {
405
+ "version-offered": true,
406
+ "version-retired": true,
407
+ "version-retirement-reminder": true,
408
+ "bundle-version-retired": true,
409
+ "bundle-version-retirement-reminder": true,
410
+ "bundle-version-offered": true
411
+ };
412
+ function toSubscriptionNoticeRecord(row) {
413
+ return {
414
+ id: row.id,
415
+ tenantId: row.tenantId,
416
+ subscriptionId: row.subscriptionId,
417
+ kind: oneOf(Object.keys(KINDS), row.kind, {
418
+ table: TABLE,
419
+ column: "kind",
420
+ id: row.id
421
+ }),
422
+ subject: row.subject,
423
+ content: row.content,
424
+ createdAt: row.createdAt,
425
+ claimedAt: row.claimedAt,
426
+ deliveredAt: row.deliveredAt,
427
+ delivery: row.deliveredAt === null ? null : deliveryOf(row)
428
+ };
429
+ }
430
+ function deliveryOf(row) {
431
+ const { recipients, channel } = row;
432
+ if (!Array.isArray(recipients) || !recipients.every((recipient) => typeof recipient === "string") || channel === null) {
433
+ throw new Error(
434
+ `${TABLE} row '${row.id}' is delivered, but its recipients are not a list of strings or its channel is missing.`
435
+ );
436
+ }
437
+ return { recipients: [...recipients], channel };
438
+ }
439
+
440
+ // src/version-sale.ts
441
+ var DAY_MS = 24 * 60 * 60 * 1e3;
442
+ function versionSale(version, now) {
443
+ if (!version.publishedAt) return { kind: "draft" };
444
+ if (isVersionActiveAt(version, now)) {
445
+ return { kind: "on-sale", until: lastDayOnSale(version) };
446
+ }
447
+ const start = dateOf(version.validFrom);
448
+ if (start && start > now && isVersionActiveAt(version, start)) {
449
+ return { kind: "scheduled", from: dayOf(start) };
450
+ }
451
+ return { kind: "off-sale", since: firstDayOffSale(version, now) };
452
+ }
453
+ function versionOnSale(versions, now) {
454
+ const onSale = versions.filter((v) => versionSale(v, now).kind === "on-sale");
455
+ const startOf = (v) => dateOf(v.validFrom)?.getTime() ?? -Infinity;
456
+ onSale.sort((a, b) => startOf(b) - startOf(a) || (b.version ?? 0) - (a.version ?? 0));
457
+ return onSale[0] ?? null;
458
+ }
459
+ function versionOnSaleOrNext(versions, now) {
460
+ const onSale = versionOnSale(versions, now);
461
+ if (onSale) return onSale;
462
+ const scheduled = versions.filter((v) => versionSale(v, now).kind === "scheduled");
463
+ const startOf = (v) => dateOf(v.validFrom)?.getTime() ?? Infinity;
464
+ scheduled.sort((a, b) => startOf(a) - startOf(b));
465
+ return scheduled[0] ?? null;
466
+ }
467
+ function lastDayOnSale(version) {
468
+ const days = [];
469
+ const validUntil = dateOf(version.validUntil);
470
+ if (validUntil) days.push(dayOf(validUntil));
471
+ const endsAt = dateOf(version.endsAt);
472
+ if (endsAt) days.push(dayOf(new Date(endsAt.getTime() - 1)));
473
+ return earliest(days);
474
+ }
475
+ function firstDayOffSale(version, now) {
476
+ const days = [];
477
+ const validUntil = dateOf(version.validUntil);
478
+ if (validUntil && dayOf(validUntil) < dayOf(now)) {
479
+ days.push(dayOf(new Date(validUntil.getTime() + DAY_MS)));
480
+ }
481
+ const endsAt = dateOf(version.endsAt);
482
+ if (endsAt && endsAt <= now) days.push(dayOf(new Date(endsAt.getTime() - 1 + DAY_MS)));
483
+ return earliest(days);
484
+ }
485
+ function earliest(days) {
486
+ return days.length === 0 ? null : days.reduce((a, b) => a < b ? a : b);
487
+ }
488
+ function dateOf(value) {
489
+ if (value === null || value === void 0) return null;
490
+ const date = new Date(value);
491
+ return Number.isNaN(date.getTime()) ? null : date;
492
+ }
493
+ function dayOf(date) {
494
+ return date.toISOString().slice(0, 10);
495
+ }
496
+
497
+ // src/version-retirement.types.ts
498
+ var VERSION_RETIREMENT_CAPABILITY = "planVersions.retire";
499
+
500
+ // src/version-retirement-mapping.ts
501
+ function toVersionRetirementRecord(row) {
502
+ return {
503
+ id: row.id,
504
+ retired: {
505
+ planVersionId: row.retiredPlanVersionId,
506
+ planKey: row.retiredPlanKey,
507
+ version: row.retiredVersion
508
+ },
509
+ replacement: {
510
+ planVersionId: row.replacementPlanVersionId,
511
+ planKey: row.replacementPlanKey,
512
+ version: row.replacementVersion
513
+ },
514
+ announcedAt: row.announcedAt,
515
+ announcedBy: row.announcedBy
516
+ };
517
+ }
518
+
519
+ // src/bundle-version-retirement.types.ts
520
+ var BUNDLE_VERSION_RETIREMENT_CAPABILITY = "bundleVersions.retire";
521
+
522
+ // src/bundle-version-retirement-mapping.ts
523
+ function toBundleVersionRetirementRecord(row) {
524
+ return {
525
+ id: row.id,
526
+ retired: {
527
+ bundleVersionId: row.retiredBundleVersionId,
528
+ bundleKey: row.retiredBundleKey,
529
+ version: row.retiredVersion
530
+ },
531
+ replacement: {
532
+ bundleVersionId: row.replacementBundleVersionId,
533
+ bundleKey: row.replacementBundleKey,
534
+ version: row.replacementVersion
535
+ },
536
+ announcedAt: row.announcedAt,
537
+ announcedBy: row.announcedBy
538
+ };
539
+ }
540
+
541
+ // src/scheduled-change-after-write.ts
542
+ var NO_SCHEDULED_CHANGE = {
543
+ pendingPlan: null,
544
+ pendingBillingCycle: null,
545
+ pendingEffectiveAt: null,
546
+ pendingChangeVersionId: null
547
+ };
548
+ function scheduledChangeAfterWrite(current, input) {
549
+ if (!input.keepsPendingChange) return NO_SCHEDULED_CHANGE;
550
+ const movesOnlyTheRhythm = current.pendingPlan === current.plan && current.pendingChangeVersionId === null;
551
+ return movesOnlyTheRhythm && current.plan !== input.planId ? { pendingPlan: input.planId } : {};
552
+ }
553
+
554
+ // src/retirement-switch.ts
555
+ function retirementSwitchTerms(notice, billingCycle) {
556
+ const priceIn = (side) => billingCycle === "YEARLY" ? side.yearlyNet : side.monthlyNet;
557
+ const replacement = priceIn(notice.replacement);
558
+ if (replacement === null) return null;
559
+ const retired = priceIn(notice.retired);
560
+ if (retired === null || replacement <= retired) return { priceNet: replacement, held: null };
561
+ return {
562
+ priceNet: replacement,
563
+ held: {
564
+ priceNet: retired,
565
+ amountNet: sumToCents(replacement, -retired),
566
+ // The last day to cancel without notice is the same day: the last
567
+ // whole one before the date the replacement takes over.
568
+ lastDay: notice.lastDayToCancel
569
+ }
570
+ };
571
+ }
572
+
573
+ // src/retirement-reminder.ts
574
+ var RETIREMENT_REMINDER_LEAD_DAYS = 14;
575
+ var DAY_MS2 = 24 * 60 * 60 * 1e3;
576
+ function retirementReminderDueAt(notice) {
577
+ return new Date(Date.parse(notice.effectiveAt) - RETIREMENT_REMINDER_LEAD_DAYS * DAY_MS2);
578
+ }
579
+ function retirementReminderIsDue(notice, now) {
580
+ return retirementReminderDueAt(notice) <= now && now.getTime() < Date.parse(notice.effectiveAt);
581
+ }
582
+ function retirementCostsTheSubscription(notice, billingCycle) {
583
+ if (notice.changes.some(takesSomethingAway)) return true;
584
+ const terms = retirementSwitchTerms(notice, billingCycle);
585
+ return terms === null || terms.held !== null;
586
+ }
587
+
291
588
  // src/maintenance-window-mapping.ts
292
589
  function toMaintenanceWindowRecord(row) {
293
590
  return {
@@ -494,11 +791,42 @@ var CATALOG_ERROR_CODES = {
494
791
  PLAN_TERMINATE_INVALID_DATE: "PLAN_TERMINATE_INVALID_DATE",
495
792
  PLAN_TERMINATE_DATE_NOT_FUTURE: "PLAN_TERMINATE_DATE_NOT_FUTURE",
496
793
  PLAN_TERMINATE_NOT_IMPLEMENTED: "PLAN_TERMINATE_NOT_IMPLEMENTED",
794
+ /**
795
+ * Subscriptions told of a retirement still move onto this version, and
796
+ * nothing moves onto a version that has ended. Carries the version, its
797
+ * plan key and the first day it may end: the day after the last move.
798
+ */
799
+ PLAN_TERMINATE_BEFORE_RETIREMENT_MOVES: "PLAN_TERMINATE_BEFORE_RETIREMENT_MOVES",
800
+ /**
801
+ * Subscriptions told of a retirement are past their date and still to be
802
+ * moved onto this version — a move the platform could not make yet — so it
803
+ * cannot end until they have moved. Carries how many, the version and its
804
+ * plan key.
805
+ */
806
+ PLAN_TERMINATE_WHILE_MOVES_OVERDUE: "PLAN_TERMINATE_WHILE_MOVES_OVERDUE",
807
+ /**
808
+ * Subscriptions on a retired version have not yet been told of their move
809
+ * onto this version — their notice has reached nobody, so their date is not
810
+ * set — and it cannot end until they have been. Carries how many, the
811
+ * version and its plan key.
812
+ */
813
+ PLAN_TERMINATE_WHILE_NOTICES_UNDELIVERED: "PLAN_TERMINATE_WHILE_NOTICES_UNDELIVERED",
497
814
  // ── bundle versions ──
498
815
  BUNDLE_VERSION_ALREADY_PUBLISHED: "BUNDLE_VERSION_ALREADY_PUBLISHED",
499
816
  BUNDLE_VERSION_NOT_EDITABLE: "BUNDLE_VERSION_NOT_EDITABLE",
500
817
  BUNDLE_VERSION_NOT_PUBLISHED: "BUNDLE_VERSION_NOT_PUBLISHED",
501
818
  BUNDLE_VERSION_SUPERSEDED: "BUNDLE_VERSION_SUPERSEDED",
819
+ /**
820
+ * The bundle version is published, and its window has not opened: it goes
821
+ * on sale on `validFrom`, and until then its predecessor is the one sold.
822
+ */
823
+ BUNDLE_VERSION_NOT_YET_ON_SALE: "BUNDLE_VERSION_NOT_YET_ON_SALE",
824
+ /**
825
+ * The add-on itself has been deleted from the catalogue. Deleting it leaves
826
+ * its versions' dates as they were, so the version asked for can still be
827
+ * inside its window; it is not on offer all the same.
828
+ */
829
+ BUNDLE_DELETED: "BUNDLE_DELETED",
502
830
  BUNDLE_VERSION_REGRESSION: "BUNDLE_VERSION_REGRESSION",
503
831
  BUNDLE_VERSION_ZERO_PRICE: "BUNDLE_VERSION_ZERO_PRICE",
504
832
  BUNDLE_VERSION_NO_PRICE: "BUNDLE_VERSION_NO_PRICE",
@@ -517,6 +845,13 @@ var CATALOG_ERROR_CODES = {
517
845
  PLAN_NOT_FOUND: "PLAN_NOT_FOUND",
518
846
  PLAN_VERSION_NOT_FOUND: "PLAN_VERSION_NOT_FOUND",
519
847
  BUNDLE_NOT_FOUND: "BUNDLE_NOT_FOUND",
848
+ /**
849
+ * Bookings told that their add-on version is being retired have still to
850
+ * move onto a version of this add-on — waiting for their notice, for their
851
+ * date, or past it — and a deleted add-on is booked by nothing, the move
852
+ * included. Carries how many, and the add-on's key.
853
+ */
854
+ BUNDLE_DELETE_WHILE_RETIREMENT_MOVES_PENDING: "BUNDLE_DELETE_WHILE_RETIREMENT_MOVES_PENDING",
520
855
  BUNDLE_VERSION_NOT_FOUND: "BUNDLE_VERSION_NOT_FOUND",
521
856
  FEATURE_NOT_FOUND: "FEATURE_NOT_FOUND",
522
857
  QUOTA_NOT_FOUND: "QUOTA_NOT_FOUND",
@@ -557,6 +892,22 @@ var BILLING_ERROR_CODES = {
557
892
  BUNDLE_NOT_SELF_SERVICE: "BUNDLE_NOT_SELF_SERVICE",
558
893
  BUNDLE_CYCLE_EXCEEDS_PLAN: "BUNDLE_CYCLE_EXCEEDS_PLAN",
559
894
  BUNDLE_NOT_PRICED_FOR_THIS_PLAN: "BUNDLE_NOT_PRICED_FOR_THIS_PLAN",
895
+ /**
896
+ * The bundle cannot run on a plan the subscription is already set to move
897
+ * to — by a scheduled change, or by a retirement it has been told of — and
898
+ * the booking would still be running then: that plan does not book it, or
899
+ * has no price for it. Carries that plan's key, the rhythm it is billed in
900
+ * there, and the day the move takes effect from, which can lie in the past
901
+ * while the move has not run yet.
902
+ */
903
+ BUNDLE_CANNOT_RUN_ON_UPCOMING_PLAN: "BUNDLE_CANNOT_RUN_ON_UPCOMING_PLAN",
904
+ /**
905
+ * As `BUNDLE_CANNOT_RUN_ON_UPCOMING_PLAN`, where only the rhythm stands in
906
+ * the way: a yearly bundle, and the subscription billed monthly from the
907
+ * day of the move — a switch of rhythm on the plan it keeps, for one, where
908
+ * naming the plan would point at the one it is already on. Same values.
909
+ */
910
+ BUNDLE_CANNOT_RUN_ON_UPCOMING_CYCLE: "BUNDLE_CANNOT_RUN_ON_UPCOMING_CYCLE",
560
911
  SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED: "SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED",
561
912
  SUBSCRIPTION_BUNDLE_NOT_CANCELLED: "SUBSCRIPTION_BUNDLE_NOT_CANCELLED",
562
913
  SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE: "SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE",
@@ -576,6 +927,12 @@ var BILLING_ERROR_CODES = {
576
927
  * in it: a plan without a yearly price is a monthly plan.
577
928
  */
578
929
  PLAN_NOT_SOLD_IN_CYCLE: "PLAN_NOT_SOLD_IN_CYCLE",
930
+ /**
931
+ * The subscription is bound to a plan version the plan repository does not
932
+ * find, or finds as a version of another plan. What the subscription pays
933
+ * cannot be read, so no change is quoted until the binding is repaired.
934
+ */
935
+ BOUND_PLAN_VERSION_UNREADABLE: "BOUND_PLAN_VERSION_UNREADABLE",
579
936
  /** Plan change refused. Carries `blockers[]` with their own codes. */
580
937
  PLAN_CHANGE_BLOCKED: "PLAN_CHANGE_BLOCKED",
581
938
  /**
@@ -598,6 +955,182 @@ var BILLING_ERROR_CODES = {
598
955
  * Carries the recomputed dates, so the page can re-ask instead of guessing.
599
956
  */
600
957
  CANCELLATION_TERMS_CHANGED: "CANCELLATION_TERMS_CHANGED",
958
+ /**
959
+ * The version the caller asked to switch to is no longer the one offered —
960
+ * another is on sale, the subscription moved, or there is no offer. Nothing
961
+ * was switched. Carries the current `offer`, or `null`, so the page can show
962
+ * it instead of guessing.
963
+ */
964
+ VERSION_OFFER_CHANGED: "VERSION_OFFER_CHANGED",
965
+ /**
966
+ * The version a change to another plan named is not the one on sale when
967
+ * the change was submitted: its preview was shown at another moment.
968
+ * Nothing was changed. Carries the current `preview`, so the page shows
969
+ * what the change binds now instead of what it would have.
970
+ */
971
+ PLAN_CHANGE_QUOTE_CHANGED: "PLAN_CHANGE_QUOTE_CHANGED",
972
+ /**
973
+ * A change to another plan named no version, where its preview names one:
974
+ * nothing says which price and terms the customer was shown, so nothing
975
+ * is changed.
976
+ */
977
+ PLAN_CHANGE_VERSION_NOT_NAMED: "PLAN_CHANGE_VERSION_NOT_NAMED",
978
+ /**
979
+ * A version that takes something away takes effect when the term ends, and
980
+ * the subscription's cancellation lands no later: the switch would never
981
+ * happen, so it is refused rather than recorded. Carries both dates.
982
+ */
983
+ VERSION_SWITCH_AFTER_CANCELLATION: "VERSION_SWITCH_AFTER_CANCELLATION",
984
+ /**
985
+ * A version that takes something away takes effect when the term ends, and
986
+ * it stops being sold before then — by its window or because an operator
987
+ * ended it — so it could not be bound when the change comes due. Refused
988
+ * rather than recorded; carries the dates.
989
+ */
990
+ VERSION_ENDS_BEFORE_SWITCH: "VERSION_ENDS_BEFORE_SWITCH",
991
+ // ── retiring a version for running subscriptions ──
992
+ /**
993
+ * The operator's terms are not confirmed to carry the clause a retirement
994
+ * rests on (`tenantBilling.orderlyRetirement.termsConfirmed` in
995
+ * `config/saas.yaml`), so none is accepted.
996
+ */
997
+ RETIREMENT_TERMS_NOT_CONFIRMED: "RETIREMENT_TERMS_NOT_CONFIRMED",
998
+ /**
999
+ * The version is still on sale: a subscription booked after the
1000
+ * announcement would be on it without having been told. Carries the plan
1001
+ * key and the version.
1002
+ */
1003
+ RETIREMENT_VERSION_ON_SALE: "RETIREMENT_VERSION_ON_SALE",
1004
+ /** The replacement is not on sale, so nobody can continue on it. Carries plan key and version. */
1005
+ RETIREMENT_REPLACEMENT_NOT_ON_SALE: "RETIREMENT_REPLACEMENT_NOT_ON_SALE",
1006
+ /**
1007
+ * The replacement has no price in the rhythm some of the subscriptions it
1008
+ * reaches are billed in, so they cannot continue on it. Carries how many,
1009
+ * and the replacement's plan key and version.
1010
+ */
1011
+ RETIREMENT_REPLACEMENT_NOT_SOLD_IN_RHYTHM: "RETIREMENT_REPLACEMENT_NOT_SOLD_IN_RHYTHM",
1012
+ /**
1013
+ * Some of the subscriptions the retirement reaches hold an add-on that
1014
+ * cannot run on the replacement's plan, so they cannot continue on it.
1015
+ * Carries how many, and the replacement's plan key and version.
1016
+ */
1017
+ RETIREMENT_REPLACEMENT_CANNOT_CARRY_BUNDLES: "RETIREMENT_REPLACEMENT_CANNOT_CARRY_BUNDLES",
1018
+ /** The replacement named is the version being retired. */
1019
+ RETIREMENT_REPLACEMENT_IS_RETIRED: "RETIREMENT_REPLACEMENT_IS_RETIRED",
1020
+ /** No running subscription is on the version: there is nobody to tell. Carries plan key and version. */
1021
+ RETIREMENT_NOTHING_AFFECTED: "RETIREMENT_NOTHING_AFFECTED",
1022
+ /**
1023
+ * Some of the subscriptions it reaches were reached by a retirement within
1024
+ * the last twelve months, and a subscription is reached at most once in that
1025
+ * time. Carries how many and which.
1026
+ */
1027
+ RETIREMENT_WITHIN_TWELVE_MONTHS: "RETIREMENT_WITHIN_TWELVE_MONTHS",
1028
+ /**
1029
+ * The subscriptions the retirement reaches, or their dates, changed since
1030
+ * the preview the operator confirmed. Carries the preview as it stands.
1031
+ */
1032
+ RETIREMENT_PREVIEW_CHANGED: "RETIREMENT_PREVIEW_CHANGED",
1033
+ /** No retirement of the subscription's version waits for its date: there is nothing to switch to. */
1034
+ RETIREMENT_SWITCH_NOT_PENDING: "RETIREMENT_SWITCH_NOT_PENDING",
1035
+ /** The switch opens once the trial has converted: a trial has no contract to hold the price on. */
1036
+ RETIREMENT_SWITCH_IN_TRIAL: "RETIREMENT_SWITCH_IN_TRIAL",
1037
+ /**
1038
+ * An add-on running today cannot run beside the replacement's plan, which
1039
+ * the switch would move the subscription onto today. Carries the add-on,
1040
+ * the plan and the earliest day the booking can end. Its own code rather
1041
+ * than a plan change's: the switch has no other plan to choose and no day
1042
+ * to pick, so the way past it is the add-on ending.
1043
+ */
1044
+ RETIREMENT_SWITCH_BUNDLE_CANNOT_FOLLOW: "RETIREMENT_SWITCH_BUNDLE_CANNOT_FOLLOW",
1045
+ /**
1046
+ * As `RETIREMENT_SWITCH_BUNDLE_CANNOT_FOLLOW`, where only the version the
1047
+ * add-on continues on from a retirement's date cannot run beside the
1048
+ * replacement's plan. The version it is on can, so cancelling it — it then
1049
+ * ends before that date — lets the switch through. Given while that date
1050
+ * is ahead and the add-on is not cancelled yet; otherwise the earlier code
1051
+ * names the day it can end. Carries the add-on, that version, its date and
1052
+ * the plan.
1053
+ */
1054
+ RETIREMENT_SWITCH_BUNDLE_REPLACEMENT_CANNOT_FOLLOW: "RETIREMENT_SWITCH_BUNDLE_REPLACEMENT_CANNOT_FOLLOW",
1055
+ /**
1056
+ * The subscription takes no switch now: a change is scheduled, it has
1057
+ * ended, or its plan is held for a special contract.
1058
+ */
1059
+ RETIREMENT_SWITCH_NOT_OPEN: "RETIREMENT_SWITCH_NOT_OPEN",
1060
+ /**
1061
+ * The version named is not the replacement the retirement names. Carries
1062
+ * the retirement as it now stands.
1063
+ */
1064
+ RETIREMENT_SWITCH_CHANGED: "RETIREMENT_SWITCH_CHANGED",
1065
+ // ── retiring an add-on version for running bookings ──
1066
+ //
1067
+ // An add-on retirement answers with the plan retirement's codes where the
1068
+ // sentence is the same — terms not confirmed, a version named as its own
1069
+ // replacement, twelve months, a preview that changed — and with these
1070
+ // where it names an add-on rather than a plan.
1071
+ /**
1072
+ * The add-on version is still on sale: a booking made after the
1073
+ * announcement would be on it without having been told. Carries the
1074
+ * add-on key and the version.
1075
+ */
1076
+ BUNDLE_RETIREMENT_VERSION_ON_SALE: "BUNDLE_RETIREMENT_VERSION_ON_SALE",
1077
+ /** The replacement is not on sale, so no booking can continue on it. Carries add-on key and version. */
1078
+ BUNDLE_RETIREMENT_REPLACEMENT_NOT_ON_SALE: "BUNDLE_RETIREMENT_REPLACEMENT_NOT_ON_SALE",
1079
+ /**
1080
+ * The replacement is a version of another add-on. A booking continues on
1081
+ * a version of its own add-on, so it stays the same booking with its term.
1082
+ * Carries both add-on keys.
1083
+ */
1084
+ BUNDLE_RETIREMENT_REPLACEMENT_OF_ANOTHER_BUNDLE: "BUNDLE_RETIREMENT_REPLACEMENT_OF_ANOTHER_BUNDLE",
1085
+ /**
1086
+ * Some of the bookings it reaches run, at their date, beside a plan the
1087
+ * replacement cannot run beside: not allowed there, without a price there
1088
+ * in the booking's rhythm, or in a longer rhythm than the plan's. Carries
1089
+ * how many, and the replacement's add-on key and version.
1090
+ */
1091
+ BUNDLE_RETIREMENT_REPLACEMENT_CANNOT_RUN: "BUNDLE_RETIREMENT_REPLACEMENT_CANNOT_RUN",
1092
+ /** No running booking is on the version: there is nobody to tell. Carries add-on key and version. */
1093
+ BUNDLE_RETIREMENT_NOTHING_AFFECTED: "BUNDLE_RETIREMENT_NOTHING_AFFECTED",
1094
+ /**
1095
+ * The booking is on an add-on version being retired, and was cancelled to
1096
+ * end before it would move, so it was never told and nothing moves it.
1097
+ * Reinstated, it would run on past the date on a version nobody sells;
1098
+ * booking the replacement once it has ended is the way. Carries the add-on
1099
+ * key, the version, the replacement's version and the day it can be booked
1100
+ * from.
1101
+ */
1102
+ BUNDLE_RETIREMENT_REINSTATE_REFUSED: "BUNDLE_RETIREMENT_REINSTATE_REFUSED",
1103
+ /**
1104
+ * As `BUNDLE_RETIREMENT_REINSTATE_REFUSED`, where the replacement cannot
1105
+ * run beside the plan the subscription is on when the booking ends, or
1106
+ * beside one it is already set to move to after that, in any rhythm it
1107
+ * could be booked in, so there is no version of the add-on to book.
1108
+ * Carries the add-on key, the version and the replacement's version.
1109
+ */
1110
+ BUNDLE_RETIREMENT_REINSTATE_REPLACEMENT_CANNOT_RUN: "BUNDLE_RETIREMENT_REINSTATE_REPLACEMENT_CANNOT_RUN",
1111
+ /**
1112
+ * As `BUNDLE_RETIREMENT_REINSTATE_REFUSED`, where the subscription ends by
1113
+ * the day the replacement could be booked from, so there is no day to
1114
+ * name. Carries the add-on key, the version and the replacement's version.
1115
+ */
1116
+ BUNDLE_RETIREMENT_REINSTATE_SUBSCRIPTION_ENDS: "BUNDLE_RETIREMENT_REINSTATE_SUBSCRIPTION_ENDS",
1117
+ /**
1118
+ * The plan the add-on runs beside, or the rhythm it is billed in, changes
1119
+ * before the date the booking was told — by a change scheduled, or by a
1120
+ * retirement told that moves the subscription to another plan — so the
1121
+ * price a switch now would hold is not the one the booking pays until
1122
+ * then. Switching once the plan has changed, or waiting for the
1123
+ * date, is the way. Carries the add-on and the date.
1124
+ */
1125
+ BUNDLE_RETIREMENT_SWITCH_PLAN_CHANGES: "BUNDLE_RETIREMENT_SWITCH_PLAN_CHANGES",
1126
+ /**
1127
+ * The add-on version the caller asked to switch a booking to is no longer
1128
+ * the one offered beside it — another is on sale, the booking moved, or
1129
+ * there is no offer. Nothing was switched. Carries the version named
1130
+ * (`bundleVersionId`) and the current `offer`, or `null`, so the page can
1131
+ * show it instead of guessing.
1132
+ */
1133
+ BUNDLE_VERSION_OFFER_CHANGED: "BUNDLE_VERSION_OFFER_CHANGED",
601
1134
  // ── the preview routes' own blockers and warnings ──
602
1135
  //
603
1136
  // These travel inside a 200 response, in `blockers[]` and `warnings[]`, not
@@ -627,14 +1160,33 @@ var BILLING_ERROR_CODES = {
627
1160
  CANCELLATION_LOCKS_THE_CYCLE: "CANCELLATION_LOCKS_THE_CYCLE",
628
1161
  /**
629
1162
  * A bundle the tenant already holds runs past the cycle they are moving to.
1163
+ * Carries the bundle, the earliest day the booking can end, and the two
1164
+ * rhythms.
630
1165
  *
631
1166
  * Its own code rather than `BUNDLE_CYCLE_EXCEEDS_PLAN`, which states the
632
1167
  * same rule about a booking that has not been made yet. The two need
633
1168
  * different sentences: this one can name the day the obstacle lifts and
634
- * tell the reader to cancel the booking, and that advice is wrong for
635
- * someone who is only about to book. One template cannot serve both.
1169
+ * tell the reader how to get past it, and that advice is wrong for someone
1170
+ * who is only about to book. One template cannot serve both.
636
1171
  */
637
1172
  BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE: "BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE",
1173
+ /**
1174
+ * A bundle the tenant already holds cannot run on the plan they are moving
1175
+ * to: that plan may not book it, or it has no price there in the rhythm
1176
+ * the booking is billed in. Carries the bundle, the plan and the earliest
1177
+ * day the booking can end.
1178
+ */
1179
+ BUNDLE_BOOKING_DOES_NOT_FIT_TARGET_PLAN: "BUNDLE_BOOKING_DOES_NOT_FIT_TARGET_PLAN",
1180
+ /**
1181
+ * A bundle the tenant already holds can run on the plan they are moving
1182
+ * to, but the version it continues on from a retirement's date cannot.
1183
+ * Cancelling it lets the change through at once: the booking then ends
1184
+ * before that date and never reaches the version. Given while that date is
1185
+ * ahead and the booking is not cancelled yet; otherwise
1186
+ * `BUNDLE_BOOKING_DOES_NOT_FIT_TARGET_PLAN` names the day it can end.
1187
+ * Carries the bundle, that version, its date and the plan.
1188
+ */
1189
+ BUNDLE_REPLACEMENT_DOES_NOT_FIT_TARGET_PLAN: "BUNDLE_REPLACEMENT_DOES_NOT_FIT_TARGET_PLAN",
638
1190
  /**
639
1191
  * Features of the previewed bundle are already covered by the plan or by
640
1192
  * another booked bundle. A warning rather than a blocker: paying twice is
@@ -656,7 +1208,6 @@ var BILLING_ERROR_CODES = {
656
1208
  * tenant reads and therefore needs a shipped text for.
657
1209
  */
658
1210
  BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED: "BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED",
659
- NO_PENDING_PLAN_VERSION: "NO_PENDING_PLAN_VERSION",
660
1211
  ONBOARDING_CREATE_FAILED: "ONBOARDING_CREATE_FAILED",
661
1212
  BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS: "BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS",
662
1213
  /**
@@ -705,6 +1256,21 @@ var CONTRACT_ERROR_CODES = {
705
1256
  * describes. Nothing was written; load the offer and conclude it again.
706
1257
  */
707
1258
  CHECKOUT_OFFER_CHANGED: "CHECKOUT_OFFER_CHANGED",
1259
+ /**
1260
+ * An offer concludes a tenant's first contract, and this tenant has a
1261
+ * contract in force at the moment the offer's would take effect, or one
1262
+ * beginning after it. Concluded, the two would run side by side. Nothing
1263
+ * was written; a running subscription changes through its plan and its
1264
+ * add-ons. Carries the offer and the contract that runs.
1265
+ */
1266
+ CHECKOUT_OFFER_CONTRACT_IN_FORCE: "CHECKOUT_OFFER_CONTRACT_IN_FORCE",
1267
+ /**
1268
+ * The offer names a version of an add-on the tenant has booked in another
1269
+ * version. Concluded, the contract would name a version the booking is not
1270
+ * on. Nothing was written; a booking changes its version through the offer
1271
+ * beside it. Carries the offer, the add-on, the booking and both versions.
1272
+ */
1273
+ CHECKOUT_OFFER_ADD_ON_BOOKED_IN_ANOTHER_VERSION: "CHECKOUT_OFFER_ADD_ON_BOOKED_IN_ANOTHER_VERSION",
708
1274
  SUBSCRIPTION_CONTRACT_NOT_FOUND: "SUBSCRIPTION_CONTRACT_NOT_FOUND",
709
1275
  NO_ACTIVE_SUBSCRIPTION_CONTRACT: "NO_ACTIVE_SUBSCRIPTION_CONTRACT",
710
1276
  SUBSCRIPTION_CONTRACT_ALREADY_CLOSED: "SUBSCRIPTION_CONTRACT_ALREADY_CLOSED",
@@ -715,7 +1281,12 @@ var CONTRACT_ERROR_CODES = {
715
1281
  * second attempt, or a contract begins after the moment the successor
716
1282
  * would take effect. Nothing was written.
717
1283
  */
718
- SUBSCRIPTION_CONTRACT_CHANGED: "SUBSCRIPTION_CONTRACT_CHANGED"
1284
+ SUBSCRIPTION_CONTRACT_CHANGED: "SUBSCRIPTION_CONTRACT_CHANGED",
1285
+ /**
1286
+ * A contract states a tax rate — `field` names where — other than the one
1287
+ * the installation's tax adapter decides for its subscriber.
1288
+ */
1289
+ SUBSCRIPTION_CONTRACT_TAX_RATE_NOT_DECIDED: "SUBSCRIPTION_CONTRACT_TAX_RATE_NOT_DECIDED"
719
1290
  };
720
1291
  var SUBSCRIBER_ERROR_CODES = {
721
1292
  /**
@@ -739,7 +1310,30 @@ var SUBSCRIBER_ERROR_CODES = {
739
1310
  SUBSCRIBER_CORRECTION_ACTOR_REQUIRED: "SUBSCRIBER_CORRECTION_ACTOR_REQUIRED",
740
1311
  SUBSCRIBER_CORRECTION_CHANGES_NOTHING: "SUBSCRIBER_CORRECTION_CHANGES_NOTHING",
741
1312
  /** The operator declared another legal entity: that is a transfer, not an edit. */
742
- SUBSCRIBER_TAKEOVER_IS_A_TRANSFER: "SUBSCRIBER_TAKEOVER_IS_A_TRANSFER"
1313
+ SUBSCRIBER_TAKEOVER_IS_A_TRANSFER: "SUBSCRIBER_TAKEOVER_IS_A_TRANSFER",
1314
+ /**
1315
+ * A contact change named whether the subscriber is a business. That is part
1316
+ * of its tax origin and changes as a recorded change naming who made it.
1317
+ */
1318
+ SUBSCRIBER_BUSINESS_STATUS_NOT_A_CONTACT: "SUBSCRIBER_BUSINESS_STATUS_NOT_A_CONTACT",
1319
+ /** A change of the subscriber's contact details or business status did not say who makes it. */
1320
+ SUBSCRIBER_CHANGE_ACTOR_REQUIRED: "SUBSCRIBER_CHANGE_ACTOR_REQUIRED",
1321
+ /**
1322
+ * Where a tax adapter decides, a contract names its subscriber only once
1323
+ * the address an invoice names is complete (`SC-PRIC-032`): a party copied
1324
+ * onto a contract incomplete cannot be completed afterwards. Carries
1325
+ * `missing`, the empty fields, for a screen to name by their labels; the
1326
+ * shipped sentence names all four rather than the keys.
1327
+ */
1328
+ SUBSCRIBER_IDENTITY_INCOMPLETE: "SUBSCRIBER_IDENTITY_INCOMPLETE",
1329
+ /**
1330
+ * A change of whether the subscriber is a business states no reason. It
1331
+ * decides the tax treatment of the next invoice, so the change log keeps
1332
+ * why it moved (`SC-PRIC-043`).
1333
+ */
1334
+ SUBSCRIBER_BUSINESS_STATUS_REASON_REQUIRED: "SUBSCRIBER_BUSINESS_STATUS_REASON_REQUIRED",
1335
+ /** A check of the subscriber's VAT identification number was asked for, and it holds none. */
1336
+ SUBSCRIBER_VAT_ID_MISSING: "SUBSCRIBER_VAT_ID_MISSING"
743
1337
  };
744
1338
  var REGISTRATION_ERROR_CODES = {
745
1339
  PENDING_REGISTRATION_NOT_FOUND: "PENDING_REGISTRATION_NOT_FOUND",
@@ -844,6 +1438,29 @@ var MAINTENANCE_ERROR_CODES = {
844
1438
  /** The message is longer than `MAINTENANCE_MESSAGE_MAX_LENGTH`. */
845
1439
  MAINTENANCE_MESSAGE_TOO_LONG: "MAINTENANCE_MESSAGE_TOO_LONG"
846
1440
  };
1441
+ var TAX_ERROR_CODES = {
1442
+ /**
1443
+ * The tax adapter answers that it does not support the subscriber's case;
1444
+ * `adapter` names it and `reason` is its sentence. Nothing is concluded with
1445
+ * a guessed tax (`SC-PRIC-039`).
1446
+ */
1447
+ TAX_TREATMENT_NOT_SUPPORTED: "TAX_TREATMENT_NOT_SUPPORTED",
1448
+ /**
1449
+ * The tax adapter needs the VAT identification number checked to treat the
1450
+ * case, and the check did not complete — the service is unavailable, timed
1451
+ * out, or answered in a way the adapter cannot read (`503`). Nothing is
1452
+ * decided in the subscriber's favour on a number not checked
1453
+ * (`SC-PRIC-040`): try again later. `adapter` names the adapter and
1454
+ * `reason` says why.
1455
+ */
1456
+ TAX_VAT_ID_CHECK_NOT_COMPLETED: "TAX_VAT_ID_CHECK_NOT_COMPLETED",
1457
+ /**
1458
+ * A VAT identification number was to be checked, and `config/saas.yaml`
1459
+ * names no tax adapter, which is what names the service to check with
1460
+ * (`409`).
1461
+ */
1462
+ TAX_VAT_ID_CHECK_NOT_AVAILABLE: "TAX_VAT_ID_CHECK_NOT_AVAILABLE"
1463
+ };
847
1464
  var PLATFORM_ERROR_CODES = {
848
1465
  ...SETUP_ERROR_CODES,
849
1466
  ...AUTH_ERROR_CODES,
@@ -855,7 +1472,8 @@ var PLATFORM_ERROR_CODES = {
855
1472
  ...REGISTRATION_ERROR_CODES,
856
1473
  ...PAYMENT_ERROR_CODES,
857
1474
  ...SETTINGS_ERROR_CODES,
858
- ...MAINTENANCE_ERROR_CODES
1475
+ ...MAINTENANCE_ERROR_CODES,
1476
+ ...TAX_ERROR_CODES
859
1477
  };
860
1478
 
861
1479
  // src/errors.ts
@@ -874,92 +1492,552 @@ var PlatformUserExistsError = class extends Error {
874
1492
  function isPlatformUserExistsError(err) {
875
1493
  return err instanceof Error && err.code === USER_ALREADY_EXISTS;
876
1494
  }
877
-
878
- // src/feature-requires.ts
879
- function buildFeatureRequiresIndex(features) {
880
- const index = /* @__PURE__ */ new Map();
881
- for (const feature of features) {
882
- const requires = (feature.requires ?? []).filter((key) => key !== feature.featureKey);
883
- if (requires.length > 0) index.set(feature.featureKey, requires);
884
- }
885
- return index;
886
- }
887
- function collectUnsatisfiedRequires(selected, index) {
888
- const own = new Set(selected);
889
- const unsatisfied = /* @__PURE__ */ new Set();
890
- for (const featureKey of selected) {
891
- for (const required of index.get(featureKey) ?? []) {
892
- if (!own.has(required)) unsatisfied.add(required);
893
- }
894
- }
895
- return [...unsatisfied].sort((a, b) => a.localeCompare(b));
896
- }
897
- function missingRequiresFor(bundle, coveredFeatures) {
898
- const missing = (bundle.requiresFeatures ?? []).filter((key) => !coveredFeatures.has(key));
899
- return [...new Set(missing)].sort((a, b) => a.localeCompare(b));
900
- }
901
- function resolveBundleAvailability(bundle, coveredFeatures) {
902
- if (bundle.features.length > 0 && bundle.features.every((f) => coveredFeatures.has(f))) {
903
- return "covered";
904
- }
905
- if (missingRequiresFor(bundle, coveredFeatures).length > 0) return "missing-requires";
906
- return "bookable";
907
- }
908
- function coverageExcludingSelf(selfVersionId, planFeatures, selectedBundles) {
909
- const covered = new Set(planFeatures);
910
- for (const bundle of selectedBundles) {
911
- if (bundle.bundleVersionId === selfVersionId) continue;
912
- for (const feature of bundle.features) covered.add(feature);
1495
+ var PERSISTENCE_REFUSAL = "PersistenceRefusal";
1496
+ var PersistenceRefusal = class extends Error {
1497
+ constructor(code, reason, message, params = {}) {
1498
+ super(message);
1499
+ this.code = code;
1500
+ this.reason = reason;
1501
+ this.params = params;
1502
+ this.name = PERSISTENCE_REFUSAL;
913
1503
  }
914
- return covered;
915
- }
916
- function isBundleRedundant(bundle, planFeatures, selectedBundles) {
917
- const covered = coverageExcludingSelf(bundle.bundleVersionId, planFeatures, selectedBundles);
918
- return resolveBundleAvailability(bundle, covered) === "covered";
919
- }
920
- function compareSelectable(a, b) {
921
- const orderA = a.sortOrder ?? Number.MAX_SAFE_INTEGER;
922
- const orderB = b.sortOrder ?? Number.MAX_SAFE_INTEGER;
923
- if (orderA !== orderB) return orderA - orderB;
924
- return a.bundleVersionId.localeCompare(b.bundleVersionId);
1504
+ code;
1505
+ reason;
1506
+ params;
1507
+ };
1508
+ function isPersistenceRefusal(err) {
1509
+ if (!(err instanceof Error) || err.name !== PERSISTENCE_REFUSAL) return false;
1510
+ const { code, reason } = err;
1511
+ return typeof code === "string" && (reason === "gone" || reason === "moved");
925
1512
  }
926
- function selectChargeableBundles(planFeatures, selectedBundles) {
927
- const kept = [...selectedBundles].sort(compareSelectable);
928
- for (; ; ) {
929
- const redundantIndex = kept.findIndex(
930
- (bundle) => isBundleRedundant(bundle, planFeatures, kept)
1513
+
1514
+ // src/optional-canonical-models.ts
1515
+ var OPTIONAL_CANONICAL_MODELS = {
1516
+ SuperAdminUser: ["core.superAdminProvisioning"],
1517
+ SuperAdminMfa: ["core.mfa"],
1518
+ AppliedSettings: ["core.appliedSettings"],
1519
+ SettingsChange: ["core.appliedSettings"],
1520
+ MaintenanceWindow: ["core.maintenanceWindows"],
1521
+ SubscriptionNotice: ["tenantBilling.subscriptionNotices"],
1522
+ VersionRetirement: ["tenantBilling.versionRetirements"],
1523
+ BundleVersionRetirement: ["tenantBilling.bundleVersionRetirements"],
1524
+ SubscriberLedgerEntry: ["entitlement.subscriberLedgerRepository"],
1525
+ PromoCodeHold: ["promo.holdRepository"]
1526
+ };
1527
+ function membersLeftOut(notAdopted = []) {
1528
+ const unknown = notAdopted.filter((model) => !Object.hasOwn(OPTIONAL_CANONICAL_MODELS, model));
1529
+ if (unknown.length > 0) {
1530
+ throw new Error(
1531
+ `notAdopted names ${unknown.join(", ")}, which the persistence bundle cannot leave out. It can leave out ${Object.keys(OPTIONAL_CANONICAL_MODELS).join(", ")}; for any other model it needs, pass your own adapter for the port that model serves.`
931
1532
  );
932
- if (redundantIndex === -1) return kept;
933
- kept.splice(redundantIndex, 1);
934
1533
  }
1534
+ return new Set(
1535
+ notAdopted.flatMap((model) => OPTIONAL_CANONICAL_MODELS[model])
1536
+ );
935
1537
  }
936
1538
 
937
- // src/payment-gateway.types.ts
938
- var PAYMENT_CALLBACK_REJECTED = "PAYMENT_CALLBACK_REJECTED";
939
- var PaymentCallbackRejectedError = class extends Error {
940
- code = PAYMENT_CALLBACK_REJECTED;
941
- constructor(reason) {
942
- super(`Payment callback rejected: ${reason}`);
943
- this.name = "PaymentCallbackRejectedError";
1539
+ // src/concurrency-gate.ts
1540
+ function concurrencyGate(limit) {
1541
+ if (!Number.isInteger(limit) || limit < 1) {
1542
+ throw new RangeError(`A concurrency limit is a whole number of at least 1, not ${limit}.`);
944
1543
  }
945
- };
946
- function isPaymentCallbackRejectedError(err) {
947
- return err instanceof Error && err.code === PAYMENT_CALLBACK_REJECTED;
1544
+ let active = 0;
1545
+ const waiting = [];
1546
+ const release = () => {
1547
+ const next = waiting.shift();
1548
+ if (next) next();
1549
+ else active -= 1;
1550
+ };
1551
+ return async (work) => {
1552
+ if (active < limit) active += 1;
1553
+ else await new Promise((admit) => waiting.push(admit));
1554
+ try {
1555
+ return await work();
1556
+ } finally {
1557
+ release();
1558
+ }
1559
+ };
1560
+ }
1561
+ var GATES = /* @__PURE__ */ new WeakMap();
1562
+ function concurrencyGateOf(pool, limit) {
1563
+ const known = GATES.get(pool);
1564
+ if (known) {
1565
+ if (known.limit !== limit) {
1566
+ throw new RangeError(
1567
+ `This pool is bounded at ${known.limit} transactions already; a second bound of ${limit} would split it.`
1568
+ );
1569
+ }
1570
+ return known.gate;
1571
+ }
1572
+ const gate = concurrencyGate(limit);
1573
+ GATES.set(pool, { limit, gate });
1574
+ return gate;
948
1575
  }
949
1576
 
950
- // src/registration.types.ts
951
- var PENDING_EMAIL_TTL_HOURS = 72;
952
- var PENDING_ONBOARDING_TTL_DAYS = 14;
953
- var PENDING_CHECKOUT_TTL_DAYS = 30;
954
- var OTP_TTL_MINUTES = 10;
955
- var PASSWORD_RESET_TTL_MINUTES = 30;
956
- var OTP_RATE_LIMIT_MAX_SENDS = 3;
957
- var OTP_RATE_LIMIT_WINDOW_MINUTES = 15;
958
- var OTP_VERIFY_MAX_ATTEMPTS = 5;
959
- var REGISTRATION_STEP_BY_STATUS = {
960
- PENDING_EMAIL_VERIFICATION: 2,
961
- EMAIL_VERIFIED: 3,
962
- PLAN_SELECTED: 4,
1577
+ // src/error-messages.ts
1578
+ var ERROR_MESSAGES_EN = {
1579
+ // ── setup ──
1580
+ SETUP_DISABLED: "{envVar} is not set \u2014 setup is disabled.",
1581
+ INVALID_SETUP_TOKEN: "The setup token is not valid.",
1582
+ SETUP_ALREADY_DONE: "Setup has already been completed.",
1583
+ INVALID_EMAIL: "That is not a valid email address.",
1584
+ EMAIL_EXISTS: "An account with this email address already exists.",
1585
+ // ── auth ──
1586
+ NOT_AUTHENTICATED: "Not authenticated",
1587
+ NO_TENANT_ASSIGNED: "No tenant assigned",
1588
+ TENANT_CONTEXT_MISSING: "No tenant ID found on the request",
1589
+ TENANT_ADMIN_REQUIRED: "This action requires the TENANT_ADMIN role.",
1590
+ BILLING_PERMISSION_REQUIRED: "This part of the billing area requires the billing permission.",
1591
+ SUPER_ADMIN_REQUIRED: "Only the SUPER_ADMIN role is allowed",
1592
+ MFA_NOT_SET_UP: "Run the MFA setup via the CLI first.",
1593
+ MFA_REQUIRED: "TOTP code required in the X-Mfa-Code header.",
1594
+ MFA_FAILED: "Invalid TOTP code.",
1595
+ AUTH_GUARDS_NOT_CONFIGURED: "TenantBillingModule.forRoot.authGuards is not configured.",
1596
+ // ── catalog ──
1597
+ PLAN_HAS_DRAFTS: "Plan '{planKey}' still has {draftCount} open draft version(s). Discard them first (DELETE /admin/catalog/plan-versions/:id) or publish them.",
1598
+ PLAN_HAS_PUBLISHED_VERSIONS: "Plan '{planKey}' cannot be {operation} \u2014 it has {publishedCount} published version(s) ({liveCount} live, {supersededCount} superseded). Existing subscriptions reference those versions (contract protection P1), so the plan record must be preserved.",
1599
+ PLAN_HARD_DELETE_NOT_IMPLEMENTED: "Hard delete is not implemented in the current repository. Implement PlanRepository.hardDelete.",
1600
+ PLAN_VERSION_ALREADY_PUBLISHED: "PlanVersion '{versionId}' is already published; it is not published again or discarded.",
1601
+ PLAN_VERSION_NOT_EDITABLE: "PlanVersion '{versionId}' is not editable. Only drafts and published versions are editable that are latest-in-chain, bind no subscription yet, and whose validFrom lies in the future.",
1602
+ PLAN_VERSION_REGRESSION: "This plan version is regressive (feature removed / quota lowered / price raised). Publishing requires an explicit `forceRegressive: true` (UI confirmation dialog with MFA).",
1603
+ PLAN_VERSION_ZERO_PRICE: "A plan version cannot be published with a price of 0.00 (guard against seed placeholder). For deliberately free special contracts, set allowZeroPrice.",
1604
+ PLAN_VERSION_DISCARD_NOT_IMPLEMENTED: "Discard is not implemented in the current repository. Implement PlanRepository.deletePlanVersionDraft.",
1605
+ PLAN_VERSION_NOT_PUBLISHED: "PlanVersion '{versionId}' is not published and cannot be terminated.",
1606
+ PLAN_VERSION_SUPERSEDED: "PlanVersion '{versionId}' has already been superseded by a newer version and cannot be terminated.",
1607
+ PLAN_VERSION_VALID_FROM_REQUIRED: "validFrom must be set when publishing (on the draft or the publish call)..",
1608
+ PLAN_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' is not a day (YYYY-MM-DD)",
1609
+ PLAN_VERSION_VALID_FROM_NOT_AFTER_PREVIOUS: "validFrom ({validFrom}) must be strictly after the validFrom of the previous version ({previousValidFrom}).",
1610
+ PLAN_VERSION_VALID_FROM_NOT_GAPLESS: "The predecessor has validUntil={previousValidUntil} \u2014 the successor must start seamlessly on the next day ({requiredValidFrom}). Received: {received}.",
1611
+ PLAN_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' is not a day (YYYY-MM-DD)",
1612
+ PLAN_VERSION_VALID_UNTIL_BEFORE_FROM: "validUntil ({validUntil}) must be strictly after validFrom ({validFrom}).",
1613
+ PLAN_TERMINATE_INVALID_DATE: "endsAt is not a valid date.",
1614
+ PLAN_TERMINATE_DATE_NOT_FUTURE: "endsAt ({endsAt}) must lie strictly in the future.",
1615
+ PLAN_TERMINATE_NOT_IMPLEMENTED: "Terminate is not implemented in the current repository. Implement PlanRepository.terminate.",
1616
+ PLAN_TERMINATE_BEFORE_RETIREMENT_MOVES: "Subscriptions still move to version {version} of {planKey}, so it can end on {date} at the earliest.",
1617
+ PLAN_TERMINATE_WHILE_MOVES_OVERDUE: "{count} subscriptions are past their date and still to be moved to version {version} of {planKey}, so it cannot end until they have moved.",
1618
+ PLAN_TERMINATE_WHILE_NOTICES_UNDELIVERED: "{count} subscriptions have not yet been told that they move to version {version} of {planKey}, so it cannot end until they have been.",
1619
+ BUNDLE_VERSION_ALREADY_PUBLISHED: "BundleVersion '{versionId}' is already published; it is not published again or discarded.",
1620
+ BUNDLE_VERSION_NOT_EDITABLE: "BundleVersion '{versionId}' is not editable. Only drafts and published versions are editable that are latest-in-chain, bind no subscription yet, and whose validFrom lies in the future.",
1621
+ BUNDLE_VERSION_NOT_PUBLISHED: "BundleVersion '{bundleVersionId}' is not published and cannot be booked.",
1622
+ BUNDLE_VERSION_SUPERSEDED: "BundleVersion '{bundleVersionId}' has been superseded by a newer version.",
1623
+ BUNDLE_VERSION_NOT_YET_ON_SALE: "BundleVersion '{bundleVersionId}' goes on sale on {validFrom} and cannot be booked before.",
1624
+ BUNDLE_DELETED: "Bundle '{bundleKey}' has been deleted from the catalogue and cannot be booked.",
1625
+ BUNDLE_VERSION_REGRESSION: "This bundle version is regressive (feature removed / quota lowered / price raised). Publishing requires an explicit `forceRegressive: true` (UI confirmation dialog with MFA).",
1626
+ BUNDLE_VERSION_ZERO_PRICE: "A bundle version cannot be published with an explicit price of 0.00 (guard against seed placeholders). For free bundles leave it null, or set allowZeroPrice.",
1627
+ BUNDLE_VERSION_NO_PRICE: "This bundle version cannot be published without a price: neither a base price nor any plan override resolves one.",
1628
+ BUNDLE_VERSION_NOT_PRICED_FOR_PLAN: "This bundle is offered to plan '{planKey}', which is sold {billingCycle}, and no {billingCycle} price resolves for it \u2014 neither a base price nor a plan override.",
1629
+ BUNDLE_VERSION_DISCARD_NOT_IMPLEMENTED: "Discard is not implemented in the current repository. Implement BundleRepository.deleteDraft.",
1630
+ BUNDLE_VERSION_VALID_FROM_REQUIRED: "Published bundle versions must keep a validFrom. Set a new future date, or edit the draft before publishing.",
1631
+ BUNDLE_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' is not a day (YYYY-MM-DD)",
1632
+ BUNDLE_VERSION_VALID_FROM_NOT_AFTER_PREVIOUS: "validFrom ({validFrom}) must be strictly after the validFrom of the previous version ({previousValidFrom}).",
1633
+ BUNDLE_VERSION_VALID_FROM_NOT_GAPLESS: "The predecessor has validUntil={previousValidUntil} \u2014 the successor must start seamlessly on the next day ({requiredValidFrom}). Received: {received}.",
1634
+ BUNDLE_VERSION_VALID_FROM_NOT_FUTURE: "validFrom ({validFrom}) must, for a published-but-future bundle version, still lie in the future.",
1635
+ BUNDLE_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' is not a day (YYYY-MM-DD)",
1636
+ BUNDLE_VERSION_VALID_UNTIL_BEFORE_FROM: "validUntil ({validUntil}) must be strictly after validFrom ({validFrom}).",
1637
+ STRICT_MODE_VIOLATIONS: "The strict-mode check found drift against the discovery snapshot.",
1638
+ PLAN_NOT_FOUND: "Plan '{planId}' not found",
1639
+ PLAN_VERSION_NOT_FOUND: "PlanVersion '{versionId}' not found",
1640
+ BUNDLE_NOT_FOUND: "Bundle '{bundleId}' not found",
1641
+ BUNDLE_DELETE_WHILE_RETIREMENT_MOVES_PENDING: "{count} bookings still move onto a version of {bundleKey}, as a retirement told them. The add-on can be deleted once they have.",
1642
+ BUNDLE_VERSION_NOT_FOUND: "BundleVersion '{bundleVersionId}' not found",
1643
+ FEATURE_NOT_FOUND: "Feature '{featureKey}' not found",
1644
+ QUOTA_NOT_FOUND: "Quota '{quotaKey}' not found",
1645
+ PROMOTION_NOT_FOUND: "Promotion '{promotionId}' not found",
1646
+ PROMOTION_VALUE_INVALID: "The value of a '{type}' promotion is not one its type takes: a percentage above 0 and at most 100, an amount above 0, an intro price of at least 0 for a whole number of months, or a whole number of free months.",
1647
+ MARKETING_PROJECTION_NOT_FOUND: "MarketingProjection '{projectionId}' not found",
1648
+ PLAN_ALREADY_EXISTS: "Plan '{planKey}' already exists",
1649
+ BUNDLE_ALREADY_EXISTS: "Bundle '{bundleKey}' already exists",
1650
+ MARKETING_PROJECTION_ALREADY_EXISTS: "Marketing projection for {targetType}/{targetVersionId}/{locale} already exists \u2014 use PATCH to edit it",
1651
+ PLAN_DRAFT_ALREADY_EXISTS: "Plan '{planKey}' already has a draft version v{draftVersion}; publish or discard it first",
1652
+ BUNDLE_DRAFT_ALREADY_EXISTS: "Bundle '{bundleKey}' already has a draft version v{draftVersion}; publish or discard it first",
1653
+ QUOTA_NOT_IN_DISCOVERY_SNAPSHOT: "Quota '{quotaKey}' is not in the discovery snapshot \u2014 a quota that is not declared in code cannot be approved",
1654
+ DISCOVERY_STATUS_TRANSITION_INVALID: "Transition '{from}' \u2192 '{to}' is not allowed",
1655
+ DISCOVERY_NOT_INITIALIZED: "Approval requires a discovery snapshot \u2014 discovery is not initialised (#25)",
1656
+ // ── catalogue import ──
1657
+ PLAN_CATALOG_UNREADABLE: "That file is not a plan catalog \u2014 it could not be read as one. Check that it is the YAML your app declares its plans in.",
1658
+ PLAN_CATALOG_INVALID: "The plan catalog was read, and then rejected: {message}",
1659
+ // ── billing ──
1660
+ BUNDLE_ALREADY_SUBSCRIBED: "Subscription '{subscriptionId}' has already actively booked this bundle.",
1661
+ BUNDLE_INCOMPATIBLE_WITH_PLAN: "This bundle cannot be booked on the {planKey} plan. The plans that can book it: {allowedPlanKeys}.",
1662
+ BUNDLE_NOT_SELF_SERVICE: "Bundle '{bundleKey}' is only activated via a special contract. Please contact the contract manager.",
1663
+ BUNDLE_CYCLE_EXCEEDS_PLAN: "A yearly bundle cannot run beside a monthly plan: it would still be committed on every day the plan could end.",
1664
+ BUNDLE_NOT_PRICED_FOR_THIS_PLAN: "This bundle has no price for the {planKey} plan in this billing cycle, so it cannot be booked from here.",
1665
+ BUNDLE_CANNOT_RUN_ON_UPCOMING_PLAN: "This bundle cannot run on the {planKey} plan, which the subscription moves to with effect from {from}.",
1666
+ BUNDLE_CANNOT_RUN_ON_UPCOMING_CYCLE: "A yearly bundle cannot run beside the monthly billing the subscription moves to with effect from {from}.",
1667
+ SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' is already cancelled.",
1668
+ SUBSCRIPTION_BUNDLE_NOT_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' is not cancelled.",
1669
+ SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE: "Cancellation already in effect \u2014 book the bundle again.",
1670
+ SUBSCRIPTION_NOT_FOUND: "No subscription for tenant {tenantId}",
1671
+ SUBSCRIPTION_TENANT_MISMATCH: "Subscription does not belong to the tenant",
1672
+ SUBSCRIPTION_BUNDLE_NOT_FOUND: "SubscriptionBundle '{subscriptionBundleId}' not found",
1673
+ TENANT_NOT_FOUND: "Tenant {slug} not found",
1674
+ NO_ACTIVE_PLAN_VERSION: "No version of plan {planId} is on sale as of {asOf}.",
1675
+ BOUND_PLAN_VERSION_UNREADABLE: 'The plan version this subscription is bound to ({planVersionId}) cannot be read for plan "{planKey}", so no change can be quoted.',
1676
+ PLAN_NOT_IN_CATALOG: 'Plan "{planKey}" is not in the catalog',
1677
+ PLAN_NOT_SELF_SERVICE: "{planName} is only activated via a special contract. Please contact the contract manager.",
1678
+ PLAN_NOT_SOLD_IN_CYCLE: "{planName} has no price for this billing rhythm and cannot be booked in it.",
1679
+ PLAN_CHANGE_BLOCKED: "Plan change during onboarding is blocked.",
1680
+ SUBSCRIPTION_CHANGED: "This subscription changed while the request was being decided. Reload it.",
1681
+ NO_SUBSCRIPTION: "This tenant has no subscription to cancel.",
1682
+ CANCELLATION_TERMS_CHANGED: "The effective date changed since it was shown. Confirm the new one.",
1683
+ VERSION_OFFER_CHANGED: "The offer changed since it was shown. Look at the current one before switching.",
1684
+ PLAN_CHANGE_QUOTE_CHANGED: "This plan changed since it was shown. Look at it again before changing to it.",
1685
+ PLAN_CHANGE_VERSION_NOT_NAMED: "A plan change has to name the version its preview showed.",
1686
+ VERSION_SWITCH_AFTER_CANCELLATION: "This subscription ends before this version would take effect, so it cannot be switched to.",
1687
+ VERSION_ENDS_BEFORE_SWITCH: "This version stops being sold before it would take effect, so it cannot be switched to.",
1688
+ RETIREMENT_TERMS_NOT_CONFIRMED: "Retiring a version for running subscriptions needs a clause in your terms. Set tenantBilling.orderlyRetirement.termsConfirmed in config/saas.yaml once they carry it.",
1689
+ RETIREMENT_VERSION_ON_SALE: "Version {version} of {planKey} is still on sale. End its sale first, so nobody books it after the announcement.",
1690
+ RETIREMENT_REPLACEMENT_NOT_ON_SALE: "Version {version} of {planKey} is not on sale, so subscriptions cannot continue on it.",
1691
+ RETIREMENT_REPLACEMENT_NOT_SOLD_IN_RHYTHM: "{count} of these subscriptions are billed in a rhythm version {version} of {planKey} has no price for, so they cannot continue on it.",
1692
+ RETIREMENT_REPLACEMENT_CANNOT_CARRY_BUNDLES: "{count} of these subscriptions hold a bundle that cannot run on version {version} of {planKey}, so they cannot continue on it.",
1693
+ RETIREMENT_REPLACEMENT_IS_RETIRED: "A version cannot be its own replacement.",
1694
+ RETIREMENT_NOTHING_AFFECTED: "No running subscription is on version {version} of {planKey}, so there is nobody to tell.",
1695
+ RETIREMENT_WITHIN_TWELVE_MONTHS: "{count} of these subscriptions were reached by a retirement within the last twelve months. A subscription is reached at most once a year.",
1696
+ RETIREMENT_PREVIEW_CHANGED: "The subscriptions this retirement reaches changed since they were shown. Look at them again before announcing it.",
1697
+ BUNDLE_RETIREMENT_VERSION_ON_SALE: "Version {version} of {bundleKey} is still on sale. Publish the version that replaces it, and retire this one once its sale has ended, so nobody books it after the announcement.",
1698
+ BUNDLE_RETIREMENT_REPLACEMENT_NOT_ON_SALE: "Version {version} of {bundleKey} is not on sale, so bookings cannot continue on it.",
1699
+ BUNDLE_RETIREMENT_REPLACEMENT_OF_ANOTHER_BUNDLE: "The replacement is a version of {replacementBundleKey}, not of {bundleKey}. A booking continues on a version of its own add-on.",
1700
+ BUNDLE_RETIREMENT_REPLACEMENT_CANNOT_RUN: "{count} of these bookings run beside a plan that version {version} of {bundleKey} cannot run beside, so they cannot continue on it.",
1701
+ BUNDLE_RETIREMENT_NOTHING_AFFECTED: "No running booking is on version {version} of {bundleKey}, so there is nobody to tell.",
1702
+ BUNDLE_RETIREMENT_REINSTATE_REFUSED: "Version {version} of {bundleKey} is being retired, and this booking ends before it would move. Book version {replacementVersion} from {bookableFrom}, when this booking has ended.",
1703
+ BUNDLE_RETIREMENT_REINSTATE_REPLACEMENT_CANNOT_RUN: "Version {version} of {bundleKey} is being retired, and this booking ends before it would move. Version {replacementVersion}, which replaces it, cannot run beside your plan, or beside one your subscription is set to move to.",
1704
+ BUNDLE_RETIREMENT_REINSTATE_SUBSCRIPTION_ENDS: "Version {version} of {bundleKey} is being retired, and this booking ends before it would move. Your subscription ends by then as well.",
1705
+ BUNDLE_RETIREMENT_SWITCH_PLAN_CHANGES: "{bundleName} moves to its new version on {date}, and your plan changes before then, so the price a switch would keep is not known yet. Switch once your plan has changed, or let it move on that date.",
1706
+ BUNDLE_VERSION_OFFER_CHANGED: "The offer changed since it was shown. Look at the current one before switching.",
1707
+ RETIREMENT_SWITCH_NOT_PENDING: "No retirement of your version is waiting for its date, so there is nothing to switch to.",
1708
+ RETIREMENT_SWITCH_IN_TRIAL: "The switch opens when your trial ends.",
1709
+ RETIREMENT_SWITCH_BUNDLE_CANNOT_FOLLOW: "{bundleName} cannot run on {planName} and runs until {until} at the earliest. Once it is cancelled, the switch can be made from that day.",
1710
+ RETIREMENT_SWITCH_BUNDLE_REPLACEMENT_CANNOT_FOLLOW: "{bundleName} continues on version {version} from {from}, which cannot run on {planName}. Once it is cancelled, the switch can be made.",
1711
+ RETIREMENT_SWITCH_NOT_OPEN: "This subscription cannot switch now: a change is scheduled, it has ended, or its plan is held for a special contract.",
1712
+ RETIREMENT_SWITCH_CHANGED: "The retirement changed since it was shown. Look at it again before switching.",
1713
+ SUBSCRIPTION_ENDED: "This subscription has ended. Its plan can no longer be changed.",
1714
+ PLAN_LOCKED: "Active {planName} special contract \u2014 please contact the contract manager to change plans.",
1715
+ QUOTA_OVER_TARGET: "Current usage {used} exceeds the target limit {targetMax} ({quotaKey}) in the {planName} plan. Please reduce usage first.",
1716
+ FEATURE_LOST: "Switching means losing access to one feature. Existing data is retained and never deleted \u2014 upgrading again unlocks it.",
1717
+ FEATURES_LOST: "Switching means losing access to {count} features. Existing data is retained and never deleted \u2014 upgrading again unlocks it.",
1718
+ NO_CHANGE: "Target plan and billing cycle already match the current state.",
1719
+ CANCELLATION_LOCKS_THE_CYCLE: "This subscription is cancelled, so its billing cycle cannot change. The plan can \u2014 keep the current cycle to change it today.",
1720
+ CYCLE_SHORTENS_AT_TERM_END: "A monthly {planName} cannot start inside the yearly term you are in. The upgrade takes effect when that term ends; to have it today, keep the yearly cycle.",
1721
+ BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE: "{bundleName} is billed yearly and runs until {until} at the earliest, which a monthly plan cannot carry. Once it is cancelled, a change that takes effect on or after that day goes through \u2014 or keep the yearly cycle.",
1722
+ BUNDLE_BOOKING_DOES_NOT_FIT_TARGET_PLAN: "{bundleName} cannot run on {planName} and runs until {until} at the earliest. Once it is cancelled, a change that takes effect on or after that day goes through \u2014 or choose another plan.",
1723
+ BUNDLE_REPLACEMENT_DOES_NOT_FIT_TARGET_PLAN: "{bundleName} continues on version {version} from {from}, which cannot run on {planName}. Cancel it, and the change goes through \u2014 or choose another plan.",
1724
+ REDUNDANT_FEATURES: "The plan or another booked bundle already includes {count} of the features in this bundle \u2014 booking it pays for them twice.",
1725
+ MINIMUM_TERM_BINDS: "The minimum term extends beyond the end of the period \u2014 the cancellation only takes effect when the minimum term ends.",
1726
+ BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED: "The bundle requires [{features}] \u2014 present neither in the plan nor in the active bundles.",
1727
+ ONBOARDING_CREATE_FAILED: "The account could not be created. Please try again.",
1728
+ BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS: "Exactly one of bundleVersionId (add preview) or subscriptionBundleId (cancel preview) must be given.",
1729
+ SUBSCRIPTION_PK_MISSING: "The adapter returned a subscription usage record without an id. Pass the subscription primary key through (see SubscriptionUsageRecord.id).",
1730
+ LIMIT_EXCEEDED: "The limit for {dimension} has been reached: {used} of {max}.",
1731
+ QUOTA_DIMENSION_UNKNOWN: 'Unknown quota dimension "{dimension}".',
1732
+ // ── promo ──
1733
+ PROMO_CODE_NOT_FOUND: "Code not found",
1734
+ PROMO_CODE_ALREADY_EXISTS: "The code exists, or a deleted code carries it; a deleted code keeps its name.",
1735
+ PROMO_CODE_HAS_REDEMPTIONS: "The code already has redemptions, or checkouts holding one \u2014 it cannot be soft-deleted. Pause it instead.",
1736
+ PROMO_CODE_NOT_REDEEMABLE: "Code cannot be redeemed: {reason}",
1737
+ PROMO_CODE_FORMAT_INVALID: 'The code may only contain upper-case letters, digits, "-" and "_" (4\u201332 characters).',
1738
+ PROMO_PERCENT_OUT_OF_RANGE: "The percentage must be between 0 and 100.",
1739
+ PROMO_AMOUNT_NOT_POSITIVE: "The amount must be positive.",
1740
+ PROMO_ONE_OFF_WITH_DURATION: "A one-off discount must not set a duration.",
1741
+ PROMO_DURATION_INVALID: "Invalid duration (at most 24 months or billing periods).",
1742
+ PROMO_VALIDITY_WINDOW_INVALID: "Invalid validity window.",
1743
+ PROMO_PLAN_NOT_DISCOUNTABLE: "{plan}-Plan cannot be discounted.",
1744
+ PROMO_MIN_AMOUNT_NOT_POSITIVE: "The minimum plan gross amount must be positive.",
1745
+ PROMO_WOULD_PRODUCE_ZERO_INVOICE: "For absolute amounts the discount must stay below the lowest applicable plan price, or allowZeroInvoice must be enabled.",
1746
+ PROMO_MAX_REDEMPTIONS_LOWERED: "maxRedemptions cannot be lowered.",
1747
+ // ── contract ──
1748
+ SUBSCRIPTION_CONTRACT_TAX_RATE_NOT_DECIDED: "The contract states {stated} % in {field}, and the tax adapter decides {decided} %.",
1749
+ CHECKOUT_OFFER_LINE_ITEMS_REQUIRED: "A checkout offer can yield only one contract, and only once its line items are frozen.",
1750
+ CHECKOUT_OFFER_PLAN_LINE_ITEM_REQUIRED: "A checkout offer requires a frozen plan line item.",
1751
+ CHECKOUT_OFFER_BUNDLE_LINE_ITEMS_REQUIRED: "Every selected bundle version requires a frozen bundle line item.",
1752
+ CHECKOUT_OFFER_BUNDLE_VERSION_NOT_BOOKABLE: "At least one bundle version from the checkout offer is no longer bookable.",
1753
+ CHECKOUT_OFFER_FEATURE_DEPENDENCY_UNSATISFIED: "The selected plan does not cover all feature dependencies: [{missingRequires}] are missing from the plan + selected bundles.",
1754
+ CHECKOUT_OFFER_PLAN_NOT_OFFERED: "Plan '{planKey}' is not offered with a {billingCycle} price at the moment.",
1755
+ CHECKOUT_OFFER_BUNDLE_NOT_OFFERED: "Bundle version '{bundleVersionId}' cannot be added to this offer ({reason}).",
1756
+ CHECKOUT_OFFER_PROMO_CODE_NOT_ACCEPTED: "The promo code cannot be applied to this offer ({reason}).",
1757
+ CHECKOUT_OFFER_PRICE_NOT_CURRENT: "The prices of checkout offer '{offerId}' no longer match the catalogue; create a new offer.",
1758
+ SUBSCRIPTION_CONTRACT_LINE_ITEMS_REQUIRED: "A subscription contract requires at least one line item.",
1759
+ SUBSCRIPTION_CONTRACT_PLAN_LINE_ITEM_REQUIRED: "A subscription contract requires exactly one plan base item.",
1760
+ SUBSCRIPTION_CONTRACT_INVALID_DATE: "{field} must be a valid date.",
1761
+ SUBSCRIPTION_CONTRACT_INVALID_WINDOW: "effectiveUntil must be after effectiveFrom.",
1762
+ SUBSCRIPTION_CONTRACT_LINE_ITEM_TAX_MISMATCH: "A line item's taxAmount must be exactly priceGross minus priceNet.",
1763
+ SUBSCRIPTION_CONTRACT_TAX_RATE_NOT_PERCENT: "A subscription contract states a tax rate of {taxRate} at {field}, which is not a percentage: a rate lies from 0 to 100, and a value between 0 and 1 is refused as a fraction.",
1764
+ SUBSCRIPTION_CONTRACT_TERMINATION_BEFORE_START: "effectiveUntil must be after the effectiveFrom of the contract.",
1765
+ SUBSCRIPTION_CONTRACT_LINE_ITEM_CURRENCY_MISMATCH: "A line item must be booked in the currency its contract was priced in.",
1766
+ SUBSCRIPTION_CONTRACT_LINES_DO_NOT_ADD_UP: "The line items of a subscription contract add up to {lines} for {field}, but the contract states {stated}.",
1767
+ SUBSCRIPTION_CONTRACT_DISCOUNT_NEGATIVE: "A subscription contract states a discount of {amount} at {field}; a discount takes money off and is never negative.",
1768
+ CHECKOUT_OFFER_NOT_FOUND: "CheckoutOffer '{offerId}' not found",
1769
+ CHECKOUT_OFFER_EXPIRED: "Checkout offer '{offerId}' has expired and cannot be {action}",
1770
+ CHECKOUT_OFFER_ALREADY_CONSUMED: "Checkout offer '{offerId}' has already been consumed and cannot be {action}",
1771
+ CHECKOUT_OFFER_NOT_CONSUMED: "CheckoutOffer '{offerId}' must be consumed before the contract is created",
1772
+ CHECKOUT_OFFER_CHANGED: "Checkout offer '{offerId}' changed while it was being concluded. Load it again.",
1773
+ CHECKOUT_OFFER_CONTRACT_IN_FORCE: "Checkout offer '{offerId}' concludes a first contract, and this tenant already has one. A running subscription changes through its plan and its add-ons.",
1774
+ CHECKOUT_OFFER_ADD_ON_BOOKED_IN_ANOTHER_VERSION: "Checkout offer '{offerId}' names version {offeredVersion} of add-on '{bundleKey}', which this tenant has booked in version {bookedVersion} (booking {subscriptionBundleId}). Its version changes through the offer beside the add-on.",
1775
+ SUBSCRIPTION_CONTRACT_NOT_FOUND: "SubscriptionContract '{contractId}' not found",
1776
+ NO_ACTIVE_SUBSCRIPTION_CONTRACT: "No active subscription contract for tenant {tenantId}",
1777
+ SUBSCRIPTION_CONTRACT_ALREADY_CLOSED: "SubscriptionContract '{contractId}' is already closed",
1778
+ SUBSCRIPTION_CONTRACT_CHANGED: "The contracts of tenant '{tenantId}' changed while a successor was being written, or one begins after the moment it would take effect, so it would run beside another. Nothing was written.",
1779
+ // ── subscriber ──
1780
+ SUBSCRIBER_REQUIRED: "Tenant '{tenantId}' has no subscriber. Nothing is agreed or charged without the party to it: create the tenant's subscriber first.",
1781
+ SUBSCRIBER_ALREADY_EXISTS: "Tenant '{tenantId}' already has a subscriber.",
1782
+ SUBSCRIBER_NOT_FOUND: "Subscriber '{subscriberId}' not found",
1783
+ SUBSCRIBER_LEGAL_NAME_REQUIRED: "A subscriber needs its legal name.",
1784
+ SUBSCRIBER_DETAIL_INVALID: "The subscriber's {field} is not valid.",
1785
+ SUBSCRIBER_IDENTITY_INCOMPLETE: "The subscriber's billing address is not complete yet: a contract names it only with street and number, postal code, city and country.",
1786
+ SUBSCRIBER_IDENTITY_NOT_A_CONTACT: "{field} is part of the subscriber's legal identity and changes only as a correction, with a reason.",
1787
+ SUBSCRIBER_BUSINESS_STATUS_REASON_REQUIRED: "A change of whether the subscriber is a business needs a reason.",
1788
+ SUBSCRIBER_VAT_ID_MISSING: "The subscriber has no VAT identification number to check.",
1789
+ SUBSCRIBER_CORRECTION_REASON_REQUIRED: "A correction of the legal identity needs a reason.",
1790
+ SUBSCRIBER_CORRECTION_ACTOR_REQUIRED: "A correction of the legal identity has to say who makes it.",
1791
+ SUBSCRIBER_CORRECTION_CHANGES_NOTHING: "The correction changes nothing: every value it names is already recorded.",
1792
+ SUBSCRIBER_TAKEOVER_IS_A_TRANSFER: "Another legal entity taking over a subscriber is a transfer, not a correction, and cannot be recorded as an edit.",
1793
+ SUBSCRIBER_BUSINESS_STATUS_NOT_A_CONTACT: "Whether the subscriber is a business is part of its tax origin and changes only as a recorded change that names who made it.",
1794
+ SUBSCRIBER_CHANGE_ACTOR_REQUIRED: "A change of the subscriber's details has to say who makes it.",
1795
+ // ── registration ──
1796
+ PENDING_REGISTRATION_NOT_FOUND: "This registration could not be found. It may have already been completed or discarded.",
1797
+ PENDING_REGISTRATION_EXPIRED: "This registration has expired. Please start again.",
1798
+ INVALID_REGISTRATION_STATE: "This step is not available at the current stage of the registration.",
1799
+ OTP_INVALID: "That code is not correct. Please check it and try again.",
1800
+ OTP_EXPIRED: "That code has expired. Please request a new one.",
1801
+ OTP_LOCKED: "Too many incorrect attempts. Please request a new code.",
1802
+ RATE_LIMITED: "Too many attempts. Please try again in {retryAfterSeconds} seconds.",
1803
+ RESUME_TOKEN_INVALID: "This resume link is no longer valid. Please request a new one.",
1804
+ RESUME_NOT_CONFIGURED: "Resuming a registration is not available.",
1805
+ CONFIGURATOR_NOT_CONFIGURED: "The configurator is not available.",
1806
+ CONFIG_NOT_SAVED: "The configuration could not be saved.",
1807
+ PLAN_NOT_AVAILABLE: "This plan is not available.",
1808
+ PLAN_NOT_SELECTED: "Please select a plan first.",
1809
+ MODEL_NOT_AVAILABLE: "This option is not available.",
1810
+ // ── payments ──
1811
+ PAYMENTS_NOT_CONFIGURED: "Payment methods cannot be set up here yet.",
1812
+ PAYMENT_GATEWAY_ACCOUNT_UNKNOWN: "No payment gateway account is configured under '{account}'.",
1813
+ PAYMENT_CALLBACK_REJECTED: "The payment callback could not be verified.",
1814
+ PAYMENT_RETURN_URL_NOT_ALLOWED: "The {field} leads to a site this installation does not return to.",
1815
+ PAYMENT_GATEWAY_FAILED: "The payment provider did not answer as expected. Please try again in a few minutes.",
1816
+ // ── entitlement (code lives in upsell.types.ts) ──
1817
+ [FEATURE_NOT_LICENSED]: "Feature {featureKeys} is not included in the current plan.",
1818
+ // ── settings ──
1819
+ SETTINGS_CHANGE_NOT_FOUND: "No recorded settings change has this id.",
1820
+ // ── maintenance ──
1821
+ MAINTENANCE: "The application is under maintenance.",
1822
+ MAINTENANCE_WINDOW_ALREADY_OPEN: "A maintenance window is already open. Move or cancel it before announcing another.",
1823
+ MAINTENANCE_WINDOW_NOT_OPEN: "No open maintenance window has this id.",
1824
+ MAINTENANCE_WINDOW_LOCKED: "This maintenance window is locked. Its start cannot move, and unlocking is what ends it.",
1825
+ MAINTENANCE_WINDOW_END_NOT_AFTER_START: "The end of a maintenance window has to be after its start.",
1826
+ MAINTENANCE_WINDOW_END_IN_PAST: "The end of a maintenance window cannot be in the past.",
1827
+ MAINTENANCE_TIME_INVALID: "The {field} has to be a date and time with its zone, such as 2026-10-02T22:00+02:00.",
1828
+ MAINTENANCE_MESSAGE_TOO_LONG: "The message may be at most {max} characters long.",
1829
+ // ── tax ──
1830
+ TAX_TREATMENT_NOT_SUPPORTED: "The tax adapter {adapter} does not support this case: {reason}",
1831
+ TAX_VAT_ID_CHECK_NOT_COMPLETED: "The VAT identification number could not be checked just now ({reason}). Please try again later.",
1832
+ TAX_VAT_ID_CHECK_NOT_AVAILABLE: "This installation names no tax adapter, so no VAT identification number is checked."
1833
+ };
1834
+ function formatErrorMessage(template, params = {}) {
1835
+ return template.replace(/\{(\w+)\}/g, (match, name) => {
1836
+ const value = params[name];
1837
+ return value === void 0 || value === null ? match : String(value);
1838
+ });
1839
+ }
1840
+ function resolveErrorMessage(body, overrides = {}, defaults = ERROR_MESSAGES_EN) {
1841
+ const code = typeof body.code === "string" ? body.code : void 0;
1842
+ const template = (code && (overrides[code] ?? defaults[code])) ?? void 0;
1843
+ if (!template) {
1844
+ return typeof body.message === "string" ? body.message : code ?? "";
1845
+ }
1846
+ const { params, ...rest } = body;
1847
+ return formatErrorMessage(template, { ...rest, ...params });
1848
+ }
1849
+
1850
+ // src/refusal.ts
1851
+ function refusal(code, reason, params) {
1852
+ return new PersistenceRefusal(
1853
+ code,
1854
+ reason,
1855
+ formatErrorMessage(ERROR_MESSAGES_EN[code], params),
1856
+ params
1857
+ );
1858
+ }
1859
+
1860
+ // src/catalog-version-refusals.ts
1861
+ var CASES = {
1862
+ PlanVersion: {
1863
+ gone: { code: CATALOG_ERROR_CODES.PLAN_VERSION_NOT_FOUND, param: "versionId" },
1864
+ published: { code: CATALOG_ERROR_CODES.PLAN_VERSION_ALREADY_PUBLISHED, param: "versionId" },
1865
+ draft: { code: CATALOG_ERROR_CODES.PLAN_DRAFT_ALREADY_EXISTS, param: "planKey" }
1866
+ },
1867
+ BundleVersion: {
1868
+ gone: { code: CATALOG_ERROR_CODES.BUNDLE_VERSION_NOT_FOUND, param: "bundleVersionId" },
1869
+ published: {
1870
+ code: CATALOG_ERROR_CODES.BUNDLE_VERSION_ALREADY_PUBLISHED,
1871
+ param: "versionId"
1872
+ },
1873
+ draft: { code: CATALOG_ERROR_CODES.BUNDLE_DRAFT_ALREADY_EXISTS, param: "bundleKey" }
1874
+ }
1875
+ };
1876
+ function catalogVersionGone(kind, versionId) {
1877
+ const { code, param } = CASES[kind].gone;
1878
+ return new PersistenceRefusal(code, "gone", `${kind} '${versionId}' not found.`, {
1879
+ [param]: versionId
1880
+ });
1881
+ }
1882
+ function catalogVersionAlreadyPublished(kind, versionId) {
1883
+ const { code, param } = CASES[kind].published;
1884
+ return new PersistenceRefusal(
1885
+ code,
1886
+ "moved",
1887
+ `${kind} '${versionId}' is already published; it is not published again or discarded.`,
1888
+ { [param]: versionId }
1889
+ );
1890
+ }
1891
+ function catalogDraftExists(kind, key, draftVersion) {
1892
+ const { code, param } = CASES[kind].draft;
1893
+ return refusal(code, "moved", { [param]: key, draftVersion });
1894
+ }
1895
+
1896
+ // src/catalog-key-refusals.ts
1897
+ function planKeyTaken(planKey) {
1898
+ return refusal(CATALOG_ERROR_CODES.PLAN_ALREADY_EXISTS, "moved", { planKey });
1899
+ }
1900
+ function bundleKeyTaken(bundleKey) {
1901
+ return refusal(CATALOG_ERROR_CODES.BUNDLE_ALREADY_EXISTS, "moved", { bundleKey });
1902
+ }
1903
+ function marketingProjectionTaken(target) {
1904
+ return refusal(CATALOG_ERROR_CODES.MARKETING_PROJECTION_ALREADY_EXISTS, "moved", {
1905
+ targetType: target.targetType,
1906
+ targetVersionId: target.targetVersionId,
1907
+ locale: target.locale
1908
+ });
1909
+ }
1910
+
1911
+ // src/decimal-string.ts
1912
+ function toDecimalString(value) {
1913
+ if (!Number.isFinite(value)) {
1914
+ throw new RangeError(`${String(value)} is not an amount a numeric column can hold.`);
1915
+ }
1916
+ return String(value);
1917
+ }
1918
+
1919
+ // src/promo-code-refusals.ts
1920
+ function promoCodeTaken(code) {
1921
+ return new PersistenceRefusal(
1922
+ PROMO_ERROR_CODES.PROMO_CODE_ALREADY_EXISTS,
1923
+ "moved",
1924
+ `Promo code '${code}' is taken.`,
1925
+ { promoCode: code }
1926
+ );
1927
+ }
1928
+
1929
+ // src/subscription-refusals.ts
1930
+ function subscriptionGone(tenantId) {
1931
+ return refusal(BILLING_ERROR_CODES.SUBSCRIPTION_NOT_FOUND, "gone", { tenantId });
1932
+ }
1933
+ function noActivePlanVersion(planId, asOf) {
1934
+ return refusal(BILLING_ERROR_CODES.NO_ACTIVE_PLAN_VERSION, "gone", {
1935
+ planId,
1936
+ asOf: asOf.toISOString().slice(0, 10)
1937
+ });
1938
+ }
1939
+ function planNotInCatalog(planKey) {
1940
+ return refusal(BILLING_ERROR_CODES.PLAN_NOT_IN_CATALOG, "gone", { planKey });
1941
+ }
1942
+ function subscriptionBundleGone(subscriptionBundleId) {
1943
+ return refusal(BILLING_ERROR_CODES.SUBSCRIPTION_BUNDLE_NOT_FOUND, "gone", {
1944
+ subscriptionBundleId
1945
+ });
1946
+ }
1947
+ function subscriptionBundleAlreadyCancelled(subscriptionBundleId) {
1948
+ return refusal(BILLING_ERROR_CODES.SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED, "moved", {
1949
+ subscriptionBundleId
1950
+ });
1951
+ }
1952
+ function subscriptionContractGone(contractId) {
1953
+ return refusal(CONTRACT_ERROR_CODES.SUBSCRIPTION_CONTRACT_NOT_FOUND, "gone", { contractId });
1954
+ }
1955
+
1956
+ // src/feature-requires.ts
1957
+ function buildFeatureRequiresIndex(features) {
1958
+ const index = /* @__PURE__ */ new Map();
1959
+ for (const feature of features) {
1960
+ const requires = (feature.requires ?? []).filter((key) => key !== feature.featureKey);
1961
+ if (requires.length > 0) index.set(feature.featureKey, requires);
1962
+ }
1963
+ return index;
1964
+ }
1965
+ function collectUnsatisfiedRequires(selected, index) {
1966
+ const own = new Set(selected);
1967
+ const unsatisfied = /* @__PURE__ */ new Set();
1968
+ for (const featureKey of selected) {
1969
+ for (const required of index.get(featureKey) ?? []) {
1970
+ if (!own.has(required)) unsatisfied.add(required);
1971
+ }
1972
+ }
1973
+ return [...unsatisfied].sort((a, b) => a.localeCompare(b));
1974
+ }
1975
+ function missingRequiresFor(bundle, coveredFeatures) {
1976
+ const missing = (bundle.requiresFeatures ?? []).filter((key) => !coveredFeatures.has(key));
1977
+ return [...new Set(missing)].sort((a, b) => a.localeCompare(b));
1978
+ }
1979
+ function resolveBundleAvailability(bundle, coveredFeatures) {
1980
+ if (bundle.features.length > 0 && bundle.features.every((f) => coveredFeatures.has(f))) {
1981
+ return "covered";
1982
+ }
1983
+ if (missingRequiresFor(bundle, coveredFeatures).length > 0) return "missing-requires";
1984
+ return "bookable";
1985
+ }
1986
+ function coverageExcludingSelf(selfVersionId, planFeatures, selectedBundles) {
1987
+ const covered = new Set(planFeatures);
1988
+ for (const bundle of selectedBundles) {
1989
+ if (bundle.bundleVersionId === selfVersionId) continue;
1990
+ for (const feature of bundle.features) covered.add(feature);
1991
+ }
1992
+ return covered;
1993
+ }
1994
+ function isBundleRedundant(bundle, planFeatures, selectedBundles) {
1995
+ const covered = coverageExcludingSelf(bundle.bundleVersionId, planFeatures, selectedBundles);
1996
+ return resolveBundleAvailability(bundle, covered) === "covered";
1997
+ }
1998
+ function compareSelectable(a, b) {
1999
+ const orderA = a.sortOrder ?? Number.MAX_SAFE_INTEGER;
2000
+ const orderB = b.sortOrder ?? Number.MAX_SAFE_INTEGER;
2001
+ if (orderA !== orderB) return orderA - orderB;
2002
+ return a.bundleVersionId.localeCompare(b.bundleVersionId);
2003
+ }
2004
+ function selectChargeableBundles(planFeatures, selectedBundles) {
2005
+ const kept = [...selectedBundles].sort(compareSelectable);
2006
+ for (; ; ) {
2007
+ const redundantIndex = kept.findIndex(
2008
+ (bundle) => isBundleRedundant(bundle, planFeatures, kept)
2009
+ );
2010
+ if (redundantIndex === -1) return kept;
2011
+ kept.splice(redundantIndex, 1);
2012
+ }
2013
+ }
2014
+
2015
+ // src/payment-gateway.types.ts
2016
+ var PAYMENT_CALLBACK_REJECTED = "PAYMENT_CALLBACK_REJECTED";
2017
+ var PaymentCallbackRejectedError = class extends Error {
2018
+ code = PAYMENT_CALLBACK_REJECTED;
2019
+ constructor(reason) {
2020
+ super(`Payment callback rejected: ${reason}`);
2021
+ this.name = "PaymentCallbackRejectedError";
2022
+ }
2023
+ };
2024
+ function isPaymentCallbackRejectedError(err) {
2025
+ return err instanceof Error && err.code === PAYMENT_CALLBACK_REJECTED;
2026
+ }
2027
+
2028
+ // src/registration.types.ts
2029
+ var PENDING_EMAIL_TTL_HOURS = 72;
2030
+ var PENDING_ONBOARDING_TTL_DAYS = 14;
2031
+ var PENDING_CHECKOUT_TTL_DAYS = 30;
2032
+ var OTP_TTL_MINUTES = 10;
2033
+ var PASSWORD_RESET_TTL_MINUTES = 30;
2034
+ var OTP_RATE_LIMIT_MAX_SENDS = 3;
2035
+ var OTP_RATE_LIMIT_WINDOW_MINUTES = 15;
2036
+ var OTP_VERIFY_MAX_ATTEMPTS = 5;
2037
+ var REGISTRATION_STEP_BY_STATUS = {
2038
+ PENDING_EMAIL_VERIFICATION: 2,
2039
+ EMAIL_VERIFIED: 3,
2040
+ PLAN_SELECTED: 4,
963
2041
  CHECKOUT_STARTED: 4,
964
2042
  EXPIRED: 1,
965
2043
  DELETED: 1
@@ -980,8 +2058,8 @@ function toPlanRow(row) {
980
2058
  deletedAt: toIsoOrNull(row.deletedAt)
981
2059
  };
982
2060
  }
983
- function toPlanVersionRow(row, planKey, fields) {
984
- const mapped = {
2061
+ function toPlanVersionRow(row, planKey) {
2062
+ return {
985
2063
  id: row.id,
986
2064
  version: row.version,
987
2065
  baseVersionId: row.baseVersionId,
@@ -996,17 +2074,14 @@ function toPlanVersionRow(row, planKey, fields) {
996
2074
  publishedChanges: Array.isArray(row.publishedChanges) ? row.publishedChanges : null,
997
2075
  changeNote: row.changeNote,
998
2076
  nonRegressive: row.nonRegressive,
999
- validFrom: fields.validityWindows ? toIsoOrNull(row.validFrom) : null,
1000
- validUntil: fields.validityWindows ? toIsoOrNull(row.validUntil) : null,
2077
+ validFrom: toIsoOrNull(row.validFrom),
2078
+ validUntil: toIsoOrNull(row.validUntil),
2079
+ endsAt: toIsoOrNull(row.endsAt),
1001
2080
  createdByUserId: row.createdByUserId,
1002
2081
  publishedByUserId: row.publishedByUserId,
1003
2082
  createdAt: row.createdAt.toISOString(),
1004
2083
  updatedAt: row.updatedAt.toISOString()
1005
2084
  };
1006
- if (fields.endsAt) {
1007
- mapped.endsAt = toIsoOrNull(row.endsAt);
1008
- }
1009
- return mapped;
1010
2085
  }
1011
2086
  function toIsoOrNull(value) {
1012
2087
  return value ? value.toISOString() : null;
@@ -1105,23 +2180,13 @@ function textOrNull(value) {
1105
2180
  return trimmed === "" ? null : trimmed;
1106
2181
  }
1107
2182
 
1108
- // src/closed-value.ts
1109
- function oneOf(allowed, value, source) {
1110
- const match = allowed.find((entry) => entry === value);
1111
- if (match === void 0) {
1112
- throw new Error(
1113
- `${source.table} row '${source.id}' holds ${source.column} '${value}', which is none of ${allowed.join(", ")}.`
1114
- );
1115
- }
1116
- return match;
1117
- }
1118
-
1119
2183
  // src/subscriber-ledger-mapping.ts
1120
2184
  var ORIGINS = {
1121
2185
  activation: true,
1122
2186
  renewal: true,
1123
2187
  planChange: true,
1124
2188
  bundleBooking: true,
2189
+ bundleChange: true,
1125
2190
  credit: true,
1126
2191
  correction: true
1127
2192
  };
@@ -1130,10 +2195,10 @@ var SOURCES = {
1130
2195
  bundle: true,
1131
2196
  discount: true
1132
2197
  };
1133
- var TABLE = "subscriber_ledger_entries";
2198
+ var TABLE2 = "subscriber_ledger_entries";
1134
2199
  var CENT_TOLERANCE = 1e-6;
1135
2200
  function toSubscriberChargeRecord(row) {
1136
- const where = (column) => ({ table: TABLE, column, id: row.id });
2201
+ const where = (column) => ({ table: TABLE2, column, id: row.id });
1137
2202
  return {
1138
2203
  id: row.id,
1139
2204
  subscriberId: row.subscriberId,
@@ -1153,34 +2218,165 @@ function toSubscriberChargeRecord(row) {
1153
2218
  };
1154
2219
  }
1155
2220
  function subscriberChargeColumns(charge) {
1156
- const cents = charge.amountNet * 100;
1157
- if (!Number.isFinite(cents) || Math.abs(cents - Math.round(cents)) > CENT_TOLERANCE) {
2221
+ const cents2 = charge.amountNet * 100;
2222
+ if (!Number.isFinite(cents2) || Math.abs(cents2 - Math.round(cents2)) > CENT_TOLERANCE) {
1158
2223
  throw new Error(
1159
2224
  `A charge of ${charge.amountNet} is not a whole number of cents; round it once where it is derived, before it is written.`
1160
2225
  );
1161
2226
  }
1162
2227
  return {
1163
- subscriberId: charge.subscriberId,
1164
- tenantId: charge.tenantId,
1165
- subscriptionId: charge.subscriptionId,
1166
- contractId: charge.contractId,
1167
- contractLineItemId: charge.contractLineItemId,
1168
- origin: charge.origin,
1169
- source: charge.source,
1170
- sourceRef: charge.sourceRef,
1171
- periodStart: charge.periodStart,
1172
- periodEnd: charge.periodEnd,
1173
- currency: charge.currency,
1174
- amountNet: charge.amountNet.toFixed(2),
1175
- bookedAt: charge.bookedAt
2228
+ subscriberId: charge.subscriberId,
2229
+ tenantId: charge.tenantId,
2230
+ subscriptionId: charge.subscriptionId,
2231
+ contractId: charge.contractId,
2232
+ contractLineItemId: charge.contractLineItemId,
2233
+ origin: charge.origin,
2234
+ source: charge.source,
2235
+ sourceRef: charge.sourceRef,
2236
+ periodStart: charge.periodStart,
2237
+ periodEnd: charge.periodEnd,
2238
+ currency: charge.currency,
2239
+ amountNet: charge.amountNet.toFixed(2),
2240
+ bookedAt: charge.bookedAt
2241
+ };
2242
+ }
2243
+ function keysOf(record) {
2244
+ return Object.keys(record);
2245
+ }
2246
+
2247
+ // src/subscriber-ledger.types.ts
2248
+ var SUBSCRIBER_ACCOUNT_CAPABILITY = "charges.read";
2249
+
2250
+ // src/subscriber.types.ts
2251
+ var SUBSCRIBER_INVOICE_ADDRESS_FIELDS = [
2252
+ "addressLine1",
2253
+ "postalCode",
2254
+ "city",
2255
+ "country"
2256
+ ];
2257
+ var SUBSCRIBER_STANDING_CAPABILITY = "subscribers.read";
2258
+ var SUBSCRIBER_ATTENTION_CAPABILITY = "subscribers.attention";
2259
+ var SUBSCRIBER_ATTENTION_PAGE_SIZE = 200;
2260
+ var SUBSCRIBER_CORRECTION_CAPABILITY = "subscribers.correct";
2261
+ var SUBSCRIBER_TAX_ORIGIN_FIELDS = ["country", "business", "vatId"];
2262
+
2263
+ // src/tax.types.ts
2264
+ var TAX_TREATMENT_KINDS = [
2265
+ "standard",
2266
+ "reduced",
2267
+ "exempt",
2268
+ "reverse-charge",
2269
+ "not-taxable",
2270
+ "small-business"
2271
+ ];
2272
+
2273
+ // src/tax-origin.ts
2274
+ var VAT_ID_SEPARATORS = /[\s.-]/g;
2275
+ function canonicalVatId(written) {
2276
+ const vatId = written.replace(VAT_ID_SEPARATORS, "").toUpperCase();
2277
+ return vatId === "" ? null : vatId;
2278
+ }
2279
+ function taxOriginOf(subscriber, currentCheck) {
2280
+ const validated = subscriber.vatId !== null && currentCheck?.valid === true && currentCheck.vatId === subscriber.vatId;
2281
+ return {
2282
+ country: subscriber.country,
2283
+ business: subscriber.business,
2284
+ vatId: subscriber.vatId,
2285
+ validatedVatId: validated ? subscriber.vatId : null
2286
+ };
2287
+ }
2288
+ function keepsVatIdCheck(held, counting, check) {
2289
+ if (held.vatId === null || check.vatId !== held.vatId) return false;
2290
+ if (held.vatIdSince !== null && check.checkedAt.getTime() < held.vatIdSince.getTime()) {
2291
+ return false;
2292
+ }
2293
+ if (counting === null || counting.vatId !== held.vatId) return true;
2294
+ return counting.checkedAt.getTime() <= check.checkedAt.getTime();
2295
+ }
2296
+ function toSubscriberVatIdCheckRecord(row) {
2297
+ return {
2298
+ id: row.id,
2299
+ subscriberId: row.subscriberId,
2300
+ vatId: row.vatId,
2301
+ checkedAt: row.checkedAt,
2302
+ valid: row.valid,
2303
+ service: row.service,
2304
+ confirmation: textEntries(row.confirmation),
2305
+ recordedAt: row.recordedAt
2306
+ };
2307
+ }
2308
+ function taxTreatmentToJson(treatment) {
2309
+ return {
2310
+ kind: treatment.kind,
2311
+ rate: treatment.rate,
2312
+ note: treatment.note,
2313
+ adapter: { name: treatment.adapter.name, version: treatment.adapter.version }
2314
+ };
2315
+ }
2316
+ function toTaxTreatment(value) {
2317
+ if (!isObject(value)) return null;
2318
+ const { kind, rate, note, adapter } = value;
2319
+ if (!isTreatmentKind(kind)) return null;
2320
+ if (typeof rate !== "number" || !Number.isFinite(rate)) return null;
2321
+ if (note !== null && typeof note !== "string") return null;
2322
+ if (!isObject(adapter)) return null;
2323
+ if (typeof adapter.name !== "string" || typeof adapter.version !== "string") return null;
2324
+ return { kind, rate, note, adapter: { name: adapter.name, version: adapter.version } };
2325
+ }
2326
+ function taxOriginWrite(current, next) {
2327
+ const previous = {};
2328
+ const changed = {};
2329
+ for (const field of SUBSCRIBER_TAX_ORIGIN_FIELDS) {
2330
+ const value = next[field];
2331
+ if (value === void 0 || value === current[field]) continue;
2332
+ previous[field] = current[field];
2333
+ changed[field] = value;
2334
+ }
2335
+ return {
2336
+ previous,
2337
+ changed,
2338
+ moved: Object.keys(changed).length > 0,
2339
+ endsCountingVatIdCheck: Object.prototype.hasOwnProperty.call(changed, "vatId")
1176
2340
  };
1177
2341
  }
1178
- function keysOf(record) {
1179
- return Object.keys(record);
2342
+ function toTaxOriginValues(value) {
2343
+ if (!isObject(value)) return {};
2344
+ const values = {};
2345
+ for (const field of SUBSCRIBER_TAX_ORIGIN_FIELDS) {
2346
+ if (!Object.prototype.hasOwnProperty.call(value, field)) continue;
2347
+ const entry = value[field];
2348
+ if (field === "business") {
2349
+ values[field] = typeof entry === "boolean" ? entry : null;
2350
+ } else {
2351
+ values[field] = typeof entry === "string" ? entry : null;
2352
+ }
2353
+ }
2354
+ return values;
2355
+ }
2356
+ function isTreatmentKind(value) {
2357
+ return TAX_TREATMENT_KINDS.includes(value);
2358
+ }
2359
+ function isObject(value) {
2360
+ return value !== null && typeof value === "object" && !Array.isArray(value);
2361
+ }
2362
+ function vatIdCheckFromStore(value) {
2363
+ if (!isObject(value)) return null;
2364
+ const { vatId, checkedAt, valid, service, confirmation } = value;
2365
+ const at = checkedAt instanceof Date ? checkedAt : new Date(String(checkedAt));
2366
+ if (typeof vatId !== "string" || typeof valid !== "boolean" || typeof service !== "string") {
2367
+ return null;
2368
+ }
2369
+ if (checkedAt === void 0 || checkedAt === null || Number.isNaN(at.getTime())) return null;
2370
+ return { vatId, checkedAt: at, valid, service, confirmation: textEntries(confirmation) };
2371
+ }
2372
+ function textEntries(value) {
2373
+ if (!isObject(value)) return {};
2374
+ const entries = {};
2375
+ for (const [key, entry] of Object.entries(value)) {
2376
+ if (typeof entry === "string") entries[key] = entry;
2377
+ }
2378
+ return entries;
1180
2379
  }
1181
-
1182
- // src/subscriber-ledger.types.ts
1183
- var SUBSCRIBER_ACCOUNT_CAPABILITY = "charges.read";
1184
2380
 
1185
2381
  // src/subscriber-mapping.ts
1186
2382
  function formatCustomerNumber(prefix, sequence) {
@@ -1199,6 +2395,7 @@ function toSubscriberRecord(row, tenantId) {
1199
2395
  vatId: row.vatId,
1200
2396
  taxNumber: row.taxNumber,
1201
2397
  invoiceEmail: row.invoiceEmail,
2398
+ business: row.business,
1202
2399
  tenantId,
1203
2400
  migrated: row.migrated,
1204
2401
  createdAt: row.createdAt,
@@ -1216,6 +2413,17 @@ function toSubscriberCorrectionRecord(row) {
1216
2413
  correctedAt: row.correctedAt
1217
2414
  };
1218
2415
  }
2416
+ function toSubscriberTaxOriginChangeRecord(row) {
2417
+ return {
2418
+ id: row.id,
2419
+ subscriberId: row.subscriberId,
2420
+ previous: toTaxOriginValues(row.previous),
2421
+ changed: toTaxOriginValues(row.changed),
2422
+ changedBy: row.changedBy,
2423
+ changedAt: row.changedAt,
2424
+ reason: row.reason
2425
+ };
2426
+ }
1219
2427
  function identityCorrectionDelta(current, corrected) {
1220
2428
  const previous = {};
1221
2429
  const next = {};
@@ -1279,7 +2487,9 @@ function subscriberFromRegistration(pending) {
1279
2487
  city: pending.city,
1280
2488
  country: pending.country,
1281
2489
  vatId: pending.vatId,
1282
- taxNumber: pending.taxNumber
2490
+ taxNumber: pending.taxNumber,
2491
+ business: pending.business,
2492
+ vatIdCheck: vatIdCheckFromStore(pending.vatIdCheck)
1283
2493
  };
1284
2494
  }
1285
2495
  function toIdentityValues(value) {
@@ -1297,7 +2507,7 @@ function toIdentityValues(value) {
1297
2507
  // src/subscriber-payment-method-mapping.ts
1298
2508
  var PAYMENT_METHOD_TYPES = ["card", "sepa_debit"];
1299
2509
  var STATUSES = ["ACTIVE", "REPLACED"];
1300
- var TABLE2 = "subscriber_payment_methods";
2510
+ var TABLE3 = "subscriber_payment_methods";
1301
2511
  function toSubscriberPaymentMethodRecord(row) {
1302
2512
  return {
1303
2513
  id: row.id,
@@ -1306,7 +2516,7 @@ function toSubscriberPaymentMethodRecord(row) {
1306
2516
  provider: row.provider,
1307
2517
  customerRef: row.customerRef,
1308
2518
  paymentMethodRef: row.paymentMethodRef,
1309
- type: oneOf(PAYMENT_METHOD_TYPES, row.type, { table: TABLE2, column: "type", id: row.id }),
2519
+ type: oneOf(PAYMENT_METHOD_TYPES, row.type, { table: TABLE3, column: "type", id: row.id }),
1310
2520
  brand: row.brand,
1311
2521
  last4: row.last4,
1312
2522
  expiryMonth: row.expiryMonth,
@@ -1314,7 +2524,7 @@ function toSubscriberPaymentMethodRecord(row) {
1314
2524
  country: row.country,
1315
2525
  bankCode: row.bankCode,
1316
2526
  mandateReference: row.mandateReference,
1317
- status: oneOf(STATUSES, row.status, { table: TABLE2, column: "status", id: row.id }),
2527
+ status: oneOf(STATUSES, row.status, { table: TABLE3, column: "status", id: row.id }),
1318
2528
  confirmedAt: row.confirmedAt,
1319
2529
  replacedAt: row.replacedAt,
1320
2530
  createdAt: row.createdAt
@@ -1380,6 +2590,8 @@ function toSubscriptionBundleRecord(row) {
1380
2590
  }),
1381
2591
  currentPeriodStart: row.currentPeriodStart ?? null,
1382
2592
  currentPeriodEnd: row.currentPeriodEnd ?? null,
2593
+ pendingBundleVersionId: row.pendingBundleVersionId ?? null,
2594
+ pendingVersionEffectiveAt: row.pendingVersionEffectiveAt ?? null,
1383
2595
  canceledAt: row.canceledAt,
1384
2596
  canceledEffectiveAt: row.canceledEffectiveAt,
1385
2597
  createdAt: row.createdAt,
@@ -1396,6 +2608,7 @@ function toSubscriptionContractRecord(row, lineItems) {
1396
2608
  subscriber: toSubscriberParty(row.subscriberSnapshot),
1397
2609
  issuer: isPlainObject2(row.issuerSnapshot) ? toIssuerParty(row.issuerSnapshot) : null,
1398
2610
  partiesMigrated: row.partiesMigrated,
2611
+ taxTreatment: toTaxTreatment(row.taxTreatment),
1399
2612
  status: row.status,
1400
2613
  effectiveFrom: row.effectiveFrom,
1401
2614
  effectiveUntil: row.effectiveUntil,
@@ -1495,6 +2708,52 @@ var ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES = [
1495
2708
  "scheduled"
1496
2709
  ];
1497
2710
 
2711
+ // src/custom-limits.ts
2712
+ var CUSTOM_LIMITS_KEYS = ["quotas", "features"];
2713
+ var NOT_AN_OBJECT = "(the value is not an object)";
2714
+ function readCustomLimits(value) {
2715
+ if (value === null || value === void 0) return { limits: null, unread: [] };
2716
+ if (typeof value !== "object" || Array.isArray(value)) {
2717
+ return { limits: null, unread: [NOT_AN_OBJECT] };
2718
+ }
2719
+ const limits = {};
2720
+ const unread = [];
2721
+ for (const [key, entry] of Object.entries(value)) {
2722
+ if (key === "quotas" && isRecord(entry)) {
2723
+ limits.quotas = {};
2724
+ for (const [quota, amount] of Object.entries(entry)) {
2725
+ const value2 = readQuotaValue(amount);
2726
+ if (value2 === null) unread.push(`quotas.${quota}`);
2727
+ else limits.quotas[quota] = value2;
2728
+ }
2729
+ } else if (key === "features" && isFeatureList(entry)) {
2730
+ limits.features = [...entry];
2731
+ } else {
2732
+ unread.push(key);
2733
+ }
2734
+ }
2735
+ return { limits, unread };
2736
+ }
2737
+ function isRecord(value) {
2738
+ return value !== null && typeof value === "object" && !Array.isArray(value);
2739
+ }
2740
+ function isFeatureList(value) {
2741
+ return Array.isArray(value) && value.every((entry) => typeof entry === "string");
2742
+ }
2743
+ function customLimitsReader(report) {
2744
+ const reported = /* @__PURE__ */ new Set();
2745
+ return (subscriptionId, stored) => {
2746
+ const { limits, unread } = readCustomLimits(stored);
2747
+ if (unread.length > 0 && !reported.has(subscriptionId)) {
2748
+ reported.add(subscriptionId);
2749
+ report(
2750
+ `Subscription ${subscriptionId}: customLimits carries ${unread.join(", ")}, which the platform does not read, so these limits are not applied. It reads { quotas: { <quotaKey>: number }, features: string[] } (CustomLimits in @saasicat/core).`
2751
+ );
2752
+ }
2753
+ return limits;
2754
+ };
2755
+ }
2756
+
1498
2757
  // src/version-editability.ts
1499
2758
  function isVersionEditable(v, now = /* @__PURE__ */ new Date()) {
1500
2759
  if (v.publishedAt === null) {
@@ -1533,227 +2792,6 @@ function keepOneRecommended(plans, inRequestedLocale) {
1533
2792
  return winner;
1534
2793
  }
1535
2794
 
1536
- // src/error-messages.ts
1537
- var ERROR_MESSAGES_EN = {
1538
- // ── setup ──
1539
- SETUP_DISABLED: "{envVar} is not set \u2014 setup is disabled.",
1540
- INVALID_SETUP_TOKEN: "The setup token is not valid.",
1541
- SETUP_ALREADY_DONE: "Setup has already been completed.",
1542
- INVALID_EMAIL: "That is not a valid email address.",
1543
- EMAIL_EXISTS: "An account with this email address already exists.",
1544
- // ── auth ──
1545
- NOT_AUTHENTICATED: "Not authenticated",
1546
- NO_TENANT_ASSIGNED: "No tenant assigned",
1547
- TENANT_CONTEXT_MISSING: "No tenant ID found on the request",
1548
- TENANT_ADMIN_REQUIRED: "This action requires the TENANT_ADMIN role.",
1549
- BILLING_PERMISSION_REQUIRED: "This part of the billing area requires the billing permission.",
1550
- SUPER_ADMIN_REQUIRED: "Only the SUPER_ADMIN role is allowed",
1551
- MFA_NOT_SET_UP: "Run the MFA setup via the CLI first.",
1552
- MFA_REQUIRED: "TOTP code required in the X-Mfa-Code header.",
1553
- MFA_FAILED: "Invalid TOTP code.",
1554
- AUTH_GUARDS_NOT_CONFIGURED: "TenantBillingModule.forRoot.authGuards is not configured.",
1555
- // ── catalog ──
1556
- PLAN_HAS_DRAFTS: "Plan '{planKey}' still has {draftCount} open draft version(s). Discard them first (DELETE /admin/catalog/plan-versions/:id) or publish them.",
1557
- PLAN_HAS_PUBLISHED_VERSIONS: "Plan '{planKey}' cannot be {operation} \u2014 it has {publishedCount} published version(s) ({liveCount} live, {supersededCount} superseded). Existing subscriptions reference those versions (contract protection P1), so the plan record must be preserved.",
1558
- PLAN_HARD_DELETE_NOT_IMPLEMENTED: "Hard delete is not implemented in the current repository. Implement PlanRepository.hardDelete.",
1559
- PLAN_VERSION_ALREADY_PUBLISHED: "PlanVersion '{versionId}' is already published and cannot be discarded.",
1560
- PLAN_VERSION_NOT_EDITABLE: "PlanVersion '{versionId}' is not editable. Only drafts and published versions are editable that are latest-in-chain, bind no subscription yet, and whose validFrom lies in the future.",
1561
- PLAN_VERSION_REGRESSION: "This plan version is regressive (feature removed / quota lowered / price raised). Publishing requires an explicit `forceRegressive: true` (UI confirmation dialog with MFA).",
1562
- PLAN_VERSION_ZERO_PRICE: "A plan version cannot be published with a price of 0.00 (guard against seed placeholder). For deliberately free special contracts, set allowZeroPrice.",
1563
- PLAN_VERSION_DISCARD_NOT_IMPLEMENTED: "Discard is not implemented in the current repository. Implement PlanRepository.deletePlanVersionDraft.",
1564
- PLAN_VERSION_NOT_PUBLISHED: "PlanVersion '{versionId}' is not published and cannot be terminated.",
1565
- PLAN_VERSION_SUPERSEDED: "PlanVersion '{versionId}' has already been superseded by a newer version and cannot be terminated.",
1566
- PLAN_VERSION_VALID_FROM_REQUIRED: "validFrom must be set when publishing (on the draft or the publish call)..",
1567
- PLAN_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' is not a valid date",
1568
- PLAN_VERSION_VALID_FROM_NOT_AFTER_PREVIOUS: "validFrom ({validFrom}) must be strictly after the validFrom of the previous version ({previousValidFrom}).",
1569
- PLAN_VERSION_VALID_FROM_NOT_GAPLESS: "The predecessor has validUntil={previousValidUntil} \u2014 the successor must start seamlessly on the next day ({requiredValidFrom}). Received: {received}.",
1570
- PLAN_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' is not a valid date",
1571
- PLAN_VERSION_VALID_UNTIL_BEFORE_FROM: "validUntil ({validUntil}) must be strictly after validFrom ({validFrom}).",
1572
- PLAN_TERMINATE_INVALID_DATE: "endsAt is not a valid date.",
1573
- PLAN_TERMINATE_DATE_NOT_FUTURE: "endsAt ({endsAt}) must lie strictly in the future.",
1574
- PLAN_TERMINATE_NOT_IMPLEMENTED: "Terminate is not implemented in the current repository. Implement PlanRepository.terminate.",
1575
- BUNDLE_VERSION_ALREADY_PUBLISHED: "BundleVersion '{versionId}' is already published and cannot be discarded.",
1576
- BUNDLE_VERSION_NOT_EDITABLE: "BundleVersion '{versionId}' is not editable. Only drafts and published versions are editable that are latest-in-chain, bind no subscription yet, and whose validFrom lies in the future.",
1577
- BUNDLE_VERSION_NOT_PUBLISHED: "BundleVersion '{bundleVersionId}' is not published and cannot be booked.",
1578
- BUNDLE_VERSION_SUPERSEDED: "BundleVersion '{bundleVersionId}' has been superseded by a newer version.",
1579
- BUNDLE_VERSION_REGRESSION: "This bundle version is regressive (feature removed / quota lowered / price raised). Publishing requires an explicit `forceRegressive: true` (UI confirmation dialog with MFA).",
1580
- BUNDLE_VERSION_ZERO_PRICE: "A bundle version cannot be published with an explicit price of 0.00 (guard against seed placeholders). For free bundles leave it null, or set allowZeroPrice.",
1581
- BUNDLE_VERSION_NO_PRICE: "This bundle version cannot be published without a price: neither a base price nor any plan override resolves one.",
1582
- BUNDLE_VERSION_NOT_PRICED_FOR_PLAN: "This bundle is offered to plan '{planKey}', which is sold {billingCycle}, and no {billingCycle} price resolves for it \u2014 neither a base price nor a plan override.",
1583
- BUNDLE_VERSION_DISCARD_NOT_IMPLEMENTED: "Discard is not implemented in the current repository. Implement BundleRepository.deleteDraft.",
1584
- BUNDLE_VERSION_VALID_FROM_REQUIRED: "Published bundle versions must keep a validFrom. Set a new future date, or edit the draft before publishing.",
1585
- BUNDLE_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' is not a valid date",
1586
- BUNDLE_VERSION_VALID_FROM_NOT_AFTER_PREVIOUS: "validFrom ({validFrom}) must be strictly after the validFrom of the previous version ({previousValidFrom}).",
1587
- BUNDLE_VERSION_VALID_FROM_NOT_GAPLESS: "The predecessor has validUntil={previousValidUntil} \u2014 the successor must start seamlessly on the next day ({requiredValidFrom}). Received: {received}.",
1588
- BUNDLE_VERSION_VALID_FROM_NOT_FUTURE: "validFrom ({validFrom}) must, for a published-but-future bundle version, still lie in the future.",
1589
- BUNDLE_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' is not a valid date",
1590
- BUNDLE_VERSION_VALID_UNTIL_BEFORE_FROM: "validUntil ({validUntil}) must be strictly after validFrom ({validFrom}).",
1591
- STRICT_MODE_VIOLATIONS: "The strict-mode check found drift against the discovery snapshot.",
1592
- PLAN_NOT_FOUND: "Plan '{planId}' not found",
1593
- PLAN_VERSION_NOT_FOUND: "PlanVersion '{versionId}' not found",
1594
- BUNDLE_NOT_FOUND: "Bundle '{bundleId}' not found",
1595
- BUNDLE_VERSION_NOT_FOUND: "BundleVersion '{bundleVersionId}' not found",
1596
- FEATURE_NOT_FOUND: "Feature '{featureKey}' not found",
1597
- QUOTA_NOT_FOUND: "Quota '{quotaKey}' not found",
1598
- PROMOTION_NOT_FOUND: "Promotion '{promotionId}' not found",
1599
- PROMOTION_VALUE_INVALID: "The value of a '{type}' promotion is not one its type takes: a percentage above 0 and at most 100, an amount above 0, an intro price of at least 0 for a whole number of months, or a whole number of free months.",
1600
- MARKETING_PROJECTION_NOT_FOUND: "MarketingProjection '{projectionId}' not found",
1601
- PLAN_ALREADY_EXISTS: "Plan '{planKey}' already exists",
1602
- BUNDLE_ALREADY_EXISTS: "Bundle '{bundleKey}' already exists",
1603
- MARKETING_PROJECTION_ALREADY_EXISTS: "Marketing projection for {targetType}/{targetVersionId}/{locale} already exists \u2014 use PATCH to edit it",
1604
- PLAN_DRAFT_ALREADY_EXISTS: "Plan '{planKey}' already has a draft version v{draftVersion}; publish or discard it first",
1605
- BUNDLE_DRAFT_ALREADY_EXISTS: "Bundle '{bundleKey}' already has a draft version v{draftVersion}; publish or discard it first",
1606
- QUOTA_NOT_IN_DISCOVERY_SNAPSHOT: "Quota '{quotaKey}' is not in the discovery snapshot \u2014 a quota that is not declared in code cannot be approved",
1607
- DISCOVERY_STATUS_TRANSITION_INVALID: "Transition '{from}' \u2192 '{to}' is not allowed",
1608
- DISCOVERY_NOT_INITIALIZED: "Approval requires a discovery snapshot \u2014 discovery is not initialised (#25)",
1609
- // ── catalogue import ──
1610
- PLAN_CATALOG_UNREADABLE: "That file is not a plan catalog \u2014 it could not be read as one. Check that it is the YAML your app declares its plans in.",
1611
- PLAN_CATALOG_INVALID: "The plan catalog was read, and then rejected: {message}",
1612
- // ── billing ──
1613
- BUNDLE_ALREADY_SUBSCRIBED: "Subscription '{subscriptionId}' has already actively booked this bundle.",
1614
- BUNDLE_INCOMPATIBLE_WITH_PLAN: "BundleVersion '{bundleVersionId}' is not compatible with plan '{planKey}'. Allowed: [{allowedPlanKeys}].",
1615
- BUNDLE_NOT_SELF_SERVICE: "Bundle '{bundleKey}' is only activated via a special contract. Please contact the contract manager.",
1616
- BUNDLE_CYCLE_EXCEEDS_PLAN: "A yearly bundle cannot run beside a monthly plan: it would still be committed on every day the plan could end.",
1617
- BUNDLE_NOT_PRICED_FOR_THIS_PLAN: "This bundle has no {billingCycle} price for the {planKey} plan, so it cannot be booked from here.",
1618
- SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' is already cancelled.",
1619
- SUBSCRIPTION_BUNDLE_NOT_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' is not cancelled.",
1620
- SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE: "Cancellation already in effect \u2014 book the bundle again.",
1621
- SUBSCRIPTION_NOT_FOUND: "No subscription for tenant {tenantId}",
1622
- SUBSCRIPTION_TENANT_MISMATCH: "Subscription does not belong to the tenant",
1623
- SUBSCRIPTION_BUNDLE_NOT_FOUND: "SubscriptionBundle '{subscriptionBundleId}' not found",
1624
- TENANT_NOT_FOUND: "Tenant {slug} not found",
1625
- NO_ACTIVE_PLAN_VERSION: "No plan version for {planId} active as of {asOf} \u2014 neither the validFrom window is satisfied nor is a latest-live version available.",
1626
- PLAN_NOT_IN_CATALOG: 'Plan "{planKey}" is not in the catalog',
1627
- PLAN_NOT_SELF_SERVICE: "{planName} is only activated via a special contract. Please contact the contract manager.",
1628
- PLAN_NOT_SOLD_IN_CYCLE: "{planName} has no price for this billing rhythm and cannot be booked in it.",
1629
- PLAN_CHANGE_BLOCKED: "Plan change during onboarding is blocked.",
1630
- SUBSCRIPTION_CHANGED: "This subscription changed while the request was being decided. Reload it.",
1631
- NO_SUBSCRIPTION: "This tenant has no subscription to cancel.",
1632
- CANCELLATION_TERMS_CHANGED: "The effective date changed since it was shown. Confirm the new one.",
1633
- SUBSCRIPTION_ENDED: "This subscription has ended. Its plan can no longer be changed.",
1634
- PLAN_LOCKED: "Active {planName} special contract \u2014 please contact the contract manager to change plans.",
1635
- QUOTA_OVER_TARGET: "Current usage {used} exceeds the target limit {targetMax} ({quotaKey}) in the {planName} plan. Please reduce usage first.",
1636
- FEATURE_LOST: "Switching means losing access to one feature. Existing data is retained and never deleted \u2014 upgrading again unlocks it.",
1637
- FEATURES_LOST: "Switching means losing access to {count} features. Existing data is retained and never deleted \u2014 upgrading again unlocks it.",
1638
- NO_CHANGE: "Target plan and billing cycle already match the current state.",
1639
- CANCELLATION_LOCKS_THE_CYCLE: "This subscription is cancelled, so its billing cycle cannot change. The plan can \u2014 keep the current cycle to change it today.",
1640
- CYCLE_SHORTENS_AT_TERM_END: "A monthly {planName} cannot start inside the yearly term you are in. The upgrade takes effect when that term ends; to have it today, keep the yearly cycle.",
1641
- BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE: "A yearly bundle is booked until {until}. A monthly plan cannot carry it \u2014 cancel the bundle first, or keep the yearly cycle.",
1642
- REDUNDANT_FEATURES: "The plan or another booked bundle already includes {count} of the features in this bundle \u2014 booking it pays for them twice.",
1643
- MINIMUM_TERM_BINDS: "The minimum term extends beyond the end of the period \u2014 the cancellation only takes effect when the minimum term ends.",
1644
- BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED: "The bundle requires [{features}] \u2014 present neither in the plan nor in the active bundles.",
1645
- NO_PENDING_PLAN_VERSION: "There is no pending plan version awaiting confirmation.",
1646
- ONBOARDING_CREATE_FAILED: "The account could not be created. Please try again.",
1647
- BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS: "Exactly one of bundleVersionId (add preview) or subscriptionBundleId (cancel preview) must be given.",
1648
- SUBSCRIPTION_PK_MISSING: "The adapter returned a subscription usage record without an id. Pass the subscription primary key through (see SubscriptionUsageRecord.id).",
1649
- LIMIT_EXCEEDED: "The limit for {dimension} has been reached: {used} of {max}.",
1650
- QUOTA_DIMENSION_UNKNOWN: 'Unknown quota dimension "{dimension}".',
1651
- // ── promo ──
1652
- PROMO_CODE_NOT_FOUND: "Code not found",
1653
- PROMO_CODE_ALREADY_EXISTS: "The code already exists.",
1654
- PROMO_CODE_HAS_REDEMPTIONS: "The code already has redemptions, or checkouts holding one \u2014 it cannot be soft-deleted. Pause it instead.",
1655
- PROMO_CODE_NOT_REDEEMABLE: "Code cannot be redeemed: {reason}",
1656
- PROMO_CODE_FORMAT_INVALID: 'The code may only contain upper-case letters, digits, "-" and "_" (4\u201332 characters).',
1657
- PROMO_PERCENT_OUT_OF_RANGE: "The percentage must be between 0 and 100.",
1658
- PROMO_AMOUNT_NOT_POSITIVE: "The amount must be positive.",
1659
- PROMO_ONE_OFF_WITH_DURATION: "A one-off discount must not set a duration.",
1660
- PROMO_DURATION_INVALID: "Invalid duration (at most 24 months or billing periods).",
1661
- PROMO_VALIDITY_WINDOW_INVALID: "Invalid validity window.",
1662
- PROMO_PLAN_NOT_DISCOUNTABLE: "{plan}-Plan cannot be discounted.",
1663
- PROMO_MIN_AMOUNT_NOT_POSITIVE: "The minimum plan gross amount must be positive.",
1664
- PROMO_WOULD_PRODUCE_ZERO_INVOICE: "For absolute amounts the discount must stay below the lowest applicable plan price, or allowZeroInvoice must be enabled.",
1665
- PROMO_MAX_REDEMPTIONS_LOWERED: "maxRedemptions cannot be lowered.",
1666
- // ── contract ──
1667
- CHECKOUT_OFFER_LINE_ITEMS_REQUIRED: "A checkout offer can yield only one contract, and only once its line items are frozen.",
1668
- CHECKOUT_OFFER_PLAN_LINE_ITEM_REQUIRED: "A checkout offer requires a frozen plan line item.",
1669
- CHECKOUT_OFFER_BUNDLE_LINE_ITEMS_REQUIRED: "Every selected bundle version requires a frozen bundle line item.",
1670
- CHECKOUT_OFFER_BUNDLE_VERSION_NOT_BOOKABLE: "At least one bundle version from the checkout offer is no longer bookable.",
1671
- CHECKOUT_OFFER_FEATURE_DEPENDENCY_UNSATISFIED: "The selected plan does not cover all feature dependencies: [{missingRequires}] are missing from the plan + selected bundles.",
1672
- CHECKOUT_OFFER_PLAN_NOT_OFFERED: "Plan '{planKey}' is not offered with a {billingCycle} price at the moment.",
1673
- CHECKOUT_OFFER_BUNDLE_NOT_OFFERED: "Bundle version '{bundleVersionId}' cannot be added to this offer ({reason}).",
1674
- CHECKOUT_OFFER_PROMO_CODE_NOT_ACCEPTED: "The promo code cannot be applied to this offer ({reason}).",
1675
- CHECKOUT_OFFER_PRICE_NOT_CURRENT: "The prices of checkout offer '{offerId}' no longer match the catalogue; create a new offer.",
1676
- SUBSCRIPTION_CONTRACT_LINE_ITEMS_REQUIRED: "A subscription contract requires at least one line item.",
1677
- SUBSCRIPTION_CONTRACT_PLAN_LINE_ITEM_REQUIRED: "A subscription contract requires exactly one plan base item.",
1678
- SUBSCRIPTION_CONTRACT_INVALID_DATE: "{field} must be a valid date.",
1679
- SUBSCRIPTION_CONTRACT_INVALID_WINDOW: "effectiveUntil must be after effectiveFrom.",
1680
- SUBSCRIPTION_CONTRACT_LINE_ITEM_TAX_MISMATCH: "A line item's taxAmount must be exactly priceGross minus priceNet.",
1681
- SUBSCRIPTION_CONTRACT_TAX_RATE_NOT_PERCENT: "A subscription contract states a tax rate of {taxRate} at {field}, which is not a percentage: a rate lies from 0 to 100, and a value between 0 and 1 is refused as a fraction.",
1682
- SUBSCRIPTION_CONTRACT_TERMINATION_BEFORE_START: "effectiveUntil must be after the effectiveFrom of the contract.",
1683
- SUBSCRIPTION_CONTRACT_LINE_ITEM_CURRENCY_MISMATCH: "A line item must be booked in the currency its contract was priced in.",
1684
- SUBSCRIPTION_CONTRACT_LINES_DO_NOT_ADD_UP: "The line items of a subscription contract add up to {lines} for {field}, but the contract states {stated}.",
1685
- SUBSCRIPTION_CONTRACT_DISCOUNT_NEGATIVE: "A subscription contract states a discount of {amount} at {field}; a discount takes money off and is never negative.",
1686
- CHECKOUT_OFFER_NOT_FOUND: "CheckoutOffer '{offerId}' not found",
1687
- CHECKOUT_OFFER_EXPIRED: "Checkout offer '{offerId}' has expired and cannot be {action}",
1688
- CHECKOUT_OFFER_ALREADY_CONSUMED: "Checkout offer '{offerId}' has already been consumed and cannot be {action}",
1689
- CHECKOUT_OFFER_NOT_CONSUMED: "CheckoutOffer '{offerId}' must be consumed before the contract is created",
1690
- CHECKOUT_OFFER_CHANGED: "Checkout offer '{offerId}' changed while it was being concluded. Load it again.",
1691
- SUBSCRIPTION_CONTRACT_NOT_FOUND: "SubscriptionContract '{contractId}' not found",
1692
- NO_ACTIVE_SUBSCRIPTION_CONTRACT: "No active subscription contract for tenant {tenantId}",
1693
- SUBSCRIPTION_CONTRACT_ALREADY_CLOSED: "SubscriptionContract '{contractId}' is already closed",
1694
- SUBSCRIPTION_CONTRACT_CHANGED: "The contracts of tenant '{tenantId}' changed while a successor was being written, or one begins after the moment it would take effect, so it would run beside another. Nothing was written.",
1695
- // ── subscriber ──
1696
- SUBSCRIBER_REQUIRED: "Tenant '{tenantId}' has no subscriber. Nothing is agreed or charged without the party to it: create the tenant's subscriber first.",
1697
- SUBSCRIBER_ALREADY_EXISTS: "Tenant '{tenantId}' already has a subscriber.",
1698
- SUBSCRIBER_NOT_FOUND: "Subscriber '{subscriberId}' not found",
1699
- SUBSCRIBER_LEGAL_NAME_REQUIRED: "A subscriber needs its legal name.",
1700
- SUBSCRIBER_DETAIL_INVALID: "The subscriber's {field} is not valid.",
1701
- SUBSCRIBER_IDENTITY_NOT_A_CONTACT: "{field} is part of the subscriber's legal identity and changes only as a correction, with a reason.",
1702
- SUBSCRIBER_CORRECTION_REASON_REQUIRED: "A correction of the legal identity needs a reason.",
1703
- SUBSCRIBER_CORRECTION_ACTOR_REQUIRED: "A correction of the legal identity has to say who makes it.",
1704
- SUBSCRIBER_CORRECTION_CHANGES_NOTHING: "The correction changes nothing: every value it names is already recorded.",
1705
- SUBSCRIBER_TAKEOVER_IS_A_TRANSFER: "Another legal entity taking over a subscriber is a transfer, not a correction, and cannot be recorded as an edit.",
1706
- // ── registration ──
1707
- PENDING_REGISTRATION_NOT_FOUND: "This registration could not be found. It may have already been completed or discarded.",
1708
- PENDING_REGISTRATION_EXPIRED: "This registration has expired. Please start again.",
1709
- INVALID_REGISTRATION_STATE: "This step is not available at the current stage of the registration.",
1710
- OTP_INVALID: "That code is not correct. Please check it and try again.",
1711
- OTP_EXPIRED: "That code has expired. Please request a new one.",
1712
- OTP_LOCKED: "Too many incorrect attempts. Please request a new code.",
1713
- RATE_LIMITED: "Too many attempts. Please try again in {retryAfterSeconds} seconds.",
1714
- RESUME_TOKEN_INVALID: "This resume link is no longer valid. Please request a new one.",
1715
- RESUME_NOT_CONFIGURED: "Resuming a registration is not available.",
1716
- CONFIGURATOR_NOT_CONFIGURED: "The configurator is not available.",
1717
- CONFIG_NOT_SAVED: "The configuration could not be saved.",
1718
- PLAN_NOT_AVAILABLE: "This plan is not available.",
1719
- PLAN_NOT_SELECTED: "Please select a plan first.",
1720
- MODEL_NOT_AVAILABLE: "This option is not available.",
1721
- // ── payments ──
1722
- PAYMENTS_NOT_CONFIGURED: "Payment methods cannot be set up here yet.",
1723
- PAYMENT_GATEWAY_ACCOUNT_UNKNOWN: "No payment gateway account is configured under '{account}'.",
1724
- PAYMENT_CALLBACK_REJECTED: "The payment callback could not be verified.",
1725
- PAYMENT_RETURN_URL_NOT_ALLOWED: "The {field} leads to a site this installation does not return to.",
1726
- PAYMENT_GATEWAY_FAILED: "The payment provider did not answer as expected. Please try again in a few minutes.",
1727
- // ── entitlement (code lives in upsell.types.ts) ──
1728
- [FEATURE_NOT_LICENSED]: "Feature {featureKeys} is not included in the current plan.",
1729
- // ── settings ──
1730
- SETTINGS_CHANGE_NOT_FOUND: "No recorded settings change has this id.",
1731
- // ── maintenance ──
1732
- MAINTENANCE: "The application is under maintenance.",
1733
- MAINTENANCE_WINDOW_ALREADY_OPEN: "A maintenance window is already open. Move or cancel it before announcing another.",
1734
- MAINTENANCE_WINDOW_NOT_OPEN: "No open maintenance window has this id.",
1735
- MAINTENANCE_WINDOW_LOCKED: "This maintenance window is locked. Its start cannot move, and unlocking is what ends it.",
1736
- MAINTENANCE_WINDOW_END_NOT_AFTER_START: "The end of a maintenance window has to be after its start.",
1737
- MAINTENANCE_WINDOW_END_IN_PAST: "The end of a maintenance window cannot be in the past.",
1738
- MAINTENANCE_TIME_INVALID: "The {field} has to be a date and time with its zone, such as 2026-10-02T22:00+02:00.",
1739
- MAINTENANCE_MESSAGE_TOO_LONG: "The message may be at most {max} characters long."
1740
- };
1741
- function formatErrorMessage(template, params = {}) {
1742
- return template.replace(/\{(\w+)\}/g, (match, name) => {
1743
- const value = params[name];
1744
- return value === void 0 || value === null ? match : String(value);
1745
- });
1746
- }
1747
- function resolveErrorMessage(body, overrides = {}, defaults = ERROR_MESSAGES_EN) {
1748
- const code = typeof body.code === "string" ? body.code : void 0;
1749
- const template = (code && (overrides[code] ?? defaults[code])) ?? void 0;
1750
- if (!template) {
1751
- return typeof body.message === "string" ? body.message : code ?? "";
1752
- }
1753
- const { params, ...rest } = body;
1754
- return formatErrorMessage(template, { ...rest, ...params });
1755
- }
1756
-
1757
2795
  // src/error-messages-de.ts
1758
2796
  var ERROR_MESSAGES_DE = {
1759
2797
  // ── setup ──
@@ -1777,7 +2815,7 @@ var ERROR_MESSAGES_DE = {
1777
2815
  PLAN_HAS_DRAFTS: "Plan '{planKey}' hat noch {draftCount} offene Entwurfsversion(en). Verwirf sie zuerst (DELETE /admin/catalog/plan-versions/:id) oder ver\xF6ffentliche sie.",
1778
2816
  PLAN_HAS_PUBLISHED_VERSIONS: "Plan '{planKey}' kann nicht {operation} werden \u2014 er hat {publishedCount} ver\xF6ffentlichte Version(en) ({liveCount} live, {supersededCount} abgel\xF6st). Bestehende Abonnements verweisen auf diese Versionen (Vertragsschutz P1), deshalb muss der Plan-Datensatz erhalten bleiben.",
1779
2817
  PLAN_HARD_DELETE_NOT_IMPLEMENTED: "Hard Delete ist im aktuellen Repository nicht implementiert. Implementiere PlanRepository.hardDelete.",
1780
- PLAN_VERSION_ALREADY_PUBLISHED: "PlanVersion '{versionId}' ist bereits ver\xF6ffentlicht und kann nicht verworfen werden.",
2818
+ PLAN_VERSION_ALREADY_PUBLISHED: "PlanVersion '{versionId}' ist bereits ver\xF6ffentlicht und wird weder erneut ver\xF6ffentlicht noch verworfen.",
1781
2819
  PLAN_VERSION_NOT_EDITABLE: "PlanVersion '{versionId}' ist nicht bearbeitbar. Bearbeitbar sind nur Entw\xFCrfe sowie ver\xF6ffentlichte Versionen, die letzte in der Kette sind, noch kein Abonnement binden und deren validFrom in der Zukunft liegt.",
1782
2820
  PLAN_VERSION_REGRESSION: "Diese Planversion ist regressiv (Feature entfernt / Quota gesenkt / Preis erh\xF6ht). Das Ver\xF6ffentlichen erfordert ein ausdr\xFCckliches `forceRegressive: true` (Best\xE4tigungsdialog in der UI mit MFA).",
1783
2821
  PLAN_VERSION_ZERO_PRICE: "Eine Planversion l\xE4sst sich nicht mit einem Preis von 0,00 ver\xF6ffentlichen (Schutz vor Seed-Platzhaltern). F\xFCr bewusst kostenlose Sondervertr\xE4ge setze allowZeroPrice.",
@@ -1785,34 +2823,40 @@ var ERROR_MESSAGES_DE = {
1785
2823
  PLAN_VERSION_NOT_PUBLISHED: "Die PlanVersion '{versionId}' ist nicht ver\xF6ffentlicht und kann nicht beendet werden.",
1786
2824
  PLAN_VERSION_SUPERSEDED: "Die PlanVersion '{versionId}' wurde bereits von einer Nachfolgeversion abgel\xF6st und kann nicht beendet werden.",
1787
2825
  PLAN_VERSION_VALID_FROM_REQUIRED: "validFrom muss beim Ver\xF6ffentlichen gesetzt sein (am Entwurf oder im Publish-Aufruf)..",
1788
- PLAN_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' ist kein g\xFCltiges Datum",
2826
+ PLAN_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' ist kein Tag (JJJJ-MM-TT)",
1789
2827
  PLAN_VERSION_VALID_FROM_NOT_AFTER_PREVIOUS: "validFrom ({validFrom}) muss strikt nach dem validFrom der Vorg\xE4ngerversion ({previousValidFrom}) liegen.",
1790
2828
  PLAN_VERSION_VALID_FROM_NOT_GAPLESS: "Der Vorg\xE4nger hat validUntil={previousValidUntil} \u2014 der Nachfolger muss l\xFCckenlos am Folgetag ({requiredValidFrom}) beginnen. Erhalten: {received}.",
1791
- PLAN_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' ist kein g\xFCltiges Datum",
2829
+ PLAN_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' ist kein Tag (JJJJ-MM-TT)",
1792
2830
  PLAN_VERSION_VALID_UNTIL_BEFORE_FROM: "validUntil ({validUntil}) muss strikt nach validFrom ({validFrom}) liegen.",
1793
2831
  PLAN_TERMINATE_INVALID_DATE: "endsAt ist kein g\xFCltiges Datum.",
1794
2832
  PLAN_TERMINATE_DATE_NOT_FUTURE: "endsAt ({endsAt}) muss strikt in der Zukunft liegen.",
1795
2833
  PLAN_TERMINATE_NOT_IMPLEMENTED: "Das Beenden ist im aktuellen Repository nicht implementiert. Implementiere PlanRepository.terminate.",
1796
- BUNDLE_VERSION_ALREADY_PUBLISHED: "BundleVersion '{versionId}' ist bereits ver\xF6ffentlicht und kann nicht verworfen werden.",
2834
+ PLAN_TERMINATE_BEFORE_RETIREMENT_MOVES: "Abonnements ziehen noch auf Version {version} von {planKey} um. Sie kann fr\xFChestens am {date} enden.",
2835
+ PLAN_TERMINATE_WHILE_MOVES_OVERDUE: "{count} Abonnements sind \xFCber ihr Datum und ziehen noch auf Version {version} von {planKey} um. Sie kann erst enden, wenn sie umgezogen sind.",
2836
+ PLAN_TERMINATE_WHILE_NOTICES_UNDELIVERED: "{count} Abonnements wissen noch nicht, dass sie auf Version {version} von {planKey} umziehen. Sie kann erst enden, wenn sie es erfahren haben.",
2837
+ BUNDLE_VERSION_ALREADY_PUBLISHED: "BundleVersion '{versionId}' ist bereits ver\xF6ffentlicht und wird weder erneut ver\xF6ffentlicht noch verworfen.",
1797
2838
  BUNDLE_VERSION_NOT_EDITABLE: "BundleVersion '{versionId}' ist nicht bearbeitbar. Bearbeitbar sind nur Entw\xFCrfe sowie ver\xF6ffentlichte Versionen, die letzte in der Kette sind, noch kein Abonnement binden und deren validFrom in der Zukunft liegt.",
1798
2839
  BUNDLE_VERSION_NOT_PUBLISHED: "BundleVersion '{bundleVersionId}' ist nicht ver\xF6ffentlicht und l\xE4sst sich nicht buchen.",
1799
2840
  BUNDLE_VERSION_SUPERSEDED: "BundleVersion '{bundleVersionId}' wurde durch eine neuere Version abgel\xF6st.",
2841
+ BUNDLE_VERSION_NOT_YET_ON_SALE: "BundleVersion '{bundleVersionId}' ist ab {validFrom} im Verkauf und kann vorher nicht gebucht werden.",
2842
+ BUNDLE_DELETED: "Bundle '{bundleKey}' wurde aus dem Katalog gel\xF6scht und l\xE4sst sich nicht buchen.",
1800
2843
  BUNDLE_VERSION_REGRESSION: "Diese Bundle-Version ist regressiv (Feature entfernt / Quota gesenkt / Preis erh\xF6ht). Das Ver\xF6ffentlichen erfordert ein ausdr\xFCckliches `forceRegressive: true` (Best\xE4tigungsdialog in der UI mit MFA).",
1801
2844
  BUNDLE_VERSION_ZERO_PRICE: "Eine Bundle-Version l\xE4sst sich nicht mit einem ausdr\xFCcklichen Preis von 0,00 ver\xF6ffentlichen (Schutz vor Seed-Platzhaltern). Kostenlose Bundles l\xE4sst du auf null, oder du setzt allowZeroPrice.",
1802
2845
  BUNDLE_VERSION_NO_PRICE: "Diese Bundle-Version kann ohne Preis nicht ver\xF6ffentlicht werden: weder ein Grundpreis noch eine Plan-\xDCberschreibung ergibt einen.",
1803
2846
  BUNDLE_VERSION_NOT_PRICED_FOR_PLAN: "Dieses Bundle wird dem Plan '{planKey}' angeboten, der {billingCycle} verkauft wird, und daf\xFCr ergibt sich kein {billingCycle} Preis \u2014 weder als Grundpreis noch als Plan-\xDCberschreibung.",
1804
2847
  BUNDLE_VERSION_DISCARD_NOT_IMPLEMENTED: "Das Verwerfen ist im aktuellen Repository nicht implementiert. Implementiere BundleRepository.deleteDraft.",
1805
2848
  BUNDLE_VERSION_VALID_FROM_REQUIRED: "Ver\xF6ffentlichte Bundle-Versionen m\xFCssen ein validFrom behalten. Setze ein neues Datum in der Zukunft, oder bearbeite den Entwurf vor dem Ver\xF6ffentlichen.",
1806
- BUNDLE_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' ist kein g\xFCltiges Datum",
2849
+ BUNDLE_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' ist kein Tag (JJJJ-MM-TT)",
1807
2850
  BUNDLE_VERSION_VALID_FROM_NOT_AFTER_PREVIOUS: "validFrom ({validFrom}) muss strikt nach dem validFrom der Vorg\xE4ngerversion ({previousValidFrom}) liegen.",
1808
2851
  BUNDLE_VERSION_VALID_FROM_NOT_GAPLESS: "Der Vorg\xE4nger hat validUntil={previousValidUntil} \u2014 der Nachfolger muss l\xFCckenlos am Folgetag ({requiredValidFrom}) beginnen. Erhalten: {received}.",
1809
2852
  BUNDLE_VERSION_VALID_FROM_NOT_FUTURE: "validFrom ({validFrom}) muss bei einer ver\xF6ffentlichten, aber zuk\xFCnftigen Bundle-Version weiterhin in der Zukunft liegen.",
1810
- BUNDLE_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' ist kein g\xFCltiges Datum",
2853
+ BUNDLE_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' ist kein Tag (JJJJ-MM-TT)",
1811
2854
  BUNDLE_VERSION_VALID_UNTIL_BEFORE_FROM: "validUntil ({validUntil}) muss strikt nach validFrom ({validFrom}) liegen.",
1812
2855
  STRICT_MODE_VIOLATIONS: "Die Strict-Mode-Pr\xFCfung hat eine Abweichung gegen\xFCber dem Discovery-Snapshot gefunden.",
1813
2856
  PLAN_NOT_FOUND: "Plan '{planId}' nicht gefunden",
1814
2857
  PLAN_VERSION_NOT_FOUND: "PlanVersion '{versionId}' nicht gefunden",
1815
2858
  BUNDLE_NOT_FOUND: "Bundle '{bundleId}' nicht gefunden",
2859
+ BUNDLE_DELETE_WHILE_RETIREMENT_MOVES_PENDING: "{count} Buchungen ziehen noch auf eine Version von {bundleKey} um, wie eine Stilllegung es ihnen mitgeteilt hat. Das Add-on l\xE4sst sich l\xF6schen, sobald sie umgezogen sind.",
1816
2860
  BUNDLE_VERSION_NOT_FOUND: "BundleVersion '{bundleVersionId}' nicht gefunden",
1817
2861
  FEATURE_NOT_FOUND: "Feature '{featureKey}' nicht gefunden",
1818
2862
  QUOTA_NOT_FOUND: "Quota '{quotaKey}' nicht gefunden",
@@ -1832,10 +2876,12 @@ var ERROR_MESSAGES_DE = {
1832
2876
  PLAN_CATALOG_INVALID: "Der Plankatalog wurde gelesen und dann abgelehnt: {message}",
1833
2877
  // ── billing ──
1834
2878
  BUNDLE_ALREADY_SUBSCRIBED: "Abonnement '{subscriptionId}' hat dieses Bundle bereits aktiv gebucht.",
1835
- BUNDLE_INCOMPATIBLE_WITH_PLAN: "BundleVersion '{bundleVersionId}' passt nicht zum Plan '{planKey}'. Erlaubt: [{allowedPlanKeys}].",
2879
+ BUNDLE_INCOMPATIBLE_WITH_PLAN: "Dieses Bundle kann im Plan {planKey} nicht gebucht werden. Buchbar ist es in: {allowedPlanKeys}.",
1836
2880
  BUNDLE_NOT_SELF_SERVICE: "Bundle '{bundleKey}' wird nur \xFCber einen Sondervertrag freigeschaltet. Bitte wende dich an die Vertragsverwaltung.",
1837
2881
  BUNDLE_CYCLE_EXCEEDS_PLAN: "Ein j\xE4hrlich abgerechnetes Bundle passt nicht zu einem monatlich abgerechneten Plan: es w\xE4re an jedem Tag gebunden, an dem der Plan enden kann.",
1838
- BUNDLE_NOT_PRICED_FOR_THIS_PLAN: "F\xFCr dieses Bundle ist im Plan {planKey} kein {billingCycle} Preis hinterlegt, es kann hier deshalb nicht gebucht werden.",
2882
+ BUNDLE_NOT_PRICED_FOR_THIS_PLAN: "F\xFCr dieses Bundle ist im Plan {planKey} in diesem Abrechnungsrhythmus kein Preis hinterlegt, es kann hier deshalb nicht gebucht werden.",
2883
+ BUNDLE_CANNOT_RUN_ON_UPCOMING_PLAN: "Dieses Bundle kann nicht im Plan {planKey} laufen, in den das Abonnement mit Wirkung ab {from} wechselt.",
2884
+ BUNDLE_CANNOT_RUN_ON_UPCOMING_CYCLE: "Ein j\xE4hrlich abgerechnetes Bundle kann nicht neben der monatlichen Abrechnung laufen, auf die das Abonnement mit Wirkung ab {from} wechselt.",
1839
2885
  SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' ist bereits gek\xFCndigt.",
1840
2886
  SUBSCRIPTION_BUNDLE_NOT_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' ist nicht gek\xFCndigt.",
1841
2887
  SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE: "Die K\xFCndigung ist bereits wirksam \u2014 buche das Bundle einfach neu.",
@@ -1843,7 +2889,8 @@ var ERROR_MESSAGES_DE = {
1843
2889
  SUBSCRIPTION_TENANT_MISMATCH: "Das Abonnement geh\xF6rt nicht zu diesem Mandanten",
1844
2890
  SUBSCRIPTION_BUNDLE_NOT_FOUND: "SubscriptionBundle '{subscriptionBundleId}' nicht gefunden",
1845
2891
  TENANT_NOT_FOUND: "Mandant {slug} nicht gefunden",
1846
- NO_ACTIVE_PLAN_VERSION: "Zum {asOf} ist keine Planversion f\xFCr {planId} aktiv \u2014 weder ist das validFrom-Fenster erf\xFCllt, noch steht eine j\xFCngste Live-Version bereit.",
2892
+ NO_ACTIVE_PLAN_VERSION: "Zum {asOf} ist keine Version des Plans {planId} im Verkauf.",
2893
+ BOUND_PLAN_VERSION_UNREADABLE: 'Die Planversion, an die dieses Abonnement gebunden ist ({planVersionId}), ist f\xFCr den Plan "{planKey}" nicht lesbar; deshalb kann kein Wechsel berechnet werden.',
1847
2894
  PLAN_NOT_IN_CATALOG: 'Plan "{planKey}" steht nicht im Katalog',
1848
2895
  PLAN_NOT_SELF_SERVICE: "{planName} wird nur \xFCber einen Sondervertrag freigeschaltet. Bitte wenden Sie sich an die Vertragsverwaltung.",
1849
2896
  PLAN_NOT_SOLD_IN_CYCLE: "{planName} hat f\xFCr diesen Abrechnungsrhythmus keinen Preis und kann darin nicht gebucht werden.",
@@ -1851,6 +2898,36 @@ var ERROR_MESSAGES_DE = {
1851
2898
  SUBSCRIPTION_CHANGED: "Dieses Abonnement hat sich ge\xE4ndert, w\xE4hrend die Anfrage entschieden wurde. Bitte lade es neu.",
1852
2899
  NO_SUBSCRIPTION: "Dieser Mandant hat kein Abonnement, das gek\xFCndigt werden kann.",
1853
2900
  CANCELLATION_TERMS_CHANGED: "Das Wirksamkeitsdatum hat sich seit der Anzeige ge\xE4ndert. Bitte best\xE4tige das neue Datum.",
2901
+ VERSION_OFFER_CHANGED: "Das Angebot hat sich seit der Anzeige ge\xE4ndert. Bitte sieh dir das aktuelle an, bevor du wechselst.",
2902
+ PLAN_CHANGE_QUOTE_CHANGED: "Dieser Plan hat sich seit der Anzeige ge\xE4ndert. Bitte sieh ihn dir noch einmal an, bevor du wechselst.",
2903
+ PLAN_CHANGE_VERSION_NOT_NAMED: "Ein Planwechsel muss die Version nennen, die seine Vorschau gezeigt hat.",
2904
+ VERSION_SWITCH_AFTER_CANCELLATION: "Dieses Abonnement endet, bevor diese Version wirksam w\xFCrde. Ein Wechsel dorthin ist nicht m\xF6glich.",
2905
+ VERSION_ENDS_BEFORE_SWITCH: "Diese Version wird nicht mehr verkauft, bevor sie wirksam w\xFCrde. Ein Wechsel dorthin ist nicht m\xF6glich.",
2906
+ RETIREMENT_TERMS_NOT_CONFIRMED: "Eine Version f\xFCr laufende Abonnements stillzulegen, braucht eine Klausel in deinen AGB. Setze tenantBilling.orderlyRetirement.termsConfirmed in config/saas.yaml, sobald sie sie enthalten.",
2907
+ RETIREMENT_VERSION_ON_SALE: "Version {version} von {planKey} wird noch verkauft. Beende zuerst ihren Verkauf, damit sie nach der Ank\xFCndigung niemand mehr bucht.",
2908
+ RETIREMENT_REPLACEMENT_NOT_ON_SALE: "Version {version} von {planKey} wird nicht verkauft. Abonnements k\xF6nnen nicht auf ihr weiterlaufen.",
2909
+ RETIREMENT_REPLACEMENT_NOT_SOLD_IN_RHYTHM: "{count} dieser Abonnements werden in einem Rhythmus abgerechnet, f\xFCr den Version {version} von {planKey} keinen Preis hat. Sie k\xF6nnen nicht auf ihr weiterlaufen.",
2910
+ RETIREMENT_REPLACEMENT_CANNOT_CARRY_BUNDLES: "{count} dieser Abonnements halten ein Bundle, das in Version {version} von {planKey} nicht laufen kann. Sie k\xF6nnen nicht auf ihr weiterlaufen.",
2911
+ RETIREMENT_REPLACEMENT_IS_RETIRED: "Eine Version kann nicht ihr eigener Ersatz sein.",
2912
+ RETIREMENT_NOTHING_AFFECTED: "Kein laufendes Abonnement nutzt Version {version} von {planKey}. Es gibt niemanden zu benachrichtigen.",
2913
+ RETIREMENT_WITHIN_TWELVE_MONTHS: "{count} dieser Abonnements waren in den letzten zw\xF6lf Monaten schon von einer Stilllegung betroffen. Ein Abonnement ist h\xF6chstens einmal im Jahr betroffen.",
2914
+ RETIREMENT_PREVIEW_CHANGED: "Die Abonnements, die diese Stilllegung betrifft, haben sich seit der Anzeige ge\xE4ndert. Sieh sie dir noch einmal an, bevor du sie ank\xFCndigst.",
2915
+ BUNDLE_RETIREMENT_VERSION_ON_SALE: "Version {version} von {bundleKey} wird noch verkauft. Ver\xF6ffentliche die Version, die sie ersetzt, und lege diese still, sobald ihr Verkauf geendet hat, damit sie nach der Ank\xFCndigung niemand mehr bucht.",
2916
+ BUNDLE_RETIREMENT_REPLACEMENT_NOT_ON_SALE: "Version {version} von {bundleKey} wird nicht verkauft. Buchungen k\xF6nnen nicht auf ihr weiterlaufen.",
2917
+ BUNDLE_RETIREMENT_REPLACEMENT_OF_ANOTHER_BUNDLE: "Der Ersatz ist eine Version von {replacementBundleKey}, nicht von {bundleKey}. Eine Buchung l\xE4uft auf einer Version ihres eigenen Add-ons weiter.",
2918
+ BUNDLE_RETIREMENT_REPLACEMENT_CANNOT_RUN: "{count} dieser Buchungen laufen neben einem Plan, neben dem Version {version} von {bundleKey} nicht laufen kann. Sie k\xF6nnen nicht auf ihr weiterlaufen.",
2919
+ BUNDLE_RETIREMENT_NOTHING_AFFECTED: "Keine laufende Buchung nutzt Version {version} von {bundleKey}. Es gibt niemanden zu benachrichtigen.",
2920
+ BUNDLE_RETIREMENT_REINSTATE_REFUSED: "Version {version} von {bundleKey} wird stillgelegt, und diese Buchung endet, bevor sie umziehen w\xFCrde. Buchen Sie Version {replacementVersion} ab dem {bookableFrom}, wenn diese Buchung beendet ist.",
2921
+ BUNDLE_RETIREMENT_REINSTATE_REPLACEMENT_CANNOT_RUN: "Version {version} von {bundleKey} wird stillgelegt, und diese Buchung endet, bevor sie umziehen w\xFCrde. Version {replacementVersion}, die sie ersetzt, kann neben Ihrem Paket oder einem Paket, zu dem Ihr Abonnement wechselt, nicht laufen.",
2922
+ BUNDLE_RETIREMENT_REINSTATE_SUBSCRIPTION_ENDS: "Version {version} von {bundleKey} wird stillgelegt, und diese Buchung endet, bevor sie umziehen w\xFCrde. Ihr Abonnement endet bis dahin ebenfalls.",
2923
+ BUNDLE_RETIREMENT_SWITCH_PLAN_CHANGES: "{bundleName} zieht am {date} auf seine neue Version um, und Ihr Paket \xE4ndert sich vorher. Der Preis, den ein Wechsel halten w\xFCrde, steht deshalb noch nicht fest. Wechseln Sie, sobald Ihr Paket gewechselt hat, oder lassen Sie es an diesem Tag umziehen.",
2924
+ BUNDLE_VERSION_OFFER_CHANGED: "Das Angebot hat sich seit der Anzeige ge\xE4ndert. Bitte sieh dir das aktuelle an, bevor du wechselst.",
2925
+ RETIREMENT_SWITCH_NOT_PENDING: "F\xFCr Ihre Version steht keine Einstellung mehr bevor. Es gibt nichts, wohin Sie wechseln k\xF6nnten.",
2926
+ RETIREMENT_SWITCH_IN_TRIAL: "Der Wechsel ist m\xF6glich, sobald Ihre Testphase endet.",
2927
+ RETIREMENT_SWITCH_BUNDLE_CANNOT_FOLLOW: "{bundleName} kann im Paket {planName} nicht laufen und l\xE4uft fr\xFChestens bis {until}. Ist es gek\xFCndigt, ist der Wechsel ab diesem Tag m\xF6glich.",
2928
+ RETIREMENT_SWITCH_BUNDLE_REPLACEMENT_CANNOT_FOLLOW: "{bundleName} l\xE4uft ab dem {from} auf Version {version} weiter, die im Paket {planName} nicht laufen kann. Ist es gek\xFCndigt, ist der Wechsel m\xF6glich.",
2929
+ RETIREMENT_SWITCH_NOT_OPEN: "Dieses Abonnement kann gerade nicht wechseln: Eine \xC4nderung ist geplant, es ist beendet, oder sein Paket gilt f\xFCr einen Sondervertrag.",
2930
+ RETIREMENT_SWITCH_CHANGED: "Die Einstellung hat sich seit der Anzeige ge\xE4ndert. Sehen Sie sie sich noch einmal an, bevor Sie wechseln.",
1854
2931
  SUBSCRIPTION_ENDED: "Dieses Abonnement ist beendet. Sein Paket kann nicht mehr gewechselt werden.",
1855
2932
  PLAN_LOCKED: "Aktiver Sondervertrag {planName} \u2014 f\xFCr einen Paketwechsel wenden Sie sich bitte an die Vertragsverwaltung.",
1856
2933
  QUOTA_OVER_TARGET: "Aktuelle Nutzung {used} \xFCberschreitet das Ziel-Limit {targetMax} ({quotaKey}) im Paket {planName}. Bitte zuerst die Nutzung reduzieren.",
@@ -1859,11 +2936,12 @@ var ERROR_MESSAGES_DE = {
1859
2936
  NO_CHANGE: "Zielpaket und Abrechnungsrhythmus entsprechen bereits dem aktuellen Stand.",
1860
2937
  CANCELLATION_LOCKS_THE_CYCLE: "Dieses Abonnement ist gek\xFCndigt, sein Abrechnungsrhythmus kann daher nicht wechseln. Das Paket schon \u2014 behalten Sie den aktuellen Rhythmus, um es heute zu wechseln.",
1861
2938
  CYCLE_SHORTENS_AT_TERM_END: "Ein monatlich abgerechnetes {planName} kann nicht innerhalb der laufenden Jahreslaufzeit beginnen. Das Upgrade greift zum Ende dieser Laufzeit; wer es sofort m\xF6chte, beh\xE4lt den j\xE4hrlichen Rhythmus.",
1862
- BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE: "Ein j\xE4hrlich abgerechnetes Bundle ist bis {until} gebucht. Ein monatlich abgerechnetes Paket kann es nicht tragen \u2014 k\xFCndigen Sie das Bundle zuerst, oder behalten Sie den j\xE4hrlichen Rhythmus.",
2939
+ BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE: "{bundleName} wird j\xE4hrlich abgerechnet und l\xE4uft fr\xFChestens bis {until}; ein monatlich abgerechnetes Paket kann es nicht tragen. Ist es gek\xFCndigt, geht ein Wechsel durch, der an diesem Tag oder sp\xE4ter wirksam wird \u2014 oder behalten Sie den j\xE4hrlichen Rhythmus.",
2940
+ BUNDLE_BOOKING_DOES_NOT_FIT_TARGET_PLAN: "{bundleName} kann im Paket {planName} nicht laufen und l\xE4uft fr\xFChestens bis {until}. Ist es gek\xFCndigt, geht ein Wechsel durch, der an diesem Tag oder sp\xE4ter wirksam wird \u2014 oder w\xE4hlen Sie ein anderes Paket.",
2941
+ BUNDLE_REPLACEMENT_DOES_NOT_FIT_TARGET_PLAN: "{bundleName} l\xE4uft ab dem {from} auf Version {version} weiter, die im Paket {planName} nicht laufen kann. K\xFCndigen Sie es, dann geht der Wechsel durch \u2014 oder w\xE4hlen Sie ein anderes Paket.",
1863
2942
  REDUNDANT_FEATURES: "Der Plan oder ein anderes gebuchtes Bundle enth\xE4lt bereits {count} der Funktionen aus diesem Bundle \u2014 mit der Buchung werden sie doppelt bezahlt.",
1864
2943
  MINIMUM_TERM_BINDS: "Die Mindestlaufzeit reicht \xFCber das Ende der Periode hinaus \u2014 die K\xFCndigung wird erst zum Ende der Mindestlaufzeit wirksam.",
1865
2944
  BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED: "Das Bundle setzt [{features}] voraus \u2014 weder im Plan noch in den aktiven Bundles vorhanden.",
1866
- NO_PENDING_PLAN_VERSION: "Es wartet keine Planversion auf eine Best\xE4tigung.",
1867
2945
  ONBOARDING_CREATE_FAILED: "Das Konto konnte nicht angelegt werden. Bitte versuche es noch einmal.",
1868
2946
  BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS: "Genau eines von bundleVersionId (Vorschau f\xFCrs Buchen) oder subscriptionBundleId (Vorschau f\xFCrs K\xFCndigen) muss angegeben sein.",
1869
2947
  SUBSCRIPTION_PK_MISSING: "Der Adapter hat einen SubscriptionUsageRecord ohne id geliefert. Bitte den Prim\xE4rschl\xFCssel der Subscription durchreichen (siehe SubscriptionUsageRecord.id).",
@@ -1871,7 +2949,7 @@ var ERROR_MESSAGES_DE = {
1871
2949
  QUOTA_DIMENSION_UNKNOWN: 'Unbekannte Quota-Dimension "{dimension}".',
1872
2950
  // ── promo ──
1873
2951
  PROMO_CODE_NOT_FOUND: "Code nicht gefunden",
1874
- PROMO_CODE_ALREADY_EXISTS: "Diesen Code gibt es bereits.",
2952
+ PROMO_CODE_ALREADY_EXISTS: "Diesen Code gibt es bereits, oder ein gel\xF6schter Code tr\xE4gt ihn; ein gel\xF6schter Code beh\xE4lt seinen Namen.",
1875
2953
  PROMO_CODE_HAS_REDEMPTIONS: "Der Code wurde bereits eingel\xF6st oder ist f\xFCr einen laufenden Checkout reserviert \u2014 er l\xE4sst sich nicht per Soft-Delete entfernen. Pausiere ihn stattdessen.",
1876
2954
  PROMO_CODE_NOT_REDEEMABLE: "Der Code l\xE4sst sich nicht einl\xF6sen: {reason}",
1877
2955
  PROMO_CODE_FORMAT_INVALID: 'Der Code darf nur Gro\xDFbuchstaben, Ziffern, "-" und "_" enthalten (4\u201332 Zeichen).',
@@ -1885,6 +2963,7 @@ var ERROR_MESSAGES_DE = {
1885
2963
  PROMO_WOULD_PRODUCE_ZERO_INVOICE: "Bei absoluten Betr\xE4gen muss der Rabatt unter dem niedrigsten anwendbaren Planpreis bleiben, oder allowZeroInvoice muss aktiviert sein.",
1886
2964
  PROMO_MAX_REDEMPTIONS_LOWERED: "maxRedemptions l\xE4sst sich nicht senken.",
1887
2965
  // ── contract ──
2966
+ SUBSCRIPTION_CONTRACT_TAX_RATE_NOT_DECIDED: "Der Vertrag nennt in {field} {stated} %, der Steueradapter entscheidet {decided} %.",
1888
2967
  CHECKOUT_OFFER_LINE_ITEMS_REQUIRED: "Aus einem Checkout-Angebot entsteht nur ein einziger Vertrag, und das erst, wenn seine Positionen eingefroren sind.",
1889
2968
  CHECKOUT_OFFER_PLAN_LINE_ITEM_REQUIRED: "Ein Checkout-Angebot braucht eine eingefrorene Plan-Position.",
1890
2969
  CHECKOUT_OFFER_BUNDLE_LINE_ITEMS_REQUIRED: "Jede gew\xE4hlte Bundle-Version braucht eine eingefrorene Bundle-Position.",
@@ -1909,6 +2988,8 @@ var ERROR_MESSAGES_DE = {
1909
2988
  CHECKOUT_OFFER_ALREADY_CONSUMED: "Checkout-Angebot '{offerId}' wurde bereits eingel\xF6st \u2014 '{action}' ist nicht mehr m\xF6glich",
1910
2989
  CHECKOUT_OFFER_NOT_CONSUMED: "CheckoutOffer '{offerId}' muss eingel\xF6st sein, bevor der Vertrag entsteht",
1911
2990
  CHECKOUT_OFFER_CHANGED: "Checkout-Angebot '{offerId}' hat sich w\xE4hrend des Abschlusses ge\xE4ndert. Bitte neu laden.",
2991
+ CHECKOUT_OFFER_CONTRACT_IN_FORCE: "Checkout-Angebot '{offerId}' schlie\xDFt einen ersten Vertrag ab, und dieser Mandant hat bereits einen. Ein laufendes Abo \xE4ndert sich \xFCber seinen Plan und seine Add-ons.",
2992
+ CHECKOUT_OFFER_ADD_ON_BOOKED_IN_ANOTHER_VERSION: "Checkout-Angebot '{offerId}' nennt Version {offeredVersion} des Add-ons '{bundleKey}', das dieser Mandant in Version {bookedVersion} gebucht hat (Buchung {subscriptionBundleId}). Die Version wechselt \xFCber das Angebot neben dem Add-on.",
1912
2993
  SUBSCRIPTION_CONTRACT_NOT_FOUND: "SubscriptionContract '{contractId}' nicht gefunden",
1913
2994
  NO_ACTIVE_SUBSCRIPTION_CONTRACT: "Kein aktiver Abo-Vertrag f\xFCr Mandant {tenantId}",
1914
2995
  SUBSCRIPTION_CONTRACT_ALREADY_CLOSED: "SubscriptionContract '{contractId}' ist bereits geschlossen",
@@ -1919,11 +3000,16 @@ var ERROR_MESSAGES_DE = {
1919
3000
  SUBSCRIBER_NOT_FOUND: "Vertragspartner '{subscriberId}' nicht gefunden",
1920
3001
  SUBSCRIBER_LEGAL_NAME_REQUIRED: "Ein Vertragspartner braucht seinen rechtlichen Namen.",
1921
3002
  SUBSCRIBER_DETAIL_INVALID: "Das Feld {field} des Vertragspartners ist ung\xFCltig.",
3003
+ SUBSCRIBER_IDENTITY_INCOMPLETE: "Die Rechnungsadresse des Vertragspartners ist noch nicht vollst\xE4ndig: Ein Vertrag nennt ihn nur mit Stra\xDFe und Hausnummer, PLZ, Ort und Land.",
3004
+ SUBSCRIBER_BUSINESS_STATUS_REASON_REQUIRED: "Eine \xC4nderung, ob der Vertragspartner ein Unternehmen ist, braucht eine Begr\xFCndung.",
3005
+ SUBSCRIBER_VAT_ID_MISSING: "Der Vertragspartner hat keine Umsatzsteuer-Identifikationsnummer, die sich pr\xFCfen lie\xDFe.",
1922
3006
  SUBSCRIBER_IDENTITY_NOT_A_CONTACT: "{field} geh\xF6rt zur rechtlichen Identit\xE4t des Vertragspartners und \xE4ndert sich nur als Korrektur mit Begr\xFCndung.",
1923
3007
  SUBSCRIBER_CORRECTION_REASON_REQUIRED: "Eine Korrektur der rechtlichen Identit\xE4t braucht eine Begr\xFCndung.",
1924
3008
  SUBSCRIBER_CORRECTION_ACTOR_REQUIRED: "Eine Korrektur der rechtlichen Identit\xE4t muss nennen, wer sie vornimmt.",
1925
3009
  SUBSCRIBER_CORRECTION_CHANGES_NOTHING: "Die Korrektur \xE4ndert nichts: Jeder genannte Wert ist bereits erfasst.",
1926
3010
  SUBSCRIBER_TAKEOVER_IS_A_TRANSFER: "\xDCbernimmt eine andere Rechtsperson, ist das eine \xDCbertragung und keine Korrektur; sie l\xE4sst sich nicht als \xC4nderung erfassen.",
3011
+ SUBSCRIBER_BUSINESS_STATUS_NOT_A_CONTACT: "Ob der Vertragspartner ein Unternehmen ist, geh\xF6rt zu seiner steuerlichen Herkunft und \xE4ndert sich nur als erfasste \xC4nderung, die nennt, wer sie vornimmt.",
3012
+ SUBSCRIBER_CHANGE_ACTOR_REQUIRED: "Eine \xC4nderung der Angaben des Vertragspartners muss nennen, wer sie vornimmt.",
1927
3013
  // ── registration ──
1928
3014
  PENDING_REGISTRATION_NOT_FOUND: "Diese Registrierung konnten wir nicht finden. Vielleicht ist sie bereits abgeschlossen oder verworfen.",
1929
3015
  PENDING_REGISTRATION_EXPIRED: "Diese Registrierung ist abgelaufen. Bitte fange noch einmal von vorn an.",
@@ -1957,16 +3043,22 @@ var ERROR_MESSAGES_DE = {
1957
3043
  MAINTENANCE_WINDOW_END_NOT_AFTER_START: "Das Ende eines Wartungsfensters muss nach seinem Beginn liegen.",
1958
3044
  MAINTENANCE_WINDOW_END_IN_PAST: "Das Ende eines Wartungsfensters darf nicht in der Vergangenheit liegen.",
1959
3045
  MAINTENANCE_TIME_INVALID: "{field} muss Datum und Uhrzeit mit Zeitzone sein, etwa 2026-10-02T22:00+02:00.",
1960
- MAINTENANCE_MESSAGE_TOO_LONG: "Die Nachricht darf h\xF6chstens {max} Zeichen lang sein."
3046
+ MAINTENANCE_MESSAGE_TOO_LONG: "Die Nachricht darf h\xF6chstens {max} Zeichen lang sein.",
3047
+ // ── tax ──
3048
+ TAX_TREATMENT_NOT_SUPPORTED: "Der Steueradapter {adapter} unterst\xFCtzt diesen Fall nicht: {reason}",
3049
+ TAX_VAT_ID_CHECK_NOT_COMPLETED: "Die Umsatzsteuer-Identifikationsnummer lie\xDF sich gerade nicht pr\xFCfen ({reason}). Bitte sp\xE4ter erneut versuchen.",
3050
+ TAX_VAT_ID_CHECK_NOT_AVAILABLE: "Diese Installation nennt keinen Steueradapter, darum wird keine Umsatzsteuer-Identifikationsnummer gepr\xFCft."
1961
3051
  };
1962
3052
  export {
1963
3053
  ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES,
1964
3054
  AUTH_ERROR_CODES,
1965
3055
  BILLING_ERROR_CODES,
1966
3056
  BUNDLE_PRICE_LOOKUP_LIMIT,
3057
+ BUNDLE_VERSION_RETIREMENT_CAPABILITY,
1967
3058
  CATALOGUE_KEYS,
1968
3059
  CATALOG_ERROR_CODES,
1969
3060
  CONTRACT_ERROR_CODES,
3061
+ CUSTOM_LIMITS_KEYS,
1970
3062
  ERROR_MESSAGES_DE,
1971
3063
  ERROR_MESSAGES_EN,
1972
3064
  FEATURE_NOT_LICENSED,
@@ -1978,6 +3070,8 @@ export {
1978
3070
  MAINTENANCE_STATE_MAX_AGE_SECONDS,
1979
3071
  MARKETING_PRIORITY_MAX,
1980
3072
  MARKETING_PRIORITY_MIN,
3073
+ NO_SCHEDULED_CHANGE,
3074
+ OPTIONAL_CANONICAL_MODELS,
1981
3075
  OTP_RATE_LIMIT_MAX_SENDS,
1982
3076
  OTP_RATE_LIMIT_WINDOW_MINUTES,
1983
3077
  OTP_TTL_MINUTES,
@@ -1992,69 +3086,121 @@ export {
1992
3086
  PROMO_ERROR_CODES,
1993
3087
  PaymentCallbackRejectedError,
1994
3088
  PersistenceCapabilityError,
3089
+ PersistenceRefusal,
1995
3090
  PlatformUserExistsError,
1996
3091
  REGISTRATION_ERROR_CODES,
1997
3092
  REGISTRATION_RESUME_TTL_MINUTES,
1998
3093
  REGISTRATION_STEP_BY_STATUS,
3094
+ RETIREMENT_REMINDER_LEAD_DAYS,
1999
3095
  SETTINGS_ERROR_CODES,
2000
3096
  SETUP_ERROR_CODES,
2001
3097
  SUBSCRIBER_ACCOUNT_CAPABILITY,
3098
+ SUBSCRIBER_ATTENTION_CAPABILITY,
3099
+ SUBSCRIBER_ATTENTION_PAGE_SIZE,
3100
+ SUBSCRIBER_CORRECTION_CAPABILITY,
2002
3101
  SUBSCRIBER_ERROR_CODES,
3102
+ SUBSCRIBER_INVOICE_ADDRESS_FIELDS,
3103
+ SUBSCRIBER_STANDING_CAPABILITY,
3104
+ SUBSCRIBER_TAX_ORIGIN_FIELDS,
3105
+ TAX_ERROR_CODES,
3106
+ TAX_TREATMENT_KINDS,
3107
+ VERSION_RETIREMENT_CAPABILITY,
2003
3108
  applyPromo,
2004
3109
  assertPersistenceCapabilities,
2005
3110
  buildActivePlanVersionWhere,
2006
3111
  buildActiveVersionWhere,
2007
3112
  buildFeatureRequiresIndex,
2008
3113
  bundleDraftDefaults,
3114
+ bundleKeyTaken,
2009
3115
  bundleStemDefaults,
2010
3116
  canonicalJson,
3117
+ canonicalVatId,
3118
+ catalogDraftExists,
3119
+ catalogVersionAlreadyPublished,
3120
+ catalogVersionGone,
2011
3121
  classifyBundleVersionDiff,
2012
3122
  classifyIssuerChange,
2013
3123
  classifyPlanDiff,
3124
+ classifyVersionOffer,
2014
3125
  collectUnsatisfiedRequires,
3126
+ computeIncludedVat,
3127
+ concurrencyGate,
3128
+ concurrencyGateOf,
2015
3129
  contractPartiesOf,
2016
3130
  coverageExcludingSelf,
3131
+ customLimitsReader,
2017
3132
  definedFields,
2018
3133
  diffSettings,
2019
3134
  formatCustomerNumber,
2020
3135
  formatErrorMessage,
3136
+ grossFromNet,
2021
3137
  identityCorrectionDelta,
2022
3138
  isBundleRedundant,
2023
3139
  isForeignPaymentMethodReferenceError,
2024
3140
  isMaintenanceAnnouncementLapsed,
2025
3141
  isMaintenanceOverrun,
2026
3142
  isPaymentCallbackRejectedError,
3143
+ isPersistenceRefusal,
2027
3144
  isPlatformUserExistsError,
3145
+ isVersionActiveAt,
2028
3146
  isVersionEditable,
2029
3147
  issuerIdentityOf,
2030
3148
  keepOneRecommended,
3149
+ keepsVatIdCheck,
2031
3150
  maintenanceRetryAfterSeconds,
2032
3151
  maintenanceStatusOf,
2033
3152
  maintenanceWindowStatusOf,
2034
3153
  maintenanceWindowViewOf,
3154
+ marketingProjectionTaken,
3155
+ membersLeftOut,
2035
3156
  missingRequiresFor,
2036
3157
  movedIdentityFields,
3158
+ netFromGross,
3159
+ noActivePlanVersion,
2037
3160
  parseZonedInstant,
3161
+ percentOf,
2038
3162
  pickActivePromo,
2039
3163
  planCatalogSettingsOf,
3164
+ planKeyTaken,
3165
+ planNotInCatalog,
2040
3166
  previousUtcDay,
3167
+ promoCodeTaken,
2041
3168
  promoStatus,
2042
3169
  promotionOnPrice,
3170
+ prorate,
3171
+ readCustomLimits,
2043
3172
  readQuotaRecord,
2044
3173
  readQuotaValue,
2045
3174
  recordedIssuerIdentity,
2046
3175
  refuseForeignPaymentMethodReference,
2047
3176
  resolveBundleAvailability,
2048
3177
  resolveErrorMessage,
3178
+ retirementCostsTheSubscription,
3179
+ retirementReminderDueAt,
3180
+ retirementReminderIsDue,
3181
+ retirementSwitchTerms,
3182
+ roundToCents,
2049
3183
  sameLegalIdentity,
3184
+ scheduledChangeAfterWrite,
2050
3185
  selectChargeableBundles,
2051
3186
  settingsSubtreeOf,
2052
3187
  startOfUtcDay,
2053
3188
  subscriberChargeColumns,
2054
3189
  subscriberFromRegistration,
2055
3190
  subscriberPaymentMethodColumns,
3191
+ subscriptionBundleAlreadyCancelled,
3192
+ subscriptionBundleGone,
3193
+ subscriptionContractGone,
3194
+ subscriptionGone,
3195
+ sumToCents,
3196
+ taxOriginOf,
3197
+ taxOriginWrite,
3198
+ taxTreatmentToJson,
2056
3199
  toBundleStemRow,
3200
+ toBundleVersionRetirementRecord,
3201
+ toCents,
2057
3202
  toContractLineItemRecord,
3203
+ toDecimalString,
2058
3204
  toMaintenanceWindowRecord,
2059
3205
  toPlanRow,
2060
3206
  toPlanVersionRow,
@@ -2063,6 +3209,16 @@ export {
2063
3209
  toSubscriberCorrectionRecord,
2064
3210
  toSubscriberPaymentMethodRecord,
2065
3211
  toSubscriberRecord,
3212
+ toSubscriberTaxOriginChangeRecord,
3213
+ toSubscriberVatIdCheckRecord,
2066
3214
  toSubscriptionBundleRecord,
2067
- toSubscriptionContractRecord
3215
+ toSubscriptionContractRecord,
3216
+ toSubscriptionNoticeRecord,
3217
+ toTaxOriginValues,
3218
+ toTaxTreatment,
3219
+ toVersionRetirementRecord,
3220
+ vatIdCheckFromStore,
3221
+ versionOnSale,
3222
+ versionOnSaleOrNext,
3223
+ versionSale
2068
3224
  };