Smart and dynamic pricing engine for global applications, supporting real-time currency conversion, quantity, discounts, tax calculations, and formatted output.
๐ Features
- ๐ Supports 160+ currencies
- ๐ Auto-fetches latest exchange rates
- ๐งพ VAT / GST / custom tax support
- ๐ธ Discount by percentage or fixed value
- ๐ฆ Quantity multiplier
- ๐ช Currency symbol & locale-aware formatting
- ๐ง Works offline using cached or fallback rates
- ๐
.envsupport for premium API keys
๐ฆ Installation
npm install globalprice
โจ Usage Example
const { calculatePrice, updateRates } = require("globalprice");
await updateRates(); // optional, updates latest rates
const result = await calculatePrice({
basePrice: 100,
quantity: 2,
currency: "LKR",
discount: { type: "percent", value: 10 },
tax: { type: "VAT", rate: 12 },
format: true
});
console.log(result.formatted); // 'Rs 7320.00'
๐งช Test Locally
npm test
๐ Environment Setup
Add .env for custom API keys:
EXCHANGE_API_KEY=your_api_key_here
๐ Folder Structure
globalprice/
โโโ src/
โ โโโ index.js
โ โโโ rates.js
โ โโโ currencies.js
โโโ cache/
โ โโโ exchangeRates.json
โโโ test/
โ โโโ globalprice.test.js
โโโ .env
โโโ package.json
โโโ LICENSE
โโโ README.md
๐ License
MIT ยฉ Menula De Silva

Top comments (0)