UNPKG

@nexim/financial-calculate

Version:

Provides a set of utils to handle common financial operations.

55 lines 2.08 kB
/** * Calculate the price after applying a discount. * * @param price - The original price. * @param discount - The discount percentage to apply. * @param decimal - The number of decimal places to round to (default is 2). * * @example * ```ts * calculateDiscountedPrice(100, 10, 1); // returns 90.0 * ``` */ export declare function calculateDiscountedPrice(price: number, discount: number, decimal?: number): number; /** * Calculate the discount amount from the original price. * * @param price - The original price. * @param discount - The discount percentage. * @param decimal - The number of decimal places to round to (default is 2). * * @example * ```ts * calculateDiscountAmount(100, 10, 1); // returns 10.0 * ``` */ export declare function calculateDiscountAmount(price: number, discount: number, decimal?: number): number; /** * Calculates the discount percentage between the market price and the sale price for profit. * * @param marketPrice - The original market price of the item. * @param salePrice - The sale price of the item. * @param decimal - The number of decimal places to round the result to(optional with default value = 2). * * @example * ```ts * calculatePercentageProfit(100, 80); // Returns 20.00 * calculatePercentageProfit(100, 80, 1, false); // Returns 25.0 * ``` */ export declare function calculatePercentageProfit(marketPrice: number, salePrice: number, decimal?: number): number; /** * Calculates the discount percentage between the market price and the sale price for discount. * * @param marketPrice - The original market price of the item. * @param salePrice - The sale price of the item. * @param decimal - The number of decimal places to round the result to(optional with default value = 2). * * @example * ```ts * calculatePercentageDiscount(100, 80); // Returns 20.00 * calculatePercentageDiscount(100, 80, 1, false); // Returns 25.0 * ``` */ export declare function calculatePercentageDiscount(marketPrice: number, salePrice: number, decimal?: number): number; //# sourceMappingURL=main.d.ts.map