import IPromiseToPurchase, { IBankAdjustment } from '../Interfaces/PromiseToPurchase'; import { IBankType } from '../Interfaces/PromiseToPurchase/BankType'; import PromiseToPurchase from '../lib/PromiseToPurchase'; import type Space from '../lib/Space'; import { IApplicablePromiseBank, IBankUsed, ICartPromiseToPurchase } from '../Interfaces/Cart'; import IIndexedBankUsed from '../Interfaces/PromiseToPurchase/IIndexedBankUsed'; /** * Get ordered array of promise data objects by starting date. * @param promises */ export declare const getOrderedPromises: (promises: IPromiseToPurchase[], orderByValue: 'starting_date' | 'promise_unique_id') => IPromiseToPurchase[]; /** * Checks list of promises for applicable banks based on space bank types. * @param promisesToCheck - The promise list to check * @param possibleBanks - the possible bank types (usually found in space data) * @returns An array of applicable banks. If no bank is active for a type, is not returned in array. If active bank of type is in a inactive promise, is returned with props pa_is_active: false. */ export declare const checkForApplicableBanks: (promisesToCheck: IPromiseToPurchase[], possibleBanks: IBankType[]) => IApplicablePromiseBank[]; /** * Returns if a promise is currently active. Promise is active if it is not archived, and if current date is same or after starting_date, and before ending_date (if defined). * @param promise - the promise data to check */ export declare const isPromiseActive: (promise: IPromiseToPurchase) => boolean; /** * A disabled bank is dropped so in a modification process we fetch it back from its promise and re-add it * @param liveApplicableBanks the banks currently applicable for the customer * @param orderPA the promise to purchase the order was originally paid with * @param space the space * @returns the applicable banks, plus any order PA bank that was missing or inactive */ export declare const getApplicableBanksWithOrderPA: (liveApplicableBanks: IApplicablePromiseBank[], orderPA: ICartPromiseToPurchase, space: Space) => Promise; export declare const getMostRecentlyCreatedPromise: (promises: IPromiseToPurchase[]) => IPromiseToPurchase; export declare const getOrderedVersionOfRules: (bankType: IBankType) => { version: number; rules: import("../Interfaces/PromiseToPurchase/BankType").IBankRule[]; }[] | undefined; export declare const getMostRecentVersionOfRules: (bankType: IBankType) => { version: number; rules: import("../Interfaces/PromiseToPurchase/BankType").IBankRule[]; } | undefined; export declare const isPromiseToPurchaseData: (promise: PromiseToPurchase | IPromiseToPurchase) => promise is IPromiseToPurchase; export declare const promiseToPurchaseStateReducer: (promises: Array) => Record; updated_at: number | null; updated_by: string; created_at: number | null; created_by: string; bank_types: string[]; promise_unique_id: string; }>; export declare const incrementPromiseIDLastTwoCharacters: (string: string) => string; export declare const getPAIdNumbers: (promiseId: string, returnYear?: boolean) => number; export declare const checkIfOtherBankOfSameTypeIsActive: (bankType: string, paListToCheck: PromiseToPurchase[]) => boolean; /** * Returns translated name for a provided bank type ID. * @param allBankTypes - The current bank types for space * @param bankTypeID - The bank type ID for which we want a name * @param locale - Optionnal. Defaults to 'fr' */ export declare const getBankTypeName: (allBankTypes: IBankType[], bankTypeID: string, locale?: string) => string; /** * Calculates the remaining amount for a specific promise's bank * @param initialBankAmount - the initial amount of the bank * @param bankHistory - array of all history entries for bank. Will be ordered by date before deducing amounts. */ export declare const calculatedRemainingBankAmount: (initialBankAmount: number | null, bankHistory: IIndexedBankUsed[] | undefined) => { initial_amount: number | null; remaining_amount: number | null; }; /** * Amount a cart consumes from a PA bank (negative = credit back): full amount on creation, otherwise the increment after − before. * @param bankIdentity the PA bank being measured (promise + bank type) * @param afterAmount the bank's consumed amount after the change * @param beforeBanksUsed the cart's banks_used before the change * @param isCreation true on cart creation process, false on modification * @returns the amount to charge the bank; negative means credited back */ export declare const getBankUsedDelta: (bankIdentity: { promise_id: string; bank_type_id: string; }, afterAmount: number, beforeBanksUsed: IBankUsed[], isCreation: boolean) => number; /** * Adjustments a cart modification produces, one per PA bank whose consumption changed. * @param beforeBanksUsed the cart's banks_used before the modification * @param afterBanksUsed the cart's banks_used after the modification * @param orderRef order ref * @returns one adjustment per bank whose delta is non-zero */ export declare const getModificationBankAdjustments: (beforeBanksUsed: IBankUsed[], afterBanksUsed: IBankUsed[], orderRef: string | number) => { promise_id: string; bank_type_id: string; adjustment: Omit; }[]; export declare const getIndexedByCustomerPromiseValues: (customerID: string, promises: (IPromiseToPurchase | PromiseToPurchase)[]) => { objectID: string; customer_id: string; has_active_promise: boolean; associated_promise_ids: Record; updated_at: number | null; updated_by: string; created_at: number | null; created_by: string; bank_types: string[]; promise_unique_id: string; }>; has_active_bank: boolean; last_updated_at: number; creation_reps: string[]; update_reps: string[]; }; /** * Returns the most recently emptied bank of a given type * @param allCustomerPAsData the array of all promises to purchase we want to check * @param type the bank_type_id to check * @param promiseUniqueID the current promise unique id * @returns An IBank with a promise_unique_id */ export declare const getLatestEmptiedBankOfType: (allCustomerPAsData: IPromiseToPurchase[], type: string, promiseUniqueID: string) => any;