@saasicat/core 1.0.0-rc.26 → 1.0.0-rc.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -198,7 +198,7 @@ interface CapabilityCatalogEntryRow {
198
198
  * `CORE` < `ADVANCED` < `PRO` < `ENTERPRISE`. Apps may add further
199
199
  * tiers; sorting then happens via `FeatureCatalogEntry.sortOrder`.
200
200
  */
201
- type FeatureTier = 'CORE' | 'ADVANCED' | 'PRO' | 'ENTERPRISE' | string;
201
+ type FeatureTier = 'CORE' | 'ADVANCED' | 'PRO' | 'ENTERPRISE' | (string & {});
202
202
  /**
203
203
  * SuperAdmin projection of a feature (aggregation of capabilities that declare
204
204
  * `feature: 'XYZ'` in the decorator). The short marketing form lives here;
@@ -646,6 +646,44 @@ type PaymentGatewayEvent = {
646
646
  occurredAt: Date;
647
647
  sessionRef: string;
648
648
  subject: PaymentMethodSetupSubject;
649
+ } | {
650
+ /**
651
+ * What became of a collection, reported by the gateway on its own:
652
+ * the same outcome `findCollection` answers, for the attempt its key
653
+ * names. Each report reads the payment as it stands when the adapter
654
+ * translates it, so reports arriving out of order never take an
655
+ * attempt back to an earlier state.
656
+ */
657
+ kind: 'collection-reported';
658
+ eventId: string;
659
+ occurredAt: Date;
660
+ attemptKey: string;
661
+ outcome: CollectionOutcome;
662
+ } | {
663
+ /**
664
+ * A refund the operator made in the gateway, of a payment an attempt
665
+ * of SaaSiCat's collected, as it stands when the adapter translates
666
+ * the report: created, settled, failed or canceled.
667
+ */
668
+ kind: 'refund-reported';
669
+ eventId: string;
670
+ occurredAt: Date;
671
+ /** The attempt that collected the payment it pays back. */
672
+ attemptKey: string;
673
+ refund: GatewayRefund;
674
+ } | {
675
+ /**
676
+ * Money the gateway took back from the operator for a payment an
677
+ * attempt of SaaSiCat's collected — a direct debit the bank returned,
678
+ * a chargeback — and what it gave back of it, both as they stand
679
+ * when the adapter translates the report.
680
+ */
681
+ kind: 'reversal-reported';
682
+ eventId: string;
683
+ occurredAt: Date;
684
+ /** The attempt that collected the payment it takes back. */
685
+ attemptKey: string;
686
+ reversal: GatewayReversal;
649
687
  } | {
650
688
  /** Genuine, and nothing SaaSiCat acts on. */
651
689
  kind: 'unhandled';
@@ -654,6 +692,107 @@ type PaymentGatewayEvent = {
654
692
  /** The gateway's own name for the event, for the log. */
655
693
  type: string;
656
694
  };
695
+ /**
696
+ * Why a collection failed, in SaaSiCat's words; the gateway's own code is kept
697
+ * beside it. Whether a second try can pass follows from the reason alone
698
+ * (`isRetryableCollectionFailure`):
699
+ *
700
+ * - `insufficient-funds` — the account or the card does not cover the amount;
701
+ * - `declined` — refused without a reason that rules out a second try, or the
702
+ * bank or issuer could not be reached;
703
+ * - `authentication-required` — the card's bank asks the subscriber to confirm
704
+ * the payment, which nobody can do while they are not present;
705
+ * - `payment-method-unusable` — the card is lost, stolen, blocked or expired,
706
+ * or the account is closed or restricted;
707
+ * - `mandate-invalid` — the direct debit's mandate was revoked, does not match
708
+ * or was disputed;
709
+ * - `other` — anything the gateway names that is none of these.
710
+ */
711
+ type CollectionFailureReason = 'insufficient-funds' | 'declined' | 'authentication-required' | 'payment-method-unusable' | 'mandate-invalid' | 'other';
712
+ /** The collection of one invoice, as the platform asks a gateway to make it. */
713
+ interface CollectInvoiceInput {
714
+ /**
715
+ * The same for this invoice and attempt across every repeat of the
716
+ * request, and kept by the gateway with what it creates, so
717
+ * `findCollection` finds it again. Never a second charge for one key.
718
+ */
719
+ attemptKey: string;
720
+ invoiceId: string;
721
+ /** The invoice's number, which the subscriber's statement names. */
722
+ invoiceNumber: string;
723
+ /** The invoice's gross amount in cents, of `currency`. */
724
+ amountCents: number;
725
+ /** As `config/saas.yaml#currency` writes it, e.g. `EUR`. */
726
+ currency: string;
727
+ /** The customer the payment method is kept for at the gateway. */
728
+ customerRef: string;
729
+ paymentMethodRef: string;
730
+ type: PaymentMethodType;
731
+ }
732
+ /**
733
+ * What became of a collection: collected, still on its way — a direct debit
734
+ * is submitted to the bank and settles days later —, or failed.
735
+ * `paymentRef` is the gateway's reference to what it created for the attempt.
736
+ */
737
+ type CollectionOutcome = {
738
+ status: 'succeeded';
739
+ paymentRef: string;
740
+ /** What the gateway received, in cents of `currency`. */
741
+ amountCents: number;
742
+ /** As `config/saas.yaml#currency` writes it, e.g. `EUR`. */
743
+ currency: string;
744
+ } | {
745
+ status: 'pending';
746
+ paymentRef: string;
747
+ } | {
748
+ status: 'failed';
749
+ /** `null` where the gateway refused before it created anything. */
750
+ paymentRef: string | null;
751
+ reason: CollectionFailureReason;
752
+ /** The gateway's own code for the reason, for the operator. */
753
+ gatewayCode: string | null;
754
+ };
755
+ /**
756
+ * A refund as the gateway reports it. `pending` and `succeeded` pay the money
757
+ * out; `failed` and `canceled` gave it back to the operator.
758
+ */
759
+ interface GatewayRefund {
760
+ /** The gateway's reference to the refund, unique within its account. */
761
+ refundRef: string;
762
+ /** The gateway's reference to the payment it pays back. */
763
+ paymentRef: string;
764
+ amountCents: number;
765
+ /** As `config/saas.yaml#currency` writes it, e.g. `EUR`. */
766
+ currency: string;
767
+ status: 'pending' | 'succeeded' | 'failed' | 'canceled';
768
+ }
769
+ /**
770
+ * A reversal as the gateway reports it: what it withdrew from the operator and
771
+ * what it gave back, each in total so far, so a report delivered late or twice
772
+ * says what stands rather than what changed. A dispute that withdraws nothing
773
+ * yet, such as an inquiry, is no reversal.
774
+ */
775
+ interface GatewayReversal {
776
+ /** The gateway's reference to it, such as a dispute's, unique within its account. */
777
+ reversalRef: string;
778
+ /** The gateway's reference to the payment it takes back. */
779
+ paymentRef: string;
780
+ /** What it withdrew so far, in cents of `currency`. */
781
+ withdrawnCents: number;
782
+ /** What the gateway gave back of it so far, in cents of `currency`: a dispute won. */
783
+ reinstatedCents: number;
784
+ /** As `config/saas.yaml#currency` writes it, e.g. `EUR`. */
785
+ currency: string;
786
+ }
787
+ /** Which attempt the gateway is asked about. */
788
+ interface FindCollectionInput {
789
+ attemptKey: string;
790
+ customerRef: string;
791
+ /** The gateway's reference, where an earlier answer named one. */
792
+ paymentRef: string | null;
793
+ /** When the attempt was first submitted: nothing created before it is its. */
794
+ submittedAt: Date;
795
+ }
657
796
  /**
658
797
  * One account at a payment gateway: its keys, its form and its callbacks.
659
798
  *
@@ -681,7 +820,34 @@ interface PaymentGateway {
681
820
  * an `immediateCallback` is read for.
682
821
  */
683
822
  readCallback(callback: PaymentGatewayCallback): Promise<PaymentGatewayEvent>;
823
+ /**
824
+ * Collects an invoice with the payment method it announced, without the
825
+ * subscriber present, under `attemptKey`: a repeat of the request with the
826
+ * same key creates nothing new.
827
+ *
828
+ * Answers a refusal — a declined card, a debit the bank turned down — as a
829
+ * `failed` outcome. Throws only where the answer is unknown: the request
830
+ * may or may not have reached the gateway, and the platform asks
831
+ * `findCollection` before it sends anything again.
832
+ */
833
+ collect(input: CollectInvoiceInput): Promise<CollectionOutcome>;
834
+ /**
835
+ * What became of the attempt `attemptKey` names, read from the gateway
836
+ * itself; `null` where the gateway holds nothing under it, so the request
837
+ * never arrived and may be sent again. Throws where the gateway cannot be
838
+ * asked. The platform relies on `null`: where the invoice was paid
839
+ * meanwhile the attempt is settled rather than sent again, and only the
840
+ * gateway's own report could still record a payment it took after all.
841
+ */
842
+ findCollection(input: FindCollectionInput): Promise<CollectionOutcome | null>;
684
843
  }
844
+ /**
845
+ * Whether a collection that failed for `reason` can pass on a second try: an
846
+ * account short of funds and a refusal without a cause can; a closed account,
847
+ * a revoked mandate, a lost card or a payment the subscriber has to confirm
848
+ * cannot, and asks the subscriber to act instead.
849
+ */
850
+ declare function isRetryableCollectionFailure(reason: CollectionFailureReason): boolean;
685
851
  /**
686
852
  * A callback that is not the gateway's: a missing or wrong signature, a stale
687
853
  * timestamp, a body that was altered. Nothing is read from it.
@@ -863,8 +1029,17 @@ interface PlanCatalogSubscribers {
863
1029
  interface PlanCatalogInvoicing {
864
1030
  /** Put in front of every invoice number: `AHP` gives `AHP-2026-000123`. */
865
1031
  numberPrefix: string;
866
- /** Days from an invoice's issue date to the day it is due (`SC-PRIC-046`). */
1032
+ /**
1033
+ * Days from an invoice's issue date to the day it is due (`SC-PRIC-046`),
1034
+ * unless it is collected by direct debit.
1035
+ */
867
1036
  paymentTermDays: number;
1037
+ /**
1038
+ * Calendar days between an invoice collected by direct debit and the day
1039
+ * it is collected, which the invoice announces and falls due on
1040
+ * (`SC-PRIC-028`). `DIRECT_DEBIT_LEAD_DAYS` where it is not set.
1041
+ */
1042
+ directDebitLeadDays?: number;
868
1043
  /**
869
1044
  * What a business letter of the issuer states beyond the invoice's own
870
1045
  * content, line by line — copied onto every invoice issued (`SC-PRIC-077`).
@@ -2157,7 +2332,7 @@ interface AdminManifest {
2157
2332
  actions?: AuditActionDef[];
2158
2333
  };
2159
2334
  }
2160
- type StandardPageKey = 'dashboard' | 'tenants' | 'subscriptions' | 'promoCodes' | 'plans' | 'audit' | 'users' | 'pilots' | 'discovery' | 'bundles' | 'marketingCatalog' | 'platformEmail' | 'platformEmailHistory' | 'settings' | 'maintenance' | 'featureWithdrawals';
2335
+ type StandardPageKey = 'dashboard' | 'tenants' | 'subscriptions' | 'promoCodes' | 'plans' | 'audit' | 'users' | 'pilots' | 'discovery' | 'bundles' | 'marketingCatalog' | 'platformEmail' | 'platformEmailHistory' | 'settings' | 'maintenance' | 'featureWithdrawals' | 'reconciliation';
2161
2336
  interface StandardPageDef {
2162
2337
  enabled: boolean;
2163
2338
  requiredCapability?: CapabilityKey;
@@ -3585,7 +3760,7 @@ interface EndedAtOnce extends EndAtOncePreview {
3585
3760
  declare function endedAtOnceSubjectOf(subscriptionOrBookingId: string, at: Date): string;
3586
3761
 
3587
3762
  /** What a notice is about. */
3588
- type SubscriptionNoticeKind = 'version-offered' | 'version-retired' | 'version-retirement-reminder' | 'bundle-version-retired' | 'bundle-version-retirement-reminder' | 'bundle-version-offered' | 'feature-withdrawn' | 'feature-withdrawal-lifted' | 'ended-at-once';
3763
+ type SubscriptionNoticeKind = 'version-offered' | 'version-retired' | 'version-retirement-reminder' | 'bundle-version-retired' | 'bundle-version-retirement-reminder' | 'bundle-version-offered' | 'feature-withdrawn' | 'feature-withdrawal-lifted' | 'ended-at-once' | 'collection-failed' | 'collection-announced' | 'collection-reversed';
3589
3764
  /** Which notice: there is one per subscription, kind and subject. */
3590
3765
  interface SubscriptionNoticeKey {
3591
3766
  readonly tenantId: string;
@@ -3606,7 +3781,10 @@ interface SubscriptionNoticeKey {
3606
3781
  * booking is told of the version once. For `feature-withdrawn` and
3607
3782
  * `feature-withdrawal-lifted`, the id of the withdrawal: a subscription is
3608
3783
  * told of each once. For `ended-at-once`, the id of what ended — the
3609
- * subscription, or the booking — which ends once.
3784
+ * subscription, or the booking — which ends once. For `collection-failed`,
3785
+ * the key of the attempt that failed; for `collection-announced`, the key
3786
+ * of the attempt announced; for `collection-reversed`, the key of the
3787
+ * attempt whose payment was reversed: each is told once.
3610
3788
  */
3611
3789
  readonly subject: string;
3612
3790
  }
@@ -4516,8 +4694,20 @@ interface PromoCodeRepository {
4516
4694
  * together, and the second one's answer is the refusal, not a driver error.
4517
4695
  */
4518
4696
  create(data: CreatePromoCodeData): Promise<PromoCodeRecord>;
4519
- update(id: string, data: UpdatePromoCodeData): Promise<PromoCodeRecord>;
4520
- softDelete(id: string): Promise<void>;
4697
+ /**
4698
+ * Changes the code under `id` only while it is not deleted, in the one
4699
+ * write that changes it, and answers `null` where no such code is there —
4700
+ * none under `id`, or one deleted, even since the platform read it
4701
+ * (`SC-PROMO-032`).
4702
+ */
4703
+ update(id: string, data: UpdatePromoCodeData): Promise<PromoCodeRecord | null>;
4704
+ /**
4705
+ * Marks the code under `id` deleted only while it is not, in the one
4706
+ * write that marks it, and answers whether it did: a second delete,
4707
+ * however close behind the first, leaves the day it was deleted
4708
+ * (`SC-PROMO-032`).
4709
+ */
4710
+ softDelete(id: string): Promise<boolean>;
4521
4711
  /**
4522
4712
  * Atomic slot reservation: increments `redemptionsCount` and checks
4523
4713
  * `status === 'ACTIVE' && (maxRedemptions IS NULL || redemptionsCount + heldCount < maxRedemptions)`.
@@ -4689,6 +4879,78 @@ interface PromoRevenueDeductionAggregator {
4689
4879
  sumGrossForPromoCode(promoCodeId: string): Promise<string>;
4690
4880
  }
4691
4881
 
4882
+ /** What follows a failed collection. */
4883
+ type CollectionFailureNext =
4884
+ /** The same card, or the card now in use, is charged on `on`. */
4885
+ {
4886
+ readonly action: 'charged-again';
4887
+ readonly on: CalendarDay;
4888
+ }
4889
+ /** A direct debit is announced again, with its own day, in a notice of its own. */
4890
+ | {
4891
+ readonly action: 'announced-again';
4892
+ }
4893
+ /** Nothing is tried again until the subscriber replaces the payment method. */
4894
+ | {
4895
+ readonly action: 'replace-payment-method';
4896
+ };
4897
+ /** The invoice a collection notice is about, as it was issued. */
4898
+ interface CollectionNoticeInvoice {
4899
+ readonly tenantId: string;
4900
+ readonly subscriptionId: string;
4901
+ readonly subscriberId: string;
4902
+ readonly invoiceId: string;
4903
+ readonly invoiceNumber: string;
4904
+ /** What the invoice asks for, of `currency`. */
4905
+ readonly amount: number;
4906
+ readonly currency: string;
4907
+ }
4908
+ /** A collection failed. Told once per failed attempt. */
4909
+ interface CollectionFailedNotice extends CollectionNoticeInvoice {
4910
+ readonly kind: 'collection-failed';
4911
+ readonly paymentMethodType: PaymentMethodType;
4912
+ readonly reason: CollectionFailureReason;
4913
+ readonly next: CollectionFailureNext;
4914
+ }
4915
+ /**
4916
+ * A direct debit announced again, for a day of its own and under the mandate
4917
+ * of the payment method it is collected with. Told once per planned attempt;
4918
+ * it stands on its own and leaves the invoice as it was issued.
4919
+ */
4920
+ interface CollectionAnnouncedNotice extends CollectionNoticeInvoice {
4921
+ readonly kind: 'collection-announced';
4922
+ /** The day the account is debited. */
4923
+ readonly collectOn: CalendarDay;
4924
+ readonly mandateReference: string;
4925
+ /** The last four digits of the account's IBAN. */
4926
+ readonly last4: string;
4927
+ }
4928
+ /** What follows a reversal that opened an invoice again. */
4929
+ type CollectionReversedNext =
4930
+ /** It is collected with the payment method now in use, which replaced the reversed one. */
4931
+ {
4932
+ readonly action: 'collected-with-payment-method-in-use';
4933
+ }
4934
+ /** Nothing is collected until the subscriber replaces the payment method. */
4935
+ | {
4936
+ readonly action: 'replace-payment-method';
4937
+ };
4938
+ /**
4939
+ * A payment was reversed — a direct debit the bank returned, a chargeback —
4940
+ * and its invoice is open again. Told once per reversed attempt; nothing is
4941
+ * collected again with the payment method the payment was made with.
4942
+ */
4943
+ interface CollectionReversedNotice extends CollectionNoticeInvoice {
4944
+ readonly kind: 'collection-reversed';
4945
+ /** How the reversed payment was made. */
4946
+ readonly paymentMethodType: PaymentMethodType;
4947
+ /** What the invoice owes again, of `currency`. */
4948
+ readonly owed: number;
4949
+ readonly next: CollectionReversedNext;
4950
+ }
4951
+ /** A notice about collecting an invoice. */
4952
+ type InvoiceCollectionNotice = CollectionFailedNotice | CollectionAnnouncedNotice | CollectionReversedNotice;
4953
+
4692
4954
  /**
4693
4955
  * What made the charge arise. activation: the first period of a subscription. renewal: a later period. planChange: what an immediate plan change adds. bundleBooking: the first, short period of an add-on. bundleChange: what an add-on's switch to a dearer version adds for the rest of its period. credit: a decision that reduces what is owed. correction: a counter-entry reversing an earlier charge, which is how the append-only journal answers a mistake. reductionTakenBack: a reduction granted in advance, taken back for the days it no longer covers — the feature it was granted for came back, or what it reduced ended at once.
4694
4956
  */
@@ -4843,6 +5105,24 @@ interface SubscriptionInvoiceLineRecord {
4843
5105
  }
4844
5106
  /** A line to write: everything but what the store assigns. */
4845
5107
  type NewSubscriptionInvoiceLine = Omit<SubscriptionInvoiceLineRecord, 'id' | 'invoiceId'>;
5108
+ /**
5109
+ * The payment method an invoice is collected with, copied from the
5110
+ * subscriber's on the day it was issued — what the invoice tells the
5111
+ * subscriber, so a later change leaves it as it was (`SC-PRIC-028`).
5112
+ */
5113
+ interface SubscriptionInvoicePayment {
5114
+ /** The subscriber's payment method, which the collection charges. */
5115
+ paymentMethodId: string;
5116
+ /** The account in `config/saas.yaml#payments.accounts` that holds it. */
5117
+ gatewayAccount: string;
5118
+ type: PaymentMethodType;
5119
+ /** The card network, such as `visa`; `null` for a direct debit. */
5120
+ brand: string | null;
5121
+ /** The last four digits of the card number or the IBAN. */
5122
+ last4: string;
5123
+ /** The mandate a direct debit is collected under; `null` for a card. */
5124
+ mandateReference: string | null;
5125
+ }
4846
5126
  /** An invoice as a store reads it back. */
4847
5127
  interface SubscriptionInvoiceRecord {
4848
5128
  id: string;
@@ -4861,8 +5141,23 @@ interface SubscriptionInvoiceRecord {
4861
5141
  issuedAt: Date;
4862
5142
  /** The day it was issued, in the installation's time zone. */
4863
5143
  issueDate: CalendarDay;
4864
- /** The day it is due: the issue date plus the payment term (`SC-PRIC-046`). */
5144
+ /**
5145
+ * The day it is due (`SC-PRIC-046`): the collection date where it is
5146
+ * collected by direct debit, the issue date plus the payment term otherwise.
5147
+ */
4865
5148
  dueDate: CalendarDay;
5149
+ /**
5150
+ * The payment method it is collected with, as it stood when the invoice
5151
+ * was issued; `null` where it is not collected — the subscriber had no
5152
+ * payment method that can be, or the invoice asks for nothing.
5153
+ */
5154
+ payment: SubscriptionInvoicePayment | null;
5155
+ /**
5156
+ * The day a direct debit is collected from, which the invoice announces
5157
+ * with its amount and mandate reference (`SC-PRIC-028`): the issue date
5158
+ * plus the lead time. `null` unless `payment` is a direct debit.
5159
+ */
5160
+ collectionDate: CalendarDay | null;
4866
5161
  /** The first day its charges cover. */
4867
5162
  servicePeriodFrom: CalendarDay;
4868
5163
  /** The last day its charges cover. */
@@ -4925,6 +5220,10 @@ interface InvoiceDocument {
4925
5220
  * the invoice's `issuedAt`. A renderer updated between two attempts renders
4926
5221
  * other bytes; while nothing is archived, those take the place of the ones
4927
5222
  * recorded, and the audit log says so (`SC-AUD-019`).
5223
+ *
5224
+ * An invoice collected by direct debit is the notice SEPA asks for before the
5225
+ * debit: its document states the amount, the `collectionDate` and the
5226
+ * `payment.mandateReference` (`SC-PRIC-028`).
4928
5227
  */
4929
5228
  interface InvoiceRenderer {
4930
5229
  render(invoice: SubscriptionInvoiceRecord): Promise<InvoiceDocument>;
@@ -4971,8 +5270,16 @@ interface InvoiceMail {
4971
5270
  /** The archived file, to attach. */
4972
5271
  document: InvoiceDocument;
4973
5272
  }
5273
+ /** A notice about collecting an invoice on its way to the subscriber. */
5274
+ interface InvoiceNoticeMail {
5275
+ notice: InvoiceCollectionNotice;
5276
+ /** The invoice email on the subscriber's record. */
5277
+ to: string;
5278
+ }
4974
5279
  /**
4975
- * Sends an invoice to the subscriber with its file attached (`SC-PRIC-047`).
5280
+ * Sends an invoice to the subscriber with its file attached (`SC-PRIC-047`),
5281
+ * and what the subscriber is told about collecting it (`SC-PRIC-028`,
5282
+ * `SC-PRIC-080`).
4976
5283
  *
4977
5284
  * The application words the message — in the subscriber's language, with a
4978
5285
  * link to the tenant's sign-in rather than to the file itself — and sends it
@@ -4988,6 +5295,15 @@ interface InvoiceMail {
4988
5295
  */
4989
5296
  interface InvoiceMailPort {
4990
5297
  deliver(mail: InvoiceMail): Promise<void>;
5298
+ /**
5299
+ * Tells the subscriber that a collection failed and what follows, or the
5300
+ * day a direct debit announced again is collected under which mandate.
5301
+ * The application words it as it words the invoice; a direct debit's
5302
+ * announcement names the amount, the day and the mandate reference. It
5303
+ * rejects where the message could not be handed on, and the next run tries
5304
+ * again; each notice is sent once however many instances run.
5305
+ */
5306
+ tell(mail: InvoiceNoticeMail): Promise<void>;
4991
5307
  }
4992
5308
  /** Where an invoice's document stands, as the invoice records it. */
4993
5309
  interface SubscriptionInvoiceDocumentRecord {
@@ -5835,6 +6151,676 @@ type AdminSubscriberHistoryEntry = {
5835
6151
  counts: boolean;
5836
6152
  };
5837
6153
 
6154
+ /**
6155
+ * Where an attempt stands: `SCHEDULED` while it is planned for a day and has
6156
+ * not left; `SUBMITTED` once it is written as sent, before its request leaves,
6157
+ * and until an answer is recorded; `PENDING` while a direct debit is on its
6158
+ * way; `SUCCEEDED` and `FAILED` once it is settled; `WITHDRAWN` where a planned
6159
+ * one will not be made, because the payment method it was planned with is no
6160
+ * longer in use; `REVERSED` where it succeeded and a reversal of its payment —
6161
+ * a returned direct debit, a chargeback — opened its invoice again, which is
6162
+ * then collected only with another payment method (`SC-PRIC-085`).
6163
+ */
6164
+ type InvoiceCollectionStatus = 'SCHEDULED' | 'SUBMITTED' | 'PENDING' | 'SUCCEEDED' | 'FAILED' | 'WITHDRAWN' | 'REVERSED';
6165
+ /** An attempt as a store reads it back. */
6166
+ interface InvoiceCollectionRecord {
6167
+ id: string;
6168
+ invoiceId: string;
6169
+ /** From 1, per invoice. */
6170
+ attempt: number;
6171
+ /** `collectionAttemptKey(invoiceId, attempt)`: the key every request of this attempt carries. */
6172
+ attemptKey: string;
6173
+ /** The account in `config/saas.yaml#payments.accounts` the request went to. */
6174
+ gatewayAccount: string;
6175
+ /** The subscriber's payment method it charges. */
6176
+ paymentMethodId: string;
6177
+ paymentMethodType: PaymentMethodType;
6178
+ customerRef: string;
6179
+ paymentMethodRef: string;
6180
+ /** The invoice's number, as the request names it. */
6181
+ invoiceNumber: string;
6182
+ /** The invoice's gross amount, of `currency`; the request carries it in cents. */
6183
+ amount: number;
6184
+ currency: string;
6185
+ status: InvoiceCollectionStatus;
6186
+ /** The gateway's reference to what it created; `null` until an answer names one. */
6187
+ paymentRef: string | null;
6188
+ /** Why it failed; `null` unless it did. */
6189
+ failureReason: CollectionFailureReason | null;
6190
+ /** The gateway's own code for the failure. */
6191
+ failureCode: string | null;
6192
+ /**
6193
+ * When it was written as sent and its request first left; `null` while it
6194
+ * is planned, and for a planned one withdrawn before it left.
6195
+ */
6196
+ submittedAt: Date | null;
6197
+ /**
6198
+ * When a run last took it on — to send it, to send it again, or to ask
6199
+ * the gateway about it. Another run leaves it alone until this is old
6200
+ * enough (`INVOICE_COLLECTION_LEASE_MS`, `INVOICE_COLLECTION_ASK_EVERY_MS`).
6201
+ * `null` where `submittedAt` is.
6202
+ */
6203
+ heldAt: Date | null;
6204
+ /** When it was settled, or withdrawn; `null` while it is not. */
6205
+ resolvedAt: Date | null;
6206
+ /**
6207
+ * The day a planned attempt is collected from; `null` for one written as
6208
+ * sent from the start, which the invoice's own date governs. A direct
6209
+ * debit's is the earliest day until it is announced, and the day its
6210
+ * announcement names after.
6211
+ */
6212
+ collectOn: CalendarDay | null;
6213
+ /** When a planned direct debit's announcement reached the subscriber; `null` until it did. */
6214
+ announcedAt: Date | null;
6215
+ /**
6216
+ * When what follows a failure or a reversal was decided — the subscriber's
6217
+ * notice recorded, and the next attempt planned where one is made; `null`
6218
+ * until it was, and for an attempt that neither failed nor was reversed.
6219
+ */
6220
+ followedUpAt: Date | null;
6221
+ }
6222
+ /** An attempt that has been sent: its request carries a moment, and a run holds it. */
6223
+ type SubmittedInvoiceCollection = InvoiceCollectionRecord & {
6224
+ submittedAt: Date;
6225
+ heldAt: Date;
6226
+ };
6227
+ /**
6228
+ * `attempt` as one that has been sent. Throws for one that has not left, which
6229
+ * a run never meets where it reads an attempt it sent or holds.
6230
+ */
6231
+ declare function sentCollectionOf(attempt: InvoiceCollectionRecord): SubmittedInvoiceCollection;
6232
+ /** An attempt to start: what its request carries, and the moment it is taken on. */
6233
+ interface NewInvoiceCollection {
6234
+ invoiceId: string;
6235
+ gatewayAccount: string;
6236
+ paymentMethodId: string;
6237
+ paymentMethodType: PaymentMethodType;
6238
+ customerRef: string;
6239
+ paymentMethodRef: string;
6240
+ invoiceNumber: string;
6241
+ amount: number;
6242
+ currency: string;
6243
+ /** Written as both `submittedAt` and `heldAt`. */
6244
+ at: Date;
6245
+ }
6246
+ /** An attempt to plan for `collectOn`: what its request will carry. */
6247
+ interface PlannedInvoiceCollection {
6248
+ invoiceId: string;
6249
+ /**
6250
+ * The number of the invoice's last attempt the plan follows — `0` where it
6251
+ * has none. A run decides what follows from the attempts it read; one that
6252
+ * read them before another run added an attempt plans nothing.
6253
+ */
6254
+ after: number;
6255
+ gatewayAccount: string;
6256
+ paymentMethodId: string;
6257
+ paymentMethodType: PaymentMethodType;
6258
+ customerRef: string;
6259
+ paymentMethodRef: string;
6260
+ invoiceNumber: string;
6261
+ amount: number;
6262
+ currency: string;
6263
+ /** The day it is collected from; for a direct debit, the earliest such day. */
6264
+ collectOn: CalendarDay;
6265
+ }
6266
+ /**
6267
+ * How long a run's hold on an attempt lasts. Longer than a request may take,
6268
+ * so a run does not ask the gateway about, or send again, a request another
6269
+ * run is still waiting for.
6270
+ */
6271
+ declare const INVOICE_COLLECTION_LEASE_MS: number;
6272
+ /**
6273
+ * How often a direct debit on its way is asked about. Most are settled within
6274
+ * six business days, and the gateway's own report of it is an event of its
6275
+ * own; asking is what finds the outcome where no report arrives.
6276
+ */
6277
+ declare const INVOICE_COLLECTION_ASK_EVERY_MS: number;
6278
+ /**
6279
+ * The key every request of an attempt carries, and that the gateway keeps
6280
+ * with what it creates: `saasicat:collect:<invoice>:<attempt>`. The same for
6281
+ * one attempt however often its request is repeated, and another for the next
6282
+ * attempt of the same invoice.
6283
+ */
6284
+ declare function collectionAttemptKey(invoiceId: string, attempt: number): string;
6285
+ /** The status an outcome settles an attempt in. */
6286
+ declare function collectionStatusOf(outcome: CollectionOutcome): InvoiceCollectionStatus;
6287
+ /**
6288
+ * What an attempt whose request never reached the gateway is settled with
6289
+ * where its invoice was paid meanwhile — a late payment for an earlier
6290
+ * attempt — instead of being sent again: failed, for no reason the
6291
+ * subscriber has to act on, under SaaSiCat's own code.
6292
+ */
6293
+ declare const COLLECTION_NOT_SENT_PAID: CollectionOutcome;
6294
+ /**
6295
+ * The same for an attempt whose payment method a payment of its invoice was
6296
+ * reversed on meanwhile: sent now, it would collect with that payment method
6297
+ * again (`SC-PRIC-085`). The reversal's notice tells the subscriber what
6298
+ * follows.
6299
+ */
6300
+ declare const COLLECTION_NOT_SENT_REVERSED: CollectionOutcome;
6301
+ /**
6302
+ * What `abandonPaid` found for an attempt whose request never reached the
6303
+ * gateway: `abandoned` — its invoice owes nothing, and it is settled as
6304
+ * `COLLECTION_NOT_SENT_PAID`; `resend` — it is still `SUBMITTED` and its
6305
+ * invoice still owes, so the same request is sent again; `settled` — it is no
6306
+ * longer `SUBMITTED`, a report having settled it or put it on its way
6307
+ * meanwhile, and nothing is sent.
6308
+ */
6309
+ type AbandonPaidOutcome = 'abandoned' | 'resend' | 'settled';
6310
+
6311
+ /** What a case is about: a refund no credit takes, or a reversal no credit takes. */
6312
+ type ReconciliationCaseKind = 'REFUND_UNMATCHED' | 'REVERSAL_UNMATCHED';
6313
+ /** A case to reconcile, as a store reads it back. */
6314
+ interface SubscriberReconciliationCaseRecord {
6315
+ id: string;
6316
+ subscriberId: string;
6317
+ /** The tenant the payment's invoice was for, as a trace. */
6318
+ tenantId: string;
6319
+ kind: ReconciliationCaseKind;
6320
+ /** What matched nothing, positive, of `currency`. */
6321
+ amount: number;
6322
+ currency: string;
6323
+ /** The payment the refund pays back, or the reversal takes back. */
6324
+ paymentId: string;
6325
+ /** The refund, for a `REFUND_UNMATCHED`; `null` otherwise. */
6326
+ refundId: string | null;
6327
+ /** The reversal, for a `REVERSAL_UNMATCHED`; `null` otherwise. */
6328
+ reversalId: string | null;
6329
+ gatewayAccount: string;
6330
+ /** The refund's or the reversal's reference at the gateway, which the operator finds it under. */
6331
+ gatewayRef: string;
6332
+ recordedAt: Date;
6333
+ /** When it was closed; `null` while it is open. */
6334
+ closedAt: Date | null;
6335
+ /** Who closed it; `null` while it is open, and where SaaSiCat closed it. */
6336
+ closedBy: string | null;
6337
+ /** Why it was closed, in the operator's words or SaaSiCat's; `null` while it is open. */
6338
+ note: string | null;
6339
+ }
6340
+ /** An operator closing a case. */
6341
+ interface CloseReconciliationCase {
6342
+ caseId: string;
6343
+ note: string;
6344
+ /** Who closes it. */
6345
+ closedBy: string;
6346
+ at: Date;
6347
+ }
6348
+ /** What closing a case did. */
6349
+ type ClosedReconciliationCase = {
6350
+ outcome: 'closed';
6351
+ case: SubscriberReconciliationCaseRecord;
6352
+ } | {
6353
+ outcome: 'unknown-case';
6354
+ }
6355
+ /** Closed before, by the operator or by SaaSiCat; nothing is written. */
6356
+ | {
6357
+ outcome: 'already-closed';
6358
+ case: SubscriberReconciliationCaseRecord;
6359
+ };
6360
+ /** Whether a list reads the cases still open or the ones closed. */
6361
+ type ReconciliationCaseState = 'open' | 'closed';
6362
+ /**
6363
+ * The manifest capability that announces the operator's list of cases to
6364
+ * reconcile. The platform sets it where it serves the list.
6365
+ */
6366
+ declare const RECONCILIATION_READ_CAPABILITY = "reconciliation.read";
6367
+ /**
6368
+ * The manifest capability that announces closing a case with a note, beside
6369
+ * the list.
6370
+ */
6371
+ declare const RECONCILIATION_CLOSE_CAPABILITY = "reconciliation.close";
6372
+ /**
6373
+ * The manifest capability that announces a tenant's invoices with what each
6374
+ * still owes, and its open cases, on its page.
6375
+ */
6376
+ declare const SUBSCRIBER_PAYMENTS_CAPABILITY = "payments.read";
6377
+ /** A case as the operator reads it. */
6378
+ interface AdminReconciliationCase {
6379
+ id: string;
6380
+ kind: ReconciliationCaseKind;
6381
+ amount: number;
6382
+ currency: string;
6383
+ /** The tenant the payment's invoice was for, which the administration's tenant list names. */
6384
+ tenantId: string;
6385
+ subscriber: {
6386
+ id: string;
6387
+ customerNumber: string;
6388
+ legalName: string;
6389
+ };
6390
+ /** The payment it is about, and the invoice that payment was collected for. */
6391
+ payment: {
6392
+ ref: string;
6393
+ invoiceNumber: string | null;
6394
+ };
6395
+ gatewayAccount: string;
6396
+ /** The refund's or the reversal's reference at the gateway. */
6397
+ reference: string;
6398
+ /** ISO 8601. */
6399
+ recordedAt: string;
6400
+ /** ISO 8601; `null` while it is open. */
6401
+ closedAt: string | null;
6402
+ /** Who closed it; `null` while it is open, and where SaaSiCat closed it. */
6403
+ closedBy: string | null;
6404
+ note: string | null;
6405
+ }
6406
+ /** One page of cases, the oldest first; `next` continues it, `null` at the end. */
6407
+ interface AdminReconciliationCases {
6408
+ cases: AdminReconciliationCase[];
6409
+ next: string | null;
6410
+ }
6411
+ /** The longest note a case is closed with, which the route and the form both hold to. */
6412
+ declare const RECONCILIATION_NOTE_MAX_LENGTH = 500;
6413
+ /** An operator's note closing a case. */
6414
+ interface AdminReconciliationClose {
6415
+ note: string;
6416
+ }
6417
+ /** An invoice on its tenant's page: what it asked for, and what it still owes. */
6418
+ interface AdminTenantInvoice {
6419
+ id: string;
6420
+ number: string;
6421
+ /** ISO 8601. */
6422
+ issuedAt: string;
6423
+ dueDate: CalendarDay;
6424
+ totalGross: number;
6425
+ currency: string;
6426
+ /**
6427
+ * What it still owes after every payment, reversal and reinstatement
6428
+ * against it; negative where the subscriber is owed, as by an invoice whose
6429
+ * total is negative.
6430
+ */
6431
+ owed: number;
6432
+ }
6433
+ /** A tenant's invoices, the newest first, and its cases still open, the oldest first. */
6434
+ interface AdminTenantPayments {
6435
+ invoices: AdminTenantInvoice[];
6436
+ openCases: AdminReconciliationCase[];
6437
+ }
6438
+
6439
+ /** A payment the gateway confirmed for an invoice, as a store reads it back. */
6440
+ interface SubscriberPaymentRecord {
6441
+ id: string;
6442
+ subscriberId: string;
6443
+ /** The tenant the invoice was for, as a trace. */
6444
+ tenantId: string;
6445
+ /** The invoice it was collected for. */
6446
+ invoiceId: string;
6447
+ /** The attempt that collected it. */
6448
+ collectionId: string;
6449
+ /** The account in `config/saas.yaml#payments.accounts` it was collected at. */
6450
+ gatewayAccount: string;
6451
+ provider: string;
6452
+ /** The gateway's own reference to the payment, unique within its account. */
6453
+ gatewayRef: string;
6454
+ /** What the gateway received, of `currency`. */
6455
+ amount: number;
6456
+ currency: string;
6457
+ recordedAt: Date;
6458
+ }
6459
+ /** A payment to record: what the gateway reported for an attempt. */
6460
+ interface NewSubscriberPayment {
6461
+ invoiceId: string;
6462
+ collectionId: string;
6463
+ gatewayAccount: string;
6464
+ provider: string;
6465
+ gatewayRef: string;
6466
+ amount: number;
6467
+ currency: string;
6468
+ at: Date;
6469
+ }
6470
+ /** What recording a payment did: what it settles of its invoice, and the credit it left. */
6471
+ interface RecordedSubscriberPayment {
6472
+ payment: SubscriberPaymentRecord;
6473
+ /** The part of the payment that settles its invoice; `0` where the invoice owed nothing. */
6474
+ settled: number;
6475
+ /** What the payment brought beyond what its invoice owed; `null` where it brought nothing more. */
6476
+ credit: SubscriberCreditRecord | null;
6477
+ }
6478
+ /** Where a credit comes from. */
6479
+ type SubscriberCreditOrigin =
6480
+ /** What a payment brought beyond what its invoice still owed. */
6481
+ {
6482
+ kind: 'payment';
6483
+ paymentId: string;
6484
+ }
6485
+ /** An invoice whose total is negative: the subscriber is owed its amount. */
6486
+ | {
6487
+ kind: 'invoice';
6488
+ invoiceId: string;
6489
+ }
6490
+ /**
6491
+ * What a reversal the gateway gave back brought beyond what the invoices
6492
+ * it had opened again still owed: the subscriber paid them meanwhile.
6493
+ */
6494
+ | {
6495
+ kind: 'reversal';
6496
+ reversalId: string;
6497
+ };
6498
+ /** Money the operator owes a subscriber, as a store reads it back. */
6499
+ interface SubscriberCreditRecord {
6500
+ id: string;
6501
+ subscriberId: string;
6502
+ /** The tenant it arose in, as a trace. */
6503
+ tenantId: string;
6504
+ /** What the subscriber is owed, positive, of `currency`. */
6505
+ amount: number;
6506
+ currency: string;
6507
+ origin: SubscriberCreditOrigin;
6508
+ createdAt: Date;
6509
+ }
6510
+ /**
6511
+ * What changed how much of a credit is paid out: a refund the gateway reported
6512
+ * against it, the same refund given back because it failed, a payout the
6513
+ * operator recorded, a reversal that took the credit's open part back to the
6514
+ * subscriber's bank, and the same reversal given back by the gateway.
6515
+ */
6516
+ type SubscriberCreditEntryKind = 'REFUND' | 'REFUND_FAILED' | 'PAYOUT' | 'REVERSAL' | 'REVERSAL_TAKEN_BACK';
6517
+ /** One change to what a credit has paid out, as a store reads it back. */
6518
+ interface SubscriberCreditEntryRecord {
6519
+ id: string;
6520
+ creditId: string;
6521
+ kind: SubscriberCreditEntryKind;
6522
+ /**
6523
+ * Positive. A `REFUND`, a `PAYOUT` and a `REVERSAL` pay this much of the
6524
+ * credit out; a `REFUND_FAILED` and a `REVERSAL_TAKEN_BACK` give it back.
6525
+ */
6526
+ amount: number;
6527
+ /** The refund, for a `REFUND` and its `REFUND_FAILED`; `null` otherwise. */
6528
+ refundId: string | null;
6529
+ /** The reversal, for a `REVERSAL` and its `REVERSAL_TAKEN_BACK`; `null` otherwise. */
6530
+ reversalId: string | null;
6531
+ /**
6532
+ * Where the operator finds it: the refund's or the reversal's reference
6533
+ * at the gateway, or the payout's, such as the transfer's.
6534
+ */
6535
+ reference: string | null;
6536
+ /** The day the payout left; `null` for a refund's entries. */
6537
+ paidOn: CalendarDay | null;
6538
+ /** Who recorded the payout; `null` for a refund's entries. */
6539
+ recordedBy: string | null;
6540
+ /** What the operator noted with the payout. */
6541
+ note: string | null;
6542
+ recordedAt: Date;
6543
+ }
6544
+ /** A credit with what has been paid out of it, and what is still open. */
6545
+ interface SubscriberCreditStanding {
6546
+ credit: SubscriberCreditRecord;
6547
+ entries: SubscriberCreditEntryRecord[];
6548
+ /** What the subscriber is still owed of it; never below `0`. */
6549
+ open: number;
6550
+ }
6551
+ /**
6552
+ * Where a refund stands, as the gateway reports it: `PENDING` and `SUCCEEDED`
6553
+ * pay out, `FAILED` and `CANCELED` gave the money back to the operator.
6554
+ */
6555
+ type SubscriberRefundStatus = 'PENDING' | 'SUCCEEDED' | 'FAILED' | 'CANCELED';
6556
+ /** A refund the operator made in the gateway, as a store reads it back. */
6557
+ interface SubscriberRefundRecord {
6558
+ id: string;
6559
+ subscriberId: string;
6560
+ /** The payment it pays back. */
6561
+ paymentId: string;
6562
+ gatewayAccount: string;
6563
+ /** The gateway's reference to the refund, unique within its account. */
6564
+ gatewayRef: string;
6565
+ amount: number;
6566
+ currency: string;
6567
+ status: SubscriberRefundStatus;
6568
+ recordedAt: Date;
6569
+ /** When it was recorded as failed or canceled; `null` while it pays out. */
6570
+ endedAt: Date | null;
6571
+ }
6572
+ /** A refund as the gateway reported it, to record against the payment it pays back. */
6573
+ interface ReportedSubscriberRefund {
6574
+ gatewayAccount: string;
6575
+ gatewayRef: string;
6576
+ /** The gateway's reference to the payment it pays back. */
6577
+ paymentRef: string;
6578
+ amount: number;
6579
+ currency: string;
6580
+ status: SubscriberRefundStatus;
6581
+ at: Date;
6582
+ }
6583
+ /** What recording a refund did. */
6584
+ type RecordedSubscriberRefund =
6585
+ /** No payment of this installation's is under its reference. */
6586
+ {
6587
+ outcome: 'unknown-payment';
6588
+ }
6589
+ /**
6590
+ * Recorded for the first time: the credits it pays out, and the part that
6591
+ * matches none, which is a case to reconcile.
6592
+ */
6593
+ | {
6594
+ outcome: 'recorded';
6595
+ refund: SubscriberRefundRecord;
6596
+ parts: CreditPart[];
6597
+ unmatched: number;
6598
+ case: SubscriberReconciliationCaseRecord | null;
6599
+ }
6600
+ /**
6601
+ * Recorded before; it failed or was canceled now, gave back what it paid
6602
+ * out, and closed the case its unmatched part had opened.
6603
+ */
6604
+ | {
6605
+ outcome: 'given-back';
6606
+ refund: SubscriberRefundRecord;
6607
+ parts: CreditPart[];
6608
+ closedCases: SubscriberReconciliationCaseRecord[];
6609
+ }
6610
+ /** Recorded before, and nothing it reports changes what is paid out. */
6611
+ | {
6612
+ outcome: 'unchanged';
6613
+ refund: SubscriberRefundRecord;
6614
+ };
6615
+ /** The part of an amount that one credit takes. */
6616
+ interface CreditPart {
6617
+ creditId: string;
6618
+ amount: number;
6619
+ }
6620
+ /** The part of an amount that one invoice takes. */
6621
+ interface InvoicePart {
6622
+ invoiceId: string;
6623
+ amount: number;
6624
+ }
6625
+ /**
6626
+ * Money the gateway took back from the operator for a payment — a returned
6627
+ * direct debit or a chargeback — as a store reads it back. What it withdrew and
6628
+ * what the gateway gave back of it only grow; each change is recorded as the
6629
+ * entries it adds.
6630
+ */
6631
+ interface SubscriberReversalRecord {
6632
+ id: string;
6633
+ subscriberId: string;
6634
+ /** The tenant the payment's invoice was for, as a trace. */
6635
+ tenantId: string;
6636
+ /** The payment it takes back. */
6637
+ paymentId: string;
6638
+ gatewayAccount: string;
6639
+ /** The gateway's reference to it, such as a dispute's, unique within its account. */
6640
+ gatewayRef: string;
6641
+ /** What the gateway withdrew, positive, of `currency`. */
6642
+ amount: number;
6643
+ currency: string;
6644
+ /**
6645
+ * The part of `amount` taken from the credit the payment left — its open
6646
+ * part and the part already paid out alike —, so a later reversal of the
6647
+ * same payment takes from what of that credit is left.
6648
+ */
6649
+ fromCredit: number;
6650
+ /** What the gateway gave back of `amount`, a dispute won; `0` until it gives anything back. */
6651
+ reinstated: number;
6652
+ recordedAt: Date;
6653
+ /** When the gateway last gave something back; `null` until it does. */
6654
+ reinstatedAt: Date | null;
6655
+ }
6656
+ /**
6657
+ * A reversal as the gateway reports it, as it stands when it is reported: what
6658
+ * it withdrew and what it gave back so far, each in total.
6659
+ */
6660
+ interface ReportedSubscriberReversal {
6661
+ gatewayAccount: string;
6662
+ gatewayRef: string;
6663
+ /** The gateway's reference to the payment it takes back. */
6664
+ paymentRef: string;
6665
+ currency: string;
6666
+ withdrawn: number;
6667
+ reinstated: number;
6668
+ at: Date;
6669
+ }
6670
+ /** What withdrawing part of a reversal's amount took back. */
6671
+ interface ReversalWithdrawal {
6672
+ /** What it took of the credit the payment left that was still open. */
6673
+ credit: CreditPart | null;
6674
+ /**
6675
+ * What it took instead of opening an invoice again, of the credits other
6676
+ * payments collected for that invoice left, the oldest first.
6677
+ */
6678
+ covering: CreditPart[];
6679
+ /** The invoices it opened again, each by how much, the oldest first. */
6680
+ invoices: InvoicePart[];
6681
+ /**
6682
+ * The covers the payment's own credit gave other reversals of its invoice,
6683
+ * lifted before anything else: each of those reversals now opens the
6684
+ * invoice by what it took (`SC-PRIC-088`).
6685
+ */
6686
+ uncovered: LiftedCover[];
6687
+ /**
6688
+ * What met the part of that credit already paid out, or went beyond what
6689
+ * the payment brought: a case to reconcile.
6690
+ */
6691
+ unmatched: number;
6692
+ case: SubscriberReconciliationCaseRecord | null;
6693
+ }
6694
+ /** A cover lifted: the reversal it was given to, that reversal's payment, and what it opens now. */
6695
+ interface LiftedCover {
6696
+ reversalId: string;
6697
+ paymentId: string;
6698
+ invoiceId: string;
6699
+ amount: number;
6700
+ }
6701
+ /** What giving back part of a reversal's amount took back in turn. */
6702
+ interface ReversalReinstatement {
6703
+ /** The cases of the reversal it covered, closed. */
6704
+ closedCases: SubscriberReconciliationCaseRecord[];
6705
+ /** What it gave back to the credits the reversal had taken from. */
6706
+ credits: CreditPart[];
6707
+ /** The invoices it settled again, each by how much. */
6708
+ invoices: InvoicePart[];
6709
+ /** What the invoices no longer owed, as a credit; `null` where they owed all of it. */
6710
+ credit: SubscriberCreditRecord | null;
6711
+ }
6712
+ /** What recording a reversal did. */
6713
+ type RecordedSubscriberReversal =
6714
+ /** No payment of this installation's is under its reference. */
6715
+ {
6716
+ outcome: 'unknown-payment';
6717
+ }
6718
+ /**
6719
+ * Recorded, or recorded before and changed now: what the newly withdrawn
6720
+ * part took back, and what the newly given back part gave back, each
6721
+ * `null` where nothing of it changed.
6722
+ */
6723
+ | {
6724
+ outcome: 'recorded';
6725
+ reversal: SubscriberReversalRecord;
6726
+ withdrawal: ReversalWithdrawal | null;
6727
+ reinstatement: ReversalReinstatement | null;
6728
+ }
6729
+ /** Recorded before, and nothing it reports changes it. */
6730
+ | {
6731
+ outcome: 'unchanged';
6732
+ reversal: SubscriberReversalRecord;
6733
+ };
6734
+ /** A payout the operator made outside the gateway, to record against a credit. */
6735
+ interface NewSubscriberPayout {
6736
+ creditId: string;
6737
+ amount: number;
6738
+ /** The transfer's reference, which the operator's bank statement names. */
6739
+ reference: string;
6740
+ paidOn: CalendarDay;
6741
+ note: string | null;
6742
+ /** Who records it. */
6743
+ recordedBy: string;
6744
+ at: Date;
6745
+ }
6746
+ /** What recording a payout did. */
6747
+ type RecordedSubscriberPayout = {
6748
+ outcome: 'recorded';
6749
+ entry: SubscriberCreditEntryRecord;
6750
+ open: number;
6751
+ } | {
6752
+ outcome: 'unknown-credit';
6753
+ }
6754
+ /** More than the credit still owes; nothing is written. */
6755
+ | {
6756
+ outcome: 'exceeds-open';
6757
+ open: number;
6758
+ };
6759
+ /**
6760
+ * The manifest capability that announces the operator's view of a
6761
+ * subscriber's credits. The platform sets it where it serves the view.
6762
+ */
6763
+ declare const SUBSCRIBER_CREDIT_CAPABILITY = "credits.read";
6764
+ /**
6765
+ * The manifest capability that announces recording a payout the operator
6766
+ * made outside the gateway, beside the view of the credits.
6767
+ */
6768
+ declare const SUBSCRIBER_PAYOUT_CAPABILITY = "credits.payout";
6769
+ /** What paid a credit out, or gave it back, as the operator reads it. */
6770
+ interface AdminSubscriberCreditEntry {
6771
+ kind: SubscriberCreditEntryKind;
6772
+ amount: number;
6773
+ /** The refund's or the reversal's reference at the gateway, or the payout's. */
6774
+ reference: string | null;
6775
+ /** The day a payout left; `null` for a refund's entries. */
6776
+ paidOn: CalendarDay | null;
6777
+ note: string | null;
6778
+ /** ISO 8601. */
6779
+ recordedAt: string;
6780
+ }
6781
+ /** A credit as the operator reads it: where it comes from, what was paid out, what is open. */
6782
+ interface AdminSubscriberCredit {
6783
+ id: string;
6784
+ amount: number;
6785
+ currency: string;
6786
+ /**
6787
+ * The payment that brought more than its invoice owed, the invoice whose
6788
+ * total is negative, or the reversal the gateway gave back.
6789
+ */
6790
+ origin: {
6791
+ kind: 'payment';
6792
+ paymentRef: string;
6793
+ invoiceNumber: string | null;
6794
+ } | {
6795
+ kind: 'invoice';
6796
+ invoiceNumber: string | null;
6797
+ } | {
6798
+ kind: 'reversal';
6799
+ reversalRef: string;
6800
+ invoiceNumber: string | null;
6801
+ };
6802
+ /** ISO 8601. */
6803
+ createdAt: string;
6804
+ open: number;
6805
+ entries: AdminSubscriberCreditEntry[];
6806
+ }
6807
+ /** A tenant's credits as the operator reads them, the oldest first. */
6808
+ interface AdminSubscriberCredits {
6809
+ credits: AdminSubscriberCredit[];
6810
+ /**
6811
+ * The installation's time zone, in which a payout's day is judged: no
6812
+ * payout lies after today there, wherever the operator sits.
6813
+ */
6814
+ timeZone: string;
6815
+ }
6816
+ /** A payout the operator records against a credit. */
6817
+ interface AdminSubscriberPayout {
6818
+ amount: number;
6819
+ reference: string;
6820
+ paidOn: CalendarDay;
6821
+ note?: string | null;
6822
+ }
6823
+
5838
6824
  /**
5839
6825
  * Snapshot form of a `Subscription` row for the EntitlementService
5840
6826
  * computation. The consumer maps its Prisma structure onto this form.
@@ -6356,6 +7342,298 @@ interface SubscriptionInvoiceRepository {
6356
7342
  after?: string;
6357
7343
  }, tx?: TransactionContext): Promise<string[]>;
6358
7344
  }
7345
+ /**
7346
+ * The attempts to collect an invoice through its payment gateway.
7347
+ *
7348
+ * An invoice has at most one attempt that is open — planned, or sent and not
7349
+ * settled — and none after one succeeded: the database holds that
7350
+ * (`sql/constraints.postgres.sql`), and the turn holds it against two runs
7351
+ * that start at once. Every write that settles
7352
+ * or takes on an attempt names the state it expects, so of two runs one wins
7353
+ * and the other is told.
7354
+ *
7355
+ * Platform-wide: the run reads across tenants inside `RlsBypassPort`.
7356
+ */
7357
+ interface InvoiceCollectionRepository {
7358
+ /**
7359
+ * The invoices to collect on `today`, by id, at most `limit`, after `after`
7360
+ * where it is given: issued with a payment method to collect with, handed
7361
+ * to the mail — so their announcement has reached the subscriber — with no
7362
+ * collection date or one on or before `today`, and no attempt yet, planned
7363
+ * or sent.
7364
+ */
7365
+ listDue(today: CalendarDay, page: {
7366
+ limit: number;
7367
+ after?: string;
7368
+ }, tx?: TransactionContext): Promise<string[]>;
7369
+ /**
7370
+ * Starts the invoice's first attempt in its turn and returns it, written as
7371
+ * `SUBMITTED` before its request leaves; `null`, writing nothing, where the
7372
+ * invoice owes nothing — its total no more than what is settled against
7373
+ * it in `subscription_invoice_settlements` — or has an attempt already —
7374
+ * every later one is planned (`plan`), so
7375
+ * a run that found the invoice due before another run's attempt failed
7376
+ * does not charge it again at once. The turn is the invoice's
7377
+ * own row, locked for the transaction — the chain of one invoice, which a
7378
+ * cancellation's replacement joins — so a cancellation never meets an
7379
+ * attempt about to be sent without knowing it (`SC-PRIC-036`). The attempt
7380
+ * is numbered after the invoice's last, and its key is
7381
+ * `collectionAttemptKey(invoiceId, attempt)`.
7382
+ */
7383
+ startAttempt(attempt: NewInvoiceCollection, tx?: TransactionContext): Promise<InvoiceCollectionRecord | null>;
7384
+ /**
7385
+ * Plans the invoice's next attempt in its turn, as `startAttempt` starts
7386
+ * one, and returns it, written as `SCHEDULED` for `plan.collectOn` with
7387
+ * nothing sent; `null`, writing nothing, where the invoice owes nothing,
7388
+ * where an attempt of it is open or one succeeded, or where its last
7389
+ * attempt is not the one numbered `plan.after` any more.
7390
+ */
7391
+ plan(plan: PlannedInvoiceCollection, tx?: TransactionContext): Promise<InvoiceCollectionRecord | null>;
7392
+ /**
7393
+ * Records that a planned direct debit's announcement reached the subscriber
7394
+ * at `at`, naming `collectOn`, and returns `true`; `false`, writing nothing,
7395
+ * where it is not planned or was announced already.
7396
+ */
7397
+ announce(id: string, collectOn: CalendarDay, at: Date, tx?: TransactionContext): Promise<boolean>;
7398
+ /**
7399
+ * Takes a planned attempt up as sent — `SUBMITTED`, sent and held at `at` —
7400
+ * in its invoice's turn, as `startAttempt` writes one, before its request
7401
+ * leaves, and returns it; `null`, writing nothing, where it is not planned
7402
+ * any more, so of two runs one sends it, or where its invoice owes nothing,
7403
+ * a payment having come for it meanwhile.
7404
+ */
7405
+ submitPlanned(id: string, at: Date, tx?: TransactionContext): Promise<SubmittedInvoiceCollection | null>;
7406
+ /**
7407
+ * Withdraws a planned attempt that will not be made, at `at`, in its
7408
+ * invoice's turn, and returns `true`; `false`, writing nothing, where it is
7409
+ * not planned.
7410
+ */
7411
+ withdraw(id: string, at: Date, tx?: TransactionContext): Promise<boolean>;
7412
+ /** The planned attempts, by id and page as above, whatever their day. */
7413
+ listPlanned(page: {
7414
+ limit: number;
7415
+ after?: string;
7416
+ }, tx?: TransactionContext): Promise<string[]>;
7417
+ /**
7418
+ * The failed and the reversed attempts, by id and page as above, whose
7419
+ * follow-up is not recorded yet.
7420
+ */
7421
+ listToFollowUp(page: {
7422
+ limit: number;
7423
+ after?: string;
7424
+ }, tx?: TransactionContext): Promise<string[]>;
7425
+ /**
7426
+ * The invoices, by id and page as above, that another payment method can
7427
+ * collect: their last attempt was withdrawn, or failed or was reversed and
7428
+ * was followed up, every attempt of theirs that was reversed was followed
7429
+ * up, and their subscriber has a payment method in use other than the one
7430
+ * the last attempt was made with and than every one a reversed attempt was
7431
+ * made with (`subscriber_payment_methods`), and they still owe something.
7432
+ * An invoice whose failed or reversed payment method is still in use, or
7433
+ * whose subscriber has none, is not read until that changes.
7434
+ */
7435
+ listCollectableAgain(page: {
7436
+ limit: number;
7437
+ after?: string;
7438
+ }, tx?: TransactionContext): Promise<string[]>;
7439
+ /**
7440
+ * Records that what follows a failed or a reversed attempt was decided, at
7441
+ * `at`, and returns `true`; `false`, writing nothing, where it neither
7442
+ * failed nor was reversed, or was followed up already.
7443
+ */
7444
+ markFollowedUp(id: string, at: Date, tx?: TransactionContext): Promise<boolean>;
7445
+ /**
7446
+ * Marks the attempt whose payment a reversal took back as `REVERSED`, at
7447
+ * `at`, where the reversal opened its invoice again, and returns `true`;
7448
+ * `false`, writing nothing, where it is neither `SUCCEEDED` nor `FAILED`.
7449
+ * A failed one brought its payment late, beside another attempt of its
7450
+ * invoice (`recordOutcome`). Either is followed up again, as a reversal;
7451
+ * the invoice is then collected only by an attempt with another payment
7452
+ * method than every reversed one, planned once the reversal is followed up.
7453
+ */
7454
+ markReversed(id: string, at: Date, tx?: TransactionContext): Promise<boolean>;
7455
+ /**
7456
+ * Records what became of an attempt that is not settled — `SUBMITTED` or
7457
+ * `PENDING` — and returns `true`; `false`, writing nothing, where it is
7458
+ * settled already. `PENDING` stays open; `SUCCEEDED` and `FAILED` settle it
7459
+ * at `at`.
7460
+ *
7461
+ * A success reported for an attempt recorded as `FAILED` is the money
7462
+ * arriving after all: in the invoice's turn, an attempt planned after it
7463
+ * is withdrawn, and the attempt succeeds and `true` is returned — unless
7464
+ * another attempt of the invoice is on its way or succeeded, which leaves
7465
+ * it failed and returns `false`.
7466
+ */
7467
+ recordOutcome(id: string, outcome: CollectionOutcome, at: Date, tx?: TransactionContext): Promise<boolean>;
7468
+ /**
7469
+ * Decides, in the invoice's turn — the one a payment is recorded in —,
7470
+ * what becomes of a `SUBMITTED` attempt whose request never reached the
7471
+ * gateway: where its invoice owes nothing it is settled as
7472
+ * `COLLECTION_NOT_SENT_PAID` at `at` (`abandoned`); where it is still
7473
+ * `SUBMITTED` and the invoice owes, it is to be sent again (`resend`),
7474
+ * and is held from `at`; where a report settled it or put it on its way
7475
+ * meanwhile, nothing is (`settled`). Both `abandoned` and `resend` rest on
7476
+ * a write conditioned on the attempt still being `SUBMITTED`, so a report
7477
+ * recorded outside the invoice's turn — a failure, an answer that it is on
7478
+ * its way — while the run decides is found rather than overlooked. A run
7479
+ * asks it before it sends such a request again, so a payment that arrived
7480
+ * meanwhile is never charged a second time.
7481
+ */
7482
+ abandonPaid(id: string, at: Date, tx?: TransactionContext): Promise<AbandonPaidOutcome>;
7483
+ /**
7484
+ * Takes on an attempt that is not settled for the run calling it at `at`,
7485
+ * where no run took it on since `heldBefore`, and returns `true`; of two
7486
+ * concurrent calls exactly one does.
7487
+ */
7488
+ hold(id: string, heldBefore: Date, at: Date, tx?: TransactionContext): Promise<boolean>;
7489
+ /**
7490
+ * The attempts a run should take on again, by id and page as above:
7491
+ * `SUBMITTED` ones no run took on since `submittedBefore` — their answer
7492
+ * was lost —, and `PENDING` ones none took on since `pendingBefore`.
7493
+ */
7494
+ listUnsettled(before: {
7495
+ submittedBefore: Date;
7496
+ pendingBefore: Date;
7497
+ }, page: {
7498
+ limit: number;
7499
+ after?: string;
7500
+ }, tx?: TransactionContext): Promise<string[]>;
7501
+ findById(id: string, tx?: TransactionContext): Promise<InvoiceCollectionRecord | null>;
7502
+ /** The attempt `attemptKey` names — the key the gateway keeps with what it created — or `null`. */
7503
+ findByKey(attemptKey: string, tx?: TransactionContext): Promise<InvoiceCollectionRecord | null>;
7504
+ /** Every attempt of one invoice, the first first. */
7505
+ listByInvoice(invoiceId: string, tx?: TransactionContext): Promise<InvoiceCollectionRecord[]>;
7506
+ /**
7507
+ * Every gateway account an attempt that is not settled was sent to, each
7508
+ * once — the accounts that have to stay configured until their attempts
7509
+ * settle, since only the account can say what became of them
7510
+ * (`SC-PRIC-030`). Platform-wide: a start asks it before anything is
7511
+ * served, through `RlsBypassPort`.
7512
+ */
7513
+ accountsInUse(tx?: TransactionContext): Promise<string[]>;
7514
+ }
7515
+ /**
7516
+ * What money moved between a subscriber and the operator: the payments the
7517
+ * gateway confirmed, what each settles of its invoice, the credits the
7518
+ * subscriber is owed, the refunds and payouts that pay them out, the reversals
7519
+ * that take a payment back and give it back again, and the cases nothing
7520
+ * matched (`SC-PRIC-029`, `SC-PRIC-083`, `SC-PRIC-084`, `SC-PRIC-086`,
7521
+ * `SC-ADM-033`). Nothing is edited once written but a refund's status, what a
7522
+ * reversal withdrew and gave back, and a case's closing; every other change is
7523
+ * an entry of its own.
7524
+ *
7525
+ * Platform-wide: the gateway's callbacks and the run read across tenants
7526
+ * inside `RlsBypassPort`.
7527
+ */
7528
+ interface SubscriberPaymentRepository {
7529
+ /**
7530
+ * Records a payment the gateway confirmed for an invoice, in the invoice's
7531
+ * turn (`SC-PRIC-036`): it settles what the invoice still owes, and what it
7532
+ * brought beyond that is a credit on the subscriber's account. Returns what
7533
+ * it did; `null`, writing nothing, where a payment is recorded under the
7534
+ * same gateway account and reference already, however it was reported
7535
+ * then (`SC-PRIC-029`). Throws for an invoice that does not exist, and for
7536
+ * a payment in another currency than its invoice's.
7537
+ */
7538
+ recordPayment(payment: NewSubscriberPayment, tx?: TransactionContext): Promise<RecordedSubscriberPayment | null>;
7539
+ /**
7540
+ * Credits an invoice whose total is negative to its subscriber, at `at`,
7541
+ * and returns the credit; `null`, writing nothing, where it is credited
7542
+ * already or its total is not negative.
7543
+ */
7544
+ creditInvoice(invoiceId: string, at: Date, tx?: TransactionContext): Promise<SubscriberCreditRecord | null>;
7545
+ /**
7546
+ * The invoices whose total is negative and that are not credited yet, by
7547
+ * id, at most `limit`, after `after` where it is given.
7548
+ */
7549
+ listUncredited(page: {
7550
+ limit: number;
7551
+ after?: string;
7552
+ }, tx?: TransactionContext): Promise<string[]>;
7553
+ /**
7554
+ * Records a refund the gateway reported against the payment it pays back.
7555
+ * Seen for the first time, it is divided across the subscriber's open
7556
+ * credits in its currency — the credit that payment left first, then the
7557
+ * oldest — and what none takes matches nothing, a case to reconcile. Seen
7558
+ * again as failed or canceled, it gives back what it paid out of each
7559
+ * credit, once, and closes its case. Every credit it reads is held for the
7560
+ * transaction, so a payout or another refund at the same moment waits for
7561
+ * it.
7562
+ */
7563
+ recordRefund(refund: ReportedSubscriberRefund, tx?: TransactionContext): Promise<RecordedSubscriberRefund>;
7564
+ /**
7565
+ * Records a payout the operator made outside the gateway against one
7566
+ * credit, holding the credit for the transaction; nothing is written where
7567
+ * the credit does not exist or owes less than the payout.
7568
+ */
7569
+ recordPayout(payout: NewSubscriberPayout, tx?: TransactionContext): Promise<RecordedSubscriberPayout>;
7570
+ /** The subscriber's credits, the oldest first, each with its entries and what it still owes. */
7571
+ listCredits(subscriberId: string, tx?: TransactionContext): Promise<SubscriberCreditStanding[]>;
7572
+ /** The payment recorded under `id`, or `null`. */
7573
+ findPaymentById(id: string, tx?: TransactionContext): Promise<SubscriberPaymentRecord | null>;
7574
+ /** The reversal recorded under `id`, or `null`. */
7575
+ findReversalById(id: string, tx?: TransactionContext): Promise<SubscriberReversalRecord | null>;
7576
+ /** The payment recorded under a gateway account and reference, or `null`. */
7577
+ findPaymentByRef(gatewayAccount: string, gatewayRef: string, tx?: TransactionContext): Promise<SubscriberPaymentRecord | null>;
7578
+ /** The payments recorded for an invoice, the first first. */
7579
+ listPaymentsByInvoice(invoiceId: string, tx?: TransactionContext): Promise<SubscriberPaymentRecord[]>;
7580
+ /** What an invoice still owes after what is settled against it; `null` where it does not exist. */
7581
+ owedBy(invoiceId: string, tx?: TransactionContext): Promise<number | null>;
7582
+ /**
7583
+ * What each of `invoiceIds` still owes, for every one that exists, in one
7584
+ * read.
7585
+ */
7586
+ owedByInvoices(invoiceIds: readonly string[], tx?: TransactionContext): Promise<{
7587
+ invoiceId: string;
7588
+ owed: number;
7589
+ }[]>;
7590
+ /**
7591
+ * Records a reversal the gateway reported against the payment it takes
7592
+ * back, in the turn of that payment's invoice (`SC-PRIC-036`), with every
7593
+ * credit of its subscriber held. What it withdrew and what the gateway gave
7594
+ * back of it are reported in total; what grew since it was last recorded is
7595
+ * applied, once however often and in whatever order it is reported. What it
7596
+ * newly withdrew takes from the credit the payment left first — its open
7597
+ * part shrinks it, its part already paid out is a case to reconcile —, then
7598
+ * opens again the invoices the payment settles, the oldest first, and what
7599
+ * exceeds both is a case as well (`SC-PRIC-084`). What it would open again
7600
+ * is taken first of the open credits that other payments collected for
7601
+ * those invoices left, the oldest first (`SC-PRIC-087`). What it takes of
7602
+ * the payment's own credit beyond the open part lifts the covers that
7603
+ * credit gave other reversals before it counts as paid out: each is given
7604
+ * back to the credit, and its reversal opens the invoice by it
7605
+ * (`SC-PRIC-088`, `ReversalWithdrawal.uncovered`). What the gateway gives
7606
+ * back returns to the payment's own credit before the covering ones. What the gateway newly
7607
+ * gave back covers the reversal's cases first, closing each it covers, then
7608
+ * gives back what it took of the credit, then settles again what it opened
7609
+ * as far as the invoice still owes, and what an invoice no longer owes is a
7610
+ * credit (`SC-PRIC-086`). Throws for a reversal in another currency than
7611
+ * its payment.
7612
+ */
7613
+ recordReversal(reversal: ReportedSubscriberReversal, tx?: TransactionContext): Promise<RecordedSubscriberReversal>;
7614
+ /**
7615
+ * The cases to reconcile in `state`, the oldest first — of one subscriber
7616
+ * where `subscriberId` is given —, at most `limit`, after the case `after`
7617
+ * names where it is given.
7618
+ */
7619
+ listCases(filter: {
7620
+ state: ReconciliationCaseState;
7621
+ subscriberId?: string;
7622
+ }, page: {
7623
+ limit: number;
7624
+ after?: string;
7625
+ }, tx?: TransactionContext): Promise<SubscriberReconciliationCaseRecord[]>;
7626
+ /** Closes an open case with the operator's note, once. */
7627
+ closeCase(close: CloseReconciliationCase, tx?: TransactionContext): Promise<ClosedReconciliationCase>;
7628
+ /**
7629
+ * Every gateway account a payment was collected at whose credit is still
7630
+ * owed, in part or whole, each once — the accounts that have to stay
7631
+ * configured, so a refund made there is recorded against the credit
7632
+ * (`SC-PRIC-030`). Platform-wide, asked at the start through
7633
+ * `RlsBypassPort`.
7634
+ */
7635
+ accountsHoldingCredits(tx?: TransactionContext): Promise<string[]>;
7636
+ }
6359
7637
  /**
6360
7638
  * Display form of a subscription for the tenant self-service UI.
6361
7639
  * Richer than `SubscriptionRecord` (which is only the aggregation form); contains
@@ -6450,7 +7728,7 @@ interface SubscriptionUsageRecord {
6450
7728
  * `null` for subscriptions that did not originate from a CheckoutOffer
6451
7729
  * (direct creation, migration).
6452
7730
  */
6453
- packageSnapshot?: unknown | null;
7731
+ packageSnapshot?: unknown;
6454
7732
  /**
6455
7733
  * P11.4: reference to the original `CheckoutOffer.id`. Mostly not needed
6456
7734
  * for the UI (the snapshot is self-contained), but useful for support
@@ -8049,6 +9327,13 @@ interface SaaSiCatPersistenceEntitlement {
8049
9327
  subscriptionInvoiceRepository?: PersistenceProvider<SubscriptionInvoiceRepository>;
8050
9328
  /** The invoices' documents, kept in the database (`chargeJournal.invoices.archive`). */
8051
9329
  subscriptionInvoiceArchive?: PersistenceProvider<InvoiceArchivePort>;
9330
+ /** The attempts to collect those invoices (`chargeJournal.invoices.collections`). */
9331
+ invoiceCollectionRepository?: PersistenceProvider<InvoiceCollectionRepository>;
9332
+ /**
9333
+ * The payments those collections brought, the credits and what pays them
9334
+ * out (`chargeJournal.invoices.payments`).
9335
+ */
9336
+ subscriberPaymentRepository?: PersistenceProvider<SubscriberPaymentRepository>;
8052
9337
  subscriptionBundleRepository?: PersistenceProvider<SubscriptionBundleRepository>;
8053
9338
  bundleRepository?: PersistenceProvider<BundleRepository>;
8054
9339
  }
@@ -8778,6 +10063,24 @@ declare const INVOICE_ERROR_CODES: {
8778
10063
  * (`SC-AUD-012`).
8779
10064
  */
8780
10065
  readonly SUBSCRIPTION_INVOICE_PARTIES_UNCONFIRMED: "SUBSCRIPTION_INVOICE_PARTIES_UNCONFIRMED";
10066
+ /**
10067
+ * The subscriber's direct debit names no mandate reference
10068
+ * (`paymentMethodId`), which has to be announced before it is debited
10069
+ * (`SC-PRIC-028`). An invoice collected by it draws no number, and one
10070
+ * planned with it is not announced, until the payment method is replaced.
10071
+ */
10072
+ readonly SUBSCRIPTION_INVOICE_MANDATE_MISSING: "SUBSCRIPTION_INVOICE_MANDATE_MISSING";
10073
+ /**
10074
+ * The subscriber (`subscriberId`) has no payment method in use, so the
10075
+ * invoice is not collected until one is (`SC-PRIC-082`).
10076
+ */
10077
+ readonly SUBSCRIPTION_INVOICE_NO_PAYMENT_METHOD: "SUBSCRIPTION_INVOICE_NO_PAYMENT_METHOD";
10078
+ /**
10079
+ * A direct debit announced again after a failed collection (`attemptKey`)
10080
+ * waits until the subscriber has been told of that failure
10081
+ * (`SC-PRIC-080`).
10082
+ */
10083
+ readonly SUBSCRIPTION_INVOICE_FAILURE_NOT_TOLD: "SUBSCRIPTION_INVOICE_FAILURE_NOT_TOLD";
8781
10084
  /**
8782
10085
  * A file of the invoice's document has another checksum than the one
8783
10086
  * recorded or archived for it (`invoiceId`, `recorded`, `rendered`), and
@@ -8808,6 +10111,25 @@ declare const INVOICE_ERROR_CODES: {
8808
10111
  * entered.
8809
10112
  */
8810
10113
  readonly SUBSCRIPTION_INVOICE_NO_INVOICE_EMAIL: "SUBSCRIPTION_INVOICE_NO_INVOICE_EMAIL";
10114
+ /** No credit under this id for the tenant's subscriber (`creditId`). */
10115
+ readonly SUBSCRIBER_CREDIT_NOT_FOUND: "SUBSCRIBER_CREDIT_NOT_FOUND";
10116
+ /**
10117
+ * A payout of more than the credit still owes (`creditId`, `open`): nothing
10118
+ * is paid out beyond it (`SC-PRIC-083`), and nothing is recorded.
10119
+ */
10120
+ readonly SUBSCRIBER_PAYOUT_EXCEEDS_CREDIT: "SUBSCRIBER_PAYOUT_EXCEEDS_CREDIT";
10121
+ /**
10122
+ * A payout on a day still to come (`paidOn`, `today` in the installation's
10123
+ * zone): a payout is recorded once it left.
10124
+ */
10125
+ readonly SUBSCRIBER_PAYOUT_NOT_MADE_YET: "SUBSCRIBER_PAYOUT_NOT_MADE_YET";
10126
+ /** No case to reconcile under this id (`caseId`). */
10127
+ readonly SUBSCRIBER_RECONCILIATION_CASE_NOT_FOUND: "SUBSCRIBER_RECONCILIATION_CASE_NOT_FOUND";
10128
+ /**
10129
+ * A case closed before (`caseId`, `closedAt`), by the operator or by
10130
+ * SaaSiCat; its note stands, and nothing is written (`SC-ADM-033`).
10131
+ */
10132
+ readonly SUBSCRIBER_RECONCILIATION_CASE_CLOSED: "SUBSCRIBER_RECONCILIATION_CASE_CLOSED";
8811
10133
  };
8812
10134
  type InvoiceErrorCode = (typeof INVOICE_ERROR_CODES)[keyof typeof INVOICE_ERROR_CODES];
8813
10135
  /** The parties contracts are concluded with (`SubscriberService`), and their absence. */
@@ -9144,6 +10466,24 @@ declare const PLATFORM_ERROR_CODES: {
9144
10466
  * (`SC-AUD-012`).
9145
10467
  */
9146
10468
  readonly SUBSCRIPTION_INVOICE_PARTIES_UNCONFIRMED: "SUBSCRIPTION_INVOICE_PARTIES_UNCONFIRMED";
10469
+ /**
10470
+ * The subscriber's direct debit names no mandate reference
10471
+ * (`paymentMethodId`), which has to be announced before it is debited
10472
+ * (`SC-PRIC-028`). An invoice collected by it draws no number, and one
10473
+ * planned with it is not announced, until the payment method is replaced.
10474
+ */
10475
+ readonly SUBSCRIPTION_INVOICE_MANDATE_MISSING: "SUBSCRIPTION_INVOICE_MANDATE_MISSING";
10476
+ /**
10477
+ * The subscriber (`subscriberId`) has no payment method in use, so the
10478
+ * invoice is not collected until one is (`SC-PRIC-082`).
10479
+ */
10480
+ readonly SUBSCRIPTION_INVOICE_NO_PAYMENT_METHOD: "SUBSCRIPTION_INVOICE_NO_PAYMENT_METHOD";
10481
+ /**
10482
+ * A direct debit announced again after a failed collection (`attemptKey`)
10483
+ * waits until the subscriber has been told of that failure
10484
+ * (`SC-PRIC-080`).
10485
+ */
10486
+ readonly SUBSCRIPTION_INVOICE_FAILURE_NOT_TOLD: "SUBSCRIPTION_INVOICE_FAILURE_NOT_TOLD";
9147
10487
  /**
9148
10488
  * A file of the invoice's document has another checksum than the one
9149
10489
  * recorded or archived for it (`invoiceId`, `recorded`, `rendered`), and
@@ -9174,6 +10514,25 @@ declare const PLATFORM_ERROR_CODES: {
9174
10514
  * entered.
9175
10515
  */
9176
10516
  readonly SUBSCRIPTION_INVOICE_NO_INVOICE_EMAIL: "SUBSCRIPTION_INVOICE_NO_INVOICE_EMAIL";
10517
+ /** No credit under this id for the tenant's subscriber (`creditId`). */
10518
+ readonly SUBSCRIBER_CREDIT_NOT_FOUND: "SUBSCRIBER_CREDIT_NOT_FOUND";
10519
+ /**
10520
+ * A payout of more than the credit still owes (`creditId`, `open`): nothing
10521
+ * is paid out beyond it (`SC-PRIC-083`), and nothing is recorded.
10522
+ */
10523
+ readonly SUBSCRIBER_PAYOUT_EXCEEDS_CREDIT: "SUBSCRIBER_PAYOUT_EXCEEDS_CREDIT";
10524
+ /**
10525
+ * A payout on a day still to come (`paidOn`, `today` in the installation's
10526
+ * zone): a payout is recorded once it left.
10527
+ */
10528
+ readonly SUBSCRIBER_PAYOUT_NOT_MADE_YET: "SUBSCRIBER_PAYOUT_NOT_MADE_YET";
10529
+ /** No case to reconcile under this id (`caseId`). */
10530
+ readonly SUBSCRIBER_RECONCILIATION_CASE_NOT_FOUND: "SUBSCRIBER_RECONCILIATION_CASE_NOT_FOUND";
10531
+ /**
10532
+ * A case closed before (`caseId`, `closedAt`), by the operator or by
10533
+ * SaaSiCat; its note stands, and nothing is written (`SC-ADM-033`).
10534
+ */
10535
+ readonly SUBSCRIBER_RECONCILIATION_CASE_CLOSED: "SUBSCRIBER_RECONCILIATION_CASE_CLOSED";
9177
10536
  readonly CHECKOUT_OFFER_LINE_ITEMS_REQUIRED: "CHECKOUT_OFFER_LINE_ITEMS_REQUIRED";
9178
10537
  readonly CHECKOUT_OFFER_PLAN_LINE_ITEM_REQUIRED: "CHECKOUT_OFFER_PLAN_LINE_ITEM_REQUIRED";
9179
10538
  readonly CHECKOUT_OFFER_BUNDLE_LINE_ITEMS_REQUIRED: "CHECKOUT_OFFER_BUNDLE_LINE_ITEMS_REQUIRED";
@@ -9873,6 +11232,14 @@ declare const OPTIONAL_CANONICAL_MODELS: {
9873
11232
  readonly SubscriptionInvoiceNumber: readonly ["entitlement.subscriptionInvoiceRepository"];
9874
11233
  readonly SubscriptionInvoiceDocument: readonly ["entitlement.subscriptionInvoiceRepository"];
9875
11234
  readonly SubscriptionInvoiceArchive: readonly ["entitlement.subscriptionInvoiceArchive"];
11235
+ readonly SubscriptionInvoiceCollection: readonly ["entitlement.invoiceCollectionRepository", "entitlement.subscriberPaymentRepository"];
11236
+ readonly SubscriberPayment: readonly ["entitlement.subscriberPaymentRepository", "entitlement.invoiceCollectionRepository"];
11237
+ readonly SubscriptionInvoiceSettlement: readonly ["entitlement.subscriberPaymentRepository", "entitlement.invoiceCollectionRepository"];
11238
+ readonly SubscriberCredit: readonly ["entitlement.subscriberPaymentRepository", "entitlement.invoiceCollectionRepository"];
11239
+ readonly SubscriberCreditEntry: readonly ["entitlement.subscriberPaymentRepository", "entitlement.invoiceCollectionRepository"];
11240
+ readonly SubscriberRefund: readonly ["entitlement.subscriberPaymentRepository", "entitlement.invoiceCollectionRepository"];
11241
+ readonly SubscriberReversal: readonly ["entitlement.subscriberPaymentRepository", "entitlement.invoiceCollectionRepository"];
11242
+ readonly SubscriberReconciliationCase: readonly ["entitlement.subscriberPaymentRepository", "entitlement.invoiceCollectionRepository"];
9876
11243
  readonly PromoCodeHold: readonly ["promo.holdRepository"];
9877
11244
  };
9878
11245
  type OptionalCanonicalModel = keyof typeof OPTIONAL_CANONICAL_MODELS;
@@ -10944,6 +12311,9 @@ interface CanonicalSubscriptionInvoiceRow {
10944
12311
  dueDate: unknown;
10945
12312
  servicePeriodFrom: unknown;
10946
12313
  servicePeriodUntil: unknown;
12314
+ /** `null` on an invoice that is not collected, and on one issued before invoices recorded it. */
12315
+ payment: unknown;
12316
+ collectionDate: unknown;
10947
12317
  currency: string;
10948
12318
  issuerParty: unknown;
10949
12319
  subscriberParty: unknown;
@@ -10991,6 +12361,8 @@ interface SubscriptionInvoiceColumns {
10991
12361
  dueDate: CalendarDay;
10992
12362
  servicePeriodFrom: CalendarDay;
10993
12363
  servicePeriodUntil: CalendarDay;
12364
+ payment: SubscriptionInvoicePayment | null;
12365
+ collectionDate: CalendarDay | null;
10994
12366
  currency: string;
10995
12367
  issuerParty: SubscriptionInvoiceIssuer;
10996
12368
  subscriberParty: SubscriptionInvoiceSubscriber;
@@ -11075,9 +12447,31 @@ interface InvoiceDraftInput {
11075
12447
  /** The installation's time zone, which every day the invoice states is read in (`SC-PRIC-045`). */
11076
12448
  timeZone: string;
11077
12449
  numberPrefix: string;
11078
- /** Days from the issue date to the due date (`SC-PRIC-046`). */
12450
+ /** Days from the issue date to the due date, unless collected by direct debit (`SC-PRIC-046`). */
11079
12451
  paymentTermDays: number;
12452
+ /**
12453
+ * The subscriber's payment method as `invoicePaymentOf` records it, or
12454
+ * `null` where it has none that can be collected.
12455
+ */
12456
+ payment: SubscriptionInvoicePayment | null;
12457
+ /** Days from the issue date to the day a direct debit is collected (`SC-PRIC-028`). */
12458
+ directDebitLeadDays: number;
11080
12459
  }
12460
+ /**
12461
+ * Calendar days a direct debit is announced before it is collected where
12462
+ * `config/saas.yaml#invoicing` names none: the SEPA rulebook's own notice.
12463
+ */
12464
+ declare const DIRECT_DEBIT_LEAD_DAYS = 14;
12465
+ /** The lead time `invoicing` names, or `DIRECT_DEBIT_LEAD_DAYS`. */
12466
+ declare function directDebitLeadDaysOf(invoicing: Pick<PlanCatalogInvoicing, 'directDebitLeadDays'>): number;
12467
+ /**
12468
+ * What an invoice records of the payment method it is collected with, or
12469
+ * `null` where there is none to collect with: the subscriber has no payment
12470
+ * method, or one that cannot be collected as an invoice announces it — a
12471
+ * direct debit without the mandate reference its announcement has to quote
12472
+ * (`SC-PRIC-028`).
12473
+ */
12474
+ declare function invoicePaymentOf(method: Pick<SubscriberPaymentMethodRecord, 'id' | 'gatewayAccount' | 'type' | 'brand' | 'last4' | 'mandateReference'> | null): SubscriptionInvoicePayment | null;
11081
12475
  /**
11082
12476
  * The invoice `input.group` makes. Its lines follow the contract's lines, so
11083
12477
  * the invoice reads in the order the contract does, each naming its charge and
@@ -11085,8 +12479,16 @@ interface InvoiceDraftInput {
11085
12479
  * line carries the treatment's rate, and the tax is the adapter's, computed
11086
12480
  * once per rate over the lines' net amounts.
11087
12481
  *
12482
+ * An invoice that asks for an amount records the payment method it is
12483
+ * collected with. A direct debit is collected the lead time after the issue
12484
+ * date, which the invoice announces and falls due on; anything else falls due
12485
+ * the payment term after it (`SC-PRIC-028`, `SC-PRIC-046`). An invoice that
12486
+ * asks for nothing is collected with nothing.
12487
+ *
11088
12488
  * Throws where the charges contradict each other — a currency or a contract
11089
- * line the group cannot have — which no invoice can be drawn up from.
12489
+ * line the group cannot have — which no invoice can be drawn up from, and for
12490
+ * a direct debit without its mandate reference, which `invoicePaymentOf`
12491
+ * never hands over.
11090
12492
  */
11091
12493
  declare function draftSubscriptionInvoice(input: InvoiceDraftInput): NewSubscriptionInvoice;
11092
12494
  /** What the tax adapter checks of an invoice before its number is drawn (`SC-PRIC-027`). */
@@ -11154,6 +12556,584 @@ declare const INVOICE_ARCHIVE_TRIGGERS: readonly ["subscription_invoice_archive_
11154
12556
  */
11155
12557
  declare function invoiceArchiveProtectionProblem(enabledTriggers: readonly string[]): string | null;
11156
12558
 
12559
+ /** Every status an attempt can stand in. */
12560
+ declare const INVOICE_COLLECTION_STATUSES: readonly InvoiceCollectionStatus[];
12561
+ /**
12562
+ * The statuses of an attempt that has been sent and is not settled: the
12563
+ * gateway is asked what became of it.
12564
+ */
12565
+ declare const UNSETTLED_COLLECTION_STATUSES: readonly InvoiceCollectionStatus[];
12566
+ /**
12567
+ * The statuses that keep an invoice from another attempt: one open — planned,
12568
+ * or sent and not settled — or one that succeeded. An invoice has one at most,
12569
+ * which `sql/constraints.postgres.sql` holds as well.
12570
+ */
12571
+ declare const BLOCKING_COLLECTION_STATUSES: readonly InvoiceCollectionStatus[];
12572
+ /** The attempts what follows is decided for: a failure, and a reversal that opened the invoice again. */
12573
+ declare const FOLLOWED_UP_COLLECTION_STATUSES: readonly InvoiceCollectionStatus[];
12574
+ /**
12575
+ * The statuses of an attempt whose payment a reversal can take back: one that
12576
+ * succeeded, and one that failed before its payment arrived after all, beside
12577
+ * another attempt of its invoice that was on its way or succeeded.
12578
+ */
12579
+ declare const REVERSIBLE_COLLECTION_STATUSES: readonly InvoiceCollectionStatus[];
12580
+ /** What the turn reads of an invoice's attempts before it writes the next one. */
12581
+ interface EarlierCollection {
12582
+ attempt: number;
12583
+ status: string;
12584
+ }
12585
+ /** The number of the last of `earlier`, `0` for none. */
12586
+ declare function lastCollectionOf(earlier: readonly EarlierCollection[]): number;
12587
+ /**
12588
+ * Whether the invoice's first attempt is refused: it has one already. Every
12589
+ * later attempt is planned, so a run that found the invoice due before another
12590
+ * run's attempt failed does not charge it again at once.
12591
+ */
12592
+ declare function refusesFirstAttempt(earlier: readonly EarlierCollection[]): boolean;
12593
+ /**
12594
+ * Whether a planned attempt that follows attempt `after` is refused: one of the
12595
+ * invoice's attempts is open or succeeded, or another came after `after`.
12596
+ */
12597
+ declare function refusesPlannedAttempt(earlier: readonly EarlierCollection[], after: number): boolean;
12598
+ /** Every reason a collection can fail for. */
12599
+ declare const COLLECTION_FAILURE_REASONS: readonly CollectionFailureReason[];
12600
+ /**
12601
+ * A `subscription_invoice_collections` row as either adapter reads it back.
12602
+ * `amount` is `unknown` because a Prisma row carries a `Decimal` where a
12603
+ * Drizzle row carries a numeric string.
12604
+ */
12605
+ interface CanonicalInvoiceCollectionRow {
12606
+ id: string;
12607
+ invoiceId: string;
12608
+ attempt: number;
12609
+ attemptKey: string;
12610
+ gatewayAccount: string;
12611
+ paymentMethodId: string;
12612
+ paymentMethodType: string;
12613
+ customerRef: string;
12614
+ paymentMethodRef: string;
12615
+ invoiceNumber: string;
12616
+ amount: unknown;
12617
+ currency: string;
12618
+ status: string;
12619
+ paymentRef: string | null;
12620
+ failureReason: string | null;
12621
+ failureCode: string | null;
12622
+ submittedAt: Date | null;
12623
+ heldAt: Date | null;
12624
+ resolvedAt: Date | null;
12625
+ /** A `date` column: a `Date` from Prisma, the text from Drizzle. */
12626
+ collectOn: unknown;
12627
+ announcedAt: Date | null;
12628
+ followedUpAt: Date | null;
12629
+ }
12630
+ /**
12631
+ * Reads an attempt row back as a record. An attempt that left carries the
12632
+ * moment it left and was held at, and one that did not carries neither; a
12633
+ * planned one carries its day. A row that breaks this is not one a run may act
12634
+ * on: a planned attempt without a day would never be collected, and a sent one
12635
+ * without a moment could not be asked about.
12636
+ */
12637
+ declare function toInvoiceCollectionRecord(row: CanonicalInvoiceCollectionRow): InvoiceCollectionRecord;
12638
+ /** The columns an attempt is started with, numbered `attempt`. */
12639
+ interface InvoiceCollectionColumns {
12640
+ invoiceId: string;
12641
+ attempt: number;
12642
+ attemptKey: string;
12643
+ gatewayAccount: string;
12644
+ paymentMethodId: string;
12645
+ paymentMethodType: string;
12646
+ customerRef: string;
12647
+ paymentMethodRef: string;
12648
+ invoiceNumber: string;
12649
+ /** A decimal string of two places, as an invoice's amounts are written. */
12650
+ amount: string;
12651
+ currency: string;
12652
+ status: InvoiceCollectionStatus;
12653
+ submittedAt: Date | null;
12654
+ heldAt: Date | null;
12655
+ /** The day of a planned attempt; `null` for one written as sent. */
12656
+ collectOn: string | null;
12657
+ }
12658
+ /** The columns of `attempt`, numbered `number`, written as submitted at its `at`. */
12659
+ declare function invoiceCollectionColumns(attempt: NewInvoiceCollection, number: number): InvoiceCollectionColumns;
12660
+ /** The columns of `plan`, numbered `number`, written as planned for its day. */
12661
+ declare function plannedCollectionColumns(plan: PlannedInvoiceCollection, number: number): InvoiceCollectionColumns;
12662
+ /** The columns an outcome sets: `PENDING` leaves the attempt open, the others settle it at `at`. */
12663
+ declare function collectionOutcomeColumns(outcome: CollectionOutcome, at: Date): {
12664
+ status: InvoiceCollectionStatus;
12665
+ paymentRef: string | null;
12666
+ failureReason: CollectionFailureReason | null;
12667
+ failureCode: string | null;
12668
+ resolvedAt: Date | null;
12669
+ };
12670
+
12671
+ /** How many days after a failure the same payment method is charged once more. */
12672
+ declare const COLLECTION_RETRY_AFTER_DAYS = 7;
12673
+ /**
12674
+ * Whether the payment method a failed attempt charged is charged once more:
12675
+ * its reason can pass, and no other attempt of the invoice failed with that
12676
+ * payment method. A replacement gets its own second try.
12677
+ */
12678
+ declare function isChargedAgain(failed: InvoiceCollectionRecord, attempts: readonly InvoiceCollectionRecord[]): boolean;
12679
+ /** The day the same payment method is charged again after a failure on `failedOn`. */
12680
+ declare function chargedAgainOn(failedOn: CalendarDay): CalendarDay;
12681
+ /**
12682
+ * The day a direct debit announced on `announcedOn` is collected: the lead
12683
+ * time after its announcement, and never before `earliest`.
12684
+ */
12685
+ declare function announcedCollectionDay(earliest: CalendarDay, announcedOn: CalendarDay, leadDays: number): CalendarDay;
12686
+
12687
+ /** A recorded `collection-failed` notice, `id` being its record's. */
12688
+ declare function toCollectionFailedNotice(content: unknown, id: string): CollectionFailedNotice;
12689
+ /** A recorded `collection-announced` notice, `id` being its record's. */
12690
+ declare function toCollectionAnnouncedNotice(content: unknown, id: string): CollectionAnnouncedNotice;
12691
+ /** A recorded `collection-reversed` notice, `id` being its record's. */
12692
+ declare function toCollectionReversedNotice(content: unknown, id: string): CollectionReversedNotice;
12693
+
12694
+ /**
12695
+ * What an entry against an invoice is: a payment that settles it, a reversal
12696
+ * that opens it again by part of what a payment settled, and the same part
12697
+ * settled again where the gateway gave the reversal back.
12698
+ */
12699
+ type InvoiceSettlementKind = 'PAYMENT' | 'REVERSAL' | 'REINSTATEMENT';
12700
+ declare const INVOICE_SETTLEMENT_KINDS: readonly InvoiceSettlementKind[];
12701
+ /**
12702
+ * The settlements that add back to what an invoice owes rather than take off
12703
+ * it; an adapter that sums settlements in SQL passes it as a parameter, so the
12704
+ * sign is decided here alone.
12705
+ */
12706
+ declare const REOPENING_SETTLEMENT_KINDS: readonly InvoiceSettlementKind[];
12707
+ declare const SUBSCRIBER_CREDIT_ENTRY_KINDS: readonly SubscriberCreditEntryKind[];
12708
+ declare const SUBSCRIBER_REFUND_STATUSES: readonly SubscriberRefundStatus[];
12709
+ /** The statuses of a refund that gave its money back to the operator. */
12710
+ declare const ENDED_REFUND_STATUSES: readonly SubscriberRefundStatus[];
12711
+ /** Whether a refund in `status` gave its money back. */
12712
+ declare function isEndedRefund(status: SubscriberRefundStatus): boolean;
12713
+ /** A `subscriber_payments` row as either adapter reads it back. */
12714
+ interface CanonicalSubscriberPaymentRow {
12715
+ id: string;
12716
+ subscriberId: string;
12717
+ tenantId: string;
12718
+ invoiceId: string;
12719
+ collectionId: string;
12720
+ gatewayAccount: string;
12721
+ provider: string;
12722
+ gatewayRef: string;
12723
+ amount: unknown;
12724
+ currency: string;
12725
+ recordedAt: Date;
12726
+ }
12727
+ declare function toSubscriberPaymentRecord(row: CanonicalSubscriberPaymentRow): SubscriberPaymentRecord;
12728
+ /** The columns a payment is written with, for the subscriber its invoice names. */
12729
+ declare function subscriberPaymentColumns(payment: NewSubscriberPayment, invoice: {
12730
+ subscriberId: string;
12731
+ tenantId: string;
12732
+ }): Omit<CanonicalSubscriberPaymentRow, 'id' | 'amount'> & {
12733
+ amount: string;
12734
+ };
12735
+ /** A `subscription_invoice_settlements` row, as far as what an invoice owes reads it. */
12736
+ interface CanonicalInvoiceSettlementRow {
12737
+ id: string;
12738
+ kind: string;
12739
+ amount: unknown;
12740
+ }
12741
+ /**
12742
+ * The amount a settlement row takes off what its invoice owes: positive for a
12743
+ * payment and a reinstatement, negative for a reversal, which opens the invoice
12744
+ * again. Its kind is checked, so a kind a later release writes stops the read
12745
+ * rather than being counted as a payment.
12746
+ */
12747
+ declare function settledAmountOf(row: CanonicalInvoiceSettlementRow): number;
12748
+ /** A `subscriber_credits` row as either adapter reads it back. */
12749
+ interface CanonicalSubscriberCreditRow {
12750
+ id: string;
12751
+ subscriberId: string;
12752
+ tenantId: string;
12753
+ amount: unknown;
12754
+ currency: string;
12755
+ originPaymentId: string | null;
12756
+ originInvoiceId: string | null;
12757
+ originReversalId: string | null;
12758
+ createdAt: Date;
12759
+ }
12760
+ /**
12761
+ * Reads a credit back. It comes from exactly one place — a payment, an invoice
12762
+ * or a reversal given back — which the database holds as well; a row that
12763
+ * names several or none cannot be paid out against anything.
12764
+ */
12765
+ declare function toSubscriberCreditRecord(row: CanonicalSubscriberCreditRow): SubscriberCreditRecord;
12766
+ /** A `subscriber_credit_entries` row as either adapter reads it back. */
12767
+ interface CanonicalSubscriberCreditEntryRow {
12768
+ id: string;
12769
+ creditId: string;
12770
+ kind: string;
12771
+ amount: unknown;
12772
+ refundId: string | null;
12773
+ reversalId: string | null;
12774
+ reference: string | null;
12775
+ /** A `date` column: a `Date` from Prisma, the text from Drizzle. */
12776
+ paidOn: unknown;
12777
+ recordedBy: string | null;
12778
+ note: string | null;
12779
+ recordedAt: Date;
12780
+ }
12781
+ declare function toSubscriberCreditEntryRecord(row: CanonicalSubscriberCreditEntryRow): SubscriberCreditEntryRecord;
12782
+ /**
12783
+ * The columns of an entry a refund writes against one credit, carrying the
12784
+ * refund's own reference at the gateway, which the operator finds it under.
12785
+ */
12786
+ declare function refundEntryColumns(creditId: string, refund: {
12787
+ id: string;
12788
+ gatewayRef: string;
12789
+ }, kind: 'REFUND' | 'REFUND_FAILED', amount: number, at: Date): Omit<CanonicalSubscriberCreditEntryRow, 'id' | 'amount' | 'paidOn'> & {
12790
+ amount: string;
12791
+ paidOn: null;
12792
+ };
12793
+ /** The columns of the entry a payout writes against its credit. */
12794
+ declare function payoutEntryColumns(payout: NewSubscriberPayout): Omit<CanonicalSubscriberCreditEntryRow, 'id' | 'amount' | 'paidOn'> & {
12795
+ amount: string;
12796
+ paidOn: string;
12797
+ };
12798
+ /** A `subscriber_refunds` row as either adapter reads it back. */
12799
+ interface CanonicalSubscriberRefundRow {
12800
+ id: string;
12801
+ subscriberId: string;
12802
+ paymentId: string;
12803
+ gatewayAccount: string;
12804
+ gatewayRef: string;
12805
+ amount: unknown;
12806
+ currency: string;
12807
+ status: string;
12808
+ recordedAt: Date;
12809
+ endedAt: Date | null;
12810
+ }
12811
+ declare function toSubscriberRefundRecord(row: CanonicalSubscriberRefundRow): SubscriberRefundRecord;
12812
+ /** The columns a refund is first written with, against the payment it pays back. */
12813
+ declare function subscriberRefundColumns(refund: ReportedSubscriberRefund, payment: {
12814
+ id: string;
12815
+ subscriberId: string;
12816
+ }): Omit<CanonicalSubscriberRefundRow, 'id' | 'amount'> & {
12817
+ amount: string;
12818
+ };
12819
+ /**
12820
+ * The columns of an entry a reversal writes against one credit: what it takes
12821
+ * of it, or gives back, carrying the reversal's own reference at the gateway.
12822
+ */
12823
+ declare function reversalEntryColumns(creditId: string, reversal: {
12824
+ id: string;
12825
+ gatewayRef: string;
12826
+ }, kind: 'REVERSAL' | 'REVERSAL_TAKEN_BACK', amount: number, at: Date): Omit<CanonicalSubscriberCreditEntryRow, 'id' | 'amount' | 'paidOn'> & {
12827
+ amount: string;
12828
+ paidOn: null;
12829
+ };
12830
+ /** A `subscriber_reversals` row as either adapter reads it back. */
12831
+ interface CanonicalSubscriberReversalRow {
12832
+ id: string;
12833
+ subscriberId: string;
12834
+ tenantId: string;
12835
+ paymentId: string;
12836
+ gatewayAccount: string;
12837
+ gatewayRef: string;
12838
+ amount: unknown;
12839
+ currency: string;
12840
+ fromCredit: unknown;
12841
+ reinstated: unknown;
12842
+ recordedAt: Date;
12843
+ reinstatedAt: Date | null;
12844
+ }
12845
+ /**
12846
+ * Reads a reversal back. What it took from the credit and what the gateway
12847
+ * gave back are parts of what it withdrew, and a give-back carries when; a row
12848
+ * that says otherwise stops the read.
12849
+ */
12850
+ declare function toSubscriberReversalRecord(row: CanonicalSubscriberReversalRow): SubscriberReversalRecord;
12851
+ /**
12852
+ * The columns a reversal is first written with, against the payment it takes
12853
+ * back: nothing withdrawn or given back yet, which the entries it writes next
12854
+ * raise.
12855
+ */
12856
+ declare function subscriberReversalColumns(reversal: ReportedSubscriberReversal, payment: {
12857
+ id: string;
12858
+ subscriberId: string;
12859
+ tenantId: string;
12860
+ }): Omit<CanonicalSubscriberReversalRow, 'id' | 'amount' | 'fromCredit' | 'reinstated'> & {
12861
+ amount: string;
12862
+ fromCredit: string;
12863
+ reinstated: string;
12864
+ };
12865
+
12866
+ /**
12867
+ * What an invoice of `gross` still owes after the entries `settled` against
12868
+ * it, each signed as `settledAmountOf` reads it — a reversal that opened the
12869
+ * invoice again counts against what was settled; negative where it owes the
12870
+ * subscriber, as an invoice whose total is negative does.
12871
+ */
12872
+ declare function owedOn(gross: number, settled: readonly number[]): number;
12873
+ /**
12874
+ * How a payment of `amount` divides against an invoice that still owes
12875
+ * `owed`: it settles what is owed, and what it brought beyond that is a credit.
12876
+ * An invoice that owes nothing, or owes the subscriber, is settled by nothing.
12877
+ */
12878
+ declare function paymentSettlement(amount: number, owed: number): {
12879
+ settles: number;
12880
+ credits: number;
12881
+ };
12882
+ /**
12883
+ * The entries that give back what an earlier entry paid out of a credit; an
12884
+ * adapter that sums entries in SQL passes it as a parameter, so the sign is
12885
+ * decided here alone.
12886
+ */
12887
+ declare const GIVING_BACK_CREDIT_ENTRY_KINDS: readonly SubscriberCreditEntryKind[];
12888
+ /**
12889
+ * What a credit of `amount` still owes after `entries`. Never below `0`: an
12890
+ * entry that would take it there is not written.
12891
+ */
12892
+ declare function openOfCredit(amount: number, entries: readonly {
12893
+ kind: SubscriberCreditEntryKind;
12894
+ amount: number;
12895
+ }[]): number;
12896
+ /** A credit as a refund is divided across it. */
12897
+ interface OpenCredit {
12898
+ id: string;
12899
+ origin: SubscriberCreditOrigin;
12900
+ createdAt: Date;
12901
+ /** What it still owes, from `openOfCredit`. */
12902
+ open: number;
12903
+ }
12904
+ /**
12905
+ * How a refund of `amount` that pays back payment `paymentId` divides across
12906
+ * the subscriber's open credits: the credit that payment left first — the
12907
+ * refund pays back what the subscriber overpaid with it —, then the oldest.
12908
+ * What no open credit takes matches nothing, and is the operator's to
12909
+ * reconcile.
12910
+ */
12911
+ declare function refundParts(amount: number, paymentId: string, credits: readonly OpenCredit[]): {
12912
+ parts: CreditPart[];
12913
+ unmatched: number;
12914
+ };
12915
+ /** The credit a payment left, as a reversal of that payment reads it. */
12916
+ interface ReversibleCredit {
12917
+ creditId: string;
12918
+ /** What of the credit no reversal of the payment took yet, open or paid out. */
12919
+ left: number;
12920
+ /** What of the credit is still owed to the subscriber, from `openOfCredit`. */
12921
+ open: number;
12922
+ }
12923
+ /**
12924
+ * A credit that another payment collected for an invoice the reversed payment
12925
+ * settles left, as the reversal reads it.
12926
+ */
12927
+ interface CoveringCredit {
12928
+ creditId: string;
12929
+ /** What of the credit is still owed to the subscriber, from `openOfCredit`. */
12930
+ open: number;
12931
+ }
12932
+ /** An invoice a payment settles, as a reversal of that payment reads it. */
12933
+ interface ReversibleInvoice {
12934
+ invoiceId: string;
12935
+ /** What the payment still settles there: its settlements less what reversals took back. */
12936
+ left: number;
12937
+ }
12938
+ /** How a withdrawn amount divides across what its payment brought. */
12939
+ interface WithdrawalParts {
12940
+ /** What it takes of the credit, open or paid out alike. */
12941
+ fromCredit: number;
12942
+ /** What it takes of the credit that is still open; `null` where nothing. */
12943
+ credit: CreditPart | null;
12944
+ /** What it takes of the covering credits instead of opening their invoices again, in the order given. */
12945
+ covering: CreditPart[];
12946
+ /** The invoices it opens again, in the order given, each by no more than the payment settles there. */
12947
+ invoices: InvoicePart[];
12948
+ /**
12949
+ * What meets the part of the credit already paid out, and what goes beyond
12950
+ * everything the payment brought: the operator's to reconcile.
12951
+ */
12952
+ unmatched: number;
12953
+ }
12954
+ /**
12955
+ * How `amount`, newly withdrawn by a reversal of a payment, divides across what
12956
+ * the payment brought: the credit it left first, so the operator is not left
12957
+ * refunding what is owed again — its open part shrinks it, its part already
12958
+ * paid out matches nothing —, then the invoices it settles, in the order given,
12959
+ * the oldest first. What the reversal would open again of them is covered
12960
+ * first by `covering`, the open credits other payments collected for those
12961
+ * invoices left, in the order given: that money was collected for the same
12962
+ * invoices, so it settles them rather than waiting to be paid out while they
12963
+ * are collected again. Whatever exceeds the credit and the invoices matches
12964
+ * nothing; no covering credit takes it.
12965
+ */
12966
+ declare function withdrawalParts(amount: number, credit: ReversibleCredit | null, invoices: readonly ReversibleInvoice[], covering?: readonly CoveringCredit[]): WithdrawalParts;
12967
+ /** What a reversal took back that an amount the gateway gives back can return. */
12968
+ interface ReinstatableParts {
12969
+ /** What of the reversal's unmatched amount is not covered by an earlier give-back yet. */
12970
+ unmatched: number;
12971
+ /** What it took of each credit and has not given back yet. */
12972
+ credits: readonly {
12973
+ creditId: string;
12974
+ left: number;
12975
+ }[];
12976
+ /**
12977
+ * What it opened again of each invoice and has not settled again yet, the
12978
+ * oldest first, with what the invoice owes now.
12979
+ */
12980
+ invoices: readonly {
12981
+ invoiceId: string;
12982
+ left: number;
12983
+ owed: number;
12984
+ }[];
12985
+ }
12986
+ /** How an amount the gateway gives back divides across what its reversal took. */
12987
+ interface ReinstatementParts {
12988
+ /** What covers the reversal's unmatched amount. */
12989
+ covered: number;
12990
+ /** What each credit is owed again. */
12991
+ credits: CreditPart[];
12992
+ /** What settles each invoice again, as far as it still owes. */
12993
+ invoices: InvoicePart[];
12994
+ /** What the invoices no longer owe — the subscriber paid them meanwhile —, as a credit. */
12995
+ credited: number;
12996
+ /** What goes beyond everything the reversal took, which nothing takes. */
12997
+ beyond: number;
12998
+ }
12999
+ /**
13000
+ * How `amount`, newly given back by the gateway for a reversal, takes it back
13001
+ * part for part, in the reverse of how it was withdrawn: the unmatched part
13002
+ * first — such as the refund the subscriber received before the dispute, which
13003
+ * the gateway returns where the dispute is lost —, then what it took of the
13004
+ * credits, then what it opened of the invoices, settling each again as far as
13005
+ * it still owes. What an invoice no longer owes becomes a credit.
13006
+ */
13007
+ declare function reinstatementParts(amount: number, took: ReinstatableParts): ReinstatementParts;
13008
+ /**
13009
+ * What each invoice nets from `entries` — settlements signed as
13010
+ * `settledAmountOf` reads them —, in whole cents, in the order the invoices
13011
+ * first appear. Read over a payment's settlements, it is what the payment still
13012
+ * settles on each; over a reversal's, the negative of what it opened and has
13013
+ * not settled again.
13014
+ */
13015
+ declare function netByInvoice(entries: readonly InvoicePart[]): InvoicePart[];
13016
+ /**
13017
+ * What `entries` paid out of each credit, net of what they gave back, in whole
13018
+ * cents, in the order the credits first appear. Read over a reversal's
13019
+ * entries, it is what the reversal took of each credit and has not given back.
13020
+ */
13021
+ declare function paidOutByCredit(entries: readonly {
13022
+ creditId: string;
13023
+ kind: SubscriberCreditEntryKind;
13024
+ amount: number;
13025
+ }[]): CreditPart[];
13026
+ /**
13027
+ * What other reversals took of one credit to cover what they would have opened
13028
+ * of its invoice (`SC-PRIC-087`) and still hold: the credit's `entries` of
13029
+ * reversals not in `own`, net of what was given back, in whole cents, in the
13030
+ * order the reversals first appear. Where the credit's own payment is reversed
13031
+ * as well, these covers are lifted first (`SC-PRIC-088`).
13032
+ */
13033
+ declare function coversOf(entries: readonly {
13034
+ reversalId: string | null;
13035
+ kind: SubscriberCreditEntryKind;
13036
+ amount: number;
13037
+ }[], own: ReadonlySet<string>): {
13038
+ reversalId: string;
13039
+ amount: number;
13040
+ }[];
13041
+ /**
13042
+ * The covers a withdrawal lifts: what it takes of its payment's credit beyond
13043
+ * the open part — `parts.fromCredit` less `parts.credit` — reaches the covers
13044
+ * that credit gave other reversals (`coversOf`) before it counts as paid out,
13045
+ * in the order given. Each lifted cover opens its reversal's invoice again;
13046
+ * what it reaches beyond them stays unmatched (`SC-PRIC-088`).
13047
+ */
13048
+ declare function coversLifted(parts: Pick<WithdrawalParts, 'fromCredit' | 'credit' | 'unmatched'>, covers: readonly {
13049
+ reversalId: string;
13050
+ amount: number;
13051
+ }[]): {
13052
+ lifted: {
13053
+ reversalId: string;
13054
+ amount: number;
13055
+ }[];
13056
+ unmatched: number;
13057
+ };
13058
+ /**
13059
+ * `parts` in the order a reversal of payment `paymentId` takes credits: the
13060
+ * credit that payment left first, then the covering ones, the oldest first —
13061
+ * so what the gateway gives back returns to them in that order, whatever order
13062
+ * a database reads their entries in.
13063
+ */
13064
+ declare function inWithdrawalOrder(parts: readonly CreditPart[], credits: readonly SubscriberCreditRecord[], paymentId: string): CreditPart[];
13065
+ /**
13066
+ * The ids of `cases`, in the order given — the order they were opened —, that
13067
+ * the first `covered` of what the gateway gave back covers in full.
13068
+ */
13069
+ declare function casesCovered(cases: readonly {
13070
+ id: string;
13071
+ amount: number;
13072
+ }[], covered: number): string[];
13073
+
13074
+ declare const RECONCILIATION_CASE_KINDS: readonly ReconciliationCaseKind[];
13075
+ /** A `subscriber_reconciliation_cases` row as either adapter reads it back. */
13076
+ interface CanonicalReconciliationCaseRow {
13077
+ id: string;
13078
+ subscriberId: string;
13079
+ tenantId: string;
13080
+ kind: string;
13081
+ amount: unknown;
13082
+ currency: string;
13083
+ paymentId: string;
13084
+ refundId: string | null;
13085
+ reversalId: string | null;
13086
+ gatewayAccount: string;
13087
+ gatewayRef: string;
13088
+ recordedAt: Date;
13089
+ closedAt: Date | null;
13090
+ closedBy: string | null;
13091
+ note: string | null;
13092
+ }
13093
+ /**
13094
+ * Reads a case back. It is about exactly what its kind says — a refund or a
13095
+ * reversal —, and a closed case carries why it was closed; a row that says
13096
+ * otherwise stops the read rather than reaching the operator's list as
13097
+ * something it is not.
13098
+ */
13099
+ declare function toSubscriberReconciliationCaseRecord(row: CanonicalReconciliationCaseRow): SubscriberReconciliationCaseRecord;
13100
+ /** What a case is opened about: a refund or a reversal, with the payment and its subscriber. */
13101
+ interface NewReconciliationCase {
13102
+ kind: ReconciliationCaseKind;
13103
+ amount: number;
13104
+ currency: string;
13105
+ payment: {
13106
+ id: string;
13107
+ subscriberId: string;
13108
+ tenantId: string;
13109
+ };
13110
+ /** The refund's id, for a `REFUND_UNMATCHED`, or the reversal's. */
13111
+ about: {
13112
+ id: string;
13113
+ gatewayAccount: string;
13114
+ gatewayRef: string;
13115
+ };
13116
+ at: Date;
13117
+ }
13118
+ /** The columns a case is opened with. */
13119
+ declare function reconciliationCaseColumns(opened: NewReconciliationCase): Omit<CanonicalReconciliationCaseRow, 'id' | 'amount'> & {
13120
+ amount: string;
13121
+ };
13122
+ /** Why SaaSiCat closes a case of a refund that failed or was canceled. */
13123
+ declare const CASE_CLOSED_REFUND_ENDED = "The refund failed or was canceled, and its money came back.";
13124
+ /** Why SaaSiCat closes a case of a reversal the gateway gave back. */
13125
+ declare const CASE_CLOSED_REVERSAL_GIVEN_BACK = "The gateway gave the reversal back, and with it what matched nothing.";
13126
+
13127
+ /** Which column of which row a value came from, for the error that names it. */
13128
+ interface ColumnWhere {
13129
+ table: string;
13130
+ column: string;
13131
+ id: string;
13132
+ }
13133
+
13134
+ /** The amount a `numeric` column holds; throws, naming the column, for anything else. */
13135
+ declare function columnAmountOf(value: unknown, where: ColumnWhere): number;
13136
+
11157
13137
  /** The VAT category of EN 16931 (UNTDID 5305) a line and a breakdown name. */
11158
13138
  type VatCategory = 'S' | 'E' | 'AE' | 'O';
11159
13139
  /** The category EN 16931 names for a treatment an adapter decides. */
@@ -11545,7 +13525,7 @@ type ErrorMessageParams = Record<string, unknown>;
11545
13525
  /**
11546
13526
  * Replaces `{name}` with `params.name`. An unknown placeholder is left
11547
13527
  * verbatim, so a missing value is visible in the UI rather than silently
11548
- * vanishing.
13528
+ * vanishing — and so is a value without a text of its own.
11549
13529
  */
11550
13530
  declare function formatErrorMessage(template: string, params?: ErrorMessageParams): string;
11551
13531
  /**
@@ -11582,4 +13562,4 @@ declare function resolveErrorMessage(body: ResolvableErrorBody, overrides?: Part
11582
13562
 
11583
13563
  declare const ERROR_MESSAGES_DE: Record<PlatformErrorCode, string>;
11584
13564
 
11585
- export { ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES, AUTH_ERROR_CODES, type ActionKey, type ActivationOrchestrator, type ActivePlanVersionWhere, type ActivePlanVersionWhereWithEndsAt, type ActiveVersionWhere, type ActiveVersionWhereWithEndsAt, type ActorTag, type AdminAccountEntry, type AdminAccountHolder, type AdminActor, type AdminAuditListFilter, type AdminManifest, type AdminResourcesPort, type AdminSubscriberAccount, type AdminSubscriberAttention, type AdminSubscriberCorrected, type AdminSubscriberHistoryEntry, type AdminSubscriptionListRow, type AdminTenantDetail, type AdminTenantListFilter, type AdminTenantListRow, type AdminTenantStateResult, type AdminTenantSubscriber, type AdminUserListFilter, type AdminUserListRow, type AdminVatIdCheckOutcome, type AppliedSettingsPort, type AppliedSettingsRecord, type AppliedSettingsValues, type ApplyOnboardingSelectionInput, type ApplyOnboardingSelectionResult, type ApprovedCatalogKeys, type ArchivedInvoiceDocument, type AuditActionDef, type AuditActor, type AuditEntry, type AuditPort, type AuditQuery, type AuditQueryPort, type AuditStatsPort, type AuditStatsSnapshot, type AuthErrorCode, BILLING_ERROR_CODES, BUNDLE_PRICE_LOOKUP_LIMIT, BUNDLE_VERSION_RETIREMENT_CAPABILITY, type BillingCycle, type BillingErrorCode, type BundleAvailabilityState, type BundleCompatibility, type BundleFeatureShape, type BundleListFilter, type BundlePricingOverride, type BundleRepository, type BundleRetirementAnnounced, type BundleRetirementPreview, type BundleRetirementReachedRow, type BundleRetirementSkipReason, type BundleRetirementSkippedRow, type BundleRetirementSwitchResult, type BundleRetirementSwitchTerms, type BundleRow, type BundleVersionFields, type BundleVersionMutationResult, type BundleVersionOfferView, type BundleVersionOfferedNotice, type BundleVersionRetiredNotice, type BundleVersionRetirementRecord, type BundleVersionRetirementReminder, type BundleVersionRetirementRepository, type BundleVersionRetirementView, type BundleVersionRow, type BundleVersionSide, type BundleVersionSwitchResult, CATALOGUE_KEYS, CATALOG_ERROR_CODES, CONTRACT_ERROR_CODES, CUSTOM_LIMITS_KEYS, type CalendarDay, type CancelSubscriptionBundleData, type CancelSubscriptionInput, type CancelSubscriptionResult, type CancellationNoticePeriods, type CanonicalBundleVersionRetirementRow, type CanonicalContractLineItemRow, type CanonicalContractRow, type CanonicalFeatureWithdrawalRow, type CanonicalMaintenanceWindowRow, type CanonicalPlanRow, type CanonicalPlanVersionRow, type CanonicalRunningContractRow, type CanonicalSubscriberChargeRow, type CanonicalSubscriberCorrectionRow, type CanonicalSubscriberPaymentMethodRow, type CanonicalSubscriberRow, type CanonicalSubscriberTaxOriginChangeRow, type CanonicalSubscriberVatIdCheckRow, type CanonicalSubscriptionBundleRow, type CanonicalSubscriptionInvoiceArchiveRow, type CanonicalSubscriptionInvoiceDocumentRow, type CanonicalSubscriptionInvoiceLineRow, type CanonicalSubscriptionInvoiceRow, type CanonicalSubscriptionNoticeRow, type CanonicalVersionRetirementRow, type CapabilityCatalogEntryRow, type CapabilityCodeStatus, type CapabilityKey, type CapabilityKind, type CatalogEntryFilter, type CatalogEntryI18n, type CatalogEntryI18nFields, type CatalogEntryRepository, type CatalogErrorCode, type CatalogVersionKind, type ChangeDirection, type CheckoutOfferFilter, type CheckoutOfferLineItem, type CheckoutOfferLineItemKind, type CheckoutOfferPriceBreakdown, type CheckoutOfferPromoCodeSnapshot, type CheckoutOfferPromotionSnapshot, type CheckoutOfferRepository, type CheckoutOfferRow, type CheckoutOfferSelection, type CheckoutOfferSelectionUpdate, type CheckoutOfferStatus, type CleanupResult, type CliUserRow, type ComponentKey, type ConcurrencyGate, type ConfiguratorCatalog, type ConfiguratorMarketingProvider, type ConfiguratorModel, type ConfiguratorPlanMarketing, type ConfiguratorPlanVersionRow, type ConfiguratorPriceBreakdown, type ConfiguratorSourcesLookup, type ConfirmedPaymentMethod, type ContractErrorCode, type ContractIssuerParty, type ContractLineItemKind, type ContractLineItemRecord, type ContractSubscriberParty, type CreateBundleData, type CreateBundleVersionDraftData, type CreateCheckoutOfferData, type CreateMarketingProjectionData, type CreatePlanData, type CreatePlanVersionDraftData, type CreatePromoCodeData, type CreatePromoCodeRequest, type CreatePromotionData, type CreateSubscriberData, type CreateSubscriptionBundleData, type CreateSubscriptionContractData, type CreateSuperAdminCliInput, type CreateTenantInput, type CustomLimits, type DiffResult, type DiscoveredCapability, type DiscoveredFeature, type DiscoveredQuota, type DiscoveredQuotaPolicy, type DiscoveryCodeStatus, type DiscoverySnapshot, type DiscoveryStatus, ERROR_MESSAGES_DE, ERROR_MESSAGES_EN, type EffectiveLimitsSnapshot, type EmailPort, type EndAtOncePreview, type EndNowInput, type EndSubscriptionNowResult, type EndedAtOnce, type EndedAtOnceNotice, type ErrorMessageParams, FEATURE_NOT_LICENSED, FEATURE_WITHDRAWAL_CAPABILITY, FEATURE_WITHDRAWAL_REASON_MAX_LENGTH, type FeatureCatalogEntryRow, type FeatureDef, type FeatureKey, type FeatureNotLicensedBody, type FeatureRequiresIndex, type FeatureTier, type FeatureUiMeta, type FeatureUiRegistry, type FeatureWithdrawalAnnounced, type FeatureWithdrawalBlocker, type FeatureWithdrawalLift, type FeatureWithdrawalLifted, type FeatureWithdrawalLiftedNotice, type FeatureWithdrawalLine, type FeatureWithdrawalLineKind, type FeatureWithdrawalMark, type FeatureWithdrawalNoticeLine, type FeatureWithdrawalPreview, type FeatureWithdrawalReachedRow, type FeatureWithdrawalRecord, type FeatureWithdrawalReduction, type FeatureWithdrawalRepository, type FeatureWithdrawalRow, type FeatureWithdrawalSkippedRow, type FeatureWithdrawalTarget, type FeatureWithdrawalView, type FeatureWithdrawnNotice, type FinalActivationResult, type FirstTimeCustomerCheck, ForeignPaymentMethodReferenceError, type HeldVatId, INVOICE_ARCHIVE_TRIGGERS, INVOICE_DOCUMENT_CAPABILITY, INVOICE_ERROR_CODES, INVOICE_SEQUENCE_DIGITS, type ImmediatePlanChangeInput, type InvoiceArchivePort, type InvoiceContentDraft, type InvoiceDocument, type InvoiceDocumentToArchive, type InvoiceDraftInput, type InvoiceErrorCode, type InvoiceGroup, type InvoiceLineItemSnapshot, type InvoiceMail, type InvoiceMailPort, type InvoiceRenderer, type InvoiceTaxLine, type IssuerCorrectionFault, type IssuerHistoryStep, type IssuerIdentityChange, type KpiCardDef, type KpiDisplayHint, LEGAL_IDENTITY_FIELDS, type LegalIdentity, type LegalIdentityField, MAINTENANCE_CAPABILITY, MAINTENANCE_ERROR_CODES, MAINTENANCE_MESSAGE_MAX_LENGTH, MAINTENANCE_STATE_MAX_AGE_SECONDS, MARKETING_PRIORITY_MAX, MARKETING_PRIORITY_MIN, type MaintenanceErrorCode, type MaintenanceLockView, type MaintenanceNotificationPort, type MaintenanceOverview, type MaintenanceStatusView, type MaintenanceUnlockView, type MaintenanceWindowChanges, type MaintenanceWindowEvent, type MaintenanceWindowPort, type MaintenanceWindowRecord, type MaintenanceWindowStage, type MaintenanceWindowStatus, type MaintenanceWindowView, type ManifestAccessPort, type ManifestContribution, type MarketingProjectionFilter, type MarketingProjectionRepository, type MarketingProjectionRow, type MarketingSettingsRepository, type MarketingSettingsRow, type MarketingTargetType, type MarketingTopFeature, type MaskedPaymentMethod, type MfaPort, NO_SCHEDULED_CHANGE, type NewBundleVersionRetirement, type NewContractLineItemData, type NewFeatureWithdrawal, type NewInvoiceRendering, type NewMaintenanceWindow, type NewSettingsChange, type NewSubscriberCharge, type NewSubscriberDetails, type NewSubscriptionContractData, type NewSubscriptionInvoice, type NewSubscriptionInvoiceLine, type NewVersionRetirement, type NotToldReasons, type NoticeToRecord, OPTIONAL_CANONICAL_MODELS, OTP_RATE_LIMIT_MAX_SENDS, OTP_RATE_LIMIT_WINDOW_MINUTES, OTP_TTL_MINUTES, OTP_VERIFY_MAX_ATTEMPTS, type OnboardingPromoRedemption, type OnboardingSelectionRequest, type OnboardingSelectionResponse, type OptionalBundleMember, type OptionalCanonicalModel, type OrderlyRetirementSettings, PASSWORD_RESET_TTL_MINUTES, PAYMENT_ERROR_CODES, PAYMENT_METHOD_TYPES, PENDING_CHECKOUT_TTL_DAYS, PENDING_EMAIL_TTL_HOURS, PENDING_ONBOARDING_TTL_DAYS, PLATFORM_ERROR_CODES, PROMO_ERROR_CODES, type Paginated, type PartyAddress, type PasswordHasher, type PasswordResetCliResult, PaymentCallbackRejectedError, type PaymentErrorCode, type PaymentEventClaim, type PaymentEventLog, type PaymentGateway, type PaymentGatewayCallback, type PaymentGatewayEvent, type PaymentMethodHolder, type PaymentMethodSetupSession, type PaymentMethodSetupSubject, type PaymentMethodType, type PendingRegistration, type PendingRegistrationCreateInput, type PendingRegistrationRepository, type PendingRegistrationSnapshot, type PendingRegistrationUpdateInput, type PersistenceCapabilities, PersistenceCapabilityError, type PersistenceClassRef, type PersistenceInjectionToken, type PersistenceProvider, PersistenceRefusal, type PersistenceRefusalReason, type PlanCatalog, type PlanCatalogApp, type PlanCatalogImportReport, type PlanCatalogImportSink, type PlanCatalogInvoicing, type PlanCatalogIssuer, type PlanCatalogIssuerCorrection, type PlanCatalogLookup, type PlanCatalogMarketing, type PlanCatalogNotifications, type PlanCatalogPaymentAccount, type PlanCatalogPayments, type PlanCatalogReadSink, type PlanCatalogReadSnapshot, type PlanCatalogSettings, type PlanCatalogSubscribers, type PlanCatalogTax, type PlanCatalogTenantBilling, type PlanDef, type PlanId, type PlanListFilter, type PlanRepository, type PlanRow, type PlanVersion, type PlanVersionFields, type PlanVersionMutationResult, type PlanVersionRecord, type PlanVersionRepository, type PlanVersionRow, type PlatformErrorBody, type PlatformErrorCode, type PlatformJobActor, type PlatformRole, type PlatformUserDto, PlatformUserExistsError, type ProjectPageDef, type PromoCode, type PromoCodeDurationType, type PromoCodeFilter, type PromoCodeHoldRecord, type PromoCodeHoldRepository, type PromoCodeHoldTaken, type PromoCodeRecord, type PromoCodeRedemption, type PromoCodeRedemptionListItem, type PromoCodeRedemptionRecord, type PromoCodeRedemptionRepository, type PromoCodeRedemptionStatus, type PromoCodeRepository, type PromoCodeStatsPort, type PromoCodeStatsSnapshot, type PromoCodeStatus, type PromoCodeValidationLog, type PromoCodeValidationLogRepository, type PromoCodeValidationResult, type PromoCodeValueType, type PromoErrorCode, type PromoPreviewInvalidReason, type PromoPreviewRequest, type PromoPreviewResponse, type PromoPreviewValidResponse, type PromoRevenueDeductionAggregator, type PromoSubscriptionLookup, type PromotionBillingCycle, type PromotionI18n, type PromotionI18nFields, type PromotionOnPrice, type PromotionRepository, type PromotionResult, type PromotionRow, type PromotionStatus, type PromotionTargetType, type PromotionType, type PromotionValue, type PublicBootResponse, type PublicComparisonRow, type PublicMarketingBundle, type PublicMarketingCatalogResponse, type PublicMarketingPlan, type PublicMarketingPromo, type PublicNewPaymentMethods, type PublicSignupPlan, type PublishBundleVersionData, type PublishBundleVersionMeta, type PublishPlanVersionData, type QuotaCatalogEntryRow, type QuotaEnforcementMode, type QuotaKey, type QuotaProvider, REGISTRATION_ERROR_CODES, REGISTRATION_RESUME_TTL_MINUTES, REGISTRATION_STEP_BY_STATUS, RETIREMENT_REMINDER_LEAD_DAYS, type ReadCustomLimits, type ReassignTenantAdminCliResult, type RecommendablePlan, type RecordSubscriberPaymentMethodData, type RecordSubscriberPaymentMethodOutcome, type RecordSubscriberPaymentMethodResult, type RecordedVatIdCheck, type RedeemPromoInTransactionCallback, type RegistrationActivation, type RegistrationAuditContext, type RegistrationAuditEvent, type RegistrationAuditEventType, type RegistrationAuditLogger, type RegistrationBillingDetails, type RegistrationConfigSelection, type RegistrationConfiguratorLookup, type RegistrationErrorCode, type RegistrationOtpDelivery, type RegistrationPromoPreview, type RegistrationResumeDelivery, type RegistrationResumeTokenSigner, type RegistrationStatus, type RegistrationStep, type RequiredCapabilities, type ResolvableErrorBody, type ResumeRegistrationInput, type ResumeRegistrationResult, type RetiredBundleVersionRef, type RetiredVersionRef, type RetirementAnnounced, type RetirementBlocker, type RetirementMoveRun, type RetirementPreview, type RetirementPricedSide, type RetirementProgress, type RetirementReachedRow, type RetirementSide, type RetirementSkipReason, type RetirementSkippedRow, type RetirementSwitchResult, type RetirementSwitchTerms, type ReviewCatalogEntryData, type RlsBypassPort, type RunningContractIssuer, type RunningContractIssuers, SETTINGS_ERROR_CODES, SETUP_ERROR_CODES, SUBSCRIBER_ACCOUNT_CAPABILITY, SUBSCRIBER_ATTENTION_CAPABILITY, SUBSCRIBER_ATTENTION_PAGE_SIZE, SUBSCRIBER_CHARGE_ORIGINS, SUBSCRIBER_CHARGE_SOURCES, SUBSCRIBER_CORRECTION_CAPABILITY, SUBSCRIBER_ERROR_CODES, SUBSCRIBER_INVOICE_ADDRESS_FIELDS, SUBSCRIBER_STANDING_CAPABILITY, SUBSCRIBER_TAX_ORIGIN_FIELDS, type SaaSiCatPersistenceAdapter, type SaaSiCatPersistenceAdminResources, type SaaSiCatPersistenceCatalog, type SaaSiCatPersistenceCore, type SaaSiCatPersistenceEntitlement, type SaaSiCatPersistencePayments, type SaaSiCatPersistencePromo, type SaaSiCatPersistenceTenantBilling, type SaveRegistrationConfigInput, type SaveRegistrationConfigResult, type ScheduledChangeColumns, type ScheduledPlanChangeInput, type SecretSealer, type SelectPlanInput, type SelectPlanResult, type SelectableBundleShape, type SelfServiceBlockedPlans, type SetCatalogEntryReviewData, type SettingsChangeFilter, type SettingsChangeRecord, type SettingsDifference, type SettingsErrorCode, type SetupConfirmMfaRequest, type SetupConfirmMfaResponse, type SetupErrorCode, type SetupRequest, type SetupResult, type SetupStatusResponse, type SlugAvailabilityCheck, type StandardPageDef, type StandardPageKey, type StartCheckoutInput, type StartCheckoutResult, type StartPaymentMethodSetupInput, type StartRegistrationInput, type StartRegistrationResult, type StoredBundleStem, type StrictModeWarning, type StrictModeWarningCode, type SubscriberBusinessStatusData, type SubscriberBusinessStatusResult, type SubscriberCharge, type SubscriberChargeOrigin, type SubscriberChargeRecord, type SubscriberChargeSource, type SubscriberContact, type SubscriberContactChange, type SubscriberCorrectionData, type SubscriberCorrectionRecord, type SubscriberCorrectionResult, type SubscriberDetails, type SubscriberErrorCode, type SubscriberIdentityCorrection, type SubscriberIdentityDelta, type SubscriberIdentityValues, type SubscriberInvoiceAddressField, type SubscriberLedgerRepository, type SubscriberPaymentMethodRecord, type SubscriberPaymentMethodReference, type SubscriberPaymentMethodRepository, type SubscriberPaymentMethodSetupData, type SubscriberPaymentMethodSetupMatch, type SubscriberPaymentMethodStatus, type SubscriberReadiness, type SubscriberRecord, type SubscriberRepository, type SubscriberTaxOrigin, type SubscriberTaxOriginChangeRecord, type SubscriberTaxOriginField, type SubscriberTaxOriginValues, type SubscriberTaxStatus, type SubscriberVatIdCheckRecord, type SubscriberVatIdCheckResult, type SubscriberWithCurrentCheck, type Subscription, type SubscriptionBundleRecord, type SubscriptionBundleRepository, type SubscriptionBundleView, type SubscriptionContractFilter, type SubscriptionContractInvoiceSnapshot, type SubscriptionContractParties, type SubscriptionContractPriceSnapshot, type SubscriptionContractRecord, type SubscriptionContractRepository, type SubscriptionContractStatus, type SubscriptionInvoiceColumns, type SubscriptionInvoiceDocumentRecord, type SubscriptionInvoiceIssuer, type SubscriptionInvoiceLineColumns, type SubscriptionInvoiceLineRecord, type SubscriptionInvoiceRecord, type SubscriptionInvoiceRepository, type SubscriptionInvoiceSubscriber, type SubscriptionNotice, type SubscriptionNoticeDelivery, type SubscriptionNoticeKey, type SubscriptionNoticeKind, type SubscriptionNoticePort, type SubscriptionNoticeRecord, type SubscriptionNoticeRepository, type SubscriptionRecord, type SubscriptionRepository, type SubscriptionStatsPort, type SubscriptionStatsSnapshot, type SubscriptionStatus, type SubscriptionUsagePort, type SubscriptionUsageRecord, type SuperAdminProvisioningPort, type SupersedeSubscriptionContractData, type SyncDiscoveryResult, TAX_ERROR_CODES, TAX_TREATMENT_KINDS, type TaxAdapter, type TaxAdapterFactory, type TaxAdapterIdentity, type TaxAtRate, type TaxDecision, type TaxDecisionRequest, type TaxErrorCode, type TaxIssuer, type TaxOriginWrite, type TaxPerRate, type TaxTreatment, type TaxTreatmentKind, type TenantActionDef, type TenantColumnDef, type TenantDto, type TenantFeatureWithdrawal, type TenantFeatureWithdrawalLine, type TenantListFilter, type TenantPort, type TenantSubscriptionUsage, type TenantSubscriptionWritePort, type TerminateSubscriptionContractData, type TopPromoCode, type TransactionContext, type TransactionRunner, type UpdateBundleData, type UpdateBundleVersionDraftData, type UpdateCatalogEntryBaseData, type UpdateCatalogEntryI18nData, type UpdateCheckoutOfferData, type UpdateMarketingProjectionData, type UpdateMarketingSettingsData, type UpdatePlanData, type UpdatePlanVersionDraftData, type UpdatePromoCodeData, type UpdatePromoCodeRequest, type UpdatePromotionData, type UpsellOffer, type UpsellOfferResolver, type UpsertCapabilityEntryData, type UpsertFeatureCatalogEntryInput, type UpsertFeatureEntryData, type UpsertPlanInput, type UpsertPlanVersionInput, type UpsertQuotaEntryData, type UpsertResult, type UsageSnapshotPort, type UserAccountLookup, type UserListFilter, type UserManagementPort, type UserPort, VERSION_RETIREMENT_CAPABILITY, type VatCategory, type VatIdCheck, type VatIdCheckOutcome, type VerifyRegistrationOtpResult, type VersionChange, type VersionChangeDirection, type VersionEditability, type VersionEditableReason, type VersionOffer, type VersionOfferClass, type VersionOfferFields, type VersionOfferSide, type VersionOfferView, type VersionOfferedNotice, type VersionRetiredNotice, type VersionRetirementRecord, type VersionRetirementReminder, type VersionRetirementRepository, type VersionRetirementView, type VersionSale, type VersionSaleDates, type VersionSaleKind, type VersionSwitchResult, type VersionWindow, type VersionedEntityBase, type WithdrawnFeature, addDaysToDay, applyPromo, asXmlReadsIt, assertPersistenceCapabilities, buildActivePlanVersionWhere, buildActiveVersionWhere, buildFeatureRequiresIndex, bundleDraftDefaults, bundleKeyTaken, bundleStemDefaults, canonicalJson, canonicalVatId, catalogDraftExists, catalogVersionAlreadyPublished, catalogVersionGone, classifyBundleVersionDiff, classifyIssuerChange, classifyPlanDiff, classifyVersionOffer, collectUnsatisfiedRequires, computeIncludedVat, concurrencyGate, concurrencyGateOf, contractPartiesOf, coverageExcludingSelf, customLimitsReader, dayInZone, definedFields, diffSettings, draftSubscriptionInvoice, endedAtOnceSubjectOf, featureWithdrawalRowOf, featuresWithdrawnAt, formatCustomerNumber, formatErrorMessage, formatInvoiceNumber, grossFromNet, holdsOnlyXmlCharacters, identityCorrectionDelta, invoiceArchiveProtectionProblem, invoiceContentDraftOf, invoiceFooterOf, invoiceGroupsOf, invoiceIssuerOf, isBundleRedundant, isFeatureWithdrawnAt, isForeignPaymentMethodReferenceError, isInvoiceDocumentChecksum, isMaintenanceAnnouncementLapsed, isMaintenanceOverrun, isPaymentCallbackRejectedError, isPersistenceRefusal, isPlatformUserExistsError, isVersionActiveAt, isVersionEditable, issuerIdentityOf, keepOneRecommended, keepsVatIdCheck, lastDayInZone, maintenanceRetryAfterSeconds, maintenanceStatusOf, maintenanceWindowStatusOf, maintenanceWindowViewOf, marketingProjectionTaken, membersLeftOut, missingRequiresFor, movedIdentityFields, netFromGross, nextWithdrawalChange, noActivePlanVersion, parseZonedInstant, percentOf, pickActivePromo, planCatalogSettingsOf, planKeyTaken, planNotInCatalog, previousUtcDay, promoCodeTaken, promoStatus, promotionOnPrice, prorate, readCustomLimits, readQuotaRecord, readQuotaValue, recordedIssuerIdentity, refuseForeignPaymentMethodReference, resolveBundleAvailability, resolveErrorMessage, retirementCostsTheSubscription, retirementReminderDueAt, retirementReminderIsDue, retirementSwitchTerms, roundToCents, sameLegalIdentity, scheduledChangeAfterWrite, selectChargeableBundles, settingsSubtreeOf, startOfUtcDay, subscriberChargeColumns, subscriberFromRegistration, subscriberPaymentMethodColumns, subscriptionBundleAlreadyCancelled, subscriptionBundleGone, subscriptionContractGone, subscriptionGone, subscriptionInvoiceChargeInvoiced, subscriptionInvoiceColumns, subscriptionInvoiceDocumentChanged, subscriptionInvoiceLineColumns, sumToCents, taxOriginOf, taxOriginWrite, taxPerRate, taxTreatmentToJson, toArchivedInvoiceDocument, toBundleStemRow, toBundleVersionRetirementRecord, toCents, toContractLineItemRecord, toDecimalString, toFeatureWithdrawalRecord, toMaintenanceWindowRecord, toPlanRow, toPlanVersionRow, toRunningContractIssuer, toSubscriberChargeRecord, toSubscriberCorrectionRecord, toSubscriberPaymentMethodRecord, toSubscriberRecord, toSubscriberTaxOriginChangeRecord, toSubscriberVatIdCheckRecord, toSubscriptionBundleRecord, toSubscriptionContractRecord, toSubscriptionInvoiceDocumentRecord, toSubscriptionInvoiceRecord, toSubscriptionNoticeRecord, toTaxOriginValues, toTaxTreatment, toVersionRetirementRecord, utcMidnightOf, vatCategoryOf, vatIdCheckFromStore, versionOnSale, versionOnSaleOrNext, versionSale, withdrawnFeaturesOf, yearOfDay };
13565
+ export { ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES, AUTH_ERROR_CODES, type AbandonPaidOutcome, type ActionKey, type ActivationOrchestrator, type ActivePlanVersionWhere, type ActivePlanVersionWhereWithEndsAt, type ActiveVersionWhere, type ActiveVersionWhereWithEndsAt, type ActorTag, type AdminAccountEntry, type AdminAccountHolder, type AdminActor, type AdminAuditListFilter, type AdminManifest, type AdminReconciliationCase, type AdminReconciliationCases, type AdminReconciliationClose, type AdminResourcesPort, type AdminSubscriberAccount, type AdminSubscriberAttention, type AdminSubscriberCorrected, type AdminSubscriberCredit, type AdminSubscriberCreditEntry, type AdminSubscriberCredits, type AdminSubscriberHistoryEntry, type AdminSubscriberPayout, type AdminSubscriptionListRow, type AdminTenantDetail, type AdminTenantInvoice, type AdminTenantListFilter, type AdminTenantListRow, type AdminTenantPayments, type AdminTenantStateResult, type AdminTenantSubscriber, type AdminUserListFilter, type AdminUserListRow, type AdminVatIdCheckOutcome, type AppliedSettingsPort, type AppliedSettingsRecord, type AppliedSettingsValues, type ApplyOnboardingSelectionInput, type ApplyOnboardingSelectionResult, type ApprovedCatalogKeys, type ArchivedInvoiceDocument, type AuditActionDef, type AuditActor, type AuditEntry, type AuditPort, type AuditQuery, type AuditQueryPort, type AuditStatsPort, type AuditStatsSnapshot, type AuthErrorCode, BILLING_ERROR_CODES, BLOCKING_COLLECTION_STATUSES, BUNDLE_PRICE_LOOKUP_LIMIT, BUNDLE_VERSION_RETIREMENT_CAPABILITY, type BillingCycle, type BillingErrorCode, type BundleAvailabilityState, type BundleCompatibility, type BundleFeatureShape, type BundleListFilter, type BundlePricingOverride, type BundleRepository, type BundleRetirementAnnounced, type BundleRetirementPreview, type BundleRetirementReachedRow, type BundleRetirementSkipReason, type BundleRetirementSkippedRow, type BundleRetirementSwitchResult, type BundleRetirementSwitchTerms, type BundleRow, type BundleVersionFields, type BundleVersionMutationResult, type BundleVersionOfferView, type BundleVersionOfferedNotice, type BundleVersionRetiredNotice, type BundleVersionRetirementRecord, type BundleVersionRetirementReminder, type BundleVersionRetirementRepository, type BundleVersionRetirementView, type BundleVersionRow, type BundleVersionSide, type BundleVersionSwitchResult, CASE_CLOSED_REFUND_ENDED, CASE_CLOSED_REVERSAL_GIVEN_BACK, CATALOGUE_KEYS, CATALOG_ERROR_CODES, COLLECTION_FAILURE_REASONS, COLLECTION_NOT_SENT_PAID, COLLECTION_NOT_SENT_REVERSED, COLLECTION_RETRY_AFTER_DAYS, CONTRACT_ERROR_CODES, CUSTOM_LIMITS_KEYS, type CalendarDay, type CancelSubscriptionBundleData, type CancelSubscriptionInput, type CancelSubscriptionResult, type CancellationNoticePeriods, type CanonicalBundleVersionRetirementRow, type CanonicalContractLineItemRow, type CanonicalContractRow, type CanonicalFeatureWithdrawalRow, type CanonicalInvoiceCollectionRow, type CanonicalInvoiceSettlementRow, type CanonicalMaintenanceWindowRow, type CanonicalPlanRow, type CanonicalPlanVersionRow, type CanonicalReconciliationCaseRow, type CanonicalRunningContractRow, type CanonicalSubscriberChargeRow, type CanonicalSubscriberCorrectionRow, type CanonicalSubscriberCreditEntryRow, type CanonicalSubscriberCreditRow, type CanonicalSubscriberPaymentMethodRow, type CanonicalSubscriberPaymentRow, type CanonicalSubscriberRefundRow, type CanonicalSubscriberReversalRow, type CanonicalSubscriberRow, type CanonicalSubscriberTaxOriginChangeRow, type CanonicalSubscriberVatIdCheckRow, type CanonicalSubscriptionBundleRow, type CanonicalSubscriptionInvoiceArchiveRow, type CanonicalSubscriptionInvoiceDocumentRow, type CanonicalSubscriptionInvoiceLineRow, type CanonicalSubscriptionInvoiceRow, type CanonicalSubscriptionNoticeRow, type CanonicalVersionRetirementRow, type CapabilityCatalogEntryRow, type CapabilityCodeStatus, type CapabilityKey, type CapabilityKind, type CatalogEntryFilter, type CatalogEntryI18n, type CatalogEntryI18nFields, type CatalogEntryRepository, type CatalogErrorCode, type CatalogVersionKind, type ChangeDirection, type CheckoutOfferFilter, type CheckoutOfferLineItem, type CheckoutOfferLineItemKind, type CheckoutOfferPriceBreakdown, type CheckoutOfferPromoCodeSnapshot, type CheckoutOfferPromotionSnapshot, type CheckoutOfferRepository, type CheckoutOfferRow, type CheckoutOfferSelection, type CheckoutOfferSelectionUpdate, type CheckoutOfferStatus, type CleanupResult, type CliUserRow, type CloseReconciliationCase, type ClosedReconciliationCase, type CollectInvoiceInput, type CollectionAnnouncedNotice, type CollectionFailedNotice, type CollectionFailureNext, type CollectionFailureReason, type CollectionOutcome, type CollectionReversedNext, type CollectionReversedNotice, type ComponentKey, type ConcurrencyGate, type ConfiguratorCatalog, type ConfiguratorMarketingProvider, type ConfiguratorModel, type ConfiguratorPlanMarketing, type ConfiguratorPlanVersionRow, type ConfiguratorPriceBreakdown, type ConfiguratorSourcesLookup, type ConfirmedPaymentMethod, type ContractErrorCode, type ContractIssuerParty, type ContractLineItemKind, type ContractLineItemRecord, type ContractSubscriberParty, type CoveringCredit, type CreateBundleData, type CreateBundleVersionDraftData, type CreateCheckoutOfferData, type CreateMarketingProjectionData, type CreatePlanData, type CreatePlanVersionDraftData, type CreatePromoCodeData, type CreatePromoCodeRequest, type CreatePromotionData, type CreateSubscriberData, type CreateSubscriptionBundleData, type CreateSubscriptionContractData, type CreateSuperAdminCliInput, type CreateTenantInput, type CreditPart, type CustomLimits, DIRECT_DEBIT_LEAD_DAYS, type DiffResult, type DiscoveredCapability, type DiscoveredFeature, type DiscoveredQuota, type DiscoveredQuotaPolicy, type DiscoveryCodeStatus, type DiscoverySnapshot, type DiscoveryStatus, ENDED_REFUND_STATUSES, ERROR_MESSAGES_DE, ERROR_MESSAGES_EN, type EarlierCollection, type EffectiveLimitsSnapshot, type EmailPort, type EndAtOncePreview, type EndNowInput, type EndSubscriptionNowResult, type EndedAtOnce, type EndedAtOnceNotice, type ErrorMessageParams, FEATURE_NOT_LICENSED, FEATURE_WITHDRAWAL_CAPABILITY, FEATURE_WITHDRAWAL_REASON_MAX_LENGTH, FOLLOWED_UP_COLLECTION_STATUSES, type FeatureCatalogEntryRow, type FeatureDef, type FeatureKey, type FeatureNotLicensedBody, type FeatureRequiresIndex, type FeatureTier, type FeatureUiMeta, type FeatureUiRegistry, type FeatureWithdrawalAnnounced, type FeatureWithdrawalBlocker, type FeatureWithdrawalLift, type FeatureWithdrawalLifted, type FeatureWithdrawalLiftedNotice, type FeatureWithdrawalLine, type FeatureWithdrawalLineKind, type FeatureWithdrawalMark, type FeatureWithdrawalNoticeLine, type FeatureWithdrawalPreview, type FeatureWithdrawalReachedRow, type FeatureWithdrawalRecord, type FeatureWithdrawalReduction, type FeatureWithdrawalRepository, type FeatureWithdrawalRow, type FeatureWithdrawalSkippedRow, type FeatureWithdrawalTarget, type FeatureWithdrawalView, type FeatureWithdrawnNotice, type FinalActivationResult, type FindCollectionInput, type FirstTimeCustomerCheck, ForeignPaymentMethodReferenceError, GIVING_BACK_CREDIT_ENTRY_KINDS, type GatewayRefund, type GatewayReversal, type HeldVatId, INVOICE_ARCHIVE_TRIGGERS, INVOICE_COLLECTION_ASK_EVERY_MS, INVOICE_COLLECTION_LEASE_MS, INVOICE_COLLECTION_STATUSES, INVOICE_DOCUMENT_CAPABILITY, INVOICE_ERROR_CODES, INVOICE_SEQUENCE_DIGITS, INVOICE_SETTLEMENT_KINDS, type ImmediatePlanChangeInput, type InvoiceArchivePort, type InvoiceCollectionColumns, type InvoiceCollectionNotice, type InvoiceCollectionRecord, type InvoiceCollectionRepository, type InvoiceCollectionStatus, type InvoiceContentDraft, type InvoiceDocument, type InvoiceDocumentToArchive, type InvoiceDraftInput, type InvoiceErrorCode, type InvoiceGroup, type InvoiceLineItemSnapshot, type InvoiceMail, type InvoiceMailPort, type InvoiceNoticeMail, type InvoicePart, type InvoiceRenderer, type InvoiceSettlementKind, type InvoiceTaxLine, type IssuerCorrectionFault, type IssuerHistoryStep, type IssuerIdentityChange, type KpiCardDef, type KpiDisplayHint, LEGAL_IDENTITY_FIELDS, type LegalIdentity, type LegalIdentityField, type LiftedCover, MAINTENANCE_CAPABILITY, MAINTENANCE_ERROR_CODES, MAINTENANCE_MESSAGE_MAX_LENGTH, MAINTENANCE_STATE_MAX_AGE_SECONDS, MARKETING_PRIORITY_MAX, MARKETING_PRIORITY_MIN, type MaintenanceErrorCode, type MaintenanceLockView, type MaintenanceNotificationPort, type MaintenanceOverview, type MaintenanceStatusView, type MaintenanceUnlockView, type MaintenanceWindowChanges, type MaintenanceWindowEvent, type MaintenanceWindowPort, type MaintenanceWindowRecord, type MaintenanceWindowStage, type MaintenanceWindowStatus, type MaintenanceWindowView, type ManifestAccessPort, type ManifestContribution, type MarketingProjectionFilter, type MarketingProjectionRepository, type MarketingProjectionRow, type MarketingSettingsRepository, type MarketingSettingsRow, type MarketingTargetType, type MarketingTopFeature, type MaskedPaymentMethod, type MfaPort, NO_SCHEDULED_CHANGE, type NewBundleVersionRetirement, type NewContractLineItemData, type NewFeatureWithdrawal, type NewInvoiceCollection, type NewInvoiceRendering, type NewMaintenanceWindow, type NewReconciliationCase, type NewSettingsChange, type NewSubscriberCharge, type NewSubscriberDetails, type NewSubscriberPayment, type NewSubscriberPayout, type NewSubscriptionContractData, type NewSubscriptionInvoice, type NewSubscriptionInvoiceLine, type NewVersionRetirement, type NotToldReasons, type NoticeToRecord, OPTIONAL_CANONICAL_MODELS, OTP_RATE_LIMIT_MAX_SENDS, OTP_RATE_LIMIT_WINDOW_MINUTES, OTP_TTL_MINUTES, OTP_VERIFY_MAX_ATTEMPTS, type OnboardingPromoRedemption, type OnboardingSelectionRequest, type OnboardingSelectionResponse, type OpenCredit, type OptionalBundleMember, type OptionalCanonicalModel, type OrderlyRetirementSettings, PASSWORD_RESET_TTL_MINUTES, PAYMENT_ERROR_CODES, PAYMENT_METHOD_TYPES, PENDING_CHECKOUT_TTL_DAYS, PENDING_EMAIL_TTL_HOURS, PENDING_ONBOARDING_TTL_DAYS, PLATFORM_ERROR_CODES, PROMO_ERROR_CODES, type Paginated, type PartyAddress, type PasswordHasher, type PasswordResetCliResult, PaymentCallbackRejectedError, type PaymentErrorCode, type PaymentEventClaim, type PaymentEventLog, type PaymentGateway, type PaymentGatewayCallback, type PaymentGatewayEvent, type PaymentMethodHolder, type PaymentMethodSetupSession, type PaymentMethodSetupSubject, type PaymentMethodType, type PendingRegistration, type PendingRegistrationCreateInput, type PendingRegistrationRepository, type PendingRegistrationSnapshot, type PendingRegistrationUpdateInput, type PersistenceCapabilities, PersistenceCapabilityError, type PersistenceClassRef, type PersistenceInjectionToken, type PersistenceProvider, PersistenceRefusal, type PersistenceRefusalReason, type PlanCatalog, type PlanCatalogApp, type PlanCatalogImportReport, type PlanCatalogImportSink, type PlanCatalogInvoicing, type PlanCatalogIssuer, type PlanCatalogIssuerCorrection, type PlanCatalogLookup, type PlanCatalogMarketing, type PlanCatalogNotifications, type PlanCatalogPaymentAccount, type PlanCatalogPayments, type PlanCatalogReadSink, type PlanCatalogReadSnapshot, type PlanCatalogSettings, type PlanCatalogSubscribers, type PlanCatalogTax, type PlanCatalogTenantBilling, type PlanDef, type PlanId, type PlanListFilter, type PlanRepository, type PlanRow, type PlanVersion, type PlanVersionFields, type PlanVersionMutationResult, type PlanVersionRecord, type PlanVersionRepository, type PlanVersionRow, type PlannedInvoiceCollection, type PlatformErrorBody, type PlatformErrorCode, type PlatformJobActor, type PlatformRole, type PlatformUserDto, PlatformUserExistsError, type ProjectPageDef, type PromoCode, type PromoCodeDurationType, type PromoCodeFilter, type PromoCodeHoldRecord, type PromoCodeHoldRepository, type PromoCodeHoldTaken, type PromoCodeRecord, type PromoCodeRedemption, type PromoCodeRedemptionListItem, type PromoCodeRedemptionRecord, type PromoCodeRedemptionRepository, type PromoCodeRedemptionStatus, type PromoCodeRepository, type PromoCodeStatsPort, type PromoCodeStatsSnapshot, type PromoCodeStatus, type PromoCodeValidationLog, type PromoCodeValidationLogRepository, type PromoCodeValidationResult, type PromoCodeValueType, type PromoErrorCode, type PromoPreviewInvalidReason, type PromoPreviewRequest, type PromoPreviewResponse, type PromoPreviewValidResponse, type PromoRevenueDeductionAggregator, type PromoSubscriptionLookup, type PromotionBillingCycle, type PromotionI18n, type PromotionI18nFields, type PromotionOnPrice, type PromotionRepository, type PromotionResult, type PromotionRow, type PromotionStatus, type PromotionTargetType, type PromotionType, type PromotionValue, type PublicBootResponse, type PublicComparisonRow, type PublicMarketingBundle, type PublicMarketingCatalogResponse, type PublicMarketingPlan, type PublicMarketingPromo, type PublicNewPaymentMethods, type PublicSignupPlan, type PublishBundleVersionData, type PublishBundleVersionMeta, type PublishPlanVersionData, type QuotaCatalogEntryRow, type QuotaEnforcementMode, type QuotaKey, type QuotaProvider, RECONCILIATION_CASE_KINDS, RECONCILIATION_CLOSE_CAPABILITY, RECONCILIATION_NOTE_MAX_LENGTH, RECONCILIATION_READ_CAPABILITY, REGISTRATION_ERROR_CODES, REGISTRATION_RESUME_TTL_MINUTES, REGISTRATION_STEP_BY_STATUS, REOPENING_SETTLEMENT_KINDS, RETIREMENT_REMINDER_LEAD_DAYS, REVERSIBLE_COLLECTION_STATUSES, type ReadCustomLimits, type ReassignTenantAdminCliResult, type RecommendablePlan, type ReconciliationCaseKind, type ReconciliationCaseState, type RecordSubscriberPaymentMethodData, type RecordSubscriberPaymentMethodOutcome, type RecordSubscriberPaymentMethodResult, type RecordedSubscriberPayment, type RecordedSubscriberPayout, type RecordedSubscriberRefund, type RecordedSubscriberReversal, type RecordedVatIdCheck, type RedeemPromoInTransactionCallback, type RegistrationActivation, type RegistrationAuditContext, type RegistrationAuditEvent, type RegistrationAuditEventType, type RegistrationAuditLogger, type RegistrationBillingDetails, type RegistrationConfigSelection, type RegistrationConfiguratorLookup, type RegistrationErrorCode, type RegistrationOtpDelivery, type RegistrationPromoPreview, type RegistrationResumeDelivery, type RegistrationResumeTokenSigner, type RegistrationStatus, type RegistrationStep, type ReinstatableParts, type ReinstatementParts, type ReportedSubscriberRefund, type ReportedSubscriberReversal, type RequiredCapabilities, type ResolvableErrorBody, type ResumeRegistrationInput, type ResumeRegistrationResult, type RetiredBundleVersionRef, type RetiredVersionRef, type RetirementAnnounced, type RetirementBlocker, type RetirementMoveRun, type RetirementPreview, type RetirementPricedSide, type RetirementProgress, type RetirementReachedRow, type RetirementSide, type RetirementSkipReason, type RetirementSkippedRow, type RetirementSwitchResult, type RetirementSwitchTerms, type ReversalReinstatement, type ReversalWithdrawal, type ReversibleCredit, type ReversibleInvoice, type ReviewCatalogEntryData, type RlsBypassPort, type RunningContractIssuer, type RunningContractIssuers, SETTINGS_ERROR_CODES, SETUP_ERROR_CODES, SUBSCRIBER_ACCOUNT_CAPABILITY, SUBSCRIBER_ATTENTION_CAPABILITY, SUBSCRIBER_ATTENTION_PAGE_SIZE, SUBSCRIBER_CHARGE_ORIGINS, SUBSCRIBER_CHARGE_SOURCES, SUBSCRIBER_CORRECTION_CAPABILITY, SUBSCRIBER_CREDIT_CAPABILITY, SUBSCRIBER_CREDIT_ENTRY_KINDS, SUBSCRIBER_ERROR_CODES, SUBSCRIBER_INVOICE_ADDRESS_FIELDS, SUBSCRIBER_PAYMENTS_CAPABILITY, SUBSCRIBER_PAYOUT_CAPABILITY, SUBSCRIBER_REFUND_STATUSES, SUBSCRIBER_STANDING_CAPABILITY, SUBSCRIBER_TAX_ORIGIN_FIELDS, type SaaSiCatPersistenceAdapter, type SaaSiCatPersistenceAdminResources, type SaaSiCatPersistenceCatalog, type SaaSiCatPersistenceCore, type SaaSiCatPersistenceEntitlement, type SaaSiCatPersistencePayments, type SaaSiCatPersistencePromo, type SaaSiCatPersistenceTenantBilling, type SaveRegistrationConfigInput, type SaveRegistrationConfigResult, type ScheduledChangeColumns, type ScheduledPlanChangeInput, type SecretSealer, type SelectPlanInput, type SelectPlanResult, type SelectableBundleShape, type SelfServiceBlockedPlans, type SetCatalogEntryReviewData, type SettingsChangeFilter, type SettingsChangeRecord, type SettingsDifference, type SettingsErrorCode, type SetupConfirmMfaRequest, type SetupConfirmMfaResponse, type SetupErrorCode, type SetupRequest, type SetupResult, type SetupStatusResponse, type SlugAvailabilityCheck, type StandardPageDef, type StandardPageKey, type StartCheckoutInput, type StartCheckoutResult, type StartPaymentMethodSetupInput, type StartRegistrationInput, type StartRegistrationResult, type StoredBundleStem, type StrictModeWarning, type StrictModeWarningCode, type SubmittedInvoiceCollection, type SubscriberBusinessStatusData, type SubscriberBusinessStatusResult, type SubscriberCharge, type SubscriberChargeOrigin, type SubscriberChargeRecord, type SubscriberChargeSource, type SubscriberContact, type SubscriberContactChange, type SubscriberCorrectionData, type SubscriberCorrectionRecord, type SubscriberCorrectionResult, type SubscriberCreditEntryKind, type SubscriberCreditEntryRecord, type SubscriberCreditOrigin, type SubscriberCreditRecord, type SubscriberCreditStanding, type SubscriberDetails, type SubscriberErrorCode, type SubscriberIdentityCorrection, type SubscriberIdentityDelta, type SubscriberIdentityValues, type SubscriberInvoiceAddressField, type SubscriberLedgerRepository, type SubscriberPaymentMethodRecord, type SubscriberPaymentMethodReference, type SubscriberPaymentMethodRepository, type SubscriberPaymentMethodSetupData, type SubscriberPaymentMethodSetupMatch, type SubscriberPaymentMethodStatus, type SubscriberPaymentRecord, type SubscriberPaymentRepository, type SubscriberReadiness, type SubscriberReconciliationCaseRecord, type SubscriberRecord, type SubscriberRefundRecord, type SubscriberRefundStatus, type SubscriberRepository, type SubscriberReversalRecord, type SubscriberTaxOrigin, type SubscriberTaxOriginChangeRecord, type SubscriberTaxOriginField, type SubscriberTaxOriginValues, type SubscriberTaxStatus, type SubscriberVatIdCheckRecord, type SubscriberVatIdCheckResult, type SubscriberWithCurrentCheck, type Subscription, type SubscriptionBundleRecord, type SubscriptionBundleRepository, type SubscriptionBundleView, type SubscriptionContractFilter, type SubscriptionContractInvoiceSnapshot, type SubscriptionContractParties, type SubscriptionContractPriceSnapshot, type SubscriptionContractRecord, type SubscriptionContractRepository, type SubscriptionContractStatus, type SubscriptionInvoiceColumns, type SubscriptionInvoiceDocumentRecord, type SubscriptionInvoiceIssuer, type SubscriptionInvoiceLineColumns, type SubscriptionInvoiceLineRecord, type SubscriptionInvoicePayment, type SubscriptionInvoiceRecord, type SubscriptionInvoiceRepository, type SubscriptionInvoiceSubscriber, type SubscriptionNotice, type SubscriptionNoticeDelivery, type SubscriptionNoticeKey, type SubscriptionNoticeKind, type SubscriptionNoticePort, type SubscriptionNoticeRecord, type SubscriptionNoticeRepository, type SubscriptionRecord, type SubscriptionRepository, type SubscriptionStatsPort, type SubscriptionStatsSnapshot, type SubscriptionStatus, type SubscriptionUsagePort, type SubscriptionUsageRecord, type SuperAdminProvisioningPort, type SupersedeSubscriptionContractData, type SyncDiscoveryResult, TAX_ERROR_CODES, TAX_TREATMENT_KINDS, type TaxAdapter, type TaxAdapterFactory, type TaxAdapterIdentity, type TaxAtRate, type TaxDecision, type TaxDecisionRequest, type TaxErrorCode, type TaxIssuer, type TaxOriginWrite, type TaxPerRate, type TaxTreatment, type TaxTreatmentKind, type TenantActionDef, type TenantColumnDef, type TenantDto, type TenantFeatureWithdrawal, type TenantFeatureWithdrawalLine, type TenantListFilter, type TenantPort, type TenantSubscriptionUsage, type TenantSubscriptionWritePort, type TerminateSubscriptionContractData, type TopPromoCode, type TransactionContext, type TransactionRunner, UNSETTLED_COLLECTION_STATUSES, type UpdateBundleData, type UpdateBundleVersionDraftData, type UpdateCatalogEntryBaseData, type UpdateCatalogEntryI18nData, type UpdateCheckoutOfferData, type UpdateMarketingProjectionData, type UpdateMarketingSettingsData, type UpdatePlanData, type UpdatePlanVersionDraftData, type UpdatePromoCodeData, type UpdatePromoCodeRequest, type UpdatePromotionData, type UpsellOffer, type UpsellOfferResolver, type UpsertCapabilityEntryData, type UpsertFeatureCatalogEntryInput, type UpsertFeatureEntryData, type UpsertPlanInput, type UpsertPlanVersionInput, type UpsertQuotaEntryData, type UpsertResult, type UsageSnapshotPort, type UserAccountLookup, type UserListFilter, type UserManagementPort, type UserPort, VERSION_RETIREMENT_CAPABILITY, type VatCategory, type VatIdCheck, type VatIdCheckOutcome, type VerifyRegistrationOtpResult, type VersionChange, type VersionChangeDirection, type VersionEditability, type VersionEditableReason, type VersionOffer, type VersionOfferClass, type VersionOfferFields, type VersionOfferSide, type VersionOfferView, type VersionOfferedNotice, type VersionRetiredNotice, type VersionRetirementRecord, type VersionRetirementReminder, type VersionRetirementRepository, type VersionRetirementView, type VersionSale, type VersionSaleDates, type VersionSaleKind, type VersionSwitchResult, type VersionWindow, type VersionedEntityBase, type WithdrawalParts, type WithdrawnFeature, addDaysToDay, announcedCollectionDay, applyPromo, asXmlReadsIt, assertPersistenceCapabilities, buildActivePlanVersionWhere, buildActiveVersionWhere, buildFeatureRequiresIndex, bundleDraftDefaults, bundleKeyTaken, bundleStemDefaults, canonicalJson, canonicalVatId, casesCovered, catalogDraftExists, catalogVersionAlreadyPublished, catalogVersionGone, chargedAgainOn, classifyBundleVersionDiff, classifyIssuerChange, classifyPlanDiff, classifyVersionOffer, collectUnsatisfiedRequires, collectionAttemptKey, collectionOutcomeColumns, collectionStatusOf, columnAmountOf, computeIncludedVat, concurrencyGate, concurrencyGateOf, contractPartiesOf, coverageExcludingSelf, coversLifted, coversOf, customLimitsReader, dayInZone, definedFields, diffSettings, directDebitLeadDaysOf, draftSubscriptionInvoice, endedAtOnceSubjectOf, featureWithdrawalRowOf, featuresWithdrawnAt, formatCustomerNumber, formatErrorMessage, formatInvoiceNumber, grossFromNet, holdsOnlyXmlCharacters, identityCorrectionDelta, inWithdrawalOrder, invoiceArchiveProtectionProblem, invoiceCollectionColumns, invoiceContentDraftOf, invoiceFooterOf, invoiceGroupsOf, invoiceIssuerOf, invoicePaymentOf, isBundleRedundant, isChargedAgain, isEndedRefund, isFeatureWithdrawnAt, isForeignPaymentMethodReferenceError, isInvoiceDocumentChecksum, isMaintenanceAnnouncementLapsed, isMaintenanceOverrun, isPaymentCallbackRejectedError, isPersistenceRefusal, isPlatformUserExistsError, isRetryableCollectionFailure, isVersionActiveAt, isVersionEditable, issuerIdentityOf, keepOneRecommended, keepsVatIdCheck, lastCollectionOf, lastDayInZone, maintenanceRetryAfterSeconds, maintenanceStatusOf, maintenanceWindowStatusOf, maintenanceWindowViewOf, marketingProjectionTaken, membersLeftOut, missingRequiresFor, movedIdentityFields, netByInvoice, netFromGross, nextWithdrawalChange, noActivePlanVersion, openOfCredit, owedOn, paidOutByCredit, parseZonedInstant, paymentSettlement, payoutEntryColumns, percentOf, pickActivePromo, planCatalogSettingsOf, planKeyTaken, planNotInCatalog, plannedCollectionColumns, previousUtcDay, promoCodeTaken, promoStatus, promotionOnPrice, prorate, readCustomLimits, readQuotaRecord, readQuotaValue, reconciliationCaseColumns, recordedIssuerIdentity, refundEntryColumns, refundParts, refuseForeignPaymentMethodReference, refusesFirstAttempt, refusesPlannedAttempt, reinstatementParts, resolveBundleAvailability, resolveErrorMessage, retirementCostsTheSubscription, retirementReminderDueAt, retirementReminderIsDue, retirementSwitchTerms, reversalEntryColumns, roundToCents, sameLegalIdentity, scheduledChangeAfterWrite, selectChargeableBundles, sentCollectionOf, settingsSubtreeOf, settledAmountOf, startOfUtcDay, subscriberChargeColumns, subscriberFromRegistration, subscriberPaymentColumns, subscriberPaymentMethodColumns, subscriberRefundColumns, subscriberReversalColumns, subscriptionBundleAlreadyCancelled, subscriptionBundleGone, subscriptionContractGone, subscriptionGone, subscriptionInvoiceChargeInvoiced, subscriptionInvoiceColumns, subscriptionInvoiceDocumentChanged, subscriptionInvoiceLineColumns, sumToCents, taxOriginOf, taxOriginWrite, taxPerRate, taxTreatmentToJson, toArchivedInvoiceDocument, toBundleStemRow, toBundleVersionRetirementRecord, toCents, toCollectionAnnouncedNotice, toCollectionFailedNotice, toCollectionReversedNotice, toContractLineItemRecord, toDecimalString, toFeatureWithdrawalRecord, toInvoiceCollectionRecord, toMaintenanceWindowRecord, toPlanRow, toPlanVersionRow, toRunningContractIssuer, toSubscriberChargeRecord, toSubscriberCorrectionRecord, toSubscriberCreditEntryRecord, toSubscriberCreditRecord, toSubscriberPaymentMethodRecord, toSubscriberPaymentRecord, toSubscriberReconciliationCaseRecord, toSubscriberRecord, toSubscriberRefundRecord, toSubscriberReversalRecord, toSubscriberTaxOriginChangeRecord, toSubscriberVatIdCheckRecord, toSubscriptionBundleRecord, toSubscriptionContractRecord, toSubscriptionInvoiceDocumentRecord, toSubscriptionInvoiceRecord, toSubscriptionNoticeRecord, toTaxOriginValues, toTaxTreatment, toVersionRetirementRecord, utcMidnightOf, vatCategoryOf, vatIdCheckFromStore, versionOnSale, versionOnSaleOrNext, versionSale, withdrawalParts, withdrawnFeaturesOf, yearOfDay };