Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@sealink/money_beans

sealink21MIT1.8.2

Create JS money objects from strings, integers or floats

money, cents, currency, dollars, add, subtract, multiply

readme

Money

Create JS money objects from strings, integers or floats

Build Status

Get started

Money = require('money')

new Money()
# returns => Object {cents: 0}

new Money('12.2')
# returns => Object {cents: 1220}

new Money(195)
# returns => Object {cents: 19500}

Render

Money = require('money')
price = new Money(10)

price.format()
# returns = '10.00'

price.render()
# returns => "<span class='money positive'>$10.00</span>"

Operations

Money = require('money')

## Multiply

productPrice = new Money('49.95')
quantity = 3
subTotal = productPrice.multiply(quantity)
# returns => Object {cents: 14985}

## Addition

shipping = new Money('20')
total = subTotal.add(shipping)
# returns => Object {cents: 16985}

## Subtraction

discount = new Money('10')
finalTotal = total.subtract(discount)
# returns => Object {cents: 15985}

Deployment

Build / Deployment is handled via travis CI. Package management is via NPM.

First create the release branch

git branch release/0.3.0

Second Update package.json and specify the version you are releasing

Next Tag and push to github

git tag v0.3.0
git push origin master --tags

Remember to merge changes back to the master branch

changelog

Unreleased

1.8.2

  • [TF-901] Fix can not find module issue

1.8.1

  • [PLAT-1203] Release with Node 18, no longer install npm@7 during build

1.8.0

  • [PLAT-1178] Add Node 18 support, drop Node 12 and 14

1.7.1

  • Fix node engines to remove node 10 include node 16

1.7.0

  • [TT-9098] Convert from Mocha to Jest
  • [OPS-213] GHActions: add Node 16 and remove Node 10
  • [PLAT-89] Github: Dependabot AutoMerge

1.6.0

  • [TT-8841] Migrate to github actions

1.5.1

  • [TT-8027] Remove "," format in thousands due to problems when parsing in rails forms

1.5.0

  • [TT-8018] Add valueOf method for backwards compatibility with v1.2.0

1.4.1

  • [TT-7968] Using currency.js intValue for greater accuracy

1.4.0

  • [TT-7922] Fixed some edge cases when initialising from string values

1.3.0

  • [TT-5649] Update Mocha / EsLint and Rollup plugins
  • [TT-5650] Remove Node6 support
  • [TT-5860] Format now includes thousand's seperator
  • [TT-6689] Update to Babel 7

1.2.0

  • Add a rounding method
  • [TT-4930] Update travis config to allow deployment

1.1.2

  • Use production build for publish

1.1.1

  • Remove coverage from dist js files
  • Update build to use rollup-js

1.1.0

  • Updated build and testing
  • Using es2015 complied with babeljs
  • Simplified tests with mocha

Added

  • [TT-1392] Changelog file