import { UpdatePricesTypeEnum } from './enums'; import { IAmount } from './interfaces'; import { CalculatedTax, ITaxBase } from './taxes'; export interface IProductPrice { productId: number; priceId: number; quantity: number; unitPrice: number; defaultUnitPrice?: number; taxes?: CalculatedTax[]; subtotal: number; totalPrice: number; taxAmount?: number; /** * used internally to store the original unit price */ originalUnitPrice?: number; /** * The cart-item group this product belongs to. `updateCartPrices` does not match on it. * Same-rate lines share one product price (`productId` + `priceId` + `originalUnitPrice`); * each line keeps its own total. */ groupId?: string; /** * When true, `totalPrice` for this product is sticky and `updateCartPrices` * must not recompute it. Honored only on the INDIVIDUAL update path; * CATEGORY and GLOBAL update paths always recompute and ignore this flag. */ keepTotalPrice?: boolean; } export interface IProductsPrices { products: IProductPrice[]; productsSubtotal: number; addons: IProductPrice[]; addonsSubtotal?: number; } export interface ICategoriesPrices { products: number; addons?: number; } export interface IUpdateCategoryPrices { /** * Target products subtotal pool (pre-exclusive-tax) for category overrides. */ products?: number; /** * Target addons subtotal pool (pre-exclusive-tax) for category overrides. */ addons?: number; } export interface ICartPricingResult { products: IProductsPrices; categories: ICategoriesPrices; totalPrice: number; subtotal: number; /** * The total tax amount (inclusive and exclusive) of the cart. */ taxAmount?: number; /** * The exclusive tax amount of the cart. */ exclusiveTaxAmount?: number; /** * The inclusive tax amount of the cart. */ inclusiveTaxAmount?: number; } export interface IUpdateProductPrices { products?: IUpdateProductPrice[]; addons?: IUpdateProductPrice[]; } export interface IUpdateCartPrices { type: UpdatePricesTypeEnum; products?: IUpdateProductPrices; categories?: IUpdateCategoryPrices; /** * Target cart subtotal pool (pre-exclusive-tax) for global overrides. */ subtotal?: number; } export interface IUpdateProductPrice { productId: number; priceId: number; unitPrice: number; originalUnitPrice: number; totalPrice?: number; /** * The cart-item group this update was captured against. `updateCartPrices` ignores it * when matching, because group ids are regenerated when the cart is rebuilt. Matching * is by `productId` + `priceId` + `originalUnitPrice` (one unit price per product). */ groupId?: string; /** * When true, `totalPrice` for this product is sticky and `updateCartPrices` * must not recompute it. Honored only on the INDIVIDUAL update path; * CATEGORY and GLOBAL update paths always recompute and ignore this flag. */ keepTotalPrice?: boolean; } export interface IPriceUpdate { unitPrice: number; totalPrice?: number; taxes?: CalculatedTax[]; totalTax?: number; priceBeforeTax?: number; } export interface ISplitCartAmount extends IAmount { key: string; }