Skip to content

Instantly share code, notes, and snippets.

@thaniaclair
Created December 7, 2015 17:09
Show Gist options
  • Save thaniaclair/d8c680ad52c571695a53 to your computer and use it in GitHub Desktop.
Save thaniaclair/d8c680ad52c571695a53 to your computer and use it in GitHub Desktop.
Renfe Logic for Availability
public boolean isTariffApproved() {
String currentTariffAvailability = tarifa.getDisponibilidad();
if (Strings.isNullOrEmpty(currentTariffAvailability)) {
return false;
}
if (HIGH_AVAILABILITY.equals(currentTariffAvailability)) {
return true;
}
Integer currentTariffAvailableSeats = Ints.tryParse(currentTariffAvailability);
if (currentTariffAvailableSeats < numberOfTravellers) {
return false;
}
int minimumSeats = getMinimumSeats();
if (currentTariffAvailableSeats >= minimumSeats) {
return true;
}
String standardTariffAvailability = getStandardTariffAvailability();
if (Strings.isNullOrEmpty(standardTariffAvailability) || HIGH_AVAILABILITY.equals(standardTariffAvailability)) {
return true;
}
Integer standardTariffAvailableSeats = Ints.tryParse(currentTariffAvailability);
return (standardTariffAvailableSeats - currentTariffAvailableSeats) > 0;
}
@tbillet
Copy link

tbillet commented Dec 7, 2015

The rest of the logic is ok.

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