Liking cljdoc? Tell your friends :D

io.randomseed.bankster.money


*clj

(*)
(* a)
(* a b)
(* a b & more)

Alias for mul.

Alias for mul.
sourceraw docstring

+clj

(+)
(+ a)
(+ a b)
(+ a b & more)

Alias for add.

Alias for add.
sourceraw docstring

-clj

(- a)
(- a b)
(- a b & more)

Alias for sub.

Alias for sub.
sourceraw docstring

->clojure-symbolclj

(->clojure-symbol a)

Converts an amount of the given money to a clojure symbol (with added M when needed).

Converts an amount of the given money to a clojure symbol (with added M when
needed).
sourceraw docstring

->doubleclj

(->double a)
(->double a scale)
(->double a rounding-mode)
(->double a scale rounding-mode)

Converts an amount of the given money to a double with optional rescaling.

Converts an amount of the given money to a double with optional rescaling.
sourceraw docstring

->floatclj

(->float a)
(->float a scale)
(->float a rounding-mode)
(->float a scale rounding-mode)

Converts an amount of the given money to a float with optional rescaling.

Converts an amount of the given money to a float with optional rescaling.
sourceraw docstring

->symbolclj

(->symbol a)

Converts an amount of the given money to a symbol.

Converts an amount of the given money to a symbol.
sourceraw docstring

/clj

(/ a)
(/ a b)
(/ a b & more)

Alias for div.

Alias for div.
sourceraw docstring

<clj

(< a)
(< a b)
(< a b & more)

Alias for lt?.

Alias for lt?.
sourceraw docstring

<=clj

(<= a)
(<= a b)
(<= a b & more)

Alias for le?.

Alias for le?.
sourceraw docstring

=clj

(= a)
(= a b)
(= a b & more)

Alias for eq?.

Alias for eq?.
sourceraw docstring

==clj

(== a)
(== a b)
(== a b & more)

Alias for eq-am?.

Alias for eq-am?.
sourceraw docstring

>clj

(> a)
(> a b)
(> a b & more)

Alias for gt?.

Alias for gt?.
sourceraw docstring

>=clj

(>= a)
(>= a b)
(>= a b & more)

Alias for ge?.

Alias for ge?.
sourceraw docstring

absclj

(abs a)

Returns the absolute amount of the given money.

Returns the absolute amount of the given money.
sourceraw docstring

Accountablecljprotocol

This protocol is used to express (monetary) values using various numeric types and currency representations.

This protocol is used to express (monetary) values using various numeric types and
currency representations.

castclj

(cast money)
(cast money currency)
(cast money currency rounding-mode)

Casts an existing Money object to another having a different currency, rescaling the amount and optionally rounding it. This is useful when operating on multiple currency registries compatible with different data sources or processing engines. For simply ensuring that a currency is sourced in the right registry, use of-registry.

Casts an existing Money object to another having a different currency, rescaling
the amount and optionally rounding it. This is useful when operating on multiple
currency registries compatible with different data sources or processing
engines. For simply ensuring that a currency is sourced in the right registry, use
`of-registry`.

valueclj

(value num)
(value currency num)
(value currency num rounding-mode)

Creates new Money object for the given value which will become an amount. If the currency is not given it will try to use the default one, taken from the *default-currency* dynamic variable. Optional rounding-mode should be a rounding mode used when the conversion to a scaled monetary amount requires rounding.

In its unary form, when the argument is not numeric, it will try to get the currency object (identified by a string, a symbol or a keyword) from the default, global registry of currencies.

For simple money creation the following macros may be convenient way to go: of, of-major, of-minor.

Be careful about using number literals for big-scale amounts (16–17 digits). Use either big decimal literals, e.g. 1234.45689101112M, or strings.

Creates new Money object for the given value which will become an amount. If the
currency is not given it will try to use the default one, taken from the
`*default-currency*` dynamic variable. Optional rounding-mode should be a rounding
mode used when the conversion to a scaled monetary amount requires rounding.

In its unary form, when the argument is not numeric, it will try to get the
currency object (identified by a string, a symbol or a keyword) from the default,
global registry of currencies.

For simple money creation the following macros may be convenient way to go: of,
of-major, of-minor.

Be careful about using number literals for big-scale amounts (16–17 digits). Use
either big decimal literals, e.g. 1234.45689101112M, or strings.
sourceraw docstring

addclj

(add)
(add a)
(add a b)
(add a b & more)

Adds two or more amounts of money of the same currency. When called without any arguments, returns 0.

Adds two or more amounts of money of the same currency. When called without any
arguments, returns 0.
sourceraw docstring

add-majorclj

(add-major a b)

Increases major amount by the given number. If the number is also expressed as money and it has decimal parts, they will be truncated.

Increases major amount by the given number. If the number is also expressed as money
and it has decimal parts, they will be truncated.
sourceraw docstring

add-minorclj

(add-minor a b)

Increases minor amount by the given number. If the number is also expressed as money and it has decimal parts, they will be truncated..

Increases minor amount by the given number. If the number is also expressed as money
and it has decimal parts, they will be truncated..
sourceraw docstring

add-scaledclj

(add-scaled)
(add-scaled a)
(add-scaled a b)
(add-scaled a b & more)

Alias for add.

Alias for add.
sourceraw docstring

amountclj

(amount money)
(amount a b)
(amount a b r)

Returns the amount of the given money.

Returns the amount of the given money.
sourceraw docstring

auto-scaled?clj

(auto-scaled? m)

Returns true if the given Money object is based on a currency which is auto-scaled.

Returns true if the given Money object is based on a currency which is auto-scaled.
sourceraw docstring

compareclj

(compare a)
(compare a b)

Compares two monetary amounts of the same currency and scale. Returns -1 if the second one is less than, 0 if equal to, and 1 if it is greater than the first.

Compares two monetary amounts of the same currency and scale. Returns -1 if the
second one is less than, 0 if equal to, and 1 if it is greater than the first.
sourceraw docstring

compare-amountsclj

(compare-amounts a)
(compare-amounts a b)

Compares two monetary amounts of the same currency, regardless of their scales. Returns -1 if the second one is less than, 0 if equal to, and 1 if it is greater than the first.

Compares two monetary amounts of the same currency, regardless of their
scales. Returns -1 if the second one is less than, 0 if equal to, and 1 if it is
greater than the first.
sourceraw docstring

convertclj

(convert money price)
(convert money price rounding-mode)
(convert money to-currency exchange-rate)
(convert money to-currency exchange-rate rounding-mode)

Converts a monetary amount from one currency to another using the given multiplier (expressing a conversion rate). When two money objects are given, the second one should express a price of 1 unit of the first currency.

