UNPKG

b-b-calculations

Version:

A cart calculation engine for buffalo burger restaurants

34 lines 1.47 kB
import { ICartItem } from '../models/CartItem'; import { IPricedCartItem } from '../models/PricedCartItem'; /** * Calculates the total net price and total price for a list of cart items. * * @param {ICartItem[]} items - Array of cart items, each with `requiredNetPrice`, `requiredTotalPrice`, and `quantity`. * @returns {IPricedCartItem} Object containing: * - `netPrice`: Sum of (requiredNetPrice × quantity) for all items * - `totalPrice`: Sum of (requiredTotalPrice × quantity) for all items * * @example * calcItemPrices([ * { requiredNetPrice: 10, requiredTotalPrice: 12, quantity: 2 }, * { requiredNetPrice: 5, requiredTotalPrice: 6, quantity: 1 } * ]); * // output: { netPrice: 25, totalPrice: 30 } */ export declare function calcItemPrices(items: ICartItem[]): IPricedCartItem; /** * Combines priced items and priced offers into a single array, ignoring undefined values. * * @param {PricedCartItem} [pricedItems] - Calculated prices for regular cart items. * @param {PricedCartItem} [pricedOffers] - Calculated prices for offers. * @returns {PricedCartItem[]} Array containing all defined priced items/offers. * * @example * collectPricedCartItems( * { netPrice: 20, totalPrice: 25 }, * undefined * ); * // output: [{ netPrice: 20, totalPrice: 25 }] */ export declare function collectPricedCartItems(pricedItems?: IPricedCartItem, pricedOffers?: IPricedCartItem): IPricedCartItem[]; //# sourceMappingURL=items.d.ts.map