Releases: kipcole9/money
Money version 2.6.1
Enhancements
- Moves the
Jason.Encoder
protocol implementation to the protocol implementation file. This prevents some circular compilation issues when using the:cldr
compiler.
Money version 2.6.0
Enhancements
-
Change the definition of the
money_with_currency
composite Postgres type fromnumeric(20,8)
tonumeric
. This provides for a much wider precision and scale. It also means that retrievingMoney.t
data from the database will be returned with the same scale as when it was stored. Closes #67. Thanks to @doughsay. -
Relaxes the requirements for ex_cldr and ex_cldr_numbers
Money version 2.5.0
Enhancements
-
Adds support for ISO4217 "X" currency codes. Currency codes that start with "X" followed by two alphabetic characters are considered valid currency codes. Some codes are defined, like "XAU" for "Gold". The undefined codes are available for application-specific usage. Note that from a
Cldr
perspective these codes are considered valid, but unknown. This means they can be used anywhere as a currency forMoney
. ButCldr.known_currency?/1
will returnfalse
for these codes since there is no definition for them inCLDR
. -
Adds basic support for Postgres aggregation functions using the
Money.Ecto.Composite.Type
type definition. This allows expression in Ecto such as:
iex> q = Ecto.Query.select Ledger, [l], type(sum(l.amount), l.amount)
#Ecto.Query<from l in Ledger, select: type(sum(l.amount), l.amount)>
iex> Repo.all q
[debug] QUERY OK source="ledgers" db=6.1ms
SELECT sum(l0."amount")::money_with_currency FROM "ledgers" AS l0 []
[#Money<:USD, 600.00000000>]
This release supports only the sum
aggregate function and only for Postgres. A migration generator is provided that when executed with mix ecto.migrate
will add the relevant functions to the Postgres database to support this functionality. See the README for more information.
Money version 2.4.0
Enhancements
-
Update ex_cldr dependency to version 1.5.0 which uses CLDR data version 33.
-
Update ex_cldr_numbers dependency to 1.4.0
-
Clarify the examples of
Money.to_string/2
to note that the default locale is "en-001". Thanks to @snewcomer. Closes #61.
Money version 2.3.0
Bug Fixes
- Fix the protocol implementation for
String.Chars
Enhancements
This version introduces a new module Money.Subscription
that supports applications that manage subscriptions. These appications often need to support upgrading and downgrading plans. This action involves the calculation of a credit amount from the current plan that is then applied to the new plan. See Money.Subscription
and Money.Subscription.change_plan/3
.
- Add
Money.Subscription.new/3
andMoney.Subscription.new!/3
to create a new subscription with its inital plan - Add
Money.Subscription.Plan.new/3
andMoney.Subscription.Plan.new!/3
to create a new plan - Add
Money.Subscription.change_plan/3
andMoney.Subscription.change_plan!/3
to change subscription plans and apply any credit for unused parts of the current period - Add
Money.Subscription.plan_days/3
to return the number of days in a plan interval - Add
Money.Subscription.days_remaining/4
to return the number of days remaining in the current interval for a plan - Add
Money.Subscription.next_interval_starts/3
to return the next interval start date for a subscription to a plan - Add
Money.zero/1
that returns aMoney.t
with a zero amount in the given currency
Money version 2.2.2
Money version 2.2.1
Bug Fixes
-
Correctly round to cash increment Money.round/2 now correctly uses the rounding increment for a currency. This is relevant for currencies like :AUD and :CHF which have minimum cash rounding of 0.05 even though the accounting increment is 0.01. Thanks to @maennchen. Closes #56.
-
Update documentation for
Money.round/2
to correctly refer to the option:currency_digits
with the valid options of:cash
,:accounting
and:iso
. The default is:iso
. The optioncash: true
is invalid.
Money version 2.2.0
This release is primarily a refactoring of the exchange rates service. It separates the concerns of retrieval and caching. It also normalises the API amongst the three modules Money.ExchangeRates
, Money.ExchangeRates.Retriever
and Money.ExchangeRates.Cache
. Each of these modules implements:
latest_rates/0
historic_rates/1
This makes it clear that rates can be retrieved through the cache or the service API. The implementation in Money.ExchangeRates
will return the cached value if available or will call the service API if not.
Migration from earlier releases
The only know issue for migrating from earlier releases is if your application requires a different supervision strategy for the exchange rate service that the default one. This is documented in the README in the section "Using Ecto or other applications from within the callback module". The change is the way in which the supervisor is defined. It is included here for completeness:
In prior releases:
supervisor(Money.ExchangeRates.Supervisor, [])
From this release onwards:
supervisor(Money.ExchangeRates.Supervisor, [[restart: true, start_retriever: true]])
Note that the option start_retriever: true
is optional. The default is false
. The option restart: true
is required in this case because the exchange rates supervisor is always started when ex_money
is started even if the retriever is not started.
Enhancements
-
Define an exchange rates cache behaviour
Money.ExchangeRates.Cache
-
Adds the config key
:exchange_rates_cache_module
which can be set to a module that implements theMoney.ExchangeRates.Cache
behaviour. Two modules are provided:Money.ExchangeRates.Cache.Ets
(the default) andMoney.ExchangeRates.Cache.Dets
-
Move all exchange rates retrieval functions to
Money.ExchangeRates.Retriever
-
Add several functions to
Money.ExchangeRates.Retriever
::config/0
to return the current retriever configuration.reconfigure/1
to allow reconfiguration of the exchange rates retriever.start/1
to start the service. Delegates toMoney.ExchangeRates.Supervisor.start_retriever/1
.stop/0
to stop the service. Delegates toMoney.ExchangeRates.Supervisor.stop_retriever/0
.restart/0
to restart the service. Delegates toMoney.ExchangeRates.Supervisor.restart_retriever/0
.delete/0
to delete the service. It can be started again withstart/1
. Delegates toMoney.ExchangeRates.Supervisor.delete_retriever/0
.
-
If the config key
:exchange_rates_retrieve_every
is set to anatom
rather than aninteger
then no periodic retrieval will be performed. This allows the configuration of the following, which is also the default:
config :ex_money,
exchange_rates_retrieve_every: :never
-
Use
etag
's in theMoney.ExchangeRates.OpenExchangeRates
API module when retrieving exchange rates from the service. -
Add
Money.known_currencies/0
which delegates toCldr.known_currencies/0
and returns the list of known currency codes -
Add
Money.known_current_currencies/0
to return the list of currencies currently active according to ISO 4217 -
Add
Money.known_historic_currencies/0
to return a list of currencies known to Cldr but which are not considered in current use -
Add
Money.known_tender_currencies/0
to return a list of currencies defined as legal tender in Cldr -
Add the configuration key
:json_library
that specifies which json library to use for decoding json. The default isCldr.Config.json_library/0
which is currentlyPoison
although this is likely to change toJason
whenPhoenix
makes this change. -
Moves the protocol implementations for
String.Chars
,Inspect
andPhoenix.HTML.Safe
to a separate file so that recompilation on locale configuration change works correctly.
Money version 2.1.0
Enhancements
-
Money.to_integer_exp/2
now uses the definition of digits (subunits) as defined by ISO 4217. Previously the definition was that supplied by CLDR. CLDR's definition is not always in alignment with ISO 4217. ISO 4217 is a firm requirement for financial transactions through payment gateways. -
Bump dependencies for
ex_cldr
to 1.4.0 andex_cldr_numbers
to 1.3.0 to support:iso_digits
Money version 2.1.0-rc.1
Enhancements
-
Money.to_integer_exp/1
is nowMoney.to_integer/2
-
Money.to_integer/2
now uses the definition of digits (subunits) as defined by ISO 4217. Previously the definition was that supplied by CLDR. CLDR's definition is not always in alignment with ISO 4217. ISO 4217 is a firm requirement for financial transactions through payment gateways. -
Note that the dependencies for
ex_cldr
andex_cldr_numbers
have been bumped accordingly.