When no rounding mode is given and rounding is required during scaling to another currency then the value of dynamic variable io.randomseed.bankster.scale/*rounding-mode* will be used.

Converts a monetary amount from one currency to another using the given
multiplier (expressing a conversion rate). When two money objects are given, the
second one should express a price of 1 unit of the first currency.

When no rounding mode is given and rounding is required during scaling to another
currency then the value of dynamic variable
`io.randomseed.bankster.scale/*rounding-mode*` will be used.
sourceraw docstring

currencyclj

(currency money)
(currency a b)
(currency a b r)

Returns the currency of the given money.

Returns the currency of the given money.
sourceraw docstring

dec-majorclj

(dec-major a)

Decreases major amount by 1.

Decreases major amount by 1.
sourceraw docstring

dec-minorclj

(dec-minor a)

Decreases minor amount by 1.

Decreases minor amount by 1.
sourceraw docstring

defliteralclj

(defliteral c)

For the given currency identifier or a currency object it creates a tagged literal in a form of #money/CURRENCY where the CURRENCY is a currency code. As a side effect it creates a function of name io.randomseed.bankster.money/of-CURRENCY that will handle the literal.

The literals will be bound to data-readers in a local thread.

For the given currency identifier or a currency object it creates a tagged literal
in a form of #money/CURRENCY where the CURRENCY is a currency code. As a side
effect it creates a function of name io.randomseed.bankster.money/of-CURRENCY that
will handle the literal.

The literals will be bound to *data-readers* in a local thread.
sourceraw docstring

divclj

(div a)
(div a b)
(div a b & more)

Divides two or more amounts of money of the same currency or numbers. If two of the given values are a kind of Money, the result will be a BigDecimal number. If the earlier value is a kind of Money and the second is a number, the result will be a Money. If the first argument is a number and the second argument is a monetary amount, an exception will be thrown. The result will always be either a kind of Money or a BigDecimal number.

For a single value it returns a division of 1 by the given number or monetary value.

For more than 2 arguments it repeatedly divides their values as described. If the previous calculations produce a regular number, all consequent divisors must be regular numbers. Practically, if the division begins with a monetary amount, only one monetary amount at some point later is permitted (which will cause the function to switch to the regular numbers calculation since the units will cancel themselves).

Note that rescaling is not based on the original scale of a currency. This is designed that way is to handle cases when monetary amount was intentionally rescaled earlier.

For regular numbers and for monetary values of auto-scaled currencies the dynamic rescaling is performed to handle corner cases where there would be a non-terminating decimal expansion. Trailing zeros are stripped before any calculation.

Rescaling is performed after all calculations are done. However, the scale can be applied on each calculation if the dynamic variable io.randomseed.bankster.scale/*each* is set to a truthy value. If the scaling requires rounding then enclosing the expression within with-rounding is required. This can also be achieved by enclosing the expression within io.randomseed.bankster.scale/with-rescaling (aliased in this namespace under the same name) macro combining the switch and setting the scale.

Divides two or more amounts of money of the same currency or numbers. If two of the
given values are a kind of Money, the result will be a BigDecimal number. If the
earlier value is a kind of Money and the second is a number, the result will be a
Money. If the first argument is a number and the second argument is a monetary
amount, an exception will be thrown. The result will always be either a kind of
Money or a BigDecimal number.

For a single value it returns a division of 1 by the given number or monetary
value.

For more than 2 arguments it repeatedly divides their values as described. If the
previous calculations produce a regular number, all consequent divisors must be
regular numbers. Practically, if the division begins with a monetary amount, only
one monetary amount at some point later is permitted (which will cause the function
to switch to the regular numbers calculation since the units will cancel themselves).

Note that rescaling is not based on the original scale of a currency. This is
designed that way is to handle cases when monetary amount was intentionally
rescaled earlier.

For regular numbers and for monetary values of auto-scaled currencies the dynamic
rescaling is performed to handle corner cases where there would be a
non-terminating decimal expansion. Trailing zeros are stripped before any
calculation.

Rescaling is performed after all calculations are done. However, the scale can be
applied on each calculation if the dynamic variable
`io.randomseed.bankster.scale/*each*` is set to a truthy value. If the scaling
requires rounding then enclosing the expression within `with-rounding` is
required. This can also be achieved by enclosing the expression within
`io.randomseed.bankster.scale/with-rescaling` (aliased in this namespace under the
same name) macro combining the switch and setting the scale.
sourceraw docstring

div-remclj

(div-rem a b)

Alias for rem.

Alias for rem.
sourceraw docstring

div-scaledclj

(div-scaled a)
(div-scaled a b)
(div-scaled a b & more)

Divides two or more amounts of money of the same currency or numbers. Scales and optionally rounds each intermediate result (if there are more divisors).

If the first given argument is a kind of money and one of the divisors is also a kind of Money, the result will be a BigDecimal kind of number. If the earlier value is a kind of Money and the second is a number, the result will be a Money. If the first argument is a number and the second argument is a monetary amount, an exception will be thrown.

For a single value it returns a division of 1 by the given number or monetary value.

For more than 2 arguments it repeatedly divides their values as described and re-scales each result to match the scale of the first encountered monetary amount. If there are no monetary amounts involved the scale is calculated dynamically.

Note that rescaling is not based on the original scale of a currency. This is designed that way is to handle cases when monetary amount was intentionally rescaled earlier.

For regular numbers and for monetary values of auto-scaled currencies the dynamic rescaling is performed to handle corner cases where there would be a non-terminating decimal expansion. Trailing zeros are stripped before any calculation.

If the scaling requires rounding then enclosing the expression within with-rounding (also present in io.randomseed.bankster.scale namespace) is required.

Divides two or more amounts of money of the same currency or numbers. Scales and
optionally rounds each intermediate result (if there are more divisors).

If the first given argument is a kind of money and one of the divisors is also a
kind of Money, the result will be a BigDecimal kind of number. If the earlier value
is a kind of Money and the second is a number, the result will be a Money. If the
first argument is a number and the second argument is a monetary amount, an
exception will be thrown.

For a single value it returns a division of 1 by the given number or monetary
value.

For more than 2 arguments it repeatedly divides their values as described and
re-scales each result to match the scale of the first encountered monetary
amount. If there are no monetary amounts involved the scale is calculated
dynamically.

Note that rescaling is not based on the original scale of a currency. This is
designed that way is to handle cases when monetary amount was intentionally
rescaled earlier.

For regular numbers and for monetary values of auto-scaled currencies the dynamic
rescaling is performed to handle corner cases where there would be a
non-terminating decimal expansion. Trailing zeros are stripped before any
calculation.

If the scaling requires rounding then enclosing the expression within
`with-rounding` (also present in `io.randomseed.bankster.scale` namespace) is
required.
sourceraw docstring

eq-am?clj

(eq-am? a)
(eq-am? a b)
(eq-am? a b & more)

Return true if the monetary amounts and their currencies are equal, regardless of their scales.

Return true if the monetary amounts and their currencies are equal, regardless of
their scales.
sourceraw docstring

eq?clj

(eq? a)
(eq? a b)
(eq? a b & more)

Return true if the money amounts and their currencies are equal. Note that currencies with different scales or other properties are considered different. Use eq-am? (aliased as ==) to compare amounts regardless of their scales.

Return true if the money amounts and their currencies are equal. Note that
currencies with different scales or other properties are considered different. Use
eq-am? (aliased as ==) to compare amounts regardless of their scales.
sourceraw docstring

formatclj

(format money)
(format money locale)
(format money locale opts)

Formats the given amount of money as a string according to localization rules. If the locale argument is not given then the default is used.

It is advised to express locale using a keyword when huge amount of operations is expected.

If there are 3 arguments passed the third one should be a map of options customizing the formatting. It can have the following keys:

  • :rounding-mode - RoundingMode, rounding mode to apply when scaling (if scale/*rounding-mode* is not set)
  • :grouping - Boolean, if true then grouping will be used
  • :grouping-size - integer, size of a group when grouping
  • :negative-prefix - String, negative prefix to use
  • :negative-suffix - String, negative suffix to use
  • :positive-prefix - String, positive prefix to use
  • :positive-suffix - String, positive suffix to use
  • :always-sep-dec - Boolean, if true then the decimal separator will always be shown
  • :currency-symbol-fn - a function used on a bankster/Currency object to get its symbol as a string
  • :min-fraction-digits - integer, the minimum number of digits allowed in the fraction portion of an amount
  • :min-integer-digits - integer, the minimum number of digits allowed in the integer portion of an amount
  • :max-fraction-digits - integer, the maximum number of digits allowed in the fraction portion of an amount
  • :max-integer-digits - integer, the maximum number of digits allowed in the integer portion of an amount
  • :scale - sets both :min-fraction-digits and :max-fraction-digits to the same value.

The function assigned to the :currency-symbol-fn should take 3 arguments: currency, locale and registry.

Note that you may gain some speed by re-using the extended formatter (basic formatter is already cached). See the documentation of the format-with function for more information.

Formats the given amount of money as a string according to localization rules. If
the locale argument is not given then the default is used.

It is advised to express locale using a keyword when huge amount of operations is
expected.

If there are 3 arguments passed the third one should be a map of options
customizing the formatting. It can have the following keys:

- :rounding-mode   - RoundingMode, rounding mode to apply when scaling (if `scale/*rounding-mode*` is not set)
- :grouping        - Boolean, if true then grouping will be used
- :grouping-size   - integer, size of a group when grouping
- :negative-prefix - String, negative prefix to use
- :negative-suffix - String, negative suffix to use
- :positive-prefix - String, positive prefix to use
- :positive-suffix - String, positive suffix to use
- :always-sep-dec  - Boolean, if true then the decimal separator will always be shown
- :currency-symbol-fn  - a function used on a bankster/Currency object to get its symbol as a string
- :min-fraction-digits - integer, the minimum number of digits allowed in the fraction portion of an amount
- :min-integer-digits  - integer, the minimum number of digits allowed in the integer portion of an amount
- :max-fraction-digits - integer, the maximum number of digits allowed in the fraction portion of an amount
- :max-integer-digits  - integer, the maximum number of digits allowed in the integer portion of an amount
- :scale               - sets both :min-fraction-digits and :max-fraction-digits to the same value.

The function assigned to the :currency-symbol-fn should take 3 arguments:
currency, locale and registry.

Note that you may gain some speed by re-using the extended formatter (basic
formatter is already cached). See the documentation of the format-with function for
more information.
sourceraw docstring

format-withclj

(format-with formatter money)

Formats the amount of money using the formatter provided. Formatters can be created with io.randomseed.bankster.currency/formatter and io.randomseed.bankster.currency/formatter-extended.

Formats the amount of money using the formatter provided. Formatters can be created
with io.randomseed.bankster.currency/formatter and
io.randomseed.bankster.currency/formatter-extended.
sourceraw docstring

ge?clj

(ge? a)
(ge? a b)
(ge? a b & more)

Returns non-nil if monetary amounts are in monotonically non-increasing order, otherwise false.

Returns non-nil if monetary amounts are in monotonically non-increasing order,
otherwise false.
sourceraw docstring

gt?clj

(gt? a)
(gt? a b)
(gt? a b & more)

Returns non-nil if monetary amounts are in monotonically decreasing order, otherwise false.

Returns non-nil if monetary amounts are in monotonically decreasing order,
otherwise false.
sourceraw docstring

inc-majorclj

(inc-major a)

Increases major amount by 1.

Increases major amount by 1.
sourceraw docstring

inc-minorclj

(inc-minor a)

Increases minor amount by 1.

Increases minor amount by 1.
sourceraw docstring

is-neg-or-zero?clj

(is-neg-or-zero? a)

Returns true if the given monetary amount is a negative number or zero.

Returns true if the given monetary amount is a negative number or zero.
sourceraw docstring

is-neg?clj

(is-neg? a)

Returns true if the given monetary amount is a negative number.

Returns true if the given monetary amount is a negative number.
sourceraw docstring

is-pos-or-zero?clj

(is-pos-or-zero? a)

Returns true if the given monetary amount is a positive number or zero.

Returns true if the given monetary amount is a positive number or zero.
sourceraw docstring

is-pos?clj

(is-pos? a)

Returns true if the given monetary amount is a positive number.

Returns true if the given monetary amount is a positive number.
sourceraw docstring

is-zero?clj

(is-zero? a)

Returns true if the given monetary amount is a positive number.

Returns true if the given monetary amount is a positive number.
sourceraw docstring

LastMoneyclj

source

le?clj

(le? a)
(le? a b)
(le? a b & more)

Returns non-nil if monetary amounts are in monotonically non-decreasing order, otherwise false.

Returns non-nil if monetary amounts are in monotonically non-decreasing order,
otherwise false.
sourceraw docstring

lt?clj

(lt? a)
(lt? a b)
(lt? a b & more)

Returns non-nil if monetary amounts are in monotonically increasing order, otherwise false.

Returns non-nil if monetary amounts are in monotonically increasing order,
otherwise false.
sourceraw docstring

majorclj

(major a)

Returns the major part of the given amount of money.

Returns the major part of the given amount of money.
sourceraw docstring

major->intclj

(major->int a)

Returns the major part of the given amount as a int number.

Returns the major part of the given amount as a int number.
sourceraw docstring

major->longclj

(major->long a)

Returns the major part of the given amount as a long number.

Returns the major part of the given amount as a long number.
sourceraw docstring

major-minorclj

(major-minor a)

Returns a vector with major and minor parts of the given monetary amount.

Returns a vector with major and minor parts of the given monetary amount.
sourceraw docstring

major-minor->intclj

(major-minor->int a)

Returns a vector with major and minor parts of the given monetary amount represented as integer numbers.

Returns a vector with major and minor parts of the given monetary amount represented
as integer numbers.
sourceraw docstring

major-minor->longclj

(major-minor->long a)

Returns a vector with major and minor parts of the given monetary amount represented as long numbers.

Returns a vector with major and minor parts of the given monetary amount represented
as long numbers.
sourceraw docstring

major-valueclj

(major-value a)
(major-value currency amount)
(major-value currency amount rounding-mode)

Creates new Money object for the given value which will become a major part of the amount. If the given number has fractional part it will be truncated. If the currency is not given it should try to use the default one, taken from the io.randomseed.bankster.currency/*default* dynamic variable. Optional rounding-mode should be a rounding mode used when the conversion to a scaled monetary amount requires rounding.

For simple money creation the following macros may be convenient way to go: of, of-major, of-minor.

Creates new Money object for the given value which will become a major part of the
amount. If the given number has fractional part it will be truncated. If the
currency is not given it should try to use the default one, taken from the
`io.randomseed.bankster.currency/*default*` dynamic variable. Optional
rounding-mode should be a rounding mode used when the conversion to a scaled
monetary amount requires rounding.

For simple money creation the following macros may be convenient way to go: of,
of-major, of-minor.
sourceraw docstring

maxclj

(max a)
(max a b)
(max a b & more)

Alias for max-amount.

Alias for max-amount.
sourceraw docstring

max-amountclj

(max-amount a)
(max-amount a b)
(max-amount a b & more)

Returns the greatest of the monetary amounts.

Returns the greatest of the monetary amounts.
sourceraw docstring

minclj

(min a)
(min a b)
(min a b & more)

Alias for min-amount.

Alias for min-amount.
sourceraw docstring

min-amountclj

(min-amount a)
(min-amount a b)
(min-amount a b & more)

Returns the least of the monetary amounts.

Returns the least of the monetary amounts.
sourceraw docstring

minorclj

(minor a)

Returns the minor part of the given amount.

Returns the minor part of the given amount.
sourceraw docstring

minor->intclj

(minor->int a)

Returns the minor part of the given amount as an integer number.

Returns the minor part of the given amount as an integer number.
sourceraw docstring

minor->longclj

(minor->long a)

Returns the minor part of the given amount as a long number.

Returns the minor part of the given amount as a long number.
sourceraw docstring

minor-valueclj

(minor-value a)
(minor-value currency amount)
(minor-value currency amount rounding-mode)

Creates new Money object for the given value which will become a minor part of the amount. If the given number has fractional part it will be truncated. If the currency is not given it should try to use the default one, taken from the io.randomseed.bankster.currency/*default* dynamic variable. Optional rounding-mode should be a rounding mode used when the conversion to a scaled monetary amount requires rounding.

For simple money creation the following macros may be convenient way to go: of, of-major, of-minor.

Creates new Money object for the given value which will become a minor part of the
amount. If the given number has fractional part it will be truncated. If the
currency is not given it should try to use the default one, taken from the
`io.randomseed.bankster.currency/*default*` dynamic variable. Optional
rounding-mode should be a rounding mode used when the conversion to a scaled
monetary amount requires rounding.

For simple money creation the following macros may be convenient way to go: of,
of-major, of-minor.
sourceraw docstring

money?clj

(money? a)

Returns true if the given value is a kind of Money.

Returns true if the given value is a kind of Money.
sourceraw docstring

mulclj

(mul)
(mul a)
(mul a b)
(mul a b & more)

Multiplies two or more values where one may be a Money object. If one of the values is a kind of Money then the result will also be a kind of Money. For a single value it simply returns it. For more than 2 arguments it repeatedly multiplies them as described.

When there is a multiplication of a monetary value by the regular number, the final result of all operations is re-scaled to match the scale of monetary amount. If the scaling requires rounding, enclosing the expression within io.randomseed.bankster.scale/with-rounding is required (the macro is aliased under the same name in this namespace).

Note that rescaling is not based on the original scale of a currency. This is designed that way is to handle cases when monetary amount was intentionally rescaled earlier.

For regular numbers dynamic rescaling is performed only to handle corner cases where there would be a non-terminating decimal expansion.

Rescaling is performed after performing all operations unless all values are regular numbers (without any Money object among them).

Multiplies two or more values where one may be a Money object. If one of the values
is a kind of Money then the result will also be a kind of Money. For a single value
it simply returns it. For more than 2 arguments it repeatedly multiplies them as
described.

When there is a multiplication of a monetary value by the regular number, the final
result of all operations is re-scaled to match the scale of monetary amount. If the
scaling requires rounding, enclosing the expression within
`io.randomseed.bankster.scale/with-rounding` is required (the macro is aliased
under the same name in this namespace).

Note that rescaling is not based on the original scale of a currency. This is
designed that way is to handle cases when monetary amount was intentionally
rescaled earlier.

For regular numbers dynamic rescaling is performed only to handle corner cases
where there would be a non-terminating decimal expansion.

Rescaling is performed after performing all operations unless all values are
regular numbers (without any Money object among them).
sourceraw docstring

mul-scaledclj

(mul-scaled)
(mul-scaled a)
(mul-scaled a b)
(mul-scaled a b & more)

Multiplies two or more values where one may be a Money object. If one of the values is a kind of Money then the result will also be a kind of Money. For a single value it simply returns it. For more than 2 arguments it repeatedly multiplies them as described.

When there is a multiplication of a monetary value by the regular number, the final result of all operations is re-scaled to match the scale of the monetary amount. If the scaling requires rounding, enclosing the expression within io.randomseed.bankster.scale/with-rounding is required (the macro is aliased under the same name in this namespace).

Note that rescaling is not based on the original scale of a currency. This is designed that way is to handle cases when monetary amount was intentionally rescaled earlier.

For regular numbers dynamic rescaling is performed only to handle corner cases where there would be a non-terminating decimal expansion.

Rescaling is performed on each operation unless/until all values are regular numbers (without any Money object among them).

Multiplies two or more values where one may be a Money object. If one of the values
is a kind of Money then the result will also be a kind of Money. For a single value
it simply returns it. For more than 2 arguments it repeatedly multiplies them as
described.

When there is a multiplication of a monetary value by the regular number, the final
result of all operations is re-scaled to match the scale of the monetary amount. If
the scaling requires rounding, enclosing the expression within
`io.randomseed.bankster.scale/with-rounding` is required (the macro is aliased
under the same name in this namespace).

Note that rescaling is not based on the original scale of a currency. This is
designed that way is to handle cases when monetary amount was intentionally
rescaled earlier.

For regular numbers dynamic rescaling is performed only to handle corner cases
where there would be a non-terminating decimal expansion.

Rescaling is performed on each operation unless/until all values are regular
numbers (without any Money object among them).
sourceraw docstring

ne-am?clj

(ne-am? a)
(ne-am? a b)
(ne-am? a b & more)

Returns true if the money amounts or their currencies are different, regardless of their scales.

Returns true if the money amounts or their currencies are different, regardless of
their scales.
sourceraw docstring

ne?clj

(ne? a)
(ne? a b)
(ne? a b & more)

Returns true if the money amounts or their currencies are different, regardless of their scales. Note that currencies with different scales are considered different.

Returns true if the money amounts or their currencies are different, regardless of
their scales. Note that currencies with different scales are considered different.
sourceraw docstring

negclj

(neg a)

Returns the negated amount of the given money. For negative amount it will reverse their sign. Same as (sub x).

Returns the negated amount of the given money. For negative amount it will reverse
their sign. Same as (sub x).
sourceraw docstring

neg-or-zero?clj

(neg-or-zero? a)

Alias for is-neg-or-zero?.

Alias for is-neg-or-zero?.
sourceraw docstring

neg?clj

(neg? a)

Alias for is-neg?.

Alias for is-neg?.
sourceraw docstring

not=clj

(not= a)
(not= a b)
(not= a b & more)

Alias for ne?.

Alias for ne?.
sourceraw docstring

not==clj

(not== a)
(not== a b)
(not== a b & more)

Alias for ne-am?.

Alias for ne-am?.
sourceraw docstring

ofcljmacro

(of)
(of a)
(of a b)
(of a b rounding-mode)

Returns the amount of money as a Money object consisting of a currency and a value. Currency can be a currency object and for registered currencies: a keyword, a symbol or a string (e.g. EUR, :EUR, "PLN" or crypto/ETH), or even a number (for ISO-compliant currencies).

The given amount can be any numeric value or a string that can be converted to java.math.BigDecimal.

When a number must be downscaled to fulfill the number of decimal places for a currency, rounding mode must be given, which may be a symbol, a keyword or a string of the following:

  • CEILING - rounds towards positive infinity.
  • DOWN - rounds towards zero.
  • FLOOR - rounds towards negative infinity.
  • HALF_DOWN - rounds towards nearest neighbor unless both neighbors are equidistant, in which case rounds down.
  • HALF_EVEN - rounds towards the nearest neighbor unless both neighbors are equidistant, and if so, rounds towards the even.
  • HALF_UP - rounds towards the nearest neighbor unless both neighbors are equidistant, and if so, rounds up.
  • UP – rounds away from zero
  • UNNECESSARY - asserts that the requested operation has an exact result, hence no rounding is necessary.

To create a monetary object using function, call io.randomseed.bankster.money/value.

Be careful about using number literals for big-scale amounts (16–17 digits). Use either big decimal literals, e.g. 1234.45689101112M, or strings.

Returns the amount of money as a Money object consisting of a currency and a
value. Currency can be a currency object and for registered currencies: a keyword,
a symbol or a string (e.g. EUR, :EUR, "PLN" or crypto/ETH), or even a number (for
ISO-compliant currencies).

The given amount can be any numeric value or a string that can be converted to
java.math.BigDecimal.

When a number must be downscaled to fulfill the number of decimal places for a
currency, rounding mode must be given, which may be a symbol, a keyword or a string
of the following:

* CEILING     - rounds towards positive infinity.
* DOWN        - rounds towards zero.
* FLOOR       - rounds towards negative infinity.
* HALF_DOWN   - rounds towards nearest neighbor unless both neighbors are equidistant, in which case rounds down.
* HALF_EVEN   - rounds towards the nearest neighbor unless both neighbors are equidistant, and if so, rounds towards the even.
* HALF_UP     - rounds towards the nearest neighbor unless both neighbors are equidistant, and if so, rounds up.
* UP          – rounds away from zero
* UNNECESSARY - asserts that the requested operation has an exact result, hence no rounding is necessary.

To create a monetary object using function, call `io.randomseed.bankster.money/value`.

Be careful about using number literals for big-scale amounts (16–17 digits). Use
either big decimal literals, e.g. 1234.45689101112M, or strings.
sourceraw docstring

of-majorcljmacro

(of-major)
(of-major a)
(of-major a b)
(of-major a b rounding-mode)

Like io.randomseed.money/of but sets the amount of major part only.

Like io.randomseed.money/of but sets the amount of major part only.
sourceraw docstring

of-minorcljmacro

(of-minor)
(of-minor a)
(of-minor a b)
(of-minor a b rounding-mode)

Like io.randomseed.money/of but sets the amount of minor part only.

Like io.randomseed.money/of but sets the amount of minor part only.
sourceraw docstring

of-registryclj

(of-registry money)
(of-registry registry money)
(of-registry registry money rounding-mode)

Ensures that a currency of the given money originates from the given registry. If the registry is not given and a dynamic registry is not set, the default one is used. Rescales the amount if needed to match the nominal scale. Optional rounding-mode can be supplied to be used when downscaling is needed (nominal currency from a registry has lower number of decimal places than the amount of money).

Money can be expressed as a Money object or any other object that will create Money when passed to the value function. Returns money.

Ensures that a currency of the given money originates from the given registry. If
the registry is not given and a dynamic registry is not set, the default one is
used. Rescales the amount if needed to match the nominal scale. Optional
rounding-mode can be supplied to be used when downscaling is needed (nominal
currency from a registry has lower number of decimal places than the amount of
money).

Money can be expressed as a Money object or any other object that will create Money
when passed to the `value` function. Returns money.
sourceraw docstring

on-amountclj

(on-amount money f)
(on-amount money f a)
(on-amount money f a b)
(on-amount money f a b & more)

Performs an operation expressed with a function f on an amount of the given money. Additional arguments will be passed to the f. Returns the money with the amount updated. The function f must return a number. Short-circuits on nil as an argument.

Performs an operation expressed with a function f on an amount of the given
money. Additional arguments will be passed to the f. Returns the money with the
amount updated. The function f must return a number. Short-circuits on nil as an
argument.
sourceraw docstring

posclj

(pos a)

Returns the given money object.

Returns the given money object.
sourceraw docstring

pos-or-zero?clj

(pos-or-zero? a)

Alias for is-pos-or-zero?.

Alias for is-pos-or-zero?.
sourceraw docstring

pos?clj

(pos? a)

Alias for is-pos?.

Alias for is-pos?.
sourceraw docstring

remclj

(rem a b)
(rem a b rounding-mode)

Returns the remainder of dividing an mount of money by the given number. For two money objects the result is BigDecimal. When only the first one is a kind of Money the result will also be a Money. In the last case the result will be rescaled to the scale of the monetary amount. When rounding mode is not give io.randomseed.bankster.scale/*rounding-mode* will be used when set.

Returns the remainder of dividing an mount of money by the given number. For two
money objects the result is BigDecimal. When only the first one is a kind of Money
the result will also be a Money. In the last case the result will be rescaled to
the scale of the monetary amount. When rounding mode is not give
`io.randomseed.bankster.scale/*rounding-mode*` will be used when set.
sourceraw docstring

rescaleclj

(rescale money)
(rescale money scale)
(rescale money scale rounding-mode)

Same as scale but its unary variant will rescale an amount of the given money to conform it to its currency settings instead of returning the scale. It has the same effect as calling io.randomseed.bankster.scale/apply on a Money object.

Same as scale but its unary variant will rescale an amount of the given money to
conform it to its currency settings instead of returning the scale. It has the same
effect as calling `io.randomseed.bankster.scale/apply` on a Money object.
sourceraw docstring

rescaled?clj

(rescaled? a)

Returns true if the given monetary value has different scale than its currency (so it was rescaled). Returns false if the scale is no different. Returns nil if the currency does not have a fixed scale.

Returns true if the given monetary value has different scale than its currency (so
it was rescaled). Returns false if the scale is no different. Returns nil if the
currency does not have a fixed scale.
sourceraw docstring

roundclj

(round money scale)
(round money scale rounding-mode)

Rounds the amount of money using the given scale and rounding mode. Returns money with rounded amount preserving the original scale. If the rounding mode is not given the one from scale/rounding-mode is used.

Rounds the amount of money using the given scale and rounding mode. Returns money
with rounded amount preserving the original scale. If the rounding mode is not
given the one from scale/*rounding-mode* is used.
sourceraw docstring

same-currencies?clj

(same-currencies? a b)

Returns true if both currencies are the same for the given money objects.

Returns true if both currencies are the same for the given money objects.
sourceraw docstring

same-currency-ids?clj

(same-currency-ids? a b)

Returns true if both currencies have the same IDs for the given money objects.

Returns true if both currencies have the same IDs for the given money objects.
sourceraw docstring

scaleclj

(scale money)
(scale money scale)
(scale money scale rounding-mode)

Re-scales the given money using a scale (number of decimal places) and an optional rounding mode (required when downscaling). The internal scale for a currency object is NOT updated. If no scale is given, returns the current scale of an amount (not the nominal scale of a currency – which is important in rescaled amount or auto-scaled currencies).

Auto-scaled monetary values are returned unchanged.

Use with caution since it can make money object no longer compliant with a scale of the currency.

Re-scales the given money using a scale (number of decimal places) and an optional
rounding mode (required when downscaling). The internal scale for a currency object
is NOT updated. If no scale is given, returns the current scale of an amount (not
the nominal scale of a currency – which is important in rescaled amount or
auto-scaled currencies).

Auto-scaled monetary values are returned unchanged.

Use with caution since it can make money object no longer compliant with a scale of
the currency.
sourceraw docstring

stripclj

(strip a)

Strips trailing zeros from the amount of money. The internal scale for a currency object is NOT updated.

Use with caution since it can make money object no longer compliant with a scale of the registered currency.

Strips trailing zeros from the amount of money. The internal scale for a currency
object is NOT updated.

Use with caution since it can make money object no longer compliant with a scale of
the registered currency.
sourceraw docstring

stripped-amountclj

(stripped-amount money)
(stripped-amount a b)
(stripped-amount a b r)

Returns the amount of the given money with trailing zeros removed.

Returns the amount of the given money with trailing zeros removed.
sourceraw docstring

subclj

(sub a)
(sub a b)
(sub a b & more)

Subtracts two or more amounts of money of the same currency. When called with a single argument, negates its value.

Subtracts two or more amounts of money of the same currency. When called with a
single argument, negates its value.
sourceraw docstring

sub-majorclj

(sub-major a b)

Decreases major amount by the given number. If the number is also expressed as money and it has decimal parts, they will be truncated.

Decreases major amount by the given number. If the number is also expressed as money
and it has decimal parts, they will be truncated.
sourceraw docstring

sub-minorclj

(sub-minor a b)

Decreases minor amount by the given number. If the number is also expressed as money and it has decimal parts, they will be truncated. If the major component comes from a money object, its currency must match the given money. This check is performed to prevent mistakes; if you need to subtract minor parts of money with different currencies, use (minor x) on the second argument.

Decreases minor amount by the given number. If the number is also expressed as money
and it has decimal parts, they will be truncated. If the major component comes from
a money object, its currency must match the given money. This check is performed to
prevent mistakes; if you need to subtract minor parts of money with different
currencies, use (minor x) on the second argument.
sourceraw docstring

sub-scaledclj

(sub-scaled a)
(sub-scaled a b)
(sub-scaled a b & more)

Alias for sub.

Alias for sub.
sourceraw docstring

unparseclj

(unparse money)
(unparse a b)
(unparse a b r)

Returns a vector with symbolic representations of amount and currency. Useful for printing to EDN or displaying on a console. The letter M will be added to the amount if its precision exceeds 15.

Returns a vector with symbolic representations of amount and currency. Useful for
printing to EDN or displaying on a console. The letter M will be added to the
amount if its precision exceeds 15.
sourceraw docstring

with-currencycljmacro

(with-currency currency & body)

Sets a default currency in a lexical context of the body. Has the same effect as io.randomseed.bankster.currency/with.

Sets a default currency in a lexical context of the body. Has the same effect as
io.randomseed.bankster.currency/with.
sourceraw docstring

with-rescalingcljmacro

(with-rescaling rounding-mode & body)

Alias for io.randomseed.bankster.scale/with-rescaling.

Alias for io.randomseed.bankster.scale/with-rescaling.
sourceraw docstring

with-roundingcljmacro

(with-rounding rounding-mode & body)

Alias for io.randomseed.bankster.scale/with-rounding.

Alias for io.randomseed.bankster.scale/with-rounding.
sourceraw docstring

zero?clj

(zero? a)

Alias for is-zero?.

Alias for is-zero?.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close