updates cleanup.

This commit is contained in:
2025-09-10 16:27:41 -04:00
parent e4aeab4e44
commit 33f3a52b3e
2 changed files with 11 additions and 9 deletions

View File

@@ -11,19 +11,21 @@ public class AccountReservationList extends ArrayList<Reservation> {
@Override @Override
public boolean add(final Reservation reservation) { public boolean add(final Reservation reservation) {
boolean result = true; boolean result = true;
Reservation rsrv = this.find(reservation.getReservation_number());
if( rsrv != null ){
result = false;
throw new DuplicateObjectException(String.format("Error Duplicate: Reservation %s", rsrv.getReservation_number()));
}
try { try {
result = reservation.checkValid(); result = reservation.checkValid();
} catch (Exception e) { } catch (ReservationException ex) {
return false; return false;
} }
for (Reservation rsrv : this) { if(result){
result = reservation.getReservation_number().compareTo(rsrv.getReservation_number()) == 0;
if (result) {
return false;
}
}
reservation.setReservation_number(AccountReservationList.reservationSerial(reservation)); reservation.setReservation_number(AccountReservationList.reservationSerial(reservation));
return super.add(reservation); result = super.add(reservation);
}
return result;
} }
@Override @Override

View File

@@ -212,7 +212,7 @@ public abstract class Reservation {
throw new IllegalOperationException ("Invalid Change, reservation has completed."); throw new IllegalOperationException ("Invalid Change, reservation has completed.");
} }
if (ZonedDateTime.now().compareTo(this.reservation_start_date) > -1) { if (ZonedDateTime.now().compareTo(this.reservation_start_date) > -1) {
throw new IllegalOperationException ("Invalid Change, reservation started."); throw new IllegalOperationException ("Invalid Change, reservation time started.");
} }
} }