DEV Community

Cover image for Introducing to globalprice
Menula De Silva
Menula De Silva

Posted on

Introducing to globalprice

Smart and dynamic pricing engine for global applications, supporting real-time currency conversion, quantity, discounts, tax calculations, and formatted output.

Github Repo Here


🚀 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
  • 🔐 .env support for premium API keys

📦 Installation

npm install globalprice
Enter fullscreen mode Exit fullscreen mode

✨ 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'
Enter fullscreen mode Exit fullscreen mode

🧪 Test Locally

npm test
Enter fullscreen mode Exit fullscreen mode

🔐 Environment Setup

Add .env for custom API keys:

EXCHANGE_API_KEY=your_api_key_here
Enter fullscreen mode Exit fullscreen mode

📁 Folder Structure

globalprice/
├── src/
│   ├── index.js
│   ├── rates.js
│   └── currencies.js
├── cache/
│   └── exchangeRates.json
├── test/
│   └── globalprice.test.js
├── .env
├── package.json
├── LICENSE
└── README.md
Enter fullscreen mode Exit fullscreen mode

📄 License

MIT © Menula De Silva

Top comments (0)