UNPKG

@nexim/financial-calculate

Version:

Provides a set of utils to handle common financial operations.

49 lines (47 loc) 2.13 kB
/* @nexim/financial-calculate v1.0.3 */ "use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/main.ts var main_exports = {}; __export(main_exports, { calculateDiscountAmount: () => calculateDiscountAmount, calculateDiscountedPrice: () => calculateDiscountedPrice, calculatePercentageDiscount: () => calculatePercentageDiscount, calculatePercentageProfit: () => calculatePercentageProfit }); module.exports = __toCommonJS(main_exports); var import_package_tracer = require("@alwatr/package-tracer"); __dev_mode__: import_package_tracer.packageTracer.add("@nexim/financial-calculate", "1.0.3"); function calculateDiscountedPrice(price, discount, decimal = 2) { const discountedPrice = price * (1 - discount / 100); return parseFloat(discountedPrice.toFixed(decimal)); } function calculateDiscountAmount(price, discount, decimal = 2) { const discountAmount = price * discount / 100; return parseFloat(discountAmount.toFixed(decimal)); } function calculatePercentageProfit(marketPrice, salePrice, decimal = 2) { const percentage = (marketPrice - salePrice) / salePrice * 100; return parseFloat(percentage.toFixed(decimal)); } function calculatePercentageDiscount(marketPrice, salePrice, decimal = 2) { const percentage = (marketPrice - salePrice) / marketPrice * 100; return parseFloat(percentage.toFixed(decimal)); } //# sourceMappingURL=main.cjs.map