import { KeyboardEvent } from 'react'; import { InvoicingCatalogItemFormLocalData, InvoicingNamedOption, InvoicingNamedOptionsByKey, NestedAccountHierarchyForReport, NestedClassHierarchyForReport } from '@zeniai/client-epic-state'; import { GroupedOption, GroupedSingleSelectFieldValue } from '../../formElements/labeledGroupSingleSelectFieldWithRecommendationCheckbox/GroupedSingleSelectField'; import { MultiSelectFieldValue } from '../../formElements/multiSelectField/MultiSelectField'; export interface CatalogSelectOption { label: string; value: string; } /** * Value sets web-components still labels itself, because the backend has no enum * for them yet (pricing model, tier type, proration, applicability). */ export interface CatalogFormValueSets { applicabilityValues: readonly string[]; pricingModelValues: readonly string[]; prorationValues: readonly string[]; tierTypeValues: readonly string[]; } /** * Option lists that come from `/1.0/config`, labelled with the backend `name`. * Passed in per render — they are server data, so unlike * {@link CATALOG_FORM_VALUE_SETS} they cannot be a module constant. */ export interface CatalogFormConfigOptions { periodUnitOptions: InvoicingNamedOption[]; trialEndActionOptions: InvoicingNamedOption[]; trialUnitOptions: InvoicingNamedOption[]; typeOptions: InvoicingNamedOption[]; qboClassHierarchy?: NestedClassHierarchyForReport[]; qboIncomeAccountHierarchy?: NestedAccountHierarchyForReport[]; } export interface CatalogFormOptions { accountingClass: GroupedOption[]; applicability: CatalogSelectOption[]; incomeAccount: GroupedOption[]; periodUnit: CatalogSelectOption[]; pricingModel: CatalogSelectOption[]; proration: CatalogSelectOption[]; tierType: CatalogSelectOption[]; trialEnd: CatalogSelectOption[]; trialUnit: CatalogSelectOption[]; type: CatalogSelectOption[]; } /** * The CES-owned value sets. The form receives them as props (the screen reads * them from CES); the catalog detail page and the create-sub-family dialog use * this constant so all three render the same options with the same labels. */ export declare const CATALOG_FORM_VALUE_SETS: CatalogFormValueSets; /** * Tier `Type` options from the FE-local value set. Available at module scope * (unlike the config-driven lists) so blank-tier seeds can use it. */ export declare const CATALOG_LOCAL_TIER_TYPE_OPTIONS: CatalogSelectOption[]; /** The form's label for a saved value, so read-only views match the form. */ export declare const catalogOptionLabel: (allOptions: readonly CatalogSelectOption[], value: string | undefined) => string | undefined; /** Block any keystroke that would put a non-digit into a period field. */ export declare const allowOnlyNumericKeys: (event: KeyboardEvent) => void; /** * Income accounts as the grouped picker renders them. `getGroupedAccountOptions` * falls back to the internal id when a node carries no `qboId`; this form submits * the QuickBooks id, so an account without one is dropped rather than offered as * a value the invoicing API would reject. */ export declare const toGroupedIncomeAccountOptions: (hierarchy?: NestedAccountHierarchyForReport[]) => GroupedOption[]; /** * Classes as the grouped picker renders them. `getGroupedClassOptions` labels * each option with the internal class id while accounts use `qboId ?? id`, so the * values are remapped to the QuickBooks id the invoicing API stores and a class * without one is dropped rather than offered as an unsavable choice. */ export declare const toGroupedAccountingClassOptions: (hierarchy?: NestedClassHierarchyForReport[]) => GroupedOption[]; /** Map the CES-owned value sets to localized `{label, value}` select options. */ export declare const buildCatalogFormOptions: (config: CatalogFormConfigOptions, valueSets?: CatalogFormValueSets) => CatalogFormOptions; /** * The tier `Type` options the backend allows for `pricingModel`, straight from * `catalog_tier_type_options_by_pricing_model` on the invoicing config. Returns * `undefined` when the config has no entry for the model — that model takes no * tiers, so callers render no tier editor at all. Deliberately has no fallback * map: widening the allowed set is a backend config change, not a release. */ export declare const catalogTierTypeOptionsFor: (optionsByPricingModel: InvoicingNamedOptionsByKey, pricingModel: string) => CatalogSelectOption[] | undefined; export declare const getSubFamilyFlagLabel: (value: string) => string; interface ApplicableItemOption { id: string; label: string; subtitle?: string; } export declare const buildApplicableItemLabelGetter: (options: readonly ApplicableItemOption[]) => ((value: string) => string); export interface PickerValue { allOptions: CatalogSelectOption[]; selectedOption?: string; } /** Unwrap a picker value to the code it holds, tolerating a bare code. */ export declare const pickerOrText: (value: { selectedOption?: string; } | string) => string; export interface CatalogTierFormValues { endingUnit: string; packageSize: string; /** Held as a float by `returnValueType: "floatValue"`; `null` when cleared. */ price: number | null; pricingType: PickerValue; startingUnit: string; } export interface CatalogSubFamilyFormValues { accountingCategory: GroupedSingleSelectFieldValue; accountingCode: GroupedSingleSelectFieldValue; billingCycles: string; description: string; flags: MultiSelectFieldValue; freeQuantity: string; id: string; invoiceNotes: string; name: string; period: string; periodUnit: PickerValue; priceCode: string; /** Held as a float by `returnValueType: "floatValue"`; `null` when cleared. */ priceDollars: number | null; pricingModel: PickerValue; prorationType: PickerValue; sku: string; tiers: CatalogTierFormValues[]; trialEndAction: PickerValue; trialPeriod: string; trialPeriodUnit: PickerValue; } /** * Form-values shape reuses the CES localData field names verbatim — only the * fields whose *shape* differs on the form (pickers, multiselect, Price points) * are overridden. Every plain field (name, productCode, externalId, …) flows * through by identity, so adding a field to the CES type needs no mapper change. */ export type CatalogFormValues = Omit & { applicableItems: MultiSelectFieldValue; catalogType: PickerValue; itemApplicability: PickerValue; subFamilies: CatalogSubFamilyFormValues[]; }; export declare const localDataToCatalogFormValues: (localData: InvoicingCatalogItemFormLocalData, options: CatalogFormOptions, applicableItemOptions: readonly { id: string; label: string; subtitle?: string; }[]) => CatalogFormValues; export declare const catalogFormValuesToLocalData: (values: CatalogFormValues) => InvoicingCatalogItemFormLocalData; /** Blank sub-family / tier in form-values shape, seeded from the CES blanks. */ export declare const blankSubFamilyFormValues: (options: CatalogFormOptions) => CatalogSubFamilyFormValues; export declare const blankTierFormValues: (tierTypeOptions: CatalogSelectOption[], startingUnit?: string) => CatalogTierFormValues; export {};