import { InvoicingSubscriptionFormLocalData } from '@zeniai/client-epic-state'; import { MultiSelectFieldValue } from '../../formElements/multiSelectField/MultiSelectField'; export interface InvoicingSubscriptionFormOption { label: string; value: string; /** * Plan options only: the plan's own paid-cycle limit, used to prefill the * form's Billing Cycles field when the plan is selected. Absent means the * plan renews forever. */ billingCycles?: number; /** * Plan options only: the price point's own billing cadence. Shown read-only, * because cadence is a property of the price point and the backend rejects a * subscription that claims a different one. */ billingPeriod?: number; billingPeriodUnit?: string; subtitle?: string; /** * Plan options only: the plan's own trial length, used to prefill the form's * Trial End field from the start date. Absent means the plan has no trial. */ trialPeriod?: number; trialPeriodUnit?: string; } export interface PickerValue { allOptions: { label: string; value: string; }[]; selectedOption?: string; } /** Option lists the form needs; the entity lists come from the connector. */ export interface InvoicingSubscriptionFormOptions { addons: InvoicingSubscriptionFormOption[]; charges: InvoicingSubscriptionFormOption[]; coupons: InvoicingSubscriptionFormOption[]; customers: InvoicingSubscriptionFormOption[]; plans: InvoicingSubscriptionFormOption[]; } /** * Create/edit form values (shipping address lives in the Address screen). * Reuses the CES localData field names verbatim — only the fields whose *shape* * differs on the form (pickers, multiselects, the trial-end date) are * overridden. Every plain field (autoCollection, poNumber, setupFee) flows * through by identity. `preferredCurrencyCode` is fixed to USD and not surfaced * in the UI, so it lives off react-hook-form and is reconstructed in the reverse * mapper for the request body. */ export type SubscriptionFormValues = Omit & { addonPriceCodes: MultiSelectFieldValue; chargePriceCodes: MultiSelectFieldValue; couponId: PickerValue; customerId: PickerValue; planPriceCode: PickerValue; /** Held as a float by `returnValueType: "floatValue"`; `null` when cleared. */ setupFee: number | null; startedAt: Date | undefined; trialEnd: Date | undefined; }; /** Value→label lookup for the add-on / one-time-charge multi-selects. */ export declare const buildSubscriptionOptionLabelGetter: (options: InvoicingSubscriptionFormOption[]) => ((value: string) => string); /** * The selected price point's billing cadence, for display only. Cadence is a * property of the price point, so the form shows what was chosen rather than * offering a cadence the price point may not have — the backend rejects any * subscription that claims a different one. */ export declare const subscriptionBillingCadenceLabel: (plan: InvoicingSubscriptionFormOption | undefined) => string; /** * Trial end implied by the selected plan: the start date walked forward by the * plan's own trial length. `undefined` when the start date is unset or the plan * carries no trial — the field is then left empty and the payload omits * `trial_end` rather than inventing a zero-length trial. */ export declare const subscriptionTrialEndForPlan: (startedAt: Date | undefined, plan: InvoicingSubscriptionFormOption | undefined) => Date | undefined; /** Trial end must land after the start date for the trial to have any length. */ export declare const isSubscriptionTrialEndAfterStart: (startedAt: Date | undefined, trialEnd: Date | undefined) => boolean; export declare const localDataToSubscriptionFormValues: (localData: InvoicingSubscriptionFormLocalData, options: InvoicingSubscriptionFormOptions) => SubscriptionFormValues; export declare const subscriptionFormValuesToLocalData: (values: SubscriptionFormValues) => InvoicingSubscriptionFormLocalData; /** Values used by the inline edit on the subscription detail page. */ export interface SubscriptionEditValues { addon_price_codes: MultiSelectFieldValue; auto_collection: boolean; coupon_id: PickerValue; plan_price_code: PickerValue; plan_quantity: string; po_number: string; } export declare const localDataToSubscriptionEditValues: (localData: InvoicingSubscriptionFormLocalData, options: Pick) => SubscriptionEditValues; export declare const subscriptionEditValuesToLocalData: (values: SubscriptionEditValues, base: InvoicingSubscriptionFormLocalData) => InvoicingSubscriptionFormLocalData; /** Seed the detail-page inline edit form from the current CES draft. */ export declare const buildSubscriptionEditDefaults: (localData: InvoicingSubscriptionFormLocalData, options: Pick) => SubscriptionEditValues;