No release in over 3 years
A configurable pricing engine for Rails/e-commerce apps that supports loyalty points, regional taxes, and flexible coupon logic.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0
~> 3.0

Runtime

 Project Readme

๐Ÿš€ Myco Pricing Engine โ€“ Rails Engine for Pricing Utilities

Gem Version Build Status License: MIT

**Myco Pricing Engine is an open-source Rails engine designed for businesses, fintech companies, and organizations to handle pricing calculations and automation for products, services, or financial instruments. It provides reusable utilities to manage complex pricing rules, apply discounts, compute taxes, and handle promotions efficiently.

๐Ÿ‘‰ RubyGems page | ๐Ÿ‘‰ Source code on GitHub


โœจ Features

  • โšก Automatic pricing calculations for products, services, or financial instruments
  • ๐Ÿ’ณ EMI, interest, and installment utilities for financial products
  • ๐Ÿท๏ธ Discounts: loyalty, tiered, early-bird, and multiple coupons
  • ๐Ÿงพ Taxes, delivery, and service fee calculations
  • ๐Ÿ›ก๏ธ Price caps and floors to enforce business rules
  • ๐Ÿงฉ Easily integratable with any Rails app

๐Ÿ“ฆ Installation

Add this line to your Rails app Gemfile:

gem 'myco_pricing_engine'

Then install the gem:

bundle install

Or install manually:

gem install myco_pricing_engine

๐Ÿš€ Usage

Automatic Features

  • Pricing calculations for products, EMI breakdown, and financial summaries.

Manual Usage

require "ostruct"

# Example user (ActiveRecord model or OpenStruct with `loyalty_points`)
user = OpenStruct.new(loyalty_points: 1200)

# Optional configuration
config = {
  loyalty_levels: {
    silver:   { threshold: 500,  discount: 0.05 },
    gold:     { threshold: 1000, discount: 0.10 },
    platinum: { threshold: 2000, discount: 0.20 }
  },
  tax_rate: 0.18,                       # 18% tax
  coupons: {                             # Coupons can stack
    "SAVE50" => 50,                      # Fixed discount
    "NEW10"  => 0.10                     # Percentage discount
  },
  early_bird_deadline: Time.current + 1.hour, # Early bird active for 1 hour
  early_bird_discount: 0.05,              # 5% early bird
  delivery_fee: 20.0,                     # Delivery fee
  min_price: 0.0,
  max_price: 2000.0                       # Price cap
}

# --- Options (Coupons applied) ---
options = {
  coupons: ["SAVE50", "NEW10"] # Multiple coupons
}

# --- Initialize Calculator ---
calc = MycoPricingEngine::Calculator.new(
  base_price: 1000,
  user: user,
  options: options,
  config: config
)

# --- Calculate final price ---
final_price = calc.final_price
puts "Final Price: #{final_price}"

# --- Step-by-step calculation ---
# Base Price: 1000
# Loyalty Discount (gold 10%): 100
# Price after loyalty: 900
# Early Bird Discount (5%): 45
# Price after early bird: 855
# Tax (18%): 153.9
# Price after tax: 1008.9
# Coupons:
#   SAVE50 (fixed) = 50
#   NEW10 (percentage) = 1008.9 * 0.10 = 100.89
# Total coupon discount = 150.89
# Price after coupons: 858.01
# Delivery Fee: +20 = 878.01
# Caps applied: min 0, max 2000 โ†’ no change
# Final Price: 878.01 โœ…

๐Ÿงช Development & Testing

Clone and setup:

git clone https://github.com/your-username/myco_pricing_engine.git
cd myco_pricing_engine
bundle install

Run specs:

bundle exec rspec

Build gem locally:

bundle exec rake install

Release a version:

bundle exec rake release

๐Ÿค Contributing

Contributions, bug reports, and pull requests are welcome! See issues.


๐Ÿ“œ License

Released under the MIT License.


๐Ÿ“ˆ SEO Keywords

Rails engine, Ruby gem, pricing utilities, EMI calculation, Rails financial gem, Myco Pricing Engine