No commit activity in last 3 years
No release in over 3 years
A tiny JavaScript library for number, money and currency formatting with Rails asset pipeline
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Accounting.js is a tiny JavaScript library for number, money and currency formatting

Provides an easy-to-use Rails 3.1 asset for Accounting.js

Install

Add it to your Rails application's Gemfile:

gem 'accountingjs-rails'

Then bundle install.

Usage

Add the following to your app/assets/javascripts/application.js:

//= require accountingjs

Then you can:

// formatMoney() - format any number into currency
accounting.formatMoney(4999.99, "€", 2, ".", ","); // €4.999,99

// formatNumber() - format a number with custom precision and localisation
accounting.formatNumber(9876543.21, 3, " "); // 9 876 543.210

// toFixed() - better rounding for floating point numbers
accounting.toFixed(0.615, 2); // "0.62"

// unformat() - get a value from any formatted number/currency string
accounting.unformat("£ 12,345,678.90 GBP"); // 12345678.9

See the full usage details on the accounting.js site.