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

WSF calculate fares from GTFS #6329

Merged

Conversation

daniel-heppner-ibigroup
Copy link
Contributor

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.

@daniel-heppner-ibigroup daniel-heppner-ibigroup requested a review from a team as a code owner December 10, 2024 05:49
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 69.80%. Comparing base (a866234) to head (4141ce9).
Report is 19 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...pentripplanner/ext/fares/impl/OrcaFareService.java 50.00% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

@@ -147,6 +147,11 @@ public Money half() {
return new Money(currency, IntUtils.round(amount / 2f));
}

public Money roundDownToNearestFiveCents() {
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

@leonardehrenfried leonardehrenfried Dec 11, 2024

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.

@leonardehrenfried leonardehrenfried merged commit b5d5d54 into opentripplanner:dev-2.x Dec 11, 2024
5 checks passed
@leonardehrenfried leonardehrenfried deleted the wsf-fares-calculation branch December 11, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants