-
Notifications
You must be signed in to change notification settings - Fork 1k
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
WSF calculate fares from GTFS #6329
WSF calculate fares from GTFS #6329
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #6329 +/- ##
=============================================
+ Coverage 69.79% 69.80% +0.01%
- Complexity 17812 17822 +10
=============================================
Files 2020 2019 -1
Lines 76221 76243 +22
Branches 7799 7802 +3
=============================================
+ Hits 53195 53225 +30
+ Misses 20312 20303 -9
- Partials 2714 2715 +1 ☔ View full report in Codecov by Sentry. |
@@ -147,6 +147,11 @@ public Money half() { | |||
return new Money(currency, IntUtils.round(amount / 2f)); | |||
} | |||
|
|||
public Money roundDownToNearestFiveCents() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you know the drill by now: this one needs Javadoc and a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! I should know better. Test added now
@@ -147,6 +147,15 @@ public Money half() { | |||
return new Money(currency, IntUtils.round(amount / 2f)); | |||
} | |||
|
|||
/** | |||
* Returns the instance rounded down to the nearest multiple of 5 cents | |||
* So $0.25 becomes $0.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
25 cents become 10 cents!? That doesn't sound right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had in my head how we use half() first.
*/ | ||
public Money roundDownToNearestFiveMinorUnits() { | ||
int rounded = (this.minorUnitAmount() / 5) * 5; | ||
return new Money(Money.USD, rounded); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not have to be USD. Use the currency from the instance.
Summary
This change is mostly in the sandbox, it removes the hard coded WSF fares and instead relies on the data in the GTFS. Senior fares are calculated by halving then rounding down to the nearest multiple of 5 cents. This seems to always match WSF fares.
Unit tests
Unit tests are updated. WSF fares are now the default test fare since they're not based on a hard coded value.