Skip to content

About

Exact currency amounts in minor units: ISO 4217 currencies, rounding, allocation and exchange

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

@deckyard/money

test Documentation release

Exact currency amounts for Jennifer, on the decimal library. An amount is an int of minor units with its ISO 4217 code, so it is exact, compares with == and stores as a plain number. Multiplying, dividing and exchanging round to whole minor units in the mode the caller names; allocate splits an amount without losing or creating a cent; amounts of different currencies never mix.

Documentation

Install

jvc add @deckyard/money

This vendors the deck to vendor/<scope>/money/. Without jvc, unpack the src/ subtree of a release archive (<scope>-money-<version>.tar.gz) there.

Usage

import "@deckyard/money/" as money;

def net as money.Money init money.parse("19.99", "EUR");
def gross as money.Money init money.multiply($net, "1.19", "half-up");
io.printf("%s EUR\n", money.format($gross));   # 23.79 EUR

for (def part in money.allocate($gross, ["1", "1", "1"])) {
    io.printf("%s ", money.format($part));      # 7.93 7.93 7.93
}

Requirements

Jennifer 0.26.0 or newer, jennifer or jennifer-tiny. No capabilities: the deck is pure computation.

Development

tools/check-all.sh                   # the full gate, as CI runs it
jennifer test src/money_test.j       # the test overlay
tools/gen-currencies.sh              # refresh the ISO 4217 table
tools/check-docs.sh                  # docs against the code
tools/pack.sh dist                   # build the release archive

Licence

LGPL-3.0-only, see LICENSE. Copyright (C) 2026 mplx <mplx@jennifer-lang.dev>.

tools/check-headers.sh checks every source file's SPDX header against deck.toml.

About

Exact currency amounts in minor units: ISO 4217 currencies, rounding, allocation and exchange

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors