Skip to content

DMS-Menula/globalprice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌍 globalprice

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
  • 🔐 .env support 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

About

Smart pricing engine with live exchange rates, discount, tax and quantity support.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published