-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field type to handle currency amounts in GTFS? #254
Comments
FWIW, "data types" in GTFS are really a semantic definition - the actual data container is a string in a CSV file encoded in UTF-8. The problem with currency calculations comes in after the String is read by consumer software, converted into a No matter what representation is in the spec, IMHO we should explicitly call out the issue with doing financial calculations using floating point values in the spec (including with the current
Some thoughts on the options:
This could work, although as I mentioned above we should still call out why you shouldn't use
This could work, but I don't think it solves the underlying problem of consumer software importing it as a
Again, the difference here between calling it a "decimal" vs "float" is just semantics in GTFS data types, but I do like that this explicitly calls out that you should be using a |
There are some normalization concerns regarding option B: AFAIK, there is no international standards for currency subdivisions. The ISO 4217 standard for currencies only brings information regarding the number of digits after the decimal separator (from 0 to 4 digits). Although the GTFS Fares v2's field definition of
|
Could that be fixed by putting some semantics in the data itself (like language codes) and/or metadata? Just musing |
Yes, indeed. However, is it in the GTFS scope to maintain lists on language and currency codes? |
https://en.wikipedia.org/wiki/ISO_4217#Unofficial_codes_for_minor_units_of_currency suggests using I still think the better solution is to define the currency values as decimals and encourage clients to process them as decimals as much as possible. |
From the conversation above, it seems like Option A or C are the more viable paths. Option A or C: Option C: Here is my proposal following Option C (updated on 2020-12-02):
|
This seems to be resolved. The proposal above for Currency Amount has been implemented in the Fares v2 proposal document. If any additional thoughts on expressing currency amounts in GTFS emerge we can reopen this issue. Thanks, everyone! |
Hi everyone,
An issue was raised in the GTFS Fares v2 extension project around describing currency amounts for fare prices. The proposal currently describes currency amounts using
float
ornon-negative float
field types. General best practices suggest to never use floats for money due to loss/gain of money during calculations.We (MobilityData) see a few options:
float
, and leave correct calculations up to consumers (i.e., defining currency amounts in a preferred type, rounding calculations to two decimal places).integer
increments of their smallest unit (i.e.,125 cents
to describe1.25 dollars
).decimal
field type to GTFS.What are your thoughts on describing currency amounts in GTFS? We are interested in hearing different perspectives: producers, consumers, and other stakeholders.
For general discussions/needs related to Fares v2, see #252.
Thanks!
The text was updated successfully, but these errors were encountered: