Closed rartych closed 7 months ago
Have checked this internally. In Telefonica, billing/charging systems manage "decimals" in a natural way.
Providing amount as "integer" would have huge impacts in systems as it is needed to manage a conversion to identify the number of decimals to be considered. Usually merchants are aware of this kind of stuff in different countries and manage it.
Then our position is to keep current model. Would also like to know opinions from other participants.
Anyway, an enhancement is derived from your analysis @rartych. We need to address scenarios with 3 decimals.
So for amount, should be needed to be described as:
amount:
type: number
format: float
multipleOf: 0.001
float also includes integers so for currencies that do not consider decimals an integer can be signalled and Schema validation does cover it.
25/10: Moving forward with
amount:
type: number
format: float
multipleOf: 0.001
Problem description Currently amounts of money are defined as:
Swafgger docs indicates
Possible evolution
Storing amount values as long integers is a common best practice
amount
integer
int64
currency
string
currency
Note: Minor units are specified according to ISO 4217 and can be found in this table.
Additional context
Recommendation in: https://github.com/team-monite/api-style-guide/blob/main/Guidelines.md#should-use-the-common-money-object
Most currencies have two decimals. Some currencies do not have decimals, and some have three decimals. For example: