UNPKG

purespectrum-lib

Version:

shared code between front and backend projects

86 lines (85 loc) 3.45 kB
export interface GetSupplierBlendInterface { suppliers: Array<BlendSupplier>; config_name: string; id: string; is_default: boolean; blend_flexibility: number; flexibilitySelectedType?: FlexibilityType; } export interface FlexibilityType { key: number; value: string; } export interface BlendSupplier { allocation_percentage: string; group_name: string; id: string; is_custom_allocation: boolean; supplier_id: Array<SubSupplierGroup>; flexibility_percentage?: string; } export interface SupplierQuantity { id: number; quantity: number; percentage: number; } export interface SubSupplierGroup { id: number; allocation: number; } export interface AllocationInterface { quantity(id: number): number; percentage(id: number): number; distribute(): void; } declare class Supplier { readonly id: number; quantity: number; percentage: number; group_name: string; readonly flexValue: number; suppliers: { id: number; }[]; constructor(id: number, quantity?: number, percentage?: number, group_name?: string, flexValue?: number); incrementQuantity(value: number): void; } export declare class AllocationFactory { static allocation(suppliers: SupplierQuantity[], completes: number, blend: GetSupplierBlendInterface, evenlyDistribution: boolean, aditionalQuantity: number): AllocationInterface; constructor(); } export declare class Flexibility { readonly flexValue: number; readonly allocation: number; readonly completesNeeded: number; constructor(flexValue: number, allocation: number, completesNeeded: number); goal(): number; } export declare class Blend { readonly blend: GetSupplierBlendInterface; readonly suppliers: Supplier[]; readonly completes: number; constructor(blend: GetSupplierBlendInterface, suppliers: Supplier[], completes: number); static empty(): { suppliers: never[]; config_name: string; id: string; is_default: boolean; blend_flexibility: number; }; static getBlendFromGetSupplierBlendInterface(blendId: string | undefined, blends: GetSupplierBlendInterface[]): GetSupplierBlendInterface; mapGroupForSrvSuppliers(suppliers: Supplier[], blend: GetSupplierBlendInterface): Supplier[]; rearrangeSuppliersAsPerGroup(suppliers: Supplier[]): Supplier[]; blendSuppliers(mappedSuppliers: Supplier[], blend: GetSupplierBlendInterface): BlendSupplier[]; setSuppliersToRedestribute(mappedSuppliers: Supplier[], blendSuppliers: BlendSupplier[], remainingCompletes: number, suppsIndexToRedistribute: number[], completes: number): number; applyBlendAllocation(mappedSuppliers: Supplier[], blend: GetSupplierBlendInterface, completes: number): Supplier[]; distributeRemainingAllocations(indexes: number[], remainingCompletes: number, mappedSuppliers: Supplier[]): void; validateRemainings(length: number, remainingCompletes: number): boolean; setAllocationToElegibleSuppliers(indexes: number[], mappedSuppliers: Supplier[]): void; isSuppEqualBlendSupp(mappedSupp: Supplier, blendSupp: BlendSupplier): boolean; validateGroupSupp(mappedSupp: Supplier, blendSupp: BlendSupplier): boolean | ""; validateIndividualSupp(mappedSupp: Supplier, blendSupp: BlendSupplier): boolean; isEmpty(value: unknown): boolean; _isRemainingAllocationPercentage(value: number): boolean; } export {};