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

fix(orca-fares): allow senior fares with cash #5922

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static void assertLegFareEquals(
void calculateFareForSingleAgency() {
List<Leg> rides = List.of(getLeg(COMM_TRANS_AGENCY_ID, "400", 0));
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE);
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE);
calculateFare(rides, FareType.senior, TWO_DOLLARS);
calculateFare(rides, FareType.youth, ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, TWO_DOLLARS);
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE);
Expand All @@ -154,18 +154,14 @@ void calculateFareWithNoFreeTransfer() {
getLeg(COMM_TRANS_AGENCY_ID, 2)
);
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(3));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(3));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.plus(usDollars(2.25f)));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(
rides,
FareType.electronicSpecial,
DEFAULT_TEST_RIDE_PRICE.plus(usDollars(1.25f))
);
calculateFare(
rides,
FareType.electronicRegular,
DEFAULT_TEST_RIDE_PRICE.plus(DEFAULT_TEST_RIDE_PRICE)
);
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.electronicSenior, DEFAULT_TEST_RIDE_PRICE.plus(usDollars(1.25f)));
calculateFare(rides, FareType.electronicYouth, Money.ZERO_USD);
}
Expand Down Expand Up @@ -200,7 +196,7 @@ void calculateFareThatExceedsTwoHourFreeTransferWindow() {
);

calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, TWO_DOLLARS);
calculateFare(rides, FareType.youth, ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, TWO_DOLLARS);
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE.times(2));
Expand All @@ -227,7 +223,7 @@ void calculateFareThatIncludesNoFreeTransfers() {
calculateFare(
rides,
FareType.senior,
DEFAULT_TEST_RIDE_PRICE.times(2).plus(usDollars(.50f)).plus(HALF_FERRY_FARE)
ONE_DOLLAR.plus(ONE_DOLLAR).plus(HALF_FERRY_FARE).plus(usDollars(0.5f))
);
calculateFare(rides, FareType.youth, Money.ZERO_USD);
// We don't get any fares for the skagit transit leg below here because they don't accept ORCA (electronic)
Expand Down Expand Up @@ -263,7 +259,7 @@ void calculateFareThatExceedsTwoHourFreeTransferWindowTwice() {
getLeg(KITSAP_TRANSIT_AGENCY_ID, 270)
);
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(3));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(3));
calculateFare(rides, FareType.senior, usDollars(3));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(3));
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE.times(3));
Expand All @@ -286,7 +282,7 @@ void calculateFareThatStartsWithACashFare() {
getLeg(KITSAP_TRANSIT_AGENCY_ID, 149)
);
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.plus(ONE_DOLLAR));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, DEFAULT_TEST_RIDE_PRICE.plus(ONE_DOLLAR));
calculateFare(
Expand All @@ -305,7 +301,7 @@ void calculateFareThatStartsWithACashFare() {
void calculateFareForKitsapFastFerry() {
List<Leg> rides = List.of(getLeg(KITSAP_TRANSIT_AGENCY_ID, 0, 4, "404", "east"));
calculateFare(rides, regular, TWO_DOLLARS);
calculateFare(rides, FareType.senior, TWO_DOLLARS);
calculateFare(rides, FareType.senior, ONE_DOLLAR);
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, ONE_DOLLAR);
calculateFare(rides, FareType.electronicRegular, TWO_DOLLARS);
Expand All @@ -314,7 +310,7 @@ void calculateFareForKitsapFastFerry() {

rides = List.of(getLeg(KITSAP_TRANSIT_AGENCY_ID, 0, 4, "404", "west"));
calculateFare(rides, regular, usDollars(10f));
calculateFare(rides, FareType.senior, usDollars(10f));
calculateFare(rides, FareType.senior, usDollars(5f));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(5f));
calculateFare(rides, FareType.electronicRegular, usDollars(10f));
Expand Down Expand Up @@ -349,7 +345,7 @@ void calculateFareForSTRail() {
getLeg(SOUND_TRANSIT_AGENCY_ID, "S Line", 100, "King Street Station", "Auburn Station")
);
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, TWO_DOLLARS);
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, ORCA_SPECIAL_FARE);
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE);
Expand All @@ -364,7 +360,7 @@ void calculateFareForSTRail() {
void calculateWaterTaxiFares() {
List<Leg> rides = List.of(getLeg(KC_METRO_AGENCY_ID, "973", 1));
calculateFare(rides, regular, WEST_SEATTLE_WATER_TAXI_CASH_FARE);
calculateFare(rides, FareType.senior, WEST_SEATTLE_WATER_TAXI_CASH_FARE);
calculateFare(rides, FareType.senior, usDollars(2.50f));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(3.75f));
calculateFare(rides, FareType.electronicRegular, usDollars(5f));
Expand All @@ -374,7 +370,7 @@ void calculateWaterTaxiFares() {
rides = List.of(getLeg(KC_METRO_AGENCY_ID, "975", 1));

calculateFare(rides, regular, VASHON_WATER_TAXI_CASH_FARE);
calculateFare(rides, FareType.senior, VASHON_WATER_TAXI_CASH_FARE);
calculateFare(rides, FareType.senior, usDollars(3f));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(4.50f));
calculateFare(rides, FareType.electronicRegular, usDollars(5.75f));
Expand All @@ -395,8 +391,7 @@ void calculateSoundTransitBusFares() {
getLeg(KC_METRO_AGENCY_ID, "550", 240)
);
calculateFare(rides, regular, usDollars(9.75f));
// Sound Transit does not accept senior fares in cash
calculateFare(rides, FareType.senior, usDollars(9.75f));
calculateFare(rides, FareType.senior, usDollars(3.00f));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(3f));
calculateFare(rides, FareType.electronicRegular, usDollars(9.75f));
Expand All @@ -410,7 +405,7 @@ void calculateSoundTransitBusFares() {
getLeg(PIERCE_COUNTY_TRANSIT_AGENCY_ID, "501", 60)
);
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, TWO_DOLLARS);
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(1f));
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE);
Expand All @@ -430,7 +425,7 @@ void calculateCashFreeTransferKCMetroAndKitsap() {
getLeg(KITSAP_TRANSIT_AGENCY_ID, 132)
);
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(4));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(4));
calculateFare(rides, FareType.senior, usDollars(4.25f));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(1.25f));
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE.times(2));
Expand All @@ -442,12 +437,12 @@ void calculateCashFreeTransferKCMetroAndKitsap() {
void calculateTransferExtension() {
List<Leg> rides = List.of(
getLeg(KITSAP_TRANSIT_AGENCY_ID, 0, 4, "Kitsap Fast Ferry", "east"), // 2.00
getLeg(KC_METRO_AGENCY_ID, 100), // Default ride price, extends transfer
getLeg(KC_METRO_AGENCY_ID, 100), // Default ride price, extends transfer for regular fare
getLeg(KITSAP_TRANSIT_AGENCY_ID, 150, 4, "Kitsap Fast Ferry", "west") // 10.00
);
var regularFare = usDollars(2.00f).plus(DEFAULT_TEST_RIDE_PRICE).plus(usDollars(10f));
calculateFare(rides, regular, regularFare);
calculateFare(rides, FareType.senior, regularFare);
calculateFare(rides, FareType.senior, usDollars(7f));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(6f));
calculateFare(rides, FareType.electronicRegular, usDollars(10f)); // transfer extended on second leg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ private Optional<Money> getSeniorFare(
var regularFare = getRegularFare(fareType, rideType, defaultFare, leg);
// Many agencies only provide senior discount if using ORCA
return switch (rideType) {
case COMM_TRANS_LOCAL_SWIFT -> usesOrca(fareType) ? optionalUSD(1.25f) : regularFare;
case COMM_TRANS_COMMUTER_EXPRESS -> usesOrca(fareType) ? optionalUSD(2f) : regularFare;
case COMM_TRANS_LOCAL_SWIFT -> optionalUSD(1.25f);
case COMM_TRANS_COMMUTER_EXPRESS -> optionalUSD(2f);
case SKAGIT_TRANSIT, WHATCOM_LOCAL, SKAGIT_LOCAL -> optionalUSD(0.5f);
case EVERETT_TRANSIT -> usesOrca(fareType) ? optionalUSD(0.5f) : regularFare;
case EVERETT_TRANSIT -> optionalUSD(0.5f);
case KITSAP_TRANSIT_FAST_FERRY_EASTBOUND,
SOUND_TRANSIT,
SOUND_TRANSIT_BUS,
Expand All @@ -365,14 +365,10 @@ private Optional<Money> getSeniorFare(
KC_METRO,
PIERCE_COUNTY_TRANSIT,
SEATTLE_STREET_CAR,
KITSAP_TRANSIT -> fareType.equals(FareType.electronicSenior)
? optionalUSD(1f)
: regularFare;
case KC_WATER_TAXI_VASHON_ISLAND -> usesOrca(fareType) ? optionalUSD(3f) : regularFare;
case KC_WATER_TAXI_WEST_SEATTLE -> usesOrca(fareType) ? optionalUSD(2.5f) : regularFare;
case KITSAP_TRANSIT_FAST_FERRY_WESTBOUND -> fareType.equals(FareType.electronicSenior)
? optionalUSD(5f)
: regularFare;
KITSAP_TRANSIT -> optionalUSD(1f);
case KC_WATER_TAXI_VASHON_ISLAND -> optionalUSD(3f);
case KC_WATER_TAXI_WEST_SEATTLE -> optionalUSD(2.5f);
case KITSAP_TRANSIT_FAST_FERRY_WESTBOUND -> optionalUSD(5f);
// Discount specific to Skagit transit and not Orca.
case WASHINGTON_STATE_FERRIES -> Optional.of(
getWashingtonStateFerriesFare(route.getLongName(), fareType, defaultFare)
Expand Down
Loading