Skip to content

touch4it/currency-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Format currency output

GitHub license npm version node version vulnerabilities last commit

Installation

$ npm install --save @touch4it/currency-format

API

constructor(amount, [currency='USD'])

Object constructor

Options:

  • amount (required) - Price amount
  • currency (optional, default: USD) - Price currency

toString([decimals])

Print string with correct number of decimal places

Options:

  • decimals (optional, default: calculated from currency) - Decimal places in output

Return:

Formatted string

toSmallestUnit([decimals])

Return number in the smallest currency unit

Options:

  • decimals (optional, default: calculated from currency) - Decimal places in input

Return:

Number

add(amount)

Add amount to previous amount

Options:

  • amount (required) - Amount to be added

Return:

Object (this)

subtract(amount)

Subtract amount from previous amount

Options:

  • amount (required) - Amount to be subtracted

Return:

Object (this)

vat(vatPercent)

Calculate VAT amount

Options:

  • vatPercent (required) - Percent of VAT as number (e.g. 40 for 40%)

Return:

VAT amount as string with correct number of decimal places

addVat(vatPercent)

Add VAT amount to previous amount

Options:

  • vatPercent (required) - Percent of VAT (e.g. 40 for 40%)

Return:

Object (this)

Example

See tests

License

MIT

Authors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published