Skip to content
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

Add fake.dollars() and fake.cents() #77

Open
serhalp opened this issue Jan 11, 2021 · 0 comments
Open

Add fake.dollars() and fake.cents() #77

serhalp opened this issue Jan 11, 2021 · 0 comments

Comments

@serhalp
Copy link
Contributor

serhalp commented Jan 11, 2021

We frequently generate currency in Good Eggs code. Though we have a standard to manipulate currency as integer cents, we do also have legacy code that manipulates dollars as floats, and we also have a need to display currency as dollar strings.

I would propose:

  • fake.cents(): returns an integer from 1 to some large upper bound inclusively
    • we do sometimes need negative cents like for a discount – should we default to positive but allow passing in a negative min? or default to negative? or make two separate methods? hmm
  • fake.dollars(): returns an integer from 0.00 to some large upper bound inclusively, with at most two decimal places
    • callers can use fake.dollars().toString() to generate a string representation of a dollar amount
    • same question about negatives above applies as well

Alternatively, we could nest these together maybe: fake.money.{dollars,cents}?

I don't think I endorse this, but alternatively we could have one or more of these "cents" methods return an instance of BigNumber/Cents?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